Cuts a body with a plane and returns the cutting surface and area.
GSErrCode ACAPI_3D_GetCutPolygonInfo ( Int32 bodyIndex, const API_Plane3D& cutPlane, GS::Array<Geometry::MultiPolygon2D>* resPolygons = nullptr, double* area = nullptr );
Parameters
- bodyIndex
- [in] The index of the body to cut.
- cutPlane
- [in] Cutting plane.
- resPolygons
- [out] Polygons of the cutting surface. (optional parameter)
- area
- [out] Area of the cutting surface. (optional parameter)
Return Values
NoError
- The function has completed with success.
APIERR_BADPARS
- The passed output parameter are both
nullptr
(resPolygons
andarea
) APIERR_REFUSEDCMD
- The 3D model is not available in the current context, or
- The body cannot be queried directly; not active body
APIERR_BADINDEX
- The bodyIndex is out of range
For other common API errors see the API Errors document.
Remarks
This function is used to cut a given body with a cutting plane and get the cutting surface.
To get the polygons of the cutting surface, pass the resPolygons
parameter. To get only the area of the cutting surface, set the area
parameter.
One of the output parameters (resPolygons
and area
) must be not nullptr.
Example
Int32 nBody, i, j; API_Plane3D cutPlane; double area; GS::Array<Geometry::MultiPolygon2D> resPolygons; cutPlane.basePoint.x = 0.0; cutPlane.basePoint.y = 0.0; cutPlane.basePoint.z = 1.0; cutPlane.axisX.x = 1.0; cutPlane.axisX.y = 0.0; cutPlane.axisX.z = 0.0; cutPlane.axisY.x = 0.0; cutPlane.axisY.y = 1.0; cutPlane.axisY.z = 0.0; cutPlane.axisZ.x = 0.0; cutPlane.axisZ.y = 0.0; cutPlane.axisZ.z = 1.0; err = ACAPI_3D_GetNum (API_BodyID, &nBody); for (i = 1; i <= nBody && err == NoError; i++) { err = ACAPI_3D_GetCutPolygonInfo (i, cutPlane, &resPolygons, &area); if (err == NoError) { for (j = 0; j <= resPolygons.GetSize (); j++) { double areaOfThisPolygon = resPolygons[j].CalcArea (); } } }
Requirements
- Version: API 17 or later
- Header: ACAPinc.h