#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_Copy.h>
+
//=================================================================================================
BuildPlugin_Edge::BuildPlugin_Edge()
{
return;
}
+ // Copy shape.
+ GeomAlgoAPI_Copy aCopyAlgo(aShape);
+
+ // Check that algo is done.
+ if(!aCopyAlgo.isDone()) {
+ setError("Error: " + getKind() + " algorithm failed.");
+ return;
+ }
+
+ // Check if shape is not null.
+ if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
+ setError("Error: Resulting shape is null.");
+ return;
+ }
+
+ // Check that resulting shape is valid.
+ if(!aCopyAlgo.isValid()) {
+ setError("Error: Resulting shape is not valid.");
+ return;
+ }
+
// Store result.
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->store(aShape);
+ aResultBody->storeModified(aShape, aCopyAlgo.shape());
+ std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = aCopyAlgo.mapOfSubShapes();
+ int aModVertexTag = 1;
+ std::string aModVertexName = "Modified_Vertex";
+ aResultBody->loadAndOrientModifiedShapes(&aCopyAlgo, aShape, GeomAPI_Shape::VERTEX,
+ aModVertexTag, aModVertexName, *aSubShapes.get());
+
setResult(aResultBody, aResultIndex);
++aResultIndex;
}
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_ResultBody.h>
+#include <GeomAlgoAPI_Copy.h>
+
//=================================================================================================
BuildPlugin_Vertex::BuildPlugin_Vertex()
{
return;
}
+ // Copy shape.
+ GeomAlgoAPI_Copy aCopyAlgo(aShape);
+
+ // Check that algo is done.
+ if(!aCopyAlgo.isDone()) {
+ setError("Error: " + getKind() + " algorithm failed.");
+ return;
+ }
+
+ // Check if shape is not null.
+ if(!aCopyAlgo.shape().get() || aCopyAlgo.shape()->isNull()) {
+ setError("Error: Resulting shape is null.");
+ return;
+ }
+
+ // Check that resulting shape is valid.
+ if(!aCopyAlgo.isValid()) {
+ setError("Error: Resulting shape is not valid.");
+ return;
+ }
+
// Store result.
ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
- aResultBody->store(aShape);
+ aResultBody->storeModified(aShape, aCopyAlgo.shape());
setResult(aResultBody, aResultIndex);
++aResultIndex;
}
GeomAlgoAPI_BoxPoints.h
GeomAlgoAPI_XAOExport.h
GeomAlgoAPI_XAOImport.h
+ GeomAlgoAPI_Copy.h
)
SET(PROJECT_SOURCES
GeomAlgoAPI_BoxPoints.cpp
GeomAlgoAPI_XAOExport.cpp
GeomAlgoAPI_XAOImport.cpp
+ GeomAlgoAPI_Copy.cpp
)
SET(PROJECT_LIBRARIES
%shared_ptr(GeomAlgoAPI_Transform)
%shared_ptr(GeomAlgoAPI_Box)
%shared_ptr(GeomAlgoAPI_BoxPoints)
+%shared_ptr(GeomAlgoAPI_Copy)
// all supported interfaces
%include "GeomAlgoAPI_MakeShape.h"
%include "GeomAlgoAPI_ShapeBuilder.h"
%include "GeomAlgoAPI_Exception.h"
%include "GeomAlgoAPI_ShapeAPI.h"
+%include "GeomAlgoAPI_Copy.h"
%typemap(out) std::list< std::shared_ptr< GeomAPI_Shape > >::value_type & {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(new std::shared_ptr<GeomAPI_Shape>(*$1)), $descriptor(std::shared_ptr<GeomAPI_Shape> *), SWIG_POINTER_OWN | 0 );
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Copy.cpp
+// Created: 06 Sept 2016
+// Author: Dmitry Bobylev
+
+#include "GeomAlgoAPI_Copy.h"
+
+
+#include <BRepBuilderAPI_Copy.hxx>
+
+//=================================================================================================
+GeomAlgoAPI_Copy::GeomAlgoAPI_Copy(const std::shared_ptr<GeomAPI_Shape> theShape,
+ const bool theCopyGeom,
+ const bool theCopyMesh)
+{
+ build(theShape, theCopyGeom, theCopyMesh);
+}
+
+
+//=================================================================================================
+void GeomAlgoAPI_Copy::build(const std::shared_ptr<GeomAPI_Shape> theShape,
+ const bool theCopyGeom,
+ const bool theCopyMesh)
+{
+ if(!theShape.get()) {
+ return;
+ }
+
+ // Getting shape.
+ const TopoDS_Shape& aBaseShape = theShape->impl<TopoDS_Shape>();
+
+ // Creating copy.
+ BRepBuilderAPI_Copy* aBuilder = new BRepBuilderAPI_Copy(aBaseShape, theCopyGeom, theCopyMesh);
+ this->setImpl(aBuilder);
+ this->setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
+
+ TopoDS_Shape aResult = aBuilder->Shape();
+
+ std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
+ aShape->setImpl(new TopoDS_Shape(aResult));
+ this->setShape(aShape);
+ this->setDone(true);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: GeomAlgoAPI_Copy.h
+// Created: 06 Sept 2016
+// Author: Dmitry Bobylev
+
+#ifndef GeomAlgoAPI_Copy_H_
+#define GeomAlgoAPI_Copy_H_
+
+#include <GeomAlgoAPI.h>
+#include <GeomAlgoAPI_MakeShape.h>
+
+#include <GeomAPI_Shape.h>
+
+/// \class GeomAlgoAPI_Copy
+/// \ingroup DataAlgo
+/// \brief Duplication of a shape.
+class GeomAlgoAPI_Copy : public GeomAlgoAPI_MakeShape
+{
+public:
+
+ /// Constructor.
+ GEOMALGOAPI_EXPORT GeomAlgoAPI_Copy(const std::shared_ptr<GeomAPI_Shape> theShape,
+ const bool theCopyGeom = true,
+ const bool theCopyMesh = false);
+
+private:
+ /// Builds resulting shape.
+ void build(const std::shared_ptr<GeomAPI_Shape> theShape,
+ const bool theCopyGeom = true,
+ const bool theCopyMesh = false);
+};
+
+#endif
}
const TopoDS_Shape& aTopoDSShape = myShape->impl<TopoDS_Shape>();
+ for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_VERTEX); anExp.More(); anExp.Next()) {
+ std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
+ aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
+ myMap->bind(aCurrentShape, aCurrentShape);
+ }
for(TopExp_Explorer anExp(aTopoDSShape,TopAbs_EDGE); anExp.More(); anExp.Next()) {
std::shared_ptr<GeomAPI_Shape> aCurrentShape(new GeomAPI_Shape());
aCurrentShape->setImpl(new TopoDS_Shape(anExp.Current()));
#include "GeomAlgoAPI_Pipe.h"
#include "GeomAlgoAPI_WireBuilder.h"
#include "GeomAlgoAPI_Sewing.h"
- #include "GeomAlgoAPI_ShapeBuilder.h"
+ #include "GeomAlgoAPI_ShapeBuilder.h"
#include "GeomAlgoAPI_Exception.h"
#include "GeomAlgoAPI_ShapeAPI.h"
#include "GeomAlgoAPI_Box.h"
#include "GeomAlgoAPI_BoxPoints.h"
+ #include "GeomAlgoAPI_Copy.h"
#include <memory>
#include <string>