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)
#include <BRepAlgoAPI_Section.hxx>
#include <BRepBndLib.hxx>
#include <BRepBuilderAPI_FindPlane.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <BRepTools.hxx>
#include <Bnd_Box.hxx>
}
// 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<GeomAPI_Shape*>(this)->impl<TopoDS_Shape>();
- 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
/// 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