}
// Getting direction.
- gp_Pnt aLoc;
gp_Vec aDirVec;
std::shared_ptr<GeomAPI_Pnt> aBaseLoc;
std::shared_ptr<GeomAPI_Dir> aBaseDir;
GeomShapePtr aBasePlane;
const bool isBoundingShapesSet = theFromShape.get() || theToShape.get();
BRepBuilderAPI_FindPlane aFindPlane(aBaseShape);
- if(aBaseShape.ShapeType() == TopAbs_VERTEX || aBaseShape.ShapeType() == TopAbs_EDGE ||
- aFindPlane.Found() != Standard_True) {
- // Direction should be set.
- if(!theDirection.get()) {
- return;
- }
-
+ if(theDirection.get()) {
aBaseDir = theDirection;
aDirVec = theDirection->impl<gp_Dir>();
+ } else if(aBaseShape.ShapeType() != TopAbs_VERTEX &&
+ aBaseShape.ShapeType() != TopAbs_EDGE &&
+ aFindPlane.Found() == Standard_True){
+ Handle(Geom_Plane) aPlane = aFindPlane.Plane();
+ gp_Pnt aLoc = aPlane->Axis().Location();
+ aDirVec = aPlane->Axis().Direction();
+ aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
+ aBaseDir.reset(new GeomAPI_Dir(aDirVec.X(), aDirVec.Y(), aDirVec.Z()));
+ } else {
+ return;
+ }
+ if(!aBaseLoc.get()) {
+ gp_Pnt aLoc;
gp_XYZ aDirXYZ = aDirVec.XYZ();
Standard_Real aMinParam = Precision::Infinite();
-
for(TopExp_Explorer anExp(aBaseShape, TopAbs_VERTEX); anExp.More(); anExp.Next()) {
const TopoDS_Shape& aVertex = anExp.Current();
gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aVertex));
aLoc = aPnt;
}
}
- } else {
- if(!theDirection.get()) {
- Handle(Geom_Plane) aPlane = aFindPlane.Plane();
- aLoc = aPlane->Axis().Location();
- aDirVec = aPlane->Axis().Direction();
-
- aBaseDir.reset(new GeomAPI_Dir(aDirVec.X(), aDirVec.Y(), aDirVec.Z()));
- } else {
- aBaseDir = theDirection;
- aDirVec = theDirection->impl<gp_Dir>();
- }
+ aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
}
- aBaseLoc.reset(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z()));
aBasePlane = GeomAlgoAPI_FaceBuilder::planarFace(aBaseLoc, aBaseDir);
TopoDS_Shape aResult;
// Naming for extrusion from vertex, edge.
for(TopExp_Explorer anExp(aResult, aShapeTypeToExp); anExp.More(); anExp.Next()) {
const TopoDS_Shape& aShape = anExp.Current();
+ GeomShapePtr aGeomSh(new GeomAPI_Shape());
if(aShapeTypeToExp == TopAbs_VERTEX) {
gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
IntTools_Context anIntTools;
if(anIntTools.IsValidPointForFace(aPnt, aToFace, Precision::Confusion()) == Standard_True) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addToShape(aGeomSh);
}
if(anIntTools.IsValidPointForFace(aPnt, aFromFace, Precision::Confusion()) == Standard_True) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addFromShape(aGeomSh);
}
BRepLib_CheckCurveOnSurface anEdgeCheck(anEdge, aToFace);
anEdgeCheck.Perform();
if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addToShape(aGeomSh);
}
anEdgeCheck.Init(anEdge, aFromFace);
anEdgeCheck.Perform();
if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addFromShape(aGeomSh);
}
// Setting naming.
for(TopExp_Explorer anExp(aResult, aShapeTypeToExp); anExp.More (); anExp.Next ()) {
const TopoDS_Shape& aShape = anExp.Current();
+ GeomShapePtr aGeomSh(new GeomAPI_Shape());
if(aShapeTypeToExp == TopAbs_VERTEX) {
gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
IntTools_Context anIntTools;
if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(aRotatedToFace), Precision::Confusion()) == Standard_True) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addToShape(aGeomSh);
}
if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(aRotatedFromFace), Precision::Confusion()) == Standard_True) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addFromShape(aGeomSh);
}
BRepLib_CheckCurveOnSurface anEdgeCheck(anEdge, TopoDS::Face(aRotatedToFace));
anEdgeCheck.Perform();
if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addToShape(aGeomSh);
}
anEdgeCheck.Init(anEdge, TopoDS::Face(aRotatedFromFace));
anEdgeCheck.Perform();
if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
- GeomShapePtr aGeomSh(new GeomAPI_Shape());
aGeomSh->setImpl(new TopoDS_Shape(aShape));
this->addFromShape(aGeomSh);
}
Handle(Geom_Surface) aFromSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedFromFace));
Handle(Geom_Surface) aToSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedToFace));
if(aFaceSurface == aFromSurface) {
- GeomShapePtr aFSHape(new GeomAPI_Shape);
- aFSHape->setImpl(new TopoDS_Shape(aShape));
- this->addFromShape(aFSHape);
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ this->addFromShape(aGeomSh);
}
if(aFaceSurface == aToSurface) {
- GeomShapePtr aTSHape(new GeomAPI_Shape);
- aTSHape->setImpl(new TopoDS_Shape(aShape));
- this->addToShape(aTSHape);
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ this->addToShape(aGeomSh);
}
}
}
}
this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBoundingCutBuilder)));
aResult = aBoundingCutBuilder->Shape();
+ if(aResult.ShapeType() == TopAbs_COMPOUND) {
+ aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+ }
// Setting naming.
- const TopTools_ListOfShape& aBndShapes = aBoundingCutBuilder->Modified(aBoundingFace);
- for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) {
- GeomShapePtr aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape);
+ if(aShapeTypeToExp == TopAbs_FACE) {
+ const TopTools_ListOfShape& aBndShapes = aBoundingCutBuilder->Modified(aBoundingFace);
+ for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) {
+ GeomShapePtr aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(anIt.Value()));
+ isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape);
+ }
}
// Try to cut with base face. If it can not be done then keep result of cut with bounding plane.
aBasePlane->Axis().Direction().Y(),
aBasePlane->Axis().Direction().Z()));
GeomShapePtr aPln = GeomAlgoAPI_FaceBuilder::planarFace(theCenter, theNormal);
-
aList.push_back(aSh);
std::list<std::shared_ptr<GeomAPI_Pnt> > aBoundingPoints = GeomAlgoAPI_ShapeTools::getBoundingBox(aList);
-
aSh = GeomAlgoAPI_ShapeTools::fitPlaneToBox(aPln, aBoundingPoints);
+ aModifiedBaseShape = aSh->impl<TopoDS_Shape>();
} else {
aModifiedBaseShape = aBaseShape;
}
aBaseCutBuilder->Build();
if(aBaseCutBuilder->IsDone()) {
TopoDS_Shape aCutResult = aBaseCutBuilder->Shape();
- TopExp_Explorer anExp(aCutResult, TopAbs_SOLID);
- if(anExp.More()) {
+ TopoDS_Iterator aCheckIt(aCutResult);
+ if(aCheckIt.More()) {
this->appendAlgo(std::shared_ptr<GeomAlgoAPI_MakeShape>(new GeomAlgoAPI_MakeShape(aBaseCutBuilder)));
aResult = aCutResult;
+ if(aResult.ShapeType() == TopAbs_COMPOUND) {
+ aResult = GeomAlgoAPI_DFLoader::refineResult(aResult);
+ }
+ if(aShapeTypeToExp == TopAbs_FACE) {
+ const TopTools_ListOfShape& aBsShapes = aBaseCutBuilder->Modified(aBoundingFace);
+ for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) {
+ GeomShapePtr aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(anIt.Value()));
+ isFromFaceSet ? this->addToShape(aShape) : this->addFromShape(aShape);
+ }
+ }
}
}
- const TopTools_ListOfShape& aBsShapes = aBaseCutBuilder->Modified(aBoundingFace);
- for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) {
- GeomShapePtr aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(anIt.Value()));
- isFromFaceSet ? this->addToShape(aShape) : this->addFromShape(aShape);
- }
-
- 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) {
GeomShapePtr aCompound(new GeomAPI_Shape);
aCompound->setImpl(new TopoDS_Shape(aResult));
aResult = findClosest(aResult, aBaseCentre);
// Setting naming.
- for(TopExp_Explorer anExp(aResult, TopAbs_FACE); anExp.More (); anExp.Next ()) {
- const TopoDS_Shape& aFaceOnResult = anExp.Current();
- Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aFaceOnResult));
- Handle(Geom_Surface) aBoundingSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedBoundingFace));
- if(aFaceSurface == aBoundingSurface) {
- GeomShapePtr aShape(new GeomAPI_Shape());
- aShape->setImpl(new TopoDS_Shape(aFaceOnResult));
- isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape);
+ for(TopExp_Explorer anExp(aResult, aShapeTypeToExp); anExp.More (); anExp.Next ()) {
+ const TopoDS_Shape& aShape = anExp.Current();
+ GeomShapePtr aGeomSh(new GeomAPI_Shape());
+ if(aShapeTypeToExp == TopAbs_VERTEX) {
+ gp_Pnt aPnt = BRep_Tool::Pnt(TopoDS::Vertex(aShape));
+ IntTools_Context anIntTools;
+ if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(aRotatedBoundingFace), Precision::Confusion()) == Standard_True) {
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ isFromFaceSet ? this->addFromShape(aGeomSh) : this->addToShape(aGeomSh);
+ }
+ if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(aModifiedBaseShape), Precision::Confusion()) == Standard_True) {
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ isFromFaceSet ? this->addToShape(aGeomSh) : this->addFromShape(aGeomSh);
+ }
+ } else if(aShapeTypeToExp == TopAbs_EDGE) {
+ TopoDS_Edge anEdge = TopoDS::Edge(aShape);
+ BRepLib_CheckCurveOnSurface anEdgeCheck(anEdge, TopoDS::Face(aRotatedBoundingFace));
+ anEdgeCheck.Perform();
+ if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ isFromFaceSet ? this->addFromShape(aGeomSh) : this->addToShape(aGeomSh);
+ }
+ anEdgeCheck.Init(anEdge, TopoDS::Face(aModifiedBaseShape));
+ anEdgeCheck.Perform();
+ if(anEdgeCheck.MaxDistance() < Precision::Confusion()) {
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ isFromFaceSet ? this->addToShape(aGeomSh) : this->addFromShape(aGeomSh);
+ }
+ } else {
+ Handle(Geom_Surface) aFaceSurface = BRep_Tool::Surface(TopoDS::Face(aShape));
+ Handle(Geom_Surface) aBoundingSurface = BRep_Tool::Surface(TopoDS::Face(aRotatedBoundingFace));
+ Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(TopoDS::Face(aModifiedBaseShape));
+ if(aFaceSurface == aBoundingSurface) {
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ isFromFaceSet ? this->addFromShape(aGeomSh) : this->addToShape(aGeomSh);
+ }
+ if(aFaceSurface == aBaseSurface) {
+ aGeomSh->setImpl(new TopoDS_Shape(aShape));
+ isFromFaceSet ? this->addToShape(aGeomSh) : this->addFromShape(aGeomSh);
+ }
}
}
}