From 9079b6b5fba638562883a8e443a31e545e5c99d3 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 18 Sep 2018 15:08:16 +0300 Subject: [PATCH] 23586: [EDF] HYDRO: Copy mesh to new geometry --- .../HexoticPlugin_Hypothesis.hxx | 8 +- .../HexoticPlugin_Hypothesis_i.cxx | 79 +++++++++++++++++-- .../HexoticPlugin_Hypothesis_i.hxx | 10 +++ 3 files changed, 88 insertions(+), 9 deletions(-) diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx index d9b20ba..a551acd 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx @@ -100,8 +100,8 @@ public: typedef std::map THexoticSizeMaps; // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo - THexoticSizeMaps GetSizeMaps() const { return _sizeMaps; }; - + const THexoticSizeMaps& GetSizeMaps() const { return _sizeMaps; } + // Add one size map to the collection of size maps (user interface) bool AddSizeMap(std::string theEntry, double theSize); bool UnsetSizeMap(std::string theEntry); @@ -119,10 +119,10 @@ public: double GetGrowth() const { return _growth; } bool SetFacesWithLayers(const std::vector& theVal); - std::vector GetFacesWithLayers() const { return _facesWithLayers; } + const std::vector& GetFacesWithLayers() const { return _facesWithLayers; } bool SetImprintedFaces(const std::vector& theVal); - std::vector GetImprintedFaces() const { return _imprintedFaces; } + const std::vector& GetImprintedFaces() const { return _imprintedFaces; } // the parameters default values static int GetDefaultHexesMinLevel(); diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx index d94fb99..1ae1087 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx @@ -541,14 +541,83 @@ SMESH::long_array* HexoticPlugin_Hypothesis_i::GetImprintedFaces() //================================================================================ /*! - * \brief Verify whether hypothesis supports given entity type - * \param type - dimension (see SMESH::Dimension enumeration) - * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise - * + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) */ -//================================================================================ +//================================================================================ CORBA::Boolean HexoticPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type ) { return type == SMESH::DIM_3D; } + +//================================================================================ +/*! + * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter + */ +//================================================================================ + +bool +HexoticPlugin_Hypothesis_i::getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const +{ + typedef ::HexoticPlugin_Hypothesis THyp; + const THyp* h = static_cast< const THyp*> ( myBaseImpl ); + + const THyp::THexoticSizeMaps& sizeMaps = h->GetSizeMaps(); + THyp::THexoticSizeMaps::const_iterator entry2size = sizeMaps.cbegin(); + for ( ; entry2size != sizeMaps.cend(); ++entry2size ) + entryArray.push_back( entry2size->first ); + + subIDArray = h->GetFacesWithLayers(); + subIDArray.insert( subIDArray.end(), + h->GetImprintedFaces().begin(), + h->GetImprintedFaces().end()); + + return true; +} + +//================================================================================ +/*! + * \brief Set new geometry instead of that returned by getObjectsDependOn() + */ +//================================================================================ + +bool +HexoticPlugin_Hypothesis_i::setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) +{ + typedef ::HexoticPlugin_Hypothesis THyp; + THyp* h = static_cast< THyp*> ( myBaseImpl ); + + size_t iEnt = 0; + + THyp::THexoticSizeMaps& sizeMapsNew = const_cast< THyp::THexoticSizeMaps& > ( h->GetSizeMaps() ); + THyp::THexoticSizeMaps sizeMaps; + sizeMaps.swap( sizeMapsNew ); + THyp::THexoticSizeMaps::const_iterator entry2size = sizeMaps.cbegin(); + for ( ; entry2size != sizeMaps.cend(); ++entry2size ) + { + const std::string& entry = entryArray[ iEnt++ ]; + if ( entry.empty() == entry2size->first.empty() ) + sizeMapsNew[ entry ] = entry2size->second; + } + + size_t nbFacesWL = h->GetFacesWithLayers().size(); + std::vector facesWithLayers; + size_t iID = 0; + for ( ; iID < nbFacesWL; ++iID ) + if ( subIDArray[ iID ] > 0 ) + facesWithLayers.push_back( subIDArray[ iID ]); + h->SetFacesWithLayers( facesWithLayers ); + + std::vector imprintedFaces; + for ( ; iID < subIDArray.size(); ++iID ) + if ( subIDArray[ iID ] > 0 ) + imprintedFaces.push_back( subIDArray[ iID ]); + h->SetImprintedFaces( imprintedFaces ); + + return iID == subIDArray.size() && iEnt == entryArray.size(); +} diff --git a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx index 8f6c818..25f21a6 100644 --- a/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx +++ b/src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx @@ -118,6 +118,16 @@ class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis_i: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Methods for copying mesh definition to other geometry + + // Return geometry this hypothesis depends on. Return false if there is no geometry parameter + virtual bool getObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ) const; + + // Set new geometry instead of that returned by getObjectsDependOn() + virtual bool setObjectsDependOn( std::vector< std::string > & entryArray, + std::vector< int > & subIDArray ); }; #endif -- 2.30.2