]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Compsolid result interface.
authornds <natalia.donis@opencascade.com>
Tue, 21 Jul 2015 09:48:38 +0000 (12:48 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 21 Jul 2015 09:48:38 +0000 (12:48 +0300)
12 files changed:
src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp
src/Model/CMakeLists.txt
src/Model/Model_Document.cpp
src/Model/Model_Document.h
src/Model/Model_Objects.cpp
src/Model/Model_Objects.h
src/Model/Model_ResultCompSolid.cpp [new file with mode: 0755]
src/Model/Model_ResultCompSolid.h [new file with mode: 0755]
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_Document.h
src/ModelAPI/ModelAPI_ResultCompSolid.cpp [new file with mode: 0755]
src/ModelAPI/ModelAPI_ResultCompSolid.h [new file with mode: 0755]

index d473f00961dfdb21f58c9b9e82398b376b1b1165..04b52ff425fd0b57f709c4cc1beffde78e8a73e3 100644 (file)
@@ -11,6 +11,7 @@
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_ResultConstruction.h>
+#include <ModelAPI_ResultCompSolid.h>
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_AttributeDouble.h>
 #include <ModelAPI_AttributeSelection.h>
@@ -26,6 +27,8 @@
 #define _LAST_TAG 3
 #define EDGE 6
 
+//#define DEBUG_COMPSOLID
+
 //=================================================================================================
 FeaturesPlugin_Extrusion::FeaturesPlugin_Extrusion()
 {
@@ -120,7 +123,12 @@ void FeaturesPlugin_Extrusion::execute()
     }
 
     for(int aFaceIndex = 0; aFaceIndex < aFacesNum || aFacesNum == -1; aFaceIndex++) {
+      //ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+#ifdef DEBUG_COMPSOLID
+      ResultCompSolidPtr aResultBody = document()->createCompSolid(data(), aResultIndex);
+#else
       ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
+#endif
       std::shared_ptr<GeomAPI_Shape> aBaseShape;
       if (aFacesNum == -1) {
         aBaseShape = aValueFace;
@@ -147,8 +155,10 @@ void FeaturesPlugin_Extrusion::execute()
         break;
       }
       //LoadNamingDS
+#ifdef DEBUG_COMPSOLID
+#else
       LoadNamingDS(aFeature, aResultBody, aBaseShape, aContext);
-
+#endif
       setResult(aResultBody, aResultIndex);
       aResultIndex++;
 
index 46c9881a214e6cf2b214b441128f256b31690fdb..b8486e53ddb9b523f43db96b8cf2675330eef378 100644 (file)
@@ -24,6 +24,7 @@ SET(PROJECT_HEADERS
     Model_Update.h
     Model_Validator.h
     Model_ResultBody.h
+    Model_ResultCompSolid.h
     Model_ResultConstruction.h
     Model_ResultPart.h
     Model_ResultGroup.h
@@ -52,6 +53,7 @@ SET(PROJECT_SOURCES
     Model_Update.cpp
     Model_Validator.cpp
     Model_ResultBody.cpp
+    Model_ResultCompSolid.cpp
     Model_ResultConstruction.cpp
     Model_ResultPart.cpp
     Model_ResultGroup.cpp
index 6e9fbf778da1aeca0802669c0e14285f9681ff9c..b160e375259d2b04afbf57cac3d00620ab834600 100644 (file)
@@ -800,6 +800,12 @@ std::shared_ptr<ModelAPI_ResultBody> Model_Document::createBody(
   return myObjs->createBody(theFeatureData, theIndex);
 }
 
+std::shared_ptr<ModelAPI_ResultCompSolid> Model_Document::createCompSolid(
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+  return myObjs->createCompSolid(theFeatureData, theIndex);
+}
+
 std::shared_ptr<ModelAPI_ResultPart> Model_Document::createPart(
     const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
index 997765a85fc6e0c738808a8361541e67933ae28d..626e2f4b2a8636abaffb9ab2cbb30236bee3e750 100644 (file)
@@ -151,6 +151,9 @@ class Model_Document : public ModelAPI_Document
   /// Creates a body results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+  /// Creates a compsolid results
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultCompSolid> createCompSolid(
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a part results
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
index 72544d26ee8e83b0e73d13b1bd3699488dde37f9..bec8764981b61c836d663b56105a010969f0b36f 100644 (file)
@@ -12,6 +12,7 @@
 #include <Model_ResultPart.h>
 #include <Model_ResultConstruction.h>
 #include <Model_ResultBody.h>
+#include <Model_ResultCompSolid.h>
 #include <Model_ResultGroup.h>
 #include <Model_ResultParameter.h>
 #include <ModelAPI_Validator.h>
@@ -763,6 +764,23 @@ std::shared_ptr<ModelAPI_ResultBody> Model_Objects::createBody(
   return aResult;
 }
 
+std::shared_ptr<ModelAPI_ResultCompSolid> Model_Objects::createCompSolid(
+    const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
+{
+  TDF_Label aLab = resultLabel(theFeatureData, theIndex);
+  TDataStd_Comment::Set(aLab, ModelAPI_ResultCompSolid::group().c_str());
+  ObjectPtr anOldObject = object(aLab);
+  std::shared_ptr<ModelAPI_ResultCompSolid> aResult;
+  if (anOldObject) {
+    aResult = std::dynamic_pointer_cast<ModelAPI_ResultCompSolid>(anOldObject);
+  }
+  if (!aResult) {
+    aResult = std::shared_ptr<ModelAPI_ResultCompSolid>(new Model_ResultCompSolid);
+    storeResult(theFeatureData, aResult, theIndex);
+  }
+  return aResult;
+}
+
 std::shared_ptr<ModelAPI_ResultPart> Model_Objects::createPart(
     const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex)
 {
index a78ac94185acb12c6cc6f716d0d5e8d22cb05dba..bf6904715014fe90783cbfb906b55e2b6dddfeb9 100644 (file)
@@ -100,6 +100,9 @@ class Model_Objects
   /// Creates a body results
   std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
+  /// Creates a body results
+  std::shared_ptr<ModelAPI_ResultCompSolid> createCompSolid(
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
   /// Creates a part results
   std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0);
diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp
new file mode 100755 (executable)
index 0000000..93f4331
--- /dev/null
@@ -0,0 +1,48 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_ResultCompSolid.cpp
+// Created:     20 Jul 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <Model_ResultCompSolid.h>
+
+Model_ResultCompSolid::Model_ResultCompSolid()
+{
+}
+
+Model_ResultCompSolid::~Model_ResultCompSolid()
+{
+}
+
+std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::addResult(std::string theID)
+{
+  std::shared_ptr<ModelAPI_ResultBody> aResult;
+  return aResult;
+}
+
+int Model_ResultCompSolid::numberOfSubs(bool forTree) const
+{
+  return 0;
+}
+
+std::shared_ptr<ModelAPI_ResultBody> Model_ResultCompSolid::subResult(const int theIndex,
+                                                                      bool forTree) const
+{
+  std::shared_ptr<ModelAPI_ResultBody> aBody;
+
+  return aBody;
+}
+
+int Model_ResultCompSolid::subResultId(const int theIndex) const
+{
+  return 0;
+}
+
+bool Model_ResultCompSolid::isSub(ObjectPtr theObject) const
+{
+  return true;
+}
+
+void Model_ResultCompSolid::removeResult(std::shared_ptr<ModelAPI_ResultBody> theResult)
+{
+}
diff --git a/src/Model/Model_ResultCompSolid.h b/src/Model/Model_ResultCompSolid.h
new file mode 100755 (executable)
index 0000000..6e7c2c6
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_ResultCompSolid.h
+// Created:     20 Jul 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef Model_ResultCompSolid_H_
+#define Model_ResultCompSolid_H_
+
+#include "Model.h"
+#include <ModelAPI_ResultCompSolid.h>
+
+/**\class Model_ResultCompSolid
+ * \ingroup DataModel
+ * \brief The compsolid (container of body results) result of a feature.
+ *
+ * Provides a container of shapes that may be displayed in the viewer.
+ */
+class Model_ResultCompSolid : public ModelAPI_ResultCompSolid
+{
+public:
+  /// Removes the stored builders
+  MODEL_EXPORT virtual ~Model_ResultCompSolid();
+
+  /// Adds result to the sketch and to its document
+  virtual std::shared_ptr<ModelAPI_ResultBody> addResult(std::string theID);
+
+  /// Returns the number of sub-elements
+  virtual int numberOfSubs(bool forTree = false) const;
+
+  /// Returns the sub-result by zero-base index
+  virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
+                                                         bool forTree = false) const;
+
+  /// Returns the sub-feature unique identifier in this composite feature by zero-base index
+  virtual int subResultId(const int theIndex) const;
+
+  /// Returns true if feature or reuslt belong to this composite feature as subs
+  virtual bool isSub(ObjectPtr theObject) const;
+
+  /// This method to inform that sub-feature is removed and must be removed from the internal data
+  /// structures of the owner (the remove from the document will be done outside just after)
+  virtual void removeResult(std::shared_ptr<ModelAPI_ResultBody> theResult);
+
+protected:
+  /// Makes a body on the given feature
+  Model_ResultCompSolid();
+
+  friend class Model_Objects;
+};
+
+#endif
index 96a42d7a875d23eb9d6c4776445459f9bd604223..6eef6143c5e687a0f53f2187ecae81c07d95d625 100644 (file)
@@ -30,6 +30,7 @@ SET(PROJECT_HEADERS
     ModelAPI_Plugin.h
     ModelAPI_Result.h
     ModelAPI_ResultBody.h
+    ModelAPI_ResultCompSolid.h
     ModelAPI_ResultConstruction.h
     ModelAPI_ResultGroup.h
     ModelAPI_ResultParameter.h
@@ -63,6 +64,7 @@ SET(PROJECT_SOURCES
     ModelAPI_Plugin.cpp
     ModelAPI_Result.cpp
     ModelAPI_ResultBody.cpp
+    ModelAPI_ResultCompSolid.cpp
     ModelAPI_ResultConstruction.cpp
     ModelAPI_ResultGroup.cpp
     ModelAPI_ResultPart.cpp
index 9f9297001404e35710b7202ba6b5be1b1520c385..719fff08ceafab1c362e26c8ebb28d7ce7dd25ec 100644 (file)
@@ -19,6 +19,7 @@ class ModelAPI_Object;
 class ModelAPI_Result;
 class ModelAPI_ResultConstruction;
 class ModelAPI_ResultBody;
+class ModelAPI_ResultCompSolid;
 class ModelAPI_ResultPart;
 class ModelAPI_ResultGroup;
 class ModelAPI_ResultParameter;
@@ -121,6 +122,9 @@ public:
   //! Creates a body results
   virtual std::shared_ptr<ModelAPI_ResultBody> createBody(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
+  /// Creates a compsolid results
+  virtual std::shared_ptr<ModelAPI_ResultCompSolid> createCompSolid(
+      const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
   //! Creates a part results
   virtual std::shared_ptr<ModelAPI_ResultPart> createPart(
       const std::shared_ptr<ModelAPI_Data>& theFeatureData, const int theIndex = 0) = 0;
diff --git a/src/ModelAPI/ModelAPI_ResultCompSolid.cpp b/src/ModelAPI/ModelAPI_ResultCompSolid.cpp
new file mode 100755 (executable)
index 0000000..d62ab8b
--- /dev/null
@@ -0,0 +1,27 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_ResultCompSolid.cpp
+// Created:     20 Jul 2015
+// Author:      Natalia ERMOLAEVA
+
+#include "ModelAPI_ResultCompSolid.h"
+
+ModelAPI_ResultCompSolid::~ModelAPI_ResultCompSolid()
+{
+}
+
+std::string ModelAPI_ResultCompSolid::groupName()
+{
+  return group();
+}
+
+void ModelAPI_ResultCompSolid::initAttributes()
+{
+}
+
+bool ModelAPI_ResultCompSolid::isDisabled() const
+{
+  return false;
+}
+
+
diff --git a/src/ModelAPI/ModelAPI_ResultCompSolid.h b/src/ModelAPI/ModelAPI_ResultCompSolid.h
new file mode 100755 (executable)
index 0000000..e2147b0
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_ResultCompSolid.hxx
+// Created:     20 Jul 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModelAPI_ResultCompSolid_H_
+#define ModelAPI_ResultCompSolid_H_
+
+#include "ModelAPI_Result.h"
+#include "ModelAPI_ResultBody.h"
+#include <string>
+
+/**\class ModelAPI_ResultCompSolid
+* \ingroup DataModel
+* \brief The comp solid (container of results) result of a feature.
+*
+* Provides a conainer of body result that may be displayed in the viewer.
+*/
+class ModelAPI_ResultCompSolid : public ModelAPI_Result
+{
+public:
+  MODELAPI_EXPORT virtual ~ModelAPI_ResultCompSolid();
+  /// Returns the group identifier of this result
+  MODELAPI_EXPORT virtual std::string groupName();
+
+  /// Returns the group identifier of this result
+  inline static std::string group()
+  {
+    static std::string MY_GROUP = "CompSolid";
+    return MY_GROUP;
+  }
+
+  /// Request for initialization of data model of the object: adding all attributes
+  MODELAPI_EXPORT virtual void initAttributes();
+
+  /// Returns the feature is disabled or not.
+  MODELAPI_EXPORT virtual bool isDisabled() const;
+
+  /// Adds result to the sketch and to its document
+  virtual std::shared_ptr<ModelAPI_ResultBody> addResult(std::string theID) = 0;
+
+  /// Returns the number of sub-elements
+  virtual int numberOfSubs(bool forTree = false) const = 0;
+
+  /// Returns the sub-result by zero-base index
+  virtual std::shared_ptr<ModelAPI_ResultBody> subResult(const int theIndex,
+                                                         bool forTree = false) const = 0;
+
+  /// Returns the sub-feature unique identifier in this composite feature by zero-base index
+  virtual int subResultId(const int theIndex) const = 0;
+
+  /// Returns true if feature or reuslt belong to this composite feature as subs
+  virtual bool isSub(ObjectPtr theObject) const = 0;
+
+  /// This method to inform that sub-feature is removed and must be removed from the internal data
+  /// structures of the owner (the remove from the document will be done outside just after)
+  virtual void removeResult(std::shared_ptr<ModelAPI_ResultBody> theResult) = 0;
+
+protected:
+};
+
+//! Pointer on feature object
+typedef std::shared_ptr<ModelAPI_ResultCompSolid> ResultCompSolidPtr;
+
+#endif