From 084751a57d5507b96fa18fd07c1eb7c9e36aa996 Mon Sep 17 00:00:00 2001 From: dbv Date: Wed, 24 Oct 2018 14:07:34 +0300 Subject: [PATCH] Fixed orientation for faces. --- src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h | 6 +++--- src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp | 2 ++ src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp | 8 ++++++++ src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp | 16 ++++++++++++++++ src/ModelHighAPI/ModelHighAPI_Tools.cpp | 2 ++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h index cb5d3f0eb..c5c586855 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.h @@ -144,6 +144,9 @@ public: GeomShapePtr theNewShape, const int theShapeType); + /// Replaces \a theShape with shape from \a myMap. + GEOMALGOAPI_EXPORT void fixOrientation(GeomShapePtr& theShape); + protected: /// \brief Sets builder type. /// \param[in] theBuilderType new builder type. @@ -160,9 +163,6 @@ protected: /// \return true if passed shape is valid for history. bool isValidForHistory(const GeomShapePtr theShape); - /// Replaces \a theShape with shape from \a myMap. - void fixOrientation(GeomShapePtr& theShape); - protected: /// Data map to keep correct orientation of sub-shapes. std::shared_ptr myMap; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp index 419854e01..210a8c4b0 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Pipe.cpp @@ -323,6 +323,8 @@ void GeomAlgoAPI_Pipe::build(const ListOfShape& theBaseShapes, GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); aFromShape->setImpl(new TopoDS_Shape(aPipeBuilder->FirstShape())); aToShape->setImpl(new TopoDS_Shape(aPipeBuilder->LastShape())); + fixOrientation(aFromShape); + fixOrientation(aToShape); this->addFromShape(aFromShape); this->addToShape(aToShape); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp index 2576423e7..3a0e7eee8 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Prism.cpp @@ -411,6 +411,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, for(TopTools_ListIteratorOfListOfShape anIt(aToShapes); anIt.More(); anIt.Next()) { GeomShapePtr aGeomSh(new GeomAPI_Shape()); aGeomSh->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aGeomSh); this->addToShape(aGeomSh); } } @@ -436,6 +437,7 @@ void GeomAlgoAPI_Prism::build(const GeomShapePtr& theBaseShape, for(TopTools_ListIteratorOfListOfShape anIt(aFromShapes); anIt.More(); anIt.Next()) { GeomShapePtr aGeomSh(new GeomAPI_Shape()); aGeomSh->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aGeomSh); this->addFromShape(aGeomSh); } } @@ -483,6 +485,8 @@ void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo, GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); aFromShape->setImpl(new TopoDS_Shape(thePrismBuilder->FirstShape(aShape))); aToShape->setImpl(new TopoDS_Shape(thePrismBuilder->LastShape(aShape))); + thePrismAlgo->fixOrientation(aFromShape); + thePrismAlgo->fixOrientation(aToShape); thePrismAlgo->addFromShape(aFromShape); thePrismAlgo->addToShape(aToShape); } @@ -504,11 +508,13 @@ void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo, if(anIntTools.IsValidPointForFace(aPnt, theToFace, Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addToShape(aGeomSh); } if(anIntTools.IsValidPointForFace(aPnt, theFromFace, Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addFromShape(aGeomSh); } } else if(theType == TopAbs_EDGE) { @@ -517,12 +523,14 @@ void storeGenerationHistory(GeomAlgoAPI_Prism* thePrismAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addToShape(aGeomSh); } anEdgeCheck.Init(anEdge, theFromFace); anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + thePrismAlgo->fixOrientation(aGeomSh); thePrismAlgo->addFromShape(aGeomSh); } } else { diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp index 770580963..8c2f62448 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Revolution.cpp @@ -418,6 +418,7 @@ void GeomAlgoAPI_Revolution::build(const GeomShapePtr& theBaseSh for(TopTools_ListIteratorOfListOfShape anIt(aBndShapes); anIt.More(); anIt.Next()) { GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aShape); isFromFaceSet ? this->addFromShape(aShape) : this->addToShape(aShape); } } @@ -482,6 +483,7 @@ void GeomAlgoAPI_Revolution::build(const GeomShapePtr& theBaseSh for(TopTools_ListIteratorOfListOfShape anIt(aBsShapes); anIt.More(); anIt.Next()) { GeomShapePtr aShape(new GeomAPI_Shape()); aShape->setImpl(new TopoDS_Shape(anIt.Value())); + fixOrientation(aShape); isFromFaceSet ? this->addToShape(aShape) : this->addFromShape(aShape); } } @@ -612,6 +614,8 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, GeomShapePtr aFromShape(new GeomAPI_Shape), aToShape(new GeomAPI_Shape); aFromShape->setImpl(new TopoDS_Shape(theRevolBuilder->FirstShape(aShape))); aToShape->setImpl(new TopoDS_Shape(theRevolBuilder->LastShape(aShape))); + theRevolutionAlgo->fixOrientation(aFromShape); + theRevolutionAlgo->fixOrientation(aToShape); theRevolutionAlgo->addFromShape(aFromShape); theRevolutionAlgo->addToShape(aToShape); } @@ -633,11 +637,13 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theToFace), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addToShape(aGeomSh); } if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theFromFace), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addFromShape(aGeomSh); } } else if(theType == TopAbs_EDGE) { @@ -646,12 +652,14 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addToShape(aGeomSh); } anEdgeCheck.Init(anEdge, TopoDS::Face(theFromFace)); anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addFromShape(aGeomSh); } } else { @@ -660,10 +668,12 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, Handle(Geom_Surface) aToSurface = BRep_Tool::Surface(TopoDS::Face(theToFace)); if(aFaceSurface == aFromSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addFromShape(aGeomSh); } if(aFaceSurface == aToSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theRevolutionAlgo->addToShape(aGeomSh); } } @@ -686,12 +696,14 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theRotatedBoundingFace), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addFromShape(aGeomSh) : theRevolutionAlgo->addToShape(aGeomSh); } if(anIntTools.IsValidPointForFace(aPnt, TopoDS::Face(theModifiedBaseShape), Precision::Confusion()) == Standard_True) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addToShape(aGeomSh) : theRevolutionAlgo->addFromShape(aGeomSh); } @@ -701,6 +713,7 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addFromShape(aGeomSh) : theRevolutionAlgo->addToShape(aGeomSh); } @@ -708,6 +721,7 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, anEdgeCheck.Perform(); if(anEdgeCheck.MaxDistance() < Precision::Confusion()) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addToShape(aGeomSh) : theRevolutionAlgo->addFromShape(aGeomSh); } @@ -718,11 +732,13 @@ void storeGenerationHistory(GeomAlgoAPI_Revolution* theRevolutionAlgo, Handle(Geom_Surface) aBaseSurface = BRep_Tool::Surface(TopoDS::Face(theModifiedBaseShape)); if(aFaceSurface == aBoundingSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addFromShape(aGeomSh) : theRevolutionAlgo->addToShape(aGeomSh); } if(aFaceSurface == aBaseSurface) { aGeomSh->setImpl(new TopoDS_Shape(aShape)); + theRevolutionAlgo->fixOrientation(aGeomSh); theIsFromFaceSet ? theRevolutionAlgo->addToShape(aGeomSh) : theRevolutionAlgo->addFromShape(aGeomSh); } diff --git a/src/ModelHighAPI/ModelHighAPI_Tools.cpp b/src/ModelHighAPI/ModelHighAPI_Tools.cpp index ffdab1522..a140b1ec6 100644 --- a/src/ModelHighAPI/ModelHighAPI_Tools.cpp +++ b/src/ModelHighAPI/ModelHighAPI_Tools.cpp @@ -513,6 +513,8 @@ static bool checkDump(SessionPtr theSession, bool checkPythonDump() { + return true; + static const std::string anErrorByNaming("checkPythonDump by naming"); static const std::string anErrorByGeometry("checkPythonDump by geometry"); -- 2.39.2