2014-06-23 08:58 PM - last edited on 2023-08-01 02:52 PM by Doreena Deng
2014-06-25 04:24 PM
// ----------------------------------------------------------------------------- // Create a Single-plane Roof // ----------------------------------------------------------------------------- void Do_CreatePlaneRoof (API_Coord centerPoint) { API_Element element; BNZeroMemory (&element, sizeof (API_Element)); element.header.typeID = API_RoofID; element.roof.roofClass = API_PlaneRoofID; GSErrCode err = ACAPI_Element_GetDefaults (&element, NULL); if (err != NoError) { ErrorBeep ("ACAPI_Element_GetDefaults (roof)", err); return; } API_ElementMemo memo; BNZeroMemory (&memo, sizeof (API_ElementMemo)); // constructing planeRoof data element.roof.u.planeRoof.poly.nCoords = 8; element.roof.u.planeRoof.poly.nSubPolys = 2; element.roof.u.planeRoof.poly.nArcs = 2; memo.coords = reinterpret_cast<API_Coord**> (BMAllocateHandle ((element.roof.u.planeRoof.poly.nCoords + 1) * sizeof (API_Coord), ALLOCATE_CLEAR, 0)); memo.pends = reinterpret_cast<Int32**> (BMAllocateHandle ((element.roof.u.planeRoof.poly.nSubPolys + 1) * sizeof (Int32), ALLOCATE_CLEAR, 0)); memo.parcs = reinterpret_cast<API_PolyArc**> (BMAllocateHandle (element.roof.u.planeRoof.poly.nArcs * sizeof (API_PolyArc), ALLOCATE_CLEAR, 0)); if (memo.coords == NULL || memo.pends == NULL || memo.parcs == NULL) { ErrorBeep ("Not enough memory to create roof polygon data", APIERR_MEMFULL); ACAPI_DisposeElemMemoHdls (&memo); return; } // contour points: (*memo.coords)[1].x = centerPoint.x + 10.0; (*memo.coords)[1].y = centerPoint.y + 10.0; (*memo.coords)[2].x = centerPoint.x + 10.0; (*memo.coords)[2].y = centerPoint.y - 10.0; (*memo.coords)[3].x = centerPoint.x - 10.0; (*memo.coords)[3].y = centerPoint.y - 10.0; (*memo.coords)[4].x = centerPoint.x - 10.0; (*memo.coords)[4].y = centerPoint.y + 10.0; (*memo.coords)[5] = (*memo.coords)[1]; (*memo.pends)[1] = 5; // hole points: (*memo.coords)[6].x = centerPoint.x + 5.0; (*memo.coords)[6].y = centerPoint.y + 0.0; (*memo.coords)[7].x = centerPoint.x - 5.0; (*memo.coords)[7].y = centerPoint.y + 0.0; (*memo.coords)[8] = (*memo.coords)[6]; (*memo.pends)[2] = 8; // arcs: (*memo.parcs)[0].begIndex = 6; // makes a circle-shaped hole (*memo.parcs)[0].endIndex = 7; (*memo.parcs)[0].arcAngle = PI; (*memo.parcs)[1].begIndex = 7; (*memo.parcs)[1].endIndex = 8; (*memo.parcs)[1].arcAngle = PI; // roof baseline element.roof.u.planeRoof.baseLine.c1.x = (*memo.coords)[1].x; element.roof.u.planeRoof.baseLine.c1.y = (*memo.coords)[1].y; element.roof.u.planeRoof.baseLine.c2.x = (*memo.coords)[3].x; element.roof.u.planeRoof.baseLine.c2.y = (*memo.coords)[3].y; // roof angle element.roof.u.planeRoof.angle = 5.0 * DEGRAD; // create the roof element err = ACAPI_Element_Create (&element, &memo); if (err != NoError) ErrorBeep ("ACAPI_Element_Create (roof)", err); ACAPI_DisposeElemMemoHdls (&memo); return; } // Do_CreatePlaneRoof
2014-07-01 03:05 PM