Inserts a node into a polygon.
GSErrCode ACAPI_Goodies ( APIAny_InsertPolyNodeID, API_ElementMemo* elementMemo, Int32* nodeIndex, API_Coord* coord );
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.
Return Values
NoError
- The function has completed with success.
APIERR_BADPARS
- any of the parameters are
nullptr
or invalidnodeIndex
passed ormemo
is not initialized APIERR_MEMFULL
- low memory condition
APIERR_IRREGULARPOLY
- Input polygon or polyline is irregular.
For other common API errors see the API Errors document.
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.
Examples
/*----------------------------------------------------------** ** Insert a new node into the clicked poly edge ** **----------------------------------------------------------*/ static void Do_Poly_InsertNode (void) { API_ElementMemo memo; API_Neig neig; API_ElemTypeID idElem; API_Coord3D begC; API_EdgeTrim edgeTrim; Int32 nodeInd; GSErrCode err; if (!ClickAnElem ("Click an edge to insert new node", API_ZombieElemID, &neig, nullptr, nullptr, &begC)) { GiveMessage ("Please click a polygon node", true); return; } if (neig.neigID != APINeig_CeilOn && neig.neigID != APINeig_RoofOn) { GiveMessage ("Please click a ceil or roof edge", true); return; } idElem = Neig_To_ElemID (neig.neigID); err = ACAPI_Element_GetMemo (neig.guid, &memo); if (err) { GiveMessage_Err ("ACAPI_Element_GetMemo", err); return; } nodeInd = neig.inIndex + 1; err = ACAPI_Goodies (APIAny_InsertPolyNodeID, &memo, &nodeInd, (API_Coord*)(&begC)); if (!err) { switch (idElem) { case API_SlabID: /* nothing to do */ break; case API_RoofID: if (memo.edgeTrims != nullptr && *memo.edgeTrims != nullptr) { /* insert edgeTrim rec; [neig.inIndex] */ } break; default: return; /* never got there */ } err = ACAPI_Element_ChangeMemo (neig.guid, APIMemoMask_Polygon, &memo); if (err) GiveMessage_Err ("ACAPI_Element_ChangeMemo", err); } else GiveMessage_Err ("APIAny_InsertPolyNodeID", err); ACAPI_DisposeElemMemoHdls (&memo); return; }
Requirements
- Version: API 4.1 or later
- Header: APIdefs_Goodies.h
See Also
API_Polygon, API_ElementMemo,
APIAny_DeletePolyNodeID, APIAny_InsertSubPolyID, APIAny_DeleteSubPolyID,
ACAPI_Goodies, API Functions