- }
-
- // Making solids from bounding planes.
- TopoDS_Shell aToShell, aFromShell;
- TopoDS_Solid aToSolid, aFromSolid;
- const TopoDS_Shape& aToShape = aBoundingToShape->impl<TopoDS_Shape>();
- const TopoDS_Shape& aFromShape = aBoundingFromShape->impl<TopoDS_Shape>();
- BRep_Builder aBoundingBuilder;
- aBoundingBuilder.MakeShell(aToShell);
- aBoundingBuilder.MakeShell(aFromShell);
- aBoundingBuilder.Add(aToShell, aToShape);
- aBoundingBuilder.Add(aFromShell, aFromShape);
- aBoundingBuilder.MakeSolid(aToSolid);
- aBoundingBuilder.MakeSolid(aFromSolid);
- aBoundingBuilder.Add(aToSolid, aToShell);
- aBoundingBuilder.Add(aFromSolid, aFromShell);
-
- // Cutting with to plane.
- BRepAlgoAPI_Cut* aToCutBuilder = new BRepAlgoAPI_Cut(aResult, aToSolid);
- aToCutBuilder->Build();
- if(!aToCutBuilder->IsDone()) {
- return;
- }
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aToCutBuilder)));
- const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape);
- for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- myToFaces.push_back(aShape);
- }
- aResult = aToCutBuilder->Shape();
-
- // Cutting with from plane.
- BRepAlgoAPI_Cut* aFromCutBuilder = new BRepAlgoAPI_Cut(aResult, aFromSolid);
- aFromCutBuilder->Build();
- if(!aFromCutBuilder->IsDone()) {
- return;
- }
- aListOfMakeShape.push_back(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aFromCutBuilder)));
- const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape);
- for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) {
- std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- myFromFaces.push_back(aShape);
- }
- aResult = aFromCutBuilder->Shape();
-
- TopExp_Explorer anExp(aResult, TopAbs_SOLID);
- if(!anExp.More()) {
- return;
- }
- if(aResult.ShapeType() == TopAbs_COMPOUND) {
- aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
- }
- if(aResult.ShapeType() == TopAbs_COMPOUND) {
- std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
- aCompound->setImpl(new TopoDS_Shape(aResult));
- ListOfShape aCompSolids, aFreeSolids;
- GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
- if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
- aResult = aCompSolids.front()->impl<TopoDS_Shape>();
- } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
- TopoDS_Compound aResultComp;
- TopoDS_Builder aBuilder;
- aBuilder.MakeCompound(aResultComp);
- for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
- }
- for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
- aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ if(aResult.ShapeType() == TopAbs_COMPOUND) {
+ std::shared_ptr<GeomAPI_Shape> aCompound(new GeomAPI_Shape);
+ aCompound->setImpl(new TopoDS_Shape(aResult));
+ ListOfShape aCompSolids, aFreeSolids;
+ GeomAlgoAPI_ShapeTools::combineShapes(aCompound, GeomAPI_Shape::COMPSOLID, aCompSolids, aFreeSolids);
+ if(aCompSolids.size() == 1 && aFreeSolids.size() == 0) {
+ aResult = aCompSolids.front()->impl<TopoDS_Shape>();
+ } else if (aCompSolids.size() > 1 || (aCompSolids.size() >= 1 && aFreeSolids.size() >= 1)) {
+ TopoDS_Compound aResultComp;
+ TopoDS_Builder aBuilder;
+ aBuilder.MakeCompound(aResultComp);
+ for(ListOfShape::const_iterator anIter = aCompSolids.cbegin(); anIter != aCompSolids.cend(); anIter++) {
+ aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ }
+ for(ListOfShape::const_iterator anIter = aFreeSolids.cbegin(); anIter != aFreeSolids.cend(); anIter++) {
+ aBuilder.Add(aResultComp, (*anIter)->impl<TopoDS_Shape>());
+ }
+ aResult = aResultComp;