Sample demonstrating section by plane of a solid implemented by BRepAlgoAPI_Section algorithm.
pload MODELING VISUALIZATION
# Make a box b with a corner at [0, 0, 0] and the specified sizes
box b 10.0 15.0 20.0
# Make a plane with the origin in box center and DZ normal
plane p 10.0/2 15.0/2 20.0/2 0.0 0.0 1.0
mkface pp p -100 100 -100 100
# make a section of box b by plane pp
bsection r b pp
# display in the viewer
vinit View1
vdisplay -dispMode 0 b pp
vaspects b -color YELLOW
vaspects pp -color GREEN
vdisplay -dispMode 1 r
vaspects r -color RED
vfit
// Make a box #1 with a corner at [0, 0, 0] and the specified sizes.Standard_RealaSizeX=10.0;Standard_RealaSizeY=15.0;Standard_RealaSizeZ=20.0;TopoDS_ShapeaShape=BRepPrimAPI_MakeBox(aSizeX,aSizeY,aSizeZ);myResult<<"Box at corner [0, 0, 0] and sizes ["<<aSizeX<<", "<<aSizeY<<", "<<aSizeZ<<"] was created in yellow wireframe"<<std::endl;// Create a boolean algo.// Make a section by a plane.gp_PlnaPln(gp_Pnt(aSizeX/2.0,aSizeY/2.0,aSizeZ/2.0),gp::DZ());BRepAlgoAPI_SectionanAlgo(aShape,aPln,Standard_False);// Make operation.anAlgo.Build();if(!anAlgo.IsDone())// Process errors{myResult<<"Errors : "<<std::endl;anAlgo.DumpErrors(myResult);}if(anAlgo.HasWarnings())// Process warnings{myResult<<"Warnings : "<<std::endl;anAlgo.DumpErrors(myResult);}if(anAlgo.IsDone()){// Get result.TopoDS_ShapeaResultShape=anAlgo.Shape();myResult<<"Result shape was created in red"<<std::endl;Handle(AIS_ColoredShape)anAisShape=newAIS_ColoredShape(aShape);Handle(AIS_Plane)anAisPlane=newAIS_Plane(newGeom_Plane(aPln));anAisShape->SetColor(Quantity_Color(Quantity_NOC_YELLOW));Handle(AIS_ColoredShape)anAisResult=newAIS_ColoredShape(aResultShape);anAisResult->SetColor(Quantity_Color(Quantity_NOC_RED));myObject3d.Append(anAisShape);myObject3d.Append(anAisPlane);myObject3d.Append(anAisResult);myContext->SetDisplayMode(anAisShape,0,Standard_True);}