From 069a438fa8474e1132064775b6b5913a8f86a614 Mon Sep 17 00:00:00 2001 From: Nicolas RECHATIN Date: Mon, 19 Jul 2021 15:37:33 +0200 Subject: [PATCH] WIP [NOT COMPILING] ResultVolume --- src/Config/dataModel.xml | 3 +- src/Model/CMakeLists.txt | 6 ++ src/Model/Model_BodyBuilder.h | 3 + src/Model/Model_Data.h | 3 + src/Model/Model_Document.cpp | 6 ++ src/Model/Model_Document.h | 6 ++ src/Model/Model_Objects.cpp | 23 +++++++- src/Model/Model_Objects.h | 4 ++ src/Model/Model_ResultVolume.cpp | 57 +++++++++++++++++++ src/Model/Model_ResultVolume.h | 51 +++++++++++++++++ src/ModelAPI/CMakeLists.txt | 9 ++- src/ModelAPI/ModelAPI_Document.h | 4 ++ src/ModelAPI/ModelAPI_Events.cpp | 4 +- src/ModelAPI/ModelAPI_Events.h | 4 +- src/ModelAPI/ModelAPI_ResultVolume.h | 55 ++++++++++++++++++ src/PartSet/PartSet_TreeNodes.cpp | 5 +- src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp | 30 +++++++++- 17 files changed, 260 insertions(+), 13 deletions(-) create mode 100644 src/Model/Model_ResultVolume.cpp create mode 100644 src/Model/Model_ResultVolume.h create mode 100644 src/ModelAPI/ModelAPI_ResultVolume.h diff --git a/src/Config/dataModel.xml b/src/Config/dataModel.xml index 0d79b9be0..6dee0a7a3 100644 --- a/src/Config/dataModel.xml +++ b/src/Config/dataModel.xml @@ -10,7 +10,8 @@ folder_features="ParametersMgr"/> + - \ No newline at end of file + diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 2f349c193..620650aa7 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -48,6 +48,9 @@ SET(PROJECT_HEADERS Model_FeatureValidator.h Model_FiltersFactory.h Model_ResultBody.h + + Model_ResultVolume.h + Model_ResultConstruction.h Model_ResultPart.h Model_ResultField.h @@ -86,6 +89,9 @@ SET(PROJECT_SOURCES Model_FeatureValidator.cpp Model_FiltersFactory.cpp Model_ResultBody.cpp + + Model_ResultVolume.cpp + Model_ResultConstruction.cpp Model_ResultPart.cpp Model_ResultField.cpp diff --git a/src/Model/Model_BodyBuilder.h b/src/Model/Model_BodyBuilder.h index 32983cd66..d4c636fff 100644 --- a/src/Model/Model_BodyBuilder.h +++ b/src/Model/Model_BodyBuilder.h @@ -153,6 +153,9 @@ private: private: friend class Model_ResultBody; + + friend class Model_ResultVolume; + friend class Model_ResultCompSolid; }; diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index df833acc0..7cc31f7d2 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -96,6 +96,9 @@ class Model_Data : public ModelAPI_Data friend class Model_SelectionNaming; friend class Model_ResultConstruction; friend class Model_ResultBody; + + friend class Model_ResultVolume; + friend class Model_Tools; public: diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 94903c205..ab44f2686 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -1577,6 +1577,12 @@ std::shared_ptr Model_Document::createBody( return myObjs->createBody(theFeatureData, theIndex); } +std::shared_ptr Model_Document::createVolume( + const std::shared_ptr& theFeatureData, const int theIndex) +{ + return myObjs->createVolume(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 122d4439e..87026b2d3 100644 --- a/src/Model/Model_Document.h +++ b/src/Model/Model_Document.h @@ -203,6 +203,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 volume results + MODEL_EXPORT virtual std::shared_ptr createVolume( + 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); @@ -421,6 +424,9 @@ class Model_Document : public ModelAPI_Document friend class Model_AttributeSelectionList; friend class Model_ResultPart; friend class Model_ResultBody; + + friend class Model_ResultVolume; + friend class Model_ResultConstruction; friend class Model_SelectionNaming; friend class Model_BodyBuilder; diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index ebb3d6be9..13af550ee 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -25,6 +25,9 @@ #include #include #include + +#include + #include #include #include @@ -34,7 +37,6 @@ #include #include - #include #include @@ -1292,6 +1294,25 @@ std::shared_ptr Model_Objects::createBody( return aResult; } +std::shared_ptr Model_Objects::createVolume( + const std::shared_ptr& theFeatureData, + const int theIndex, + const std::wstring& theNameShape) +{ + TDF_Label aLab = resultLabel(theFeatureData, theIndex); + TDataStd_Comment::Set(aLab, ModelAPI_ResultVolume::group().c_str()); + ObjectPtr anOldObject = object(aLab); + std::shared_ptr aResult; + if (anOldObject.get()) { + aResult = std::dynamic_pointer_cast(anOldObject); + } + if (!aResult.get()) { + aResult = std::shared_ptr(new Model_ResultVolume); + storeResult(theFeatureData, aResult, theIndex, theNameShape); + } + 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 a598b3033..d64456060 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -125,6 +125,10 @@ class Model_Objects std::shared_ptr createBody( const std::shared_ptr& theFeatureData, const int theIndex = 0, const std::wstring& theNameShape = L""); + /// Creates a body result + std::shared_ptr createVolume( + const std::shared_ptr& theFeatureData, const int theIndex = 0, + const std::wstring& theNameShape = L""); /// Creates a part result std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); diff --git a/src/Model/Model_ResultVolume.cpp b/src/Model/Model_ResultVolume.cpp new file mode 100644 index 000000000..3145ebe9b --- /dev/null +++ b/src/Model/Model_ResultVolume.cpp @@ -0,0 +1,57 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +// if this attribute exists, the shape is connected topology +Standard_GUID kIsConnectedTopology("e51392e0-3a4d-405d-8e36-bbfe19858ef5"); +// if this attribute exists, the connected topology flag must be recomputed +Standard_GUID kUpdateConnectedTopology("01ef7a45-0bec-4266-b0b4-4aa570921818"); + +Model_ResultVolume::Model_ResultVolume() : Model_ResultVolume() +{ + myBuilder = new Model_BodyBuilder(this); + // myLastConcealed = false; + // updateSubs(shape()); // in case of open, etc. +} + +Model_ResultVolume::~Model_ResultVolume() +{ + // updateSubs(std::shared_ptr()); // erase sub-results + delete myBuilder; +} diff --git a/src/Model/Model_ResultVolume.h b/src/Model/Model_ResultVolume.h new file mode 100644 index 000000000..63e5684bb --- /dev/null +++ b/src/Model/Model_ResultVolume.h @@ -0,0 +1,51 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef Model_ResultVolume_H_ +#define Model_ResultVolume_H_ + +#include "Model.h" +#include +#include +#include + +#include + +/**\class Model_ResultVolume +* \ingroup DataModel +* \brief The body (shape) result of a feature. +* +* Provides a shape that may be displayed in the viewer. +* May provide really huge results, so, working with this kind +* of result must be optimized. +* Also provides a container of sub-body result in case it is compound or compsolid. +*/ +class Model_ResultVolume : public ModelAPI_ResultVolume +{ + + public: + /// Removes the stored builders + MODEL_EXPORT virtual ~Model_ResultVolume(); + + protected: + /// Makes a body on the given feature + Model_ResultVolume(); +}; + +#endif diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index c6a298461..5a8668f2a 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -61,6 +61,9 @@ SET(PROJECT_HEADERS ModelAPI_Plugin.h ModelAPI_Result.h ModelAPI_ResultBody.h + + ModelAPI_ResultVolume.h + ModelAPI_ResultConstruction.h ModelAPI_ResultField.h ModelAPI_ResultGroup.h @@ -172,16 +175,16 @@ ADD_UNIT_TESTS(${TEST_NAMES}) if(${HAVE_SALOME}) enable_testing() set(TEST_INSTALL_DIRECTORY "${SALOME_SHAPER_INSTALL_TESTS}/ModelAPI") - + install(FILES CTestTestfileInstall.cmake DESTINATION ${TEST_INSTALL_DIRECTORY} RENAME CTestTestfile.cmake) install(FILES tests.set DESTINATION ${TEST_INSTALL_DIRECTORY}) - + set(TMP_TESTS_NAMES) foreach(tfile ${TEST_NAMES}) list(APPEND TMP_TESTS_NAMES "Test/${tfile}") endforeach(tfile ${TEST_NAMES}) - + install(FILES ${TMP_TESTS_NAMES} DESTINATION ${TEST_INSTALL_DIRECTORY}) endif(${HAVE_SALOME}) diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 7aa75c92d..95e1d6d47 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -35,6 +35,7 @@ class ModelAPI_Object; class ModelAPI_Result; class ModelAPI_ResultConstruction; class ModelAPI_ResultBody; +class ModelAPI_ResultVolume; class ModelAPI_ResultPart; class ModelAPI_ResultGroup; class ModelAPI_ResultField; @@ -154,6 +155,9 @@ public: //! Creates a body result virtual std::shared_ptr createBody( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; + //! Creates a volume result + virtual std::shared_ptr createVolume( + const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; //! Creates a part result virtual std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0) = 0; diff --git a/src/ModelAPI/ModelAPI_Events.cpp b/src/ModelAPI/ModelAPI_Events.cpp index 22b8aa12d..87900fcf8 100644 --- a/src/ModelAPI/ModelAPI_Events.cpp +++ b/src/ModelAPI/ModelAPI_Events.cpp @@ -169,10 +169,10 @@ void ModelAPI_ParameterEvalMessage::setResults( void ModelAPI_ParameterEvalMessage::setVolumes( const std::list >& theParamsList, - const double theResult, const std::string& theError) + const double theVolume, const std::string& theError) { myParamsList = theParamsList; - myResult = theResult; + myResult = theVolume; myError = theError; myIsProcessed = true; } diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index c8d77349c..57e2c70eb 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -344,7 +344,7 @@ class ModelAPI_ParameterEvalMessage : public Events_Message const double theResult, const std::string& theError); MODELAPI_EXPORT void setVolumes( const std::list >& theParamsList, - const double theResult, const std::string& theError); + const double theVolume, const std::string& theError); /// Returns true if the expression is processed MODELAPI_EXPORT bool isProcessed(); /// Returns the results of processing: list of parameters found in the expression @@ -398,7 +398,7 @@ class ModelAPI_BuildEvalMessage : public Events_Message MODELAPI_EXPORT void setResults( const std::list >& theParamsList, const std::string& theError); - /// Sets the results of processing + /// Sets the volumes of processing MODELAPI_EXPORT void setVolumes( const std::list >& theParamsList, const std::string& theError); diff --git a/src/ModelAPI/ModelAPI_ResultVolume.h b/src/ModelAPI/ModelAPI_ResultVolume.h new file mode 100644 index 000000000..ad15c197f --- /dev/null +++ b/src/ModelAPI/ModelAPI_ResultVolume.h @@ -0,0 +1,55 @@ +// Copyright (C) 2014-2021 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef ModelAPI_ResultVolume_H_ +#define ModelAPI_ResultVolume_H_ + +#include "ModelAPI_ResultBody.h" + +class ModelAPI_BodyBuilder; +class GeomAlgoAPI_MakeShape; + +/**\class ModelAPI_ResultVolume +* \ingroup DataModel +* \brief The body (shape) result of a feature. +* +* Provides a shape that may be displayed in the viewer. +* May provide really huge results, so, working with this kind +* of result must be optimized. +* Also provides a container of sub-body result in case it is compound or compsolid. +*/ +class ModelAPI_ResultVolume : public ModelAPI_ResultBody +{ + public: + + inline static std::string group() + { + static std::string MY_GROUP = "Volumes"; + return MY_GROUP; + } + + protected: + ModelAPI_BodyBuilder* myBuilder; ///< provides the body processing in naming shape + +}; + +//! Pointer on feature object +typedef std::shared_ptr ResultVolumePtr; + +#endif diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index aea786b9d..4fdb4767d 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -33,6 +33,9 @@ #include #include #include + +#include + #include #include #include @@ -576,7 +579,7 @@ std::string PartSet_FolderNode::groupName() const case GroupsFolder: return ModelAPI_ResultGroup::group(); case VolumesFolder: - return ModelAPI_ResultBody::group(); + return ModelAPI_ResultVolume::group(); } return ""; } diff --git a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp index feea6763d..ccddc413d 100644 --- a/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp +++ b/src/PrimitivesPlugin/PrimitivesPlugin_Box.cpp @@ -21,6 +21,9 @@ #include #include + +#include + #include #include #include @@ -161,6 +164,27 @@ void PrimitivesPlugin_Box::createBoxByTwoPoints() setResult(aResultBox, aResultIndex); } +//================================================================================================= +static void toto(std::shared_ptr theBoxAlgo, + std::shared_ptr theResultBox) +{ + // Load the result + theResultBox->store(theBoxAlgo->shape()); + + // Prepare the naming + theBoxAlgo->prepareNamingFaces(); + + // Insert to faces + std::map< std::string, std::shared_ptr > listOfFaces = + theBoxAlgo->getCreatedFaces(); + for (std::map< std::string, std::shared_ptr >::iterator it = listOfFaces.begin(); + it != listOfFaces.end(); + ++it) + { + theResultBox->generated((*it).second, (*it).first); + } +} + //================================================================================================= void PrimitivesPlugin_Box::createBoxByOnePointAndDims() { @@ -200,9 +224,9 @@ void PrimitivesPlugin_Box::createBoxByOnePointAndDims() } int aResultIndex = 0; - ResultBodyPtr aResultBox = document()->createBody(data(), aResultIndex); - loadNamingDS(aBoxAlgo, aResultBox); - setResult(aResultBox, aResultIndex); + ResultVolumePtr aResultBox = document()->createVolume(data(), aResultIndex); + toto(aBoxAlgo, aResultBox); + setVolume(aResultBox, aResultIndex); } //================================================================================================= -- 2.39.2