From: mpv Date: Tue, 17 Dec 2019 11:38:15 +0000 (+0300) Subject: Correct work with shapes and SObjects X-Git-Tag: V9_5_0a1~17^2~15 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=689cf0cf4c12d33f4b2850975e9b466a28903da1;p=modules%2Fshaper.git Correct work with shapes and SObjects --- diff --git a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py index 45a1aed6c..a21dca2c6 100644 --- a/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py +++ b/src/ConnectorPlugin/ConnectorPlugin_PublishToStudyFeature.py @@ -84,6 +84,7 @@ class PublishToStudyFeature(ModelAPI.ModelAPI_Feature): print("Found a result to publish ", aRes.data().name()) aResFeatureId = aPartDoc.feature(aRes).data().featureId() aSSEntry = str(aPartFeatureId) + ":" + str(aResFeatureId) - aSShape = anEngine.CreateShape(aSSEntry) - aSShape.SetShapeByStream(aRes.shape().getShapeStream()) - anEngine.AddInStudy(aSShape, aRes.data().name(), None) + aSShape = anEngine.FindOrCreateShape(aSSEntry) + aSShape.SetShapeByStream(aRes.shape().getShapeStream(False)) + if not aSShape.GetSO(): # publish in case it is a new shape + anEngine.AddInStudy(aSShape, aRes.data().name(), None) diff --git a/src/GeomAPI/GeomAPI_Shape.cpp b/src/GeomAPI/GeomAPI_Shape.cpp index a0c9061d7..60ca800a3 100644 --- a/src/GeomAPI/GeomAPI_Shape.cpp +++ b/src/GeomAPI/GeomAPI_Shape.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -638,11 +639,17 @@ GeomPointPtr GeomAPI_Shape::middlePoint() const } // LCOV_EXCL_START -std::string GeomAPI_Shape::getShapeStream() const +std::string GeomAPI_Shape::getShapeStream(const bool theWithTriangulation) const { std::ostringstream aStream; const TopoDS_Shape& aShape = const_cast(this)->impl(); - BRepTools::Write(aShape, aStream); + if (!theWithTriangulation) { // make a copy of shape without triangulation + BRepBuilderAPI_Copy aCopy(aShape, Standard_False, Standard_False); + const TopoDS_Shape& aCopyShape = aCopy.Shape(); + BRepTools::Write(aCopyShape, aStream); + } else { + BRepTools::Write(aShape, aStream); + } return aStream.str(); } // LCOV_EXCL_STOP diff --git a/src/GeomAPI/GeomAPI_Shape.h b/src/GeomAPI/GeomAPI_Shape.h index 7c3a2a6cc..34887d85f 100644 --- a/src/GeomAPI/GeomAPI_Shape.h +++ b/src/GeomAPI/GeomAPI_Shape.h @@ -192,7 +192,7 @@ public: /// Returns the shape as BRep stream GEOMAPI_EXPORT - std::string getShapeStream() const; + std::string getShapeStream(const bool theWithTriangulation = true) const; /// Returns intersection of shapes GEOMAPI_EXPORT