]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for naming in Build features.
authordbv <dbv@opencascade.com>
Tue, 6 Sep 2016 09:36:28 +0000 (12:36 +0300)
committerdbv <dbv@opencascade.com>
Tue, 6 Sep 2016 09:36:49 +0000 (12:36 +0300)
src/BuildPlugin/BuildPlugin_Edge.cpp
src/BuildPlugin/BuildPlugin_Vertex.cpp
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI.i
src/GeomAlgoAPI/GeomAlgoAPI_Copy.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Copy.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_MakeShape.cpp
src/GeomAlgoAPI/GeomAlgoAPI_swig.h

index df60a8715655e72dbc2d27724f62285fff212a63..b78100d15a5f886cdf6f8febff64706ac0661d16 100644 (file)
@@ -9,6 +9,8 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_ResultBody.h>
 
+#include <GeomAlgoAPI_Copy.h>
+
 //=================================================================================================
 BuildPlugin_Edge::BuildPlugin_Edge()
 {
@@ -59,9 +61,36 @@ void BuildPlugin_Edge::execute()
       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;
   }
index d70bcc49761ce6b80324df941ac67a19ad03bdaa..9ba78575497390665c944eba5c5f5a27c56fcf1f 100644 (file)
@@ -9,6 +9,8 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_ResultBody.h>
 
+#include <GeomAlgoAPI_Copy.h>
+
 //=================================================================================================
 BuildPlugin_Vertex::BuildPlugin_Vertex()
 {
@@ -59,9 +61,30 @@ void BuildPlugin_Vertex::execute()
       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;
   }
index bb0ce3fe485bb768a3a989537ec6824a7fca197f..c4ff34d4d8ea4cf607ddba60454cd64a5fce2796 100644 (file)
@@ -45,6 +45,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_BoxPoints.h
     GeomAlgoAPI_XAOExport.h
     GeomAlgoAPI_XAOImport.h
+    GeomAlgoAPI_Copy.h
 )
 
 SET(PROJECT_SOURCES
@@ -86,6 +87,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_BoxPoints.cpp
     GeomAlgoAPI_XAOExport.cpp
     GeomAlgoAPI_XAOImport.cpp
+    GeomAlgoAPI_Copy.cpp
 )
 
 SET(PROJECT_LIBRARIES
index 762d6b44f97f561078f1fb0f29efc92b65d58d0f..7e62725059446925b87181bfc3c3ed6da98fced6 100644 (file)
@@ -35,6 +35,7 @@
 %shared_ptr(GeomAlgoAPI_Transform)
 %shared_ptr(GeomAlgoAPI_Box)
 %shared_ptr(GeomAlgoAPI_BoxPoints)
+%shared_ptr(GeomAlgoAPI_Copy)
 
 // all supported interfaces
 %include "GeomAlgoAPI_MakeShape.h"
@@ -70,6 +71,7 @@
 %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 );
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Copy.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Copy.cpp
new file mode 100644 (file)
index 0000000..68f682d
--- /dev/null
@@ -0,0 +1,44 @@
+// 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);
+}
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Copy.h b/src/GeomAlgoAPI/GeomAlgoAPI_Copy.h
new file mode 100644 (file)
index 0000000..66e5aad
--- /dev/null
@@ -0,0 +1,34 @@
+// 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
index fa9e808bfb7e8188d6240cd0289c1c0f4fdf75a3..14b3bcb3886369a8c31335f3ff2089ef3f25e2a5 100644 (file)
@@ -157,6 +157,11 @@ void GeomAlgoAPI_MakeShape::setShape(const std::shared_ptr<GeomAPI_Shape> theSha
     }
 
     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()));
index 668a5d1b04e2189c87ebd064cffd1f2733c5e583..39468c70168230ce158870dedc4f07ef2fafa9ed 100644 (file)
   #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>