X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FGeomAPI%2FGeomAPI_Shape.cpp;h=a0c9061d78a4f1a7cf0eea160ce47db96f211fbc;hb=bb4ab20a1f03f936d4d8511eb9e9733ee965bb72;hp=7427c4e72dc96e27921453b0734578b8c093ed1d;hpb=696c11e9e4cb089e1c5496dac79420147d85496a;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index 7427c4e72..a0c9061d7 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "GeomAPI_Shape.h" @@ -27,6 +26,7 @@ #include #include #include +#include #include #include @@ -102,6 +102,15 @@ bool GeomAPI_Shape::isSame(const std::shared_ptr theShape) const return MY_SHAPE->IsSame(theShape->impl()) == Standard_True; } +bool GeomAPI_Shape::isSameGeometry(const std::shared_ptr theShape) const +{ + if (isFace()) + return face()->isSameGeometry(theShape); + else if (isEdge()) + return edge()->isSameGeometry(theShape); + return false; +} + bool GeomAPI_Shape::isVertex() const { const TopoDS_Shape& aShape = const_cast(this)->impl(); @@ -391,12 +400,29 @@ GeomAPI_Shape::subShapes(ShapeType theSubShapeType) const if (aShape.IsNull()) return aSubs; - for (TopExp_Explorer anExp(aShape, (TopAbs_ShapeEnum)theSubShapeType); - anExp.More(); anExp.Next()) { + // process multi-level compounds + if (shapeType() == COMPOUND && theSubShapeType == COMPOUND) { + for (TopoDS_Iterator anIt(aShape); anIt.More(); anIt.Next()) { + const TopoDS_Shape& aCurrent = anIt.Value(); + if (aCurrent.ShapeType() == TopAbs_COMPOUND) { + GeomShapePtr aSub(new GeomAPI_Shape); + aSub->setImpl(new TopoDS_Shape(aCurrent)); + aSubs.push_back(aSub); + } + } + // add self GeomShapePtr aSub(new GeomAPI_Shape); - aSub->setImpl(new TopoDS_Shape(anExp.Current())); + aSub->setImpl(new TopoDS_Shape(aShape)); aSubs.push_back(aSub); } + else { + for (TopExp_Explorer anExp(aShape, (TopAbs_ShapeEnum)theSubShapeType); + anExp.More(); anExp.Next()) { + GeomShapePtr aSub(new GeomAPI_Shape); + aSub->setImpl(new TopoDS_Shape(anExp.Current())); + aSubs.push_back(aSub); + } + } return aSubs; } @@ -444,21 +470,21 @@ GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeType() const GeomAPI_Shape::ShapeType GeomAPI_Shape::shapeTypeByStr(std::string theType) { std::transform(theType.begin(), theType.end(), theType.begin(), ::toupper); - if (theType == "COMPOUND") + if (theType == "COMPOUND" || theType == "COMPOUNDS") return COMPOUND; - if (theType == "COMPSOLID") + if (theType == "COMPSOLID" || theType == "COMPSOLIDS") return COMPSOLID; - if (theType == "SOLID") + if (theType == "SOLID" || theType == "SOLIDS") return SOLID; - if (theType == "SHELL") + if (theType == "SHELL" || theType == "SHELLS") return SHELL; - if (theType == "FACE") + if (theType == "FACE" || theType == "FACES") return FACE; - if (theType == "WIRE") + if (theType == "WIRE" || theType == "WIRES") return WIRE; - if (theType == "EDGE") + if (theType == "EDGE" || theType == "EDGES") return EDGE; - if (theType == "VERTEX") + if (theType == "VERTEX" || theType == "VERTICES") return VERTEX; return SHAPE; // default } @@ -674,6 +700,12 @@ void GeomAPI_Shape::translate(const std::shared_ptr theDir, const d setImpl(new TopoDS_Shape(aResult)); } +void GeomAPI_Shape::move(const std::shared_ptr theTransformation) +{ + TopoDS_Shape aResult = MY_SHAPE->Moved(theTransformation->impl()); + setImpl(new TopoDS_Shape(aResult)); +} + bool GeomAPI_Shape::isSelfIntersected(const int theLevelOfCheck) const { BOPAlgo_CheckerSI aCSI; // checker of self-interferences @@ -693,5 +725,29 @@ bool GeomAPI_Shape::isSelfIntersected(const int theLevelOfCheck) const bool GeomAPI_Shape::Comparator::operator()(const std::shared_ptr& theShape1, const std::shared_ptr& theShape2) const { - return theShape1->impl().TShape() < theShape2->impl().TShape(); + const TopoDS_Shape& aShape1 = theShape1->impl(); + const TopoDS_Shape& aShape2 = theShape2->impl(); + bool isLess = aShape1.TShape() < aShape2.TShape(); + if (aShape1.TShape() == aShape2.TShape()) { + Standard_Integer aHash1 = aShape1.Location().HashCode(IntegerLast()); + Standard_Integer aHash2 = aShape2.Location().HashCode(IntegerLast()); + isLess = aHash1 < aHash2; + } + return isLess; +} + +bool GeomAPI_Shape::ComparatorWithOri::operator()( + const std::shared_ptr& theShape1, + const std::shared_ptr& theShape2) const +{ + const TopoDS_Shape& aShape1 = theShape1->impl(); + const TopoDS_Shape& aShape2 = theShape2->impl(); + bool isLess = aShape1.TShape() < aShape2.TShape(); + if (aShape1.TShape() == aShape2.TShape()) { + Standard_Integer aHash1 = aShape1.Location().HashCode(IntegerLast()); + Standard_Integer aHash2 = aShape2.Location().HashCode(IntegerLast()); + isLess = (aHash1 < aHash2) || + (aHash1 == aHash2 && aShape1.Orientation() < aShape2.Orientation()); + } + return isLess; }