X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAlgoAPI%2FGeomAlgoAPI_MakeShape.cpp;h=5419c4f151465f565c3eaec968608ef3600ac674;hb=03b823cbbe43236117bc50c34398f3ce273f729b;hp=3b0d3ca8b2462b5b33812439740a31d5be284cf9;hpb=cbde248859fb0072f6012907391ea90cfc254574;p=modules%2Fshaper.git diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp index 3b0d3ca8b..5419c4f15 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp @@ -4,18 +4,21 @@ // Created: 20 Oct 2014 // Author: Sergey ZARITCHNY -#include +#include "GeomAlgoAPI_MakeShape.h" #include #include -#include +#include +#include +#include +#include #include #include #include //================================================================================================= GeomAlgoAPI_MakeShape::GeomAlgoAPI_MakeShape() -: myBuilderType(OCCT_BRepBuilderAPI_MakeShape), +: myBuilderType(UNKNOWN), myDone(false) { } @@ -32,6 +35,33 @@ const std::shared_ptr GeomAlgoAPI_MakeShape::shape() const return myShape; } +//================================================================================================= +bool GeomAlgoAPI_MakeShape::isValid() const +{ + BRepCheck_Analyzer aChecker(myShape->impl()); + return (aChecker.IsValid() == Standard_True); +} + +//================================================================================================= +bool GeomAlgoAPI_MakeShape::hasVolume() const +{ + bool hasVolume = false; + if(isValid()) { + const TopoDS_Shape& aRShape = myShape->impl(); + GProp_GProps aGProp; + BRepGProp::VolumeProperties(aRShape, aGProp); + if(aGProp.Mass() > Precision::Confusion()) + hasVolume = true; + } + return hasVolume; +} + +//================================================================================================= +std::shared_ptr GeomAlgoAPI_MakeShape::mapOfSubShapes() const +{ + return myMap; +} + //================================================================================================= void GeomAlgoAPI_MakeShape::generated(const std::shared_ptr theShape, ListOfShape& theHistory) @@ -106,7 +136,31 @@ void GeomAlgoAPI_MakeShape::setDone(const bool theFlag) //================================================================================================= void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr theShape) { + if(myShape.get() && myShape->isEqual(theShape)) { + return; + } + myShape = theShape; + + // Filling data map to keep correct orientation of sub-shapes. + if(myShape.get()) { + if(myMap.get()) { + myMap->clear(); + } else { + myMap.reset(new GeomAPI_DataMapOfShapeShape); + } + + const TopoDS_Shape& aTopoDSSHape = myShape->impl(); + for(TopExp_Explorer anExp(aTopoDSSHape,TopAbs_FACE); anExp.More(); anExp.Next()) { + std::shared_ptr aCurrentShape(new GeomAPI_Shape()); + aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current())); + myMap->bind(aCurrentShape, aCurrentShape); + } + } else { + if(myMap.get()) { + myMap->clear(); + } + } } //=================================================================================================