From: dbv Date: Wed, 6 Apr 2016 09:34:37 +0000 (+0300) Subject: Issue #1343 Fixes for naming when creating extrusion from vertex or edge X-Git-Tag: V_2.3.0~296 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=01cfaed78e7e3a720c5363ca5ba5465fe3840376;p=modules%2Fshaper.git Issue #1343 Fixes for naming when creating extrusion from vertex or edge --- diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 979692742..d8599e767 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -21,12 +21,18 @@ #include #include #include +#include +#include +#include #include #include #include #include #include +#include #include +#include +#include #include #include #include @@ -158,10 +164,10 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, // Setting naming. for(TopExp_Explorer anExp(aMovedBase, aShapeTypeToExp); anExp.More(); anExp.Next()) { - const TopoDS_Shape& aFace = anExp.Current(); + const TopoDS_Shape& aShape = anExp.Current(); GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); - aFromShape->setImpl(new TopoDS_Shape(aPrismBuilder->FirstShape(aFace))); - aToShape->setImpl(new TopoDS_Shape(aPrismBuilder->LastShape(aFace))); + aFromShape->setImpl(new TopoDS_Shape(aPrismBuilder->FirstShape(aShape))); + aToShape->setImpl(new TopoDS_Shape(aPrismBuilder->LastShape(aShape))); this->addFromShape(aFromShape); this->addToShape(aToShape); } @@ -170,15 +176,13 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, GeomShapePtr aBoundingToShape = theToShape ? theToShape : aBasePlane; // Moving prism bounding faces according to "from" and "to" sizes. - std::shared_ptr aFromFace(new GeomAPI_Face(aBoundingFromShape)); - std::shared_ptr aFromPln = aFromFace->getPlane(); - std::shared_ptr aFromLoc = aFromPln->location(); - std::shared_ptr aFromDir = aFromPln->direction(); + std::shared_ptr aFromPln = GeomAPI_Face(aBoundingFromShape).getPlane(); + std::shared_ptr aFromLoc = aFromPln->location(); + std::shared_ptr aFromDir = aFromPln->direction(); - std::shared_ptr aToFace(new GeomAPI_Face(aBoundingToShape)); - std::shared_ptr aToPln = aToFace->getPlane(); - std::shared_ptr aToLoc = aToPln->location(); - std::shared_ptr aToDir = aToPln->direction(); + std::shared_ptr aToPln = GeomAPI_Face(aBoundingToShape).getPlane(); + std::shared_ptr aToLoc = aToPln->location(); + std::shared_ptr aToDir = aToPln->direction(); bool aSign = aFromLoc->xyz()->dot(aBaseDir->xyz()) > aToLoc->xyz()->dot(aBaseDir->xyz()); @@ -292,6 +296,8 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, TopoDS_Solid aToSolid, aFromSolid; const TopoDS_Shape& aToShape = aBoundingToShape->impl(); const TopoDS_Shape& aFromShape = aBoundingFromShape->impl(); + TopoDS_Face aToFace = TopoDS::Face(aToShape); + TopoDS_Face aFromFace = TopoDS::Face(aFromShape); BRep_Builder aBoundingBuilder; aBoundingBuilder.MakeShell(aToShell); aBoundingBuilder.Add(aToShell, aToShape); @@ -309,16 +315,18 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, return; } this->appendAlgo(std::shared_ptr(new GeomAlgoAPI_MakeShape(aToCutBuilder))); - const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape); - for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) { - GeomShapePtr aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(anIt.Value())); - this->addToShape(aShape); - } aResult = aToCutBuilder->Shape(); if(aResult.ShapeType() == TopAbs_COMPOUND) { aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); } + if(aShapeTypeToExp == TopAbs_FACE) { + const TopTools_ListOfShape& aToShapes = aToCutBuilder->Modified(aToShape); + for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) { + GeomShapePtr aGeomSh(new GeomAPI_Shape()); + aGeomSh->setImpl(new TopoDS_Shape(anIt.Value())); + this->addToShape(aGeomSh); + } + } // Cutting with from plane. BRepAlgoAPI_Cut* aFromCutBuilder = new BRepAlgoAPI_Cut(aResult, aFromSolid); @@ -327,21 +335,60 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, return; } this->appendAlgo(std::shared_ptr(new GeomAlgoAPI_MakeShape(aFromCutBuilder))); - const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape); - for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) { - GeomShapePtr aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(anIt.Value())); - this->addFromShape(aShape); - } aResult = aFromCutBuilder->Shape(); - - TopoDS_Iterator anIt(aResult); - if(!anIt.More()) { + TopoDS_Iterator aCheckIt(aResult); + if(!aCheckIt.More()) { return; } if(aResult.ShapeType() == TopAbs_COMPOUND) { aResult = GeomAlgoAPI_DFLoader::refineResult(aResult); } + if(aShapeTypeToExp == TopAbs_FACE) { + const TopTools_ListOfShape& aFromShapes = aFromCutBuilder->Modified(aFromShape); + for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) { + GeomShapePtr aGeomSh(new GeomAPI_Shape()); + aGeomSh->setImpl(new TopoDS_Shape(anIt.Value())); + this->addFromShape(aGeomSh); + } + } + + // Naming for extrusion from vertex, edge. + for(TopExp_Explorer anExp(aResult, aShapeTypeToExp); anExp.More(); anExp.Next()) { + const TopoDS_Shape& aShape = anExp.Current(); + 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); + } + } else if(aShapeTypeToExp == TopAbs_EDGE) { + TopoDS_Edge anEdge = TopoDS::Edge(aShape); + 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); + } + } else { + break; + } + } + if(aResult.ShapeType() == TopAbs_COMPOUND) { GeomShapePtr aCompound(new GeomAPI_Shape); aCompound->setImpl(new TopoDS_Shape(aResult)); @@ -368,8 +415,8 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, if(aResult.IsNull()) { return; } - GeomShapePtr aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aResult)); - this->setShape(aShape); + GeomShapePtr aGeomSh(new GeomAPI_Shape()); + aGeomSh->setImpl(new TopoDS_Shape(aResult)); + this->setShape(aGeomSh); this->setDone(true); }