Salome HOME
23586: [EDF] HYDRO: Copy mesh to new geometry V9_2_0a1
authoreap <eap@opencascade.com>
Tue, 18 Sep 2018 12:08:16 +0000 (15:08 +0300)
committereap <eap@opencascade.com>
Tue, 18 Sep 2018 12:08:16 +0000 (15:08 +0300)
src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx
src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx
src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx

index d9b20ba0c768bb2ab8a775f156639e57cb057a67..a551acdbf232d8d5e44669bf38ef747dd067d55b 100644 (file)
@@ -100,8 +100,8 @@ public:
   typedef std::map<std::string,double> 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<int>& theVal);
-  std::vector<int> GetFacesWithLayers() const { return _facesWithLayers; }
+  const std::vector<int>& GetFacesWithLayers() const { return _facesWithLayers; }
 
   bool SetImprintedFaces(const std::vector<int>& theVal);
-  std::vector<int> GetImprintedFaces() const { return _imprintedFaces; }
+  const std::vector<int>& GetImprintedFaces() const { return _imprintedFaces; }
 
   // the parameters default values 
   static int GetDefaultHexesMinLevel();
index d94fb994eaf220696dc5111c26f6454223b4b7d7..1ae10873396afbb04072bc6d5325618b47716939 100644 (file)
@@ -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<int> facesWithLayers;
+  size_t iID = 0;
+  for ( ; iID < nbFacesWL; ++iID )
+    if ( subIDArray[ iID ] > 0 )
+      facesWithLayers.push_back( subIDArray[ iID ]);
+  h->SetFacesWithLayers( facesWithLayers );
+
+  std::vector<int> 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();
+}
index 8f6c8184f98efb4836c9760f4e76df0ff2bebd7f..25f21a67e18baf4e5458e6b0fa576e6f296a3813 100644 (file)
@@ -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