From: nds Date: Tue, 21 Jul 2015 09:48:38 +0000 (+0300) Subject: Compsolid result interface. X-Git-Tag: V_1.4.0_beta4~456 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=470905ace04b0b7345038bb2277050a6c8fcc585;p=modules%2Fshaper.git Compsolid result interface. --- diff --git a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp index d473f0096..04b52ff42 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Extrusion.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -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 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++; diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 46c9881a2..b8486e53d 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -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 diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 6e9fbf778..b160e3752 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -800,6 +800,12 @@ std::shared_ptr Model_Document::createBody( return myObjs->createBody(theFeatureData, theIndex); } +std::shared_ptr Model_Document::createCompSolid( + const std::shared_ptr& theFeatureData, const int theIndex) +{ + return myObjs->createCompSolid(theFeatureData, theIndex); +} + std::shared_ptr Model_Document::createPart( const std::shared_ptr& theFeatureData, const int theIndex) { diff --git a/src/Model/Model_Document.h b/src/Model/Model_Document.h index 997765a85..626e2f4b2 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -151,6 +151,9 @@ class Model_Document : public ModelAPI_Document /// Creates a body results MODEL_EXPORT virtual std::shared_ptr createBody( const std::shared_ptr& theFeatureData, const int theIndex = 0); + /// Creates a compsolid results + MODEL_EXPORT virtual std::shared_ptr createCompSolid( + const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a part results MODEL_EXPORT virtual std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 72544d26e..bec876498 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -763,6 +764,23 @@ std::shared_ptr Model_Objects::createBody( return aResult; } +std::shared_ptr Model_Objects::createCompSolid( + const std::shared_ptr& 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 aResult; + if (anOldObject) { + aResult = std::dynamic_pointer_cast(anOldObject); + } + if (!aResult) { + aResult = std::shared_ptr(new Model_ResultCompSolid); + storeResult(theFeatureData, aResult, theIndex); + } + return aResult; +} + std::shared_ptr Model_Objects::createPart( const std::shared_ptr& theFeatureData, const int theIndex) { diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index a78ac9418..bf6904715 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -100,6 +100,9 @@ class Model_Objects /// Creates a body results std::shared_ptr createBody( const std::shared_ptr& theFeatureData, const int theIndex = 0); + /// Creates a body results + std::shared_ptr createCompSolid( + const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a part results std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp new file mode 100755 index 000000000..93f4331a0 --- /dev/null +++ b/src/Model/Model_ResultCompSolid.cpp @@ -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::Model_ResultCompSolid() +{ +} + +Model_ResultCompSolid::~Model_ResultCompSolid() +{ +} + +std::shared_ptr Model_ResultCompSolid::addResult(std::string theID) +{ + std::shared_ptr aResult; + return aResult; +} + +int Model_ResultCompSolid::numberOfSubs(bool forTree) const +{ + return 0; +} + +std::shared_ptr Model_ResultCompSolid::subResult(const int theIndex, + bool forTree) const +{ + std::shared_ptr 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 theResult) +{ +} diff --git a/src/Model/Model_ResultCompSolid.h b/src/Model/Model_ResultCompSolid.h new file mode 100755 index 000000000..6e7c2c663 --- /dev/null +++ b/src/Model/Model_ResultCompSolid.h @@ -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 + +/**\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 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 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 theResult); + +protected: + /// Makes a body on the given feature + Model_ResultCompSolid(); + + friend class Model_Objects; +}; + +#endif diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 96a42d7a8..6eef6143c 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -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 diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 9f9297001..719fff08c 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -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 createBody( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + /// Creates a compsolid results + virtual std::shared_ptr createCompSolid( + const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; //! Creates a part results virtual std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; diff --git a/src/ModelAPI/ModelAPI_ResultCompSolid.cpp b/src/ModelAPI/ModelAPI_ResultCompSolid.cpp new file mode 100755 index 000000000..d62ab8bc7 --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultCompSolid.cpp @@ -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 index 000000000..e2147b07a --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultCompSolid.h @@ -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 + +/**\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 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 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 theResult) = 0; + +protected: +}; + +//! Pointer on feature object +typedef std::shared_ptr ResultCompSolidPtr; + +#endif