]> SALOME platform Git repositories - plugins/hybridplugin.git/commitdiff
Salome HOME
Add snapping (use existing surface layers as base of the prismatic layer)
authorChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 27 Sep 2018 14:16:19 +0000 (16:16 +0200)
committerChristophe Bourcier <christophe.bourcier@cea.fr>
Thu, 27 Sep 2018 14:16:19 +0000 (16:16 +0200)
13 files changed:
idl/HYBRIDPlugin_Algorithm.idl
src/GUI/HYBRIDPluginGUI_Enums.h
src/GUI/HYBRIDPluginGUI_HypothesisCreator.cxx
src/GUI/HYBRIDPluginGUI_HypothesisCreator.h
src/GUI/HYBRIDPlugin_msg_en.ts
src/GUI/HYBRIDPlugin_msg_fr.ts
src/GUI/HYBRIDPlugin_msg_ja.ts
src/HYBRIDPlugin/HYBRIDPluginBuilder.py
src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.cxx
src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis.hxx
src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.cxx
src/HYBRIDPlugin/HYBRIDPlugin_Hypothesis_i.hxx
tests/tests.set

index a226d813d464ecd51decf335d44d2c4dd590f285..04f0a386e7ec855b01c07dbb33adf546e04052b7 100644 (file)
@@ -88,6 +88,11 @@ module HYBRIDPlugin
      */
     void SetFacesWithImprinting(in SMESH::long_array faceIDs);
     SMESH::long_array GetFacesWithImprinting();
+    /*!
+     * To snap layers on given faces.
+     */
+    void SetFacesWithSnapping(in SMESH::long_array faceIDs);
+    SMESH::long_array GetFacesWithSnapping();
     /*!
      * To make groups of volumes of different domains when mesh is generated from skin.
      * Default is to make groups.
index 629d4b14736f710799c49835eb12e01a959b126a..4612ee922f7f17a141ade070da2f516b50429e2a 100644 (file)
@@ -31,6 +31,7 @@ enum {
   ADV_TAB,
   FACE_SEL_LAYERS_TAB,
   FACE_SEL_IMPRINTING_TAB,
+  FACE_SEL_SNAPPING_TAB,
   ENF_MESH_TAB
 };
 
index 20b21ce927476cef686a47ea22fdcddfd7c08afe..cfa65f4a2596764bebee1dab82ce8cbcf40c3ce0 100644 (file)
@@ -717,6 +717,19 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
   faceSelImprintingLayout->addWidget( myFaceSelectorImprinting, 1, 0, 2, 2 );
   faceSelImprintingLayout->setRowStretch( 1, 10);
 
+  // selection of faces for snapping
+
+  QWidget* faceSelSnappingGroup = new QWidget( dlg() );
+  QGridLayout* faceSelSnappingLayout = new QGridLayout( faceSelSnappingGroup );
+
+  QLabel* facesLblSnapping = new QLabel( tr("HYBRID_FACE_IDS"), faceSelSnappingGroup );
+  faceSelSnappingLayout->addWidget( facesLblSnapping, 0, 0 );
+
+  myFaceSelectorSnapping = new StdMeshersGUI_SubShapeSelectorWdg( faceSelSnappingGroup, TopAbs_FACE, true, true );
+  myFaceSelectorSnapping->SetGeomShapeEntry( aSubEntry, aMainEntry );
+  faceSelSnappingLayout->addWidget( myFaceSelectorSnapping, 1, 0, 2, 2 );
+  faceSelSnappingLayout->setRowStretch( 1, 10);
+
   // add tabs
   tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
   tab->insertTab( ADV_TAB, myAdvGroup, tr( "HYBRID_ADV_ARGS" ) );
@@ -725,6 +738,7 @@ QFrame* HYBRIDPluginGUI_HypothesisCreator::buildFrame()
   else {
     tab->insertTab( FACE_SEL_LAYERS_TAB, faceSelLayersGroup, tr( "HYBRID_FACES_LAYERS_TAB" ));
     tab->insertTab( FACE_SEL_IMPRINTING_TAB, faceSelImprintingGroup, tr( "HYBRID_FACES_IMPRINTING_TAB" ));
+    tab->insertTab( FACE_SEL_SNAPPING_TAB, faceSelSnappingGroup, tr( "HYBRID_FACES_SNAPPING_TAB" ));
   }
   tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "HYBRID_ENFORCED_MESHES" ) );
   tab->setCurrentIndex( STD_TAB );
@@ -1473,6 +1487,8 @@ void HYBRIDPluginGUI_HypothesisCreator::onTabChanged( int )
   myFaceSelectorLayers->ShowPreview( false );
   myFaceSelectorImprinting->ActivateSelection( false );
   myFaceSelectorImprinting->ShowPreview( false );
+  myFaceSelectorSnapping->ActivateSelection( false );
+  myFaceSelectorSnapping->ShowPreview( false );
 }
 
 void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
@@ -1497,6 +1513,7 @@ void HYBRIDPluginGUI_HypothesisCreator::updateWidgets()
   myFaceSelectorLayers->setEnabled(enabled);
   if ( QTabWidget* tab = qobject_cast<QTabWidget*>( myStdGroup->parentWidget()->parentWidget() )) {
     tab->setTabEnabled( FACE_SEL_IMPRINTING_TAB, enabled );
+    tab->setTabEnabled( FACE_SEL_SNAPPING_TAB, enabled );
   }
 }
 
@@ -1547,6 +1564,7 @@ void HYBRIDPluginGUI_HypothesisCreator::retrieveParams() const
   myMultinormalsAngleSpin         -> setValue( data.myMultinormalsAngle );
   myFaceSelectorLayers            ->SetListOfIDs( data.myFaceWLIds );
   myFaceSelectorImprinting        ->SetListOfIDs( data.myFaceWIIds );
+  myFaceSelectorSnapping          ->SetListOfIDs( data.myFaceWSIds );
 
   myAdvWidget->workingDirectoryLineEdit       ->setText   ( data.myWorkingDir );
   myAdvWidget->keepWorkingFilesCheck          ->setChecked( data.myKeepFiles );
@@ -1778,6 +1796,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromHypo( HYBRIDHypothesisData
   h_data.myNbOfBoundaryLayers         = h->GetNbOfBoundaryLayers();
   h_data.myFaceWLIds                  = h->GetFacesWithLayers();
   h_data.myFaceWIIds                  = h->GetFacesWithImprinting();
+  h_data.myFaceWSIds                  = h->GetFacesWithSnapping();
 
   h_data.myLayersOnAllWrap            = h->GetLayersOnAllWrap();
   h_data.myToMeshHoles                = h->GetToMeshHoles();
@@ -1890,6 +1909,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::storeParamsToHypo( const HYBRIDHypothesi
       h->SetNbOfBoundaryLayers       ( h_data.myNbOfBoundaryLayers );
     h->SetFacesWithLayers( h_data.myFaceWLIds );
     h->SetFacesWithImprinting( h_data.myFaceWIIds );
+    h->SetFacesWithSnapping( h_data.myFaceWSIds );
 
     if ( h->GetKeepFiles() != h_data.myKeepFiles)
       h->SetKeepFiles       ( h_data.myKeepFiles);
@@ -2013,6 +2033,7 @@ bool HYBRIDPluginGUI_HypothesisCreator::readParamsFromWidgets( HYBRIDHypothesisD
   h_data.myMultinormalsAngle          = myMultinormalsAngleSpin -> value();
   h_data.myFaceWLIds                  = myFaceSelectorLayers->GetListOfIDs();
   h_data.myFaceWIIds                  = myFaceSelectorImprinting->GetListOfIDs();
+  h_data.myFaceWSIds                  = myFaceSelectorSnapping->GetListOfIDs();
 
   h_data.myKeepFiles                  = myAdvWidget->keepWorkingFilesCheck->isChecked();
   h_data.myWorkingDir                 = myAdvWidget->workingDirectoryLineEdit->text().trimmed();
index 2d3b70e9f2032b9e1093f613e87ac87f29dff34e..4dd913033e62b47e9acea6bd8dde9aeefaee1445 100644 (file)
@@ -168,6 +168,8 @@ typedef struct
   SMESH::long_array_var myFaceWLIds;
   // IDs of faces with imprinting
   SMESH::long_array_var myFaceWIIds;
+  // IDs of faces with snapping
+  SMESH::long_array_var myFaceWSIds;
 
 } HYBRIDHypothesisData;
 
@@ -283,6 +285,7 @@ private:
   QLabel* myFacesLbl;
   StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorLayers;
   StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorImprinting;
+  StdMeshersGUI_SubShapeSelectorWdg* myFaceSelectorSnapping;
 };
 
 class EnforcedVertexTableWidgetDelegate : public QItemDelegate
index 5da01eb43c9d8512fb00fdb035c701b5325a1e7e..536c322db5b7190b7b8bd0725c260dcb89e6a6a2 100644 (file)
@@ -326,6 +326,10 @@ downward means inward and upward means outward ...
         <source>HYBRID_FACES_IMPRINTING_TAB</source>
         <translation>Faces with imprinting</translation>
     </message>
+    <message>
+        <source>HYBRID_FACES_SNAPPING_TAB</source>
+        <translation>Faces with snapping</translation>
+    </message>
     <message>
         <source>HYBRID_FACE_IDS</source>
         <translation>Face IDs</translation>
index a189df015f06d79b9b075b6a47ddb0b26eb7dd81..03259e4d31b2e1c5368ffa6cb6deeb17f3800ce5 100755 (executable)
@@ -327,6 +327,10 @@ en conséquence au dessous signifie à l&apos;intérieur et au dessus signifie 
         <source>HYBRID_FACES_IMPRINTING_TAB</source>
         <translation>Faces avec empreinte</translation>
     </message>
+    <message>
+        <source>HYBRID_FACES_SNAPPING_TAB</source>
+        <translation>Faces avec empreinte existante</translation>
+    </message>
     <message>
         <source>HYBRID_FACE_IDS</source>
         <translation>Numéros des faces</translation>
index c0627e2061edb1d0f571cef174d9dbbce89e7ae6..084178a64922433399e9545dbb606dbe011fc676 100644 (file)
@@ -327,6 +327,10 @@ downward means inward and upward means outward ...
       <source>HYBRID_FACES_IMPRINTING_TAB</source>
       <translation>プリント付フェイス</translation>
     </message>
+    <message>
+      <source>HYBRID_FACES_SNAPPING_TAB</source>
+      <translation type="unfinished">Faces with snapping</translation>
+    </message>
     <message>
       <source>HYBRID_FACE_IDS</source>
       <translation>面ID</translation>
index 682a48f1fb7af420ef41501899443671f4ded44c..c6cf6a15517decb2656a9e0d227a5349104e1e76 100644 (file)
@@ -141,6 +141,28 @@ class HYBRID_Algorithm(Mesh_Algorithm):
             self.SetLayersOnAllWrap( False )
         pass
 
+    ## To snap the layers on given surface (use existing surface layers as base for volume layers).
+    #  @param faceIDs faces or face IDs that already have surface layers
+    def SetFacesWithSnapping(self, faceIDs):
+        import GEOM
+        ids = []
+        if not isinstance( faceIDs, list ) and not isinstance( faceIDs, tuple ):
+            faceIDs = [ faceIDs ]
+        for fid in faceIDs:
+            if isinstance( fid, int ):
+                ids.append( fid )
+            elif isinstance( fid, GEOM._objref_GEOM_Object):
+                faces = self.mesh.geompyD.SubShapeAll( fid, self.mesh.geompyD.ShapeType["FACE"])
+                for f in faces:
+                    ids.append( self.mesh.geompyD.GetSubShapeID( self.mesh.geom, f ))
+            else:
+                raise TypeError("Face should be either ID or GEOM_Object, not %s" % type(fid))
+            pass
+        self.Parameters().SetFacesWithSnapping(ids)
+        if ids:
+            self.SetLayersOnAllWrap( False )
+        pass
+
     """
     obsolete
     ## To mesh "holes" in a solid or not. Default is to mesh.
index 2d14876675cfeba531ac6d5af15d53f3456788b1..95ce0eaa9e4076657456d479c57220301b5bfecb 100644 (file)
@@ -155,6 +155,32 @@ const std::vector<int>& HYBRIDPlugin_Hypothesis::GetFacesWithImprinting() const
   return myFacesWithImprinting;
 }
 
+//=======================================================================
+//function : SetFacesWithSnapping
+//purpose  : Set IDs of faces that already have surface layers
+//=======================================================================
+
+bool HYBRIDPlugin_Hypothesis::SetFacesWithSnapping(const std::vector<int>& theVal)
+{
+  if ( myFacesWithSnapping != theVal )
+  {
+    myFacesWithSnapping = theVal;
+    NotifySubMeshesHypothesisModification();
+    return true;
+  }
+  return false;
+}
+
+//=======================================================================
+//function : GetFacesWithSnapping
+//purpose  : Return IDs of faces that already have surface layers
+//=======================================================================
+
+const std::vector<int>& HYBRIDPlugin_Hypothesis::GetFacesWithSnapping() const
+{
+  return myFacesWithSnapping;
+}
+
 //=======================================================================
 //function : SetToMeshHoles
 //=======================================================================
@@ -1452,6 +1478,10 @@ std::ostream & HYBRIDPlugin_Hypothesis::SaveTo(std::ostream & save)
   for ( size_t i = 0; i < myFacesWithImprinting.size(); ++i )
     save << " " << myFacesWithImprinting[i];
 
+  save << " " << myFacesWithSnapping.size();
+  for ( size_t i = 0; i < myFacesWithSnapping.size(); ++i )
+    save << " " << myFacesWithSnapping[i];
+
   return save;
 }
 
@@ -1797,6 +1827,20 @@ std::istream & HYBRIDPlugin_Hypothesis::LoadFrom(std::istream & load)
     }
   }
 
+  isOK = static_cast<bool>(load >> separator);
+  if ( isOK )
+  {
+    i = atoi( separator.c_str() );
+    isOK = ( i >= 0 );
+    if ( isOK )
+    {
+      myFacesWithSnapping.reserve( i );
+      while (( myFacesWithSnapping.size() < myFacesWithSnapping.capacity() ) &&
+             ( isOK = static_cast<bool>(load >> i)) )
+        myFacesWithSnapping.push_back( i );
+    }
+  }
+
   return load;
 }
 
@@ -1924,6 +1968,13 @@ std::string HYBRIDPlugin_Hypothesis::CommandToRun(const HYBRIDPlugin_Hypothesis*
         cmd << " --boundary_layer_imprinting yes --boundary_layer_imprinting_tags ";
       for ( size_t i = 0; i < faceImprintingIDs.size(); ++i )
         cmd << faceImprintingIDs[i] << ",";
+
+      // faces with snapping
+      const std::vector<int>& faceSnappingIDs = hyp->GetFacesWithSnapping();
+      if ( !faceSnappingIDs.empty() )
+        cmd << " --boundary_layer_snapping yes --boundary_layer_snapping_tags ";
+      for ( size_t i = 0; i < faceSnappingIDs.size(); ++i )
+        cmd << faceSnappingIDs[i] << ",";
     }
   }
 
index 934b28c91945360e399d6710b8a3a50d2fd03d3f..3334e44ac4842a9d7525f2564a2fa60dbb42b356 100644 (file)
@@ -139,6 +139,11 @@ public:
    */
   bool SetFacesWithImprinting(const std::vector<int>& theVal);
   const std::vector<int>& GetFacesWithImprinting() const;
+  /*!
+   * IDs of faces with snapping (faces that already have surface layers)
+   */
+  bool SetFacesWithSnapping(const std::vector<int>& theVal);
+  const std::vector<int>& GetFacesWithSnapping() const;
   /*!
    * To make groups of volumes of different domains when mesh is generated from skin.
    * Default is to make groups.
@@ -432,6 +437,7 @@ private:
   bool             myLayersOnAllWrap;
   std::vector<int> myFacesWithLayers;
   std::vector<int> myFacesWithImprinting;
+  std::vector<int> myFacesWithSnapping;
   bool             myToMakeGroupsOfDomains;
   double           myMaximumMemory;
   double           myInitialMemory;
index d4348f519259770e23888a401a0a65509c37a368..662312f3824866549a1aad6c153b44758f9015be 100644 (file)
@@ -143,6 +143,35 @@ SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithImprinting()
   return ids._retn();
 }
 
+//=======================================================================
+//function : SetFacesWithSnapping
+//=======================================================================
+
+void HYBRIDPlugin_Hypothesis_i::SetFacesWithSnapping(const ::SMESH::long_array& theVal)
+{
+  std::vector<int> ids( theVal.length() );
+  for ( size_t i = 0; i < ids.size(); ++i )
+   ids[i] = theVal[i];
+
+  bool valueChanged = this->GetImpl()->SetFacesWithSnapping(ids);
+  if (valueChanged)
+    SMESH::TPythonDump() << _this() << ".SetFacesWithSnapping( "<< theVal << " )";
+}
+
+//=======================================================================
+//function : GetFacesWithSnapping
+//=======================================================================
+
+SMESH::long_array* HYBRIDPlugin_Hypothesis_i::GetFacesWithSnapping()
+{
+  const std::vector<int>& idsVec = this->GetImpl()->GetFacesWithSnapping();
+  SMESH::long_array_var ids = new SMESH::long_array;
+  ids->length( idsVec.size() );
+  for ( size_t i = 0; i < idsVec.size(); ++i )
+    ids[i] = idsVec[i];
+  return ids._retn();
+}
+
 //=======================================================================
 //function : SetToMeshHoles
 //=======================================================================
index 8774a2e1063d3c93a5125f42a95b8251e028a66d..32eec1e9515d9fd99d7193f3735979b6cfe4b308 100644 (file)
@@ -64,6 +64,11 @@ class HYBRIDPLUGIN_EXPORT HYBRIDPlugin_Hypothesis_i:
    */
   void SetFacesWithImprinting(const SMESH::long_array& faceIDs);
   SMESH::long_array* GetFacesWithImprinting();
+  /*!
+   * IDs of faces to snap the layers on (faces that already have surface layers)
+   */
+  void SetFacesWithSnapping(const SMESH::long_array& faceIDs);
+  SMESH::long_array* GetFacesWithSnapping();
   /*!
    * To mesh "layers on all wrap". Default is to mesh.
    */
index 5ecb682df2a549e9f8796a41403879f7e2316d83..6b6be114a98ac1d733a5cf559b764b946c1637e0 100644 (file)
@@ -22,6 +22,7 @@ SET(TEST_NAMES
   enforced_mesh
   layers_imprinting
   layers_imprinting_hexa_core
+  layers_with_snapping
   mg_hybrid_pyramids
   advanced_text_option
 )