Archicad 29 C++ API
Loading...
Searching...
No Matches
Polygons

Functions to change the shape of a polygon. These polygons are always provided through API_ElementMemo. More...

Classes

struct  API_RegularizedPoly
 Structure for regularizing polygon or polyline. More...
 

Enumerations

enum  API_SurfaceTypeID {
  APISurfaceType_NotSpecified = 0 , APISurfaceType_BeamFirst = 0x1000 , APISurfaceType_BeamRight = 0x1000 , APISurfaceType_BeamLeft ,
  APISurfaceType_BeamSide , APISurfaceType_BeamTop , APISurfaceType_BeamBottom , APISurfaceType_BeamCut ,
  APISurfaceType_BeamLast = APISurfaceType_BeamCut , APISurfaceType_ColumnFisrt = 0x2000 , APISurfaceType_ColumnTop = 0x2000 , APISurfaceType_ColumnBottom ,
  APISurfaceType_ColumnCoreSide , APISurfaceType_ColumnVeneerSide , APISurfaceType_ColumnCut , APISurfaceType_ColumnLast = APISurfaceType_ColumnCut ,
  APISurfaceType_SlabFirst = 0x3000 , APISurfaceType_SlabTop = 0x3000 , APISurfaceType_SlabBottom , APISurfaceType_SlabSide ,
  APISurfaceType_SlabCut , APISurfaceType_SlabLast = APISurfaceType_SlabCut , APISurfaceType_WallFirst = 0x4000 , APISurfaceType_WallRefSide = 0x4000 ,
  APISurfaceType_WallOppSide , APISurfaceType_WallSide , APISurfaceType_WallCut , APISurfaceType_WallLast = APISurfaceType_WallCut ,
  APISurfaceType_ShellReferenceFirst = 0x5000 , APISurfaceType_ShellReferenceSide = 0x5000 , APISurfaceType_ShellOppositeSide , APISurfaceType_ShellRidge ,
  APISurfaceType_ShellValley , APISurfaceType_ShellGable , APISurfaceType_ShellHip , APISurfaceType_ShellEaves ,
  APISurfaceType_ShellPeak , APISurfaceType_ShellSideWall , APISurfaceType_ShellEndWall , APISurfaceType_ShellRTDome ,
  APISurfaceType_ShellRTHollow , APISurfaceType_ShellSide , APISurfaceType_ShellCut , APISurfaceType_ShellInnerReferenceSide ,
  APISurfaceType_ShellInnerOppositeSide , APISurfaceType_ShellLast = APISurfaceType_ShellInnerOppositeSide , APISurfaceType_PlaneRoofFirst = 0x6000 , APISurfaceType_PlaneRoofTop = 0x6000 ,
  APISurfaceType_PlaneRoofBottom , APISurfaceType_PlaneRoofRidge , APISurfaceType_PlaneRoofValley , APISurfaceType_PlaneRoofGable ,
  APISurfaceType_PlaneRoofHip , APISurfaceType_PlaneRoofEaves , APISurfaceType_PlaneRoofPeak , APISurfaceType_PlaneRoofSideWall ,
  APISurfaceType_PlaneRoofEndWall , APISurfaceType_PlaneRoofRTDome , APISurfaceType_PlaneRoofRTHollow , APISurfaceType_PlaneRoofSide ,
  APISurfaceType_PlaneRoofCut , APISurfaceType_PlaneRoofLast = APISurfaceType_PlaneRoofCut , APISurfaceType_PolyRoofFirst = 0x7000 , APISurfaceType_PolyRoofTop = 0x7000 ,
  APISurfaceType_PolyRoofBottom , APISurfaceType_PolyRoofRidge , APISurfaceType_PolyRoofValley , APISurfaceType_PolyRoofGable ,
  APISurfaceType_PolyRoofHip , APISurfaceType_PolyRoofEaves , APISurfaceType_PolyRoofPeak , APISurfaceType_PolyRoofSideWall ,
  APISurfaceType_PolyRoofEndWall , APISurfaceType_PolyRoofRTDome , APISurfaceType_PolyRoofRTHollow , APISurfaceType_PolyRoofUndefined ,
  APISurfaceType_PolyRoofInner , APISurfaceType_PolyRoofCut , APISurfaceType_PolyRoofLast = APISurfaceType_PolyRoofCut
}
 Possible types of a surface. More...
 

Functions

GSErrCode ACAPI_Polygon_InsertPolyNode (API_ElementMemo *elementMemo, Int32 *nodeIndex, API_Coord *coord)
 Inserts a node into a polygon.
 
GSErrCode ACAPI_Polygon_DeletePolyNode (API_ElementMemo *memo, Int32 *inIndex)
 Deletes a node from a polygon.
 
GSErrCode ACAPI_Polygon_InsertSubPoly (API_ElementMemo *memo, API_ElementMemo *insMemo)
 Inserts a whole subpolygon (hole) into a polygon.
 
GSErrCode ACAPI_Polygon_DeleteSubPoly (API_ElementMemo *elementMemo, Int32 *subPolyIndex)
 Deletes a whole subpolygon (hole) from a polygon.
 
GSErrCode ACAPI_Polygon_RegularizePolygon (const API_RegularizedPoly *polygon, Int32 *nResult, API_RegularizedPoly ***regularizedPolygons)
 Regularizes a polygon and returns the regularized polygons.
 
GSErrCode ACAPI_Polygon_RegularizePolyline (const API_RegularizedPoly *polyline, API_RegularizedPoly *regularizedPolyline)
 Regularizes a polyline and returns the regularized polyline.
 
GSErrCode ACAPI_Polygon_DisposeRegularizedPoly (API_RegularizedPoly *regularizedPoly)
 Deallocates handles in an API_RegularizedPoly struct.
 
GSErrCode ACAPI_Polygon_TriangulatePoly (API_ElementMemo *memo, API_Coord ***coords)
 Decomposes a polygon into triangles.
 
GSErrCode ACAPI_Polygon_PolygonId2SurfaceType (const API_Element *elem=nullptr, const Int32 *polygonId=nullptr, API_SurfaceTypeID *surfaceType=nullptr)
 Converts a picture into another image format.
 

Detailed Description

Functions to change the shape of a polygon. These polygons are always provided through API_ElementMemo.

Enumeration Type Documentation

◆ API_SurfaceTypeID

Possible types of a surface.

Remarks
This enum defines various surface types that can be used in Archicad. Each surface type is associated with specific elements such as beams, columns, slabs, walls, shells, and roofs. The types are organized hierarchically, with each category having designated first and last values for better management.
Enumerator
APISurfaceType_NotSpecified 

APISurfaceType_NotSpecified

APISurfaceType_BeamFirst 

APISurfaceType_BeamFirst

APISurfaceType_BeamRight 

APISurfaceType_BeamRight

APISurfaceType_BeamLeft 

APISurfaceType_BeamLeft

APISurfaceType_BeamSide 

APISurfaceType_BeamSide

APISurfaceType_BeamTop 

APISurfaceType_BeamTop

APISurfaceType_BeamBottom 

APISurfaceType_BeamBottom

APISurfaceType_BeamCut 

APISurfaceType_BeamCut

APISurfaceType_BeamLast 

APISurfaceType_BeamLast

APISurfaceType_ColumnFisrt 

APISurfaceType_ColumnFirst

APISurfaceType_ColumnTop 

APISurfaceType_ColumnTop

APISurfaceType_ColumnBottom 

APISurfaceType_ColumnBottom

APISurfaceType_ColumnCoreSide 

APISurfaceType_ColumnCoreSide

APISurfaceType_ColumnVeneerSide 

APISurfaceType_ColumnVeneerSide

APISurfaceType_ColumnCut 

APISurfaceType_ColumnCut

APISurfaceType_ColumnLast 

APISurfaceType_ColumnLast

APISurfaceType_SlabFirst 

APISurfaceType_SlabFirst

APISurfaceType_SlabTop 

APISurfaceType_SlabTop

APISurfaceType_SlabBottom 

APISurfaceType_SlabBottom

APISurfaceType_SlabSide 

APISurfaceType_SlabSide

APISurfaceType_SlabCut 

APISurfaceType_SlabCut

APISurfaceType_SlabLast 

APISurfaceType_SlabLast

APISurfaceType_WallFirst 

APISurfaceType_WallFirst

APISurfaceType_WallRefSide 

APISurfaceType_WallRefSide

APISurfaceType_WallOppSide 

APISurfaceType_WallOppSide

APISurfaceType_WallSide 

APISurfaceType_WallSide

APISurfaceType_WallCut 

APISurfaceType_WallCut

APISurfaceType_WallLast 

APISurfaceType_WallLast

APISurfaceType_ShellReferenceFirst 

APISurfaceType_ShellReferenceFirst

APISurfaceType_ShellReferenceSide 

APISurfaceType_ShellReferenceSide

APISurfaceType_ShellOppositeSide 

APISurfaceType_ShellOppositeSide

APISurfaceType_ShellRidge 

APISurfaceType_ShellRidge

APISurfaceType_ShellValley 

APISurfaceType_ShellValley

APISurfaceType_ShellGable 

APISurfaceType_ShellGable

APISurfaceType_ShellHip 

APISurfaceType_ShellHip

APISurfaceType_ShellEaves 

APISurfaceType_ShellEaves

APISurfaceType_ShellPeak 

APISurfaceType_ShellPeak

APISurfaceType_ShellSideWall 

APISurfaceType_ShellSideWall

APISurfaceType_ShellEndWall 

APISurfaceType_ShellEndWall

APISurfaceType_ShellRTDome 

APISurfaceType_ShellRTDome

APISurfaceType_ShellRTHollow 

APISurfaceType_ShellRTHollow

APISurfaceType_ShellSide 

APISurfaceType_ShellSide

APISurfaceType_ShellCut 

APISurfaceType_ShellCut

APISurfaceType_ShellInnerReferenceSide 

APISurfaceType_ShellInnerReferenceSide

APISurfaceType_ShellInnerOppositeSide 

APISurfaceType_ShellInnerOppositeSide

APISurfaceType_ShellLast 

APISurfaceType_ShellLast

APISurfaceType_PlaneRoofFirst 

APISurfaceType_PlaneRoofFirst

APISurfaceType_PlaneRoofTop 

APISurfaceType_PlaneRoofTop

APISurfaceType_PlaneRoofBottom 

APISurfaceType_PlaneRoofBottom

APISurfaceType_PlaneRoofRidge 

APISurfaceType_PlaneRoofRidge

APISurfaceType_PlaneRoofValley 

APISurfaceType_PlaneRoofValley

APISurfaceType_PlaneRoofGable 

APISurfaceType_PlaneRoofGable

APISurfaceType_PlaneRoofHip 

APISurfaceType_PlaneRoofHip

APISurfaceType_PlaneRoofEaves 

APISurfaceType_PlaneRoofEaves

APISurfaceType_PlaneRoofPeak 

APISurfaceType_PlaneRoofPeak

APISurfaceType_PlaneRoofSideWall 

APISurfaceType_PlaneRoofSideWall

APISurfaceType_PlaneRoofEndWall 

APISurfaceType_PlaneRoofEndWall

APISurfaceType_PlaneRoofRTDome 

APISurfaceType_PlaneRoofRTDome

APISurfaceType_PlaneRoofRTHollow 

APISurfaceType_PlaneRoofRTHollow

APISurfaceType_PlaneRoofSide 

APISurfaceType_PlaneRoofSide

APISurfaceType_PlaneRoofCut 

APISurfaceType_PlaneRoofCut

APISurfaceType_PlaneRoofLast 

APISurfaceType_PlaneRoofLast

APISurfaceType_PolyRoofFirst 

APISurfaceType_PolyRoofFirst

APISurfaceType_PolyRoofTop 

APISurfaceType_PolyRoofTop

APISurfaceType_PolyRoofBottom 

APISurfaceType_PolyRoofBottom

APISurfaceType_PolyRoofRidge 

APISurfaceType_PolyRoofRidge

APISurfaceType_PolyRoofValley 

APISurfaceType_PolyRoofValley

APISurfaceType_PolyRoofGable 

APISurfaceType_PolyRoofGable

APISurfaceType_PolyRoofHip 

APISurfaceType_PolyRoofHip

APISurfaceType_PolyRoofEaves 

APISurfaceType_PolyRoofEaves

APISurfaceType_PolyRoofPeak 

APISurfaceType_PolyRoofPeak

APISurfaceType_PolyRoofSideWall 

APISurfaceType_PolyRoofSideWall

APISurfaceType_PolyRoofEndWall 

APISurfaceType_PolyRoofEndWall

APISurfaceType_PolyRoofRTDome 

APISurfaceType_PolyRoofRTDome

APISurfaceType_PolyRoofRTHollow 

APISurfaceType_PolyRoofRTHollow

APISurfaceType_PolyRoofUndefined 

APISurfaceType_PolyRoofUndefined

APISurfaceType_PolyRoofInner 

APISurfaceType_PolyRoofInner

APISurfaceType_PolyRoofCut 

APISurfaceType_PolyRoofCut

APISurfaceType_PolyRoofLast 

APISurfaceType_PolyRoofLast

Function Documentation

◆ ACAPI_Polygon_DeletePolyNode()

GSErrCode ACAPI_Polygon_DeletePolyNode ( API_ElementMemo * memo,
Int32 * inIndex )

Deletes a node from a polygon.

Parameters
memo[in/out] The polygon data.
inIndex[in] node index (subindex of the element) to delete
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or invalid nodeIndex passed or memo is not initialized
  • APIERR_MEMFULL - low memory condition
  • APIERR_IRREGULARPOLY - Input polygon or polyline is irregular.
Remarks
This function is used to delete a node from a polygon passed in an API_ElementMemo structure. Refer to the API_Polygon structure to have more details on the polygon data structure. The coords, pends, parcs and vertexIDs handles in the API_ElementMemo structure must be initialized. Note that other memo handles are not touched. In the case the polygon belongs to a roof with side angles initialized, it must be aligned manually.
Example
// -----------------------------------------------------------------------------
// Delete the clicked node from the polygon
// - dimensions must be updated automatically
// -----------------------------------------------------------------------------
void Do_Poly_DeleteNode (void)
{
API_Neig neig;
Int32 nodeInd;
GSErrCode err;
if (!ClickAnElem ("Click a polygon node to delete", API_ZombieElemID, &neig, &type)) {
WriteReport_Alert ("No element was clicked");
return;
}
switch (neig.neigID) {
case APINeig_Ceil:
case APINeig_Roof:
case APINeig_Mesh:
case APINeig_Room:
case APINeig_Hatch:
case APINeig_PolyLine:
case APINeig_DetailPoly:
case APINeig_WorksheetPoly:
case APINeig_DrawingFrame:
case APINeig_InteriorElevation: break;
default: WriteReport_Alert ("Only polygon nodes are accepted");
return;
}
err = ACAPI_Element_GetMemo (neig.guid, &memo);
if (err != NoError) {
ErrorBeep ("ACAPI_Element_GetMemo", err);
return;
}
if (BMhGetSize ((GSHandle) memo.coords) / sizeof (API_Coord) <= 5) {
return;
}
nodeInd = neig.inIndex;
err = ACAPI_Polygon_DeletePolyNode (&memo, &nodeInd);
if (err == NoError) {
API_ElementMemo tmpMemo {};
tmpMemo.coords = memo.coords;
tmpMemo.pends = memo.pends;
tmpMemo.parcs = memo.parcs;
tmpMemo.vertexIDs = memo.vertexIDs;
tmpMemo.meshPolyZ = memo.meshPolyZ;
tmpMemo.edgeIDs = memo.edgeIDs;
tmpMemo.edgeTrims = memo.edgeTrims;
tmpMemo.contourIDs = memo.contourIDs;
err = ACAPI_Element_ChangeMemo (neig.guid, GetMemoMask (neig), &tmpMemo);
if (err != NoError)
ErrorBeep ("ACAPI_Element_ChangeMemo", err);
} else
ErrorBeep ("APIAny_DeletePolyNodeID", err);
return;
} // Do_Poly_DeleteNode

◆ ACAPI_Polygon_DeleteSubPoly()

GSErrCode ACAPI_Polygon_DeleteSubPoly ( API_ElementMemo * elementMemo,
Int32 * subPolyIndex )

Deletes a whole subpolygon (hole) from a polygon.

Parameters
elementMemo[in/out] The polygon data.
subPolyIndex[in] subpolygon index to delete
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or invalid subPolyIndex passed
  • APIERR_MEMFULL - low memory condition
  • APIERR_IRREGULARPOLY - Input polygon is irregular.
Remarks
This function is used to delete a whole subpolygon (hole) from a polygon passed in an API_ElementMemo structure. Refer to the API_Polygon structure to have more details on the polygon data structure. The coords, pends, parcs and vertexIDs handles in the API_ElementMemo structure must be initialized. Note that other memo handles are not touched. In the case the polygon belongs to a roof with side angles initialized, it must be aligned manually.
Example
GSErrCode DeleteSubPoly (const API_Guid& guid)
{
Int32 lastSubPoly;
GSErrCode err;
err = ACAPI_Element_GetMemo (guid, &memo);
if (err) {
lastSubPoly = BMGetHandleSize ((GSHandle) memo.pends) / sizeof (Int32) - 1;
if (lastSubPoly > 1)
err = ACAPI_Polygon_DeleteSubPoly (&memo, &lastSubPoly);
}
return err;
}

◆ ACAPI_Polygon_DisposeRegularizedPoly()

GSErrCode ACAPI_Polygon_DisposeRegularizedPoly ( API_RegularizedPoly * regularizedPoly)

Deallocates handles in an API_RegularizedPoly struct.

Parameters
regularizedPoly[in] The polygon or polyline data to dipose.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or memo or insMemo is not initialized
  • APIERR_MEMFULL - low memory condition

◆ ACAPI_Polygon_InsertPolyNode()

GSErrCode ACAPI_Polygon_InsertPolyNode ( API_ElementMemo * elementMemo,
Int32 * nodeIndex,
API_Coord * coord )

Inserts a node into a polygon.

Parameters
elementMemo[in/out] The polygon data.
nodeIndex[in] node index (subindex of the element) to insert a new node after
coord[in] The coordinate of the new node.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or invalid nodeIndex passed or memo is not initialized
  • APIERR_MEMFULL - low memory condition
  • APIERR_IRREGULARPOLY - Input polygon or polyline is irregular.
Remarks
This function is used to insert a new node into a polygon passed in an API_ElementMemo structure. This function inserts the given coordinate into the right place. Refer to the API_Polygon structure to have more details on the polygon data structure. The coords, pends, parcs and vertexIDs handles in the API_ElementMemo structure must be initialized. Note that other memo handles are not touched. In the case the polygon belongs to a roof with side angles initialized, it must be aligned manually.
Example
// -----------------------------------------------------------------------------
// Insert a new node into the clicked polygon edge
// - dimensions must be updated automatically
// -----------------------------------------------------------------------------
void Do_Poly_InsertNode (void)
{
API_Neig neig;
Int32 nodeInd;
GSErrCode err;
if (!ClickAnElem ("Click a polygon edge to insert a new node into", API_ZombieElemID, &neig, &type, nullptr, &begC)) {
WriteReport_Alert ("No element was clicked");
return;
}
switch (neig.neigID) {
case APINeig_CeilOn:
case APINeig_RoofOn:
case APINeig_MeshOn:
case APINeig_RoomOn:
case APINeig_HatchOn:
case APINeig_PolyLineOn:
case APINeig_DetailPolyOn:
case APINeig_WorksheetPolyOn:
case APINeig_DrawingFrameOn:
case APINeig_InteriorElevationOn: break;
default: WriteReport_Alert ("Only polygon edges are accepted");
return;
}
API_Element elem {};
elem.header.guid = neig.guid;
err = ACAPI_Element_Get (&elem);
if (err != NoError) {
ErrorBeep ("ACAPI_Element_Get", err);
return;
}
if (elem.header.type == API_RoofID && elem.roof.roofClass != API_PlaneRoofID) {
WriteReport_Alert ("Only plane roofs are accepted");
return;
}
err = ACAPI_Element_GetMemo (neig.guid, &memo);
if (err != NoError) {
ErrorBeep ("ACAPI_Element_GetMemo", err);
return;
}
nodeInd = neig.inIndex + 1;
API_Coord toInsert {};
toInsert.x = begC.x;
toInsert.y = begC.y;
err = ACAPI_Polygon_InsertPolyNode (&memo, &nodeInd, &toInsert);
if (err == NoError) {
API_ElementMemo tmpMemo {};
tmpMemo.coords = memo.coords;
tmpMemo.pends = memo.pends;
tmpMemo.parcs = memo.parcs;
tmpMemo.vertexIDs = memo.vertexIDs;
tmpMemo.edgeIDs = memo.edgeIDs;
tmpMemo.edgeTrims = memo.edgeTrims;
tmpMemo.contourIDs = memo.contourIDs;
tmpMemo.meshPolyZ = memo.meshPolyZ;
err = ACAPI_Element_ChangeMemo (neig.guid, GetMemoMask (neig), &tmpMemo);
if (err != NoError)
ErrorBeep ("ACAPI_Element_ChangeMemo", err);
} else
ErrorBeep ("APIAny_InsertPolyNodeID", err);
return;
} // Do_Poly_InsertNode

◆ ACAPI_Polygon_InsertSubPoly()

GSErrCode ACAPI_Polygon_InsertSubPoly ( API_ElementMemo * memo,
API_ElementMemo * insMemo )

Inserts a whole subpolygon (hole) into a polygon.

Parameters
memo[in/out] The polygon data.
insMemo[in] Data of the new subpolygon.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or memo or insMemo is not initialized
  • APIERR_MEMFULL - low memory condition
  • APIERR_IRREGULARPOLY - Input polygon is irregular.
Remarks
This function is used to insert a new subpolygon (hole) into a polygon passed in an API_ElementMemo structure. The shape of the new hole should be passed in the insMemo parameter. Refer to the API_Polygon structure to have more details on the polygon data structure. The coords, pends, parcs and vertexIDs handles in the API_ElementMemo structure must be initialized in the case of the memo parameter. The vertexID and pends handles are ignored in the insMemo parameter. The function places the new hole to the and of the contour list. Note that other memo handles are not touched. In the case the polygon belongs to a roof with side angles initialized, it must be aligned manually.

◆ ACAPI_Polygon_PolygonId2SurfaceType()

GSErrCode ACAPI_Polygon_PolygonId2SurfaceType ( const API_Element * elem = nullptr,
const Int32 * polygonId = nullptr,
API_SurfaceTypeID * surfaceType = nullptr )

Converts a picture into another image format.

Parameters
elem[in] Parameter elem for element type identification. Give elem.header.guid or elem.header.typeId. For roofs specify elem.roof.roofClass also.
polygonId[in] Parameter polygonId.
surfaceType[out] Parameter surfaceType.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - parameters are nullptr or invalid
  • APIERR_BADID - elemGuid does not refer to a valid element in the database.
Remarks
This function is used to convert a polygonId returned by ModelerAPI::Polygon::GetPolygonId to a API_SurfaceTypeID.

◆ ACAPI_Polygon_RegularizePolygon()

GSErrCode ACAPI_Polygon_RegularizePolygon ( const API_RegularizedPoly * polygon,
Int32 * nResult,
API_RegularizedPoly *** regularizedPolygons )

Regularizes a polygon and returns the regularized polygons.

Parameters
polygon[in] The polygon to regularize.
nResult[out] The number of resulting regularized polygons.
regularizedPolygons[out] The result of regularization.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or polygon or regularizedPolygons is not initialized
  • APIERR_MEMFULL - low memory condition
Remarks
This function is used to regularize a polygon. The result may be 0, 1 or more regularized polygons. Refer to the API_RegularizedPoly structure to have more details on the polygon data structure.

◆ ACAPI_Polygon_RegularizePolyline()

GSErrCode ACAPI_Polygon_RegularizePolyline ( const API_RegularizedPoly * polyline,
API_RegularizedPoly * regularizedPolyline )

Regularizes a polyline and returns the regularized polyline.

Parameters
polyline[in] The polyline to regularize.
regularizedPolyline[out] The result of regularization.
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr or polyline or regularizedPolyline is not initialized
  • APIERR_MEMFULL - low memory condition
Remarks
This function is used to regularize a polyline. A polyline is considered irregular when two or more consecutive vertices in the coord array are the same. The result may be an empty polyline. Refer to the API_RegularizedPoly structure to have more details on the polyline data structure.

◆ ACAPI_Polygon_TriangulatePoly()

GSErrCode ACAPI_Polygon_TriangulatePoly ( API_ElementMemo * memo,
API_Coord *** coords )

Decomposes a polygon into triangles.

Parameters
memo[in] Parameters of an polygon. The coordinates of the polygon and the subpolygon endpoints must be coords handle and pends handle in the memo.
coords[out] Coordinates of the triangles
Returns
  • NoError - The function has completed with success.
  • APIERR_BADPARS - any of the parameters are nullptr
  • APIERR_REFUSEDPAR - Arc in the polygon
  • APIERR_MEMFULL - Not enough memory to complete the operation
  • APIERR_IRREGULARPOLY - Input polygon is irregular.
Remarks
This function is used to decompose a polygon into triangles. The coords handle will be allocated by the server application and filled with coordinates. The number of generated triangles should be determined based on the returned handle size. The function accept only polygons which has no arc segments. Do not forget to dispose the coords handle if it is not needed any more.
Example
#include "BM.hpp" /* BMhKill */
GSErrCode TriangulateSlab (const API_Guid& slabGuid)
{
API_Element element {};
API_ElementMemo memo {};
API_Coord **coords;
Int32 nTriangles;
GSErrCode err;
element.header.guid = slabGuid;
err = ACAPI_Element_Get (&element);
if (!err) {
if (element.slab.poly.nArcs > 0)
err = ACAPI_Element_GetMemo (element.header.guid, &memo);
if (!err) {
err = ACAPI_Polygon_TriangulatePoly (&memo, &coords);
if (!err) {
nTriangles = BMGetHandleSize ((GSHandle) coords) / (3 * sizeof (API_Coord));
ACAPI_WriteReport ("Number of triangles: %d", false, nTriangles);
/* ... */
BMKillHandle ((GSHandle *) &coords);
}
}
}
return err;
}