]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
bos #20543: EDF 22638 - hyperpatch with CADSurf
authoreap <eap@opencascade.com>
Mon, 1 Feb 2021 15:29:14 +0000 (18:29 +0300)
committereap <eap@opencascade.com>
Mon, 1 Feb 2021 15:29:14 +0000 (18:29 +0300)
Add a methods to hypothesis allowing to set hyper-patch by shapes

idl/BLSURFPlugin_Algorithm.idl
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_BLSURF.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.h

index 2e4b0014a16a9a1fc18ee5992c3907a5a2317ec6..0812e1fe5fe4ac852b6295408412a5c8b52fbf8c 100644 (file)
@@ -121,8 +121,11 @@ module BLSURFPlugin
   typedef sequence<TPreCadPeriodicity> TPeriodicityList;
 
   // Hyper-patches
-  typedef sequence<long> THyperPatch;
-  typedef sequence<THyperPatch> THyperPatchList;
+  typedef sequence< long               > THyperPatch;
+  typedef sequence< THyperPatch        > THyperPatchList;
+  typedef sequence< string             > THyperPatchEntries;
+  typedef sequence< THyperPatchEntries > THyperPatchEntriesList;
+  typedef sequence< GEOM::ListOfGO     > THyperPatchShapesList;
   
   /*!
    * BLSURFPlugin_BLSURF: interface of BLSURF algorithm
@@ -500,7 +503,10 @@ module BLSURFPlugin
      * Set hyper-patches
      */
     void SetHyperPatches(in THyperPatchList hpl);
-    THyperPatchList GetHyperPatches();
+    THyperPatchList GetHyperPatches( in GEOM::GEOM_Object mainShape );
+    void SetHyperPatchShapes(in THyperPatchShapesList hpsl);
+    THyperPatchEntriesList GetHyperPatchShapes();
+    void SetHyperPatchEntries(in THyperPatchEntriesList hpel);
 
     /*!
      * To merges edges.
index eaa9178efe6f7ded80ca9193fae7dac097c22c6e..27695e9d144adb0fce577fcac00e35b3a02e9e67 100644 (file)
@@ -991,6 +991,14 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp,
       if ( !opIt->second.empty() ) {
         set_param(css, opIt->first.c_str(), opIt->second.c_str());
       }
+
+    if ( hyp->GetHyperPatches().size() < hyp->GetHyperPatchEntries().size() )
+    {
+      std::map< std::string, TopoDS_Shape > entryToShape;
+      FillEntryToShape( hyp, entryToShape );
+      const_cast<BLSURFPlugin_Hypothesis*>( hyp )->SetHyperPatchIDsByEntry( theGeomShape,
+                                                                            entryToShape );
+    }
   }
 
   if ( BLSURFPlugin_Hypothesis::HasPreCADOptions( hyp ))
@@ -3602,3 +3610,23 @@ bool BLSURFPlugin_BLSURF::Evaluate(SMESH_Mesh&         aMesh,
 
   return true;
 }
+
+//================================================================================
+/*!
+ * \brief Find TopoDS_Shape for each hyper-patch study entry in a hypothesis
+ */
+//================================================================================
+
+void BLSURFPlugin_BLSURF::FillEntryToShape( const BLSURFPlugin_Hypothesis*          hyp,
+                                            std::map< std::string, TopoDS_Shape > & entryToShape )
+{
+  SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
+  for ( const ::BLSURFPlugin_Hypothesis::THyperPatchEntries& entries : hyp->GetHyperPatchEntries() )
+    for ( const std::string& entry : entries )
+    {
+      GEOM::GEOM_Object_var go = smeshGen->GetGeomObjectByEntry( entry );
+      TopoDS_Shape       shape = smeshGen->GeomObjectToShape( go );
+      if ( !shape.IsNull() )
+        entryToShape.insert({ entry, shape });
+    }
+}
index 4c7b1a91b7f67f31d5a0cc79c9f86f5a86f7cbdc..860181988d1e59f0ef42a5550cfad796d972e553 100644 (file)
@@ -73,94 +73,98 @@ extern "C"{
 
 class TopoDS_Shape;
 
-class BLSURFPlugin_BLSURF: public SMESH_2D_Algo {
-  public:
-    BLSURFPlugin_BLSURF(int hypId, SMESH_Gen* gen, bool theHasGEOM);
-
-    virtual ~BLSURFPlugin_BLSURF();
-
-    virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
-                                 const TopoDS_Shape&                  aShape,
-                                 SMESH_Hypothesis::Hypothesis_Status& aStatus);
-
-    void SetParameters(const BLSURFPlugin_Hypothesis* hyp, cadsurf_session_t *css, const TopoDS_Shape& shape);
-
-    virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
-    virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
-
-    virtual void CancelCompute();
-    bool computeCanceled() { return _compute_canceled; }
-
-    virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
-                          MapShapeNbElems& aResMap);
-
-    // List of ids
-    typedef std::vector<int> TListOfIDs;
-
-    // PreCad Edges periodicity
-    struct TPreCadPeriodicityIDs {
-      TListOfIDs shape1IDs;
-      TListOfIDs shape2IDs;
-      std::vector<double> theSourceVerticesCoords;
-      std::vector<double> theTargetVerticesCoords;
-    };
-
-    // Edge periodicity
-    struct TEdgePeriodicityIDs {
-      int theFace1ID;
-      int theEdge1ID;
-      int theFace2ID;
-      int theEdge2ID;
-      int edge_orientation;
-    };
-
-    // Vertex periodicity
-    struct TVertexPeriodicityIDs {
-      int theEdge1ID;
-      int theVertex1ID;
-      int theEdge2ID;
-      int theVertex2ID;
-    };
-
-    // Vector of pairs of ids
-    typedef std::vector< TPreCadPeriodicityIDs > TPreCadIDsPeriodicityVector;
-    typedef std::vector< std::pair<int, int> > TShapesIDsPeriodicityVector;
-    typedef std::vector< TEdgePeriodicityIDs > TEdgesIDsPeriodicityVector;
-    typedef std::vector< TVertexPeriodicityIDs > TVerticesIDsPeriodicityVector;
-
-
-
-  protected:
-    const BLSURFPlugin_Hypothesis* _hypothesis;
-    bool                           _haveViscousLayers;
-
-    TPreCadIDsPeriodicityVector _preCadFacesIDsPeriodicityVector;
-    TPreCadIDsPeriodicityVector _preCadEdgesIDsPeriodicityVector;
-
-  private:
-    bool compute(SMESH_Mesh&          aMesh,
-                 const TopoDS_Shape&  aShape,
-                 bool                 allowSubMeshClearing);
-
-    void set_param(cadsurf_session_t *css,
-                   const char *       option_name,
-                   const char *       option_value);
-
-    TopoDS_Shape entryToShape(std::string entry);
-    void addCoordsFromVertices(const std::vector<std::string> &theVerticesEntries, std::vector<double> &theVerticesCoords);
-    void addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector<double> &theVerticesCoords);
-    void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList);
-    void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
-    void createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
-    void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, const SMDS_MeshNode* node, const TopoDS_Shape& ed);
-    void BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc, const TopoDS_Face& face, const gp_Pnt& P, const Standard_Real Tol);
-
-  private:
-      PyObject *          main_mod;
-      PyObject *          main_dict;
-      SMESH_MesherHelper* myHelper;
-
-      volatile bool _compute_canceled;
+class BLSURFPlugin_BLSURF: public SMESH_2D_Algo
+{
+public:
+  BLSURFPlugin_BLSURF(int hypId, SMESH_Gen* gen, bool theHasGEOM);
+
+  virtual ~BLSURFPlugin_BLSURF();
+
+  virtual bool CheckHypothesis(SMESH_Mesh&                          aMesh,
+                               const TopoDS_Shape&                  aShape,
+                               SMESH_Hypothesis::Hypothesis_Status& aStatus);
+
+  void SetParameters(const BLSURFPlugin_Hypothesis* hyp, cadsurf_session_t *css, const TopoDS_Shape& shape);
+
+  virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
+  virtual bool Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHelper);
+
+  virtual void CancelCompute();
+  bool computeCanceled() { return _compute_canceled; }
+
+  virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
+                        MapShapeNbElems& aResMap);
+
+  static void FillEntryToShape( const BLSURFPlugin_Hypothesis*          hyp,
+                                std::map< std::string, TopoDS_Shape > & s2eMap );
+
+  // List of ids
+  typedef std::vector<int> TListOfIDs;
+
+  // PreCad Edges periodicity
+  struct TPreCadPeriodicityIDs {
+    TListOfIDs shape1IDs;
+    TListOfIDs shape2IDs;
+    std::vector<double> theSourceVerticesCoords;
+    std::vector<double> theTargetVerticesCoords;
+  };
+
+  // Edge periodicity
+  struct TEdgePeriodicityIDs {
+    int theFace1ID;
+    int theEdge1ID;
+    int theFace2ID;
+    int theEdge2ID;
+    int edge_orientation;
+  };
+
+  // Vertex periodicity
+  struct TVertexPeriodicityIDs {
+    int theEdge1ID;
+    int theVertex1ID;
+    int theEdge2ID;
+    int theVertex2ID;
+  };
+
+  // Vector of pairs of ids
+  typedef std::vector< TPreCadPeriodicityIDs > TPreCadIDsPeriodicityVector;
+  typedef std::vector< std::pair<int, int> > TShapesIDsPeriodicityVector;
+  typedef std::vector< TEdgePeriodicityIDs > TEdgesIDsPeriodicityVector;
+  typedef std::vector< TVertexPeriodicityIDs > TVerticesIDsPeriodicityVector;
+
+
+
+protected:
+  const BLSURFPlugin_Hypothesis* _hypothesis;
+  bool                           _haveViscousLayers;
+
+  TPreCadIDsPeriodicityVector _preCadFacesIDsPeriodicityVector;
+  TPreCadIDsPeriodicityVector _preCadEdgesIDsPeriodicityVector;
+
+private:
+  bool compute(SMESH_Mesh&          aMesh,
+               const TopoDS_Shape&  aShape,
+               bool                 allowSubMeshClearing);
+
+  void set_param(cadsurf_session_t *css,
+                 const char *       option_name,
+                 const char *       option_value);
+
+  TopoDS_Shape entryToShape(std::string entry);
+  void addCoordsFromVertices(const std::vector<std::string> &theVerticesEntries, std::vector<double> &theVerticesCoords);
+  void addCoordsFromVertex(BLSURFPlugin_Hypothesis::TEntry theVertexEntry, std::vector<double> &theVerticesCoords);
+  void createEnforcedVertexOnFace(TopoDS_Shape FaceShape, BLSURFPlugin_Hypothesis::TEnfVertexList enfVertexList);
+  void createPreCadFacesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
+  void createPreCadEdgesPeriodicity(TopoDS_Shape theGeomShape, const BLSURFPlugin_Hypothesis::TPreCadPeriodicity &preCadPeriodicity);
+  void Set_NodeOnEdge(SMESHDS_Mesh* meshDS, const SMDS_MeshNode* node, const TopoDS_Shape& ed);
+  void BRepClass_FaceClassifierPerform(BRepClass_FaceClassifier* fc, const TopoDS_Face& face, const gp_Pnt& P, const Standard_Real Tol);
+
+private:
+  PyObject *          main_mod;
+  PyObject *          main_dict;
+  SMESH_MesherHelper* myHelper;
+
+  volatile bool _compute_canceled;
 };
 
 #endif
index 038b59ba0191e4750a852d9e23ca82169cf1c34a..3db9478142e23e66ef8d0712c4867db5c5b97e36 100644 (file)
 #include <meshgems/meshgems.h>
 #define MESHGEMS_VERSION_HEX (MESHGEMS_VERSION_MAJOR << 16 | MESHGEMS_VERSION_MINOR << 8 | MESHGEMS_VERSION_PATCH)
 
+#include <boost/archive/text_oarchive.hpp>
+#include <boost/archive/text_iarchive.hpp>
+#include <boost/serialization/set.hpp>
+#include <boost/serialization/vector.hpp>
+#include <boost/serialization/string.hpp>
+
 namespace
 {
   struct GET_DEFAULT // struct used to get default value from GetOptionValue()
@@ -816,8 +822,9 @@ std::string BLSURFPlugin_Hypothesis::GetTags()
 {
   return GetPreCADOptionValue("tags", GET_DEFAULT());
 }
+
 //=============================================================================
-void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl, bool notifyMesh)
 {
   if ( hpl != _hyperPatchList )
   {
@@ -862,9 +869,63 @@ void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchList& hpl)
               _hyperPatchList.erase( _hyperPatchList.begin() + j );
       }
     }
+    if ( notifyMesh )
+      NotifySubMeshesHypothesisModification();
+  }
+}
+//=============================================================================
+void BLSURFPlugin_Hypothesis::SetHyperPatches(const THyperPatchEntriesList& hpel)
+{
+  if ( hpel != _hyperPatchEntriesList )
+  {
+    _hyperPatchEntriesList = hpel;
+    _hyperPatchList.clear();
+
     NotifySubMeshesHypothesisModification();
   }
 }
+//================================================================================
+/*!
+ * \brief Set _hyperPatchList by _hyperPatchEntriesList
+ */
+//================================================================================
+
+void BLSURFPlugin_Hypothesis::
+SetHyperPatchIDsByEntry( const TopoDS_Shape&                          mainShape,
+                         const std::map< std::string, TopoDS_Shape >& entryToShape)
+{
+  _hyperPatchList.clear();
+  if ( _hyperPatchEntriesList.empty() || mainShape.IsNull() )
+    return;
+
+  _hyperPatchList.resize( _hyperPatchEntriesList.size() );
+
+  TopTools_IndexedMapOfShape shapeMap;
+  TopExp::MapShapes( mainShape, shapeMap );
+
+  for ( size_t i = 0; i < _hyperPatchEntriesList.size(); ++i )
+  {
+    THyperPatchTags &            idsList = _hyperPatchList       [ i ];
+    const THyperPatchEntries & entryList = _hyperPatchEntriesList[ i ];
+    for ( const std::string & entry : entryList )
+    {
+      auto e2sIt = entryToShape.find( entry );
+      if ( e2sIt != entryToShape.end() )
+      {
+        for ( TopExp_Explorer fExp( e2sIt->second, TopAbs_FACE ); fExp.More(); fExp.Next() )
+        {
+          int id = shapeMap.FindIndex( fExp.Current() );
+          if ( id > 0 )
+            idsList.insert( id );
+        }
+      }
+    }
+  }
+  THyperPatchList hpl;
+  hpl.swap( _hyperPatchList );
+  SetHyperPatches( hpl, /*notifyMesh=*/false );
+}
+
 //=============================================================================
 /*!
  * \brief Return a tag of a face taking into account the hyper-patches. Optionally
@@ -2187,6 +2248,13 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save)
   save << " " << _nbVolumeProximityLayers;
   save << " " << _volumeProximityRatio;
 
+  // hyper-patches as entries
+  std::ostringstream hpStream;
+  boost::archive::text_oarchive( hpStream ) << _hyperPatchEntriesList;
+  std::string hpString = hpStream.str();
+  save << " " << hpString.size() <<  " " << hpString;
+
+
   return save;
 }
 
@@ -3218,6 +3286,21 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     isOK = static_cast<bool>( load >> _volumeProximityRatio );
   }
 
+  // hyper-patches as entries (issue bos #20543)
+  if ( static_cast<bool>( load >> i ) && i > 0 )
+  {
+    std::string buffer( i, '\0' );
+    load.get( buffer[0] ); // remove a white-space
+    load.get( & buffer[0], i + 1 );
+
+    std::istringstream istream( buffer.data() );
+    boost::archive::text_iarchive archive( istream );
+    try {
+      archive >> _hyperPatchEntriesList;
+    }
+    catch (...) {}
+  }
+
   return load;
 }
 
index 0bc60618041a3368e83fae61d35f4c78dd18a1c1..e6b73340fb6460c2987ed551eb7f3e56e4d0e1b2 100644 (file)
@@ -222,11 +222,18 @@ public:
   // Hyper-patches
   typedef std::set< int > THyperPatchTags;
   typedef std::vector< THyperPatchTags > THyperPatchList;
-
-  void SetHyperPatches(const THyperPatchList& hpl);
-  const THyperPatchList& GetHyperPatches() const { return _hyperPatchList; }
+  typedef std::set< std::string > THyperPatchEntries;
+  typedef std::vector< THyperPatchEntries > THyperPatchEntriesList;
+
+  void SetHyperPatches(const THyperPatchList& hpl, bool notifyMesh=true);
+  void SetHyperPatches(const THyperPatchEntriesList& hpl);
+  void SetHyperPatchIDsByEntry( const TopoDS_Shape&                          mainShape,
+                                const std::map< std::string, TopoDS_Shape >& entryToShape);
+  const THyperPatchList&        GetHyperPatches() const { return _hyperPatchList; }
+  const THyperPatchEntriesList& GetHyperPatchEntries() const { return _hyperPatchEntriesList; }
   static int GetHyperPatchTag( int faceTag, const BLSURFPlugin_Hypothesis* hyp, int* iPatch=0 );
 
+
   void SetPreCADMergeEdges(bool theVal);
   bool GetPreCADMergeEdges() const { return _preCADMergeEdges; }
 
@@ -657,11 +664,12 @@ private:
   TPreCadPeriodicityVector _preCadFacesPeriodicityVector;
   TPreCadPeriodicityVector _preCadEdgesPeriodicityVector;
 
-  TFacesPeriodicityVector _facesPeriodicityVector;
-  TEdgesPeriodicityVector _edgesPeriodicityVector;
+  TFacesPeriodicityVector    _facesPeriodicityVector;
+  TEdgesPeriodicityVector    _edgesPeriodicityVector;
   TVerticesPeriodicityVector _verticesPeriodicityVector;
 
-  THyperPatchList _hyperPatchList;
+  THyperPatchList        _hyperPatchList;
+  THyperPatchEntriesList _hyperPatchEntriesList;
 
   // Called by SaveTo to store content of _preCadFacesPeriodicityVector and _preCadEdgesPeriodicityVector
   void SavePreCADPeriodicity(std::ostream & save, const char* shapeType);
index 4fb63f657d0d3e49c77b5779e86a243e24d68041..9495b48da1c68c2d764e2fc6384cdda3cb2129a2 100644 (file)
@@ -24,6 +24,7 @@
 // ---
 //
 #include "BLSURFPlugin_Hypothesis_i.hxx"
+#include "BLSURFPlugin_BLSURF.hxx"
 
 #include <SMESH_Gen.hxx>
 #include <SMESH_Gen_i.hxx>
@@ -1212,16 +1213,80 @@ void BLSURFPlugin_Hypothesis_i::SetHyperPatches(const BLSURFPlugin::THyperPatchL
   }
   if ( GetImpl()->GetHyperPatches() != patchList )
   {
+    GetImpl()->SetHyperPatches( ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList() ); // erase entries
     GetImpl()->SetHyperPatches( patchList );
     SMESH::TPythonDump() << _this() << ".SetHyperPatches( " << hplDump << " )";
   }
 }
 
 //=============================================================================
-BLSURFPlugin::THyperPatchList* BLSURFPlugin_Hypothesis_i::GetHyperPatches()
+void BLSURFPlugin_Hypothesis_i::SetHyperPatchEntries(const BLSURFPlugin::THyperPatchEntriesList& hpe)
+{
+  ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList patchList( hpe.length() );
+  SMESH_Comment hpeDump;
+  hpeDump << "[";
+  for ( size_t i = 0; i < patchList.size(); ++i )
+  {
+    hpeDump << "[ ";
+    const BLSURFPlugin::THyperPatchEntries& entryList = hpe[ i ];
+    for ( CORBA::ULong j = 0; j < entryList.length(); ++j )
+    {
+      patchList[ i ].insert( entryList[ j ].in() );
+      hpeDump << entryList[ j ].in() << ( j+1 < entryList.length() ? ", " : " ]" );
+    }
+    hpeDump << ( i+1 < patchList.size() ? "," : "]");
+  }
+  if ( GetImpl()->GetHyperPatchEntries() != patchList )
+  {
+    GetImpl()->SetHyperPatches( ::BLSURFPlugin_Hypothesis::THyperPatchList(), /*notify=*/false );
+    GetImpl()->SetHyperPatches( patchList );
+    // TPythonDump converts entries to objects
+    SMESH::TPythonDump() << _this() << ".SetHyperPatchShapes( " << hpeDump << " )";
+  }
+}
+
+//=============================================================================
+void BLSURFPlugin_Hypothesis_i::SetHyperPatchShapes(const BLSURFPlugin::THyperPatchShapesList& hpsl)
+{
+  BLSURFPlugin::THyperPatchEntriesList patchList;
+  patchList.length( hpsl.length() );
+  for ( size_t i = 0; i < hpsl.length(); ++i )
+  {
+    const GEOM::ListOfGO&             shapeList = hpsl[ i ];
+    BLSURFPlugin::THyperPatchEntries& entryList = patchList[ i ];
+    entryList.length( shapeList.length() );
+    for ( CORBA::ULong j = 0; j < shapeList.length(); ++j )
+    {
+      CORBA::String_var entry = shapeList[ j ]->GetStudyEntry();
+      if ( !entry.in() || !entry.in()[0] )
+        THROW_SALOME_CORBA_EXCEPTION( "BLSURFPlugin_Hypothesis::SetHyperPatchShapes(), "
+                                      "Not published hyper-patch shape", SALOME::BAD_PARAM );
+      entryList[ j ] = CORBA::string_dup( entry );
+    }
+  }
+  this->SetHyperPatchEntries( patchList );
+}
+
+//=============================================================================
+BLSURFPlugin::THyperPatchList*
+BLSURFPlugin_Hypothesis_i::GetHyperPatches( GEOM::GEOM_Object_ptr mainShape )
 {
   const ::BLSURFPlugin_Hypothesis::THyperPatchList& hpl = GetImpl()->GetHyperPatches();
-  BLSURFPlugin::THyperPatchList* resHpl = new BLSURFPlugin::THyperPatchList();
+  BLSURFPlugin::THyperPatchList*                 resHpl = new BLSURFPlugin::THyperPatchList();
+  if ( hpl.empty() &&
+       !CORBA::is_nil( mainShape ) &&
+       !GetImpl()->GetHyperPatchEntries().empty() )
+  {
+    // set IDs by entries
+    SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
+    TopoDS_Shape S = smeshGen->GeomObjectToShape( mainShape );
+    if ( !S.IsNull() )
+    {
+      std::map< std::string, TopoDS_Shape > entryToShape;
+      BLSURFPlugin_BLSURF::FillEntryToShape( GetImpl(), entryToShape );
+      GetImpl()->SetHyperPatchIDsByEntry( S, entryToShape );
+    }
+  }
   resHpl->length( hpl.size() );
 
   ::BLSURFPlugin_Hypothesis::THyperPatchList::const_iterator hpIt = hpl.begin();
@@ -1238,6 +1303,27 @@ BLSURFPlugin::THyperPatchList* BLSURFPlugin_Hypothesis_i::GetHyperPatches()
   return resHpl;
 }
 
+//=============================================================================
+BLSURFPlugin::THyperPatchEntriesList* BLSURFPlugin_Hypothesis_i::GetHyperPatchShapes()
+{
+  const ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList& hpel = GetImpl()->GetHyperPatchEntries();
+  BLSURFPlugin::THyperPatchEntriesList* resHpl = new BLSURFPlugin::THyperPatchEntriesList();
+  resHpl->length( hpel.size() );
+
+  ::BLSURFPlugin_Hypothesis::THyperPatchEntriesList::const_iterator hpIt = hpel.begin();
+  for ( int i = 0; hpIt != hpel.end(); ++hpIt, ++i )
+  {
+    const ::BLSURFPlugin_Hypothesis::THyperPatchEntries& hp = *hpIt;
+    BLSURFPlugin::THyperPatchEntries& resHp = (*resHpl)[ i ];
+    resHp.length( hp.size() );
+
+    ::BLSURFPlugin_Hypothesis::THyperPatchEntries::const_iterator entry = hp.begin();
+    for ( int j = 0; entry != hp.end(); ++entry, ++j )
+      resHp[ j ] = CORBA::string_dup( entry->c_str() );
+  }
+  return resHpl;
+}
+
 //=============================================================================
 /*!
  *  BLSURFPlugin_Hypothesis_i::SetPreCADMergeEdges
index 9dd669147608efb4e7e649f3d1a660534dc90b5c..e6ccf2bb973ccbaea4e80e1d95a60d32ba3e0248 100644 (file)
@@ -216,7 +216,10 @@ public:
   char* GetTags();
 
   void SetHyperPatches(const BLSURFPlugin::THyperPatchList& hpl);
-  BLSURFPlugin::THyperPatchList* GetHyperPatches();
+  BLSURFPlugin::THyperPatchList* GetHyperPatches( GEOM::GEOM_Object_ptr mainShape );
+  void SetHyperPatchShapes(const BLSURFPlugin::THyperPatchShapesList& hpsl);
+  BLSURFPlugin::THyperPatchEntriesList* GetHyperPatchShapes();
+  void SetHyperPatchEntries(const BLSURFPlugin::THyperPatchEntriesList& hpel);
 
   void SetPreCADMergeEdges(CORBA::Boolean theValue);
   CORBA::Boolean GetPreCADMergeEdges();
index 873f78142f4468a7eb49ad6fcf029c9167feec74..e13c6c578b8845c244bad881c265024124cd9f5a 100644 (file)
@@ -2019,9 +2019,13 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   }
 
   // Hyper patches
+  QString patchEntries;
   for ( int i = 0; i < data.hyperpatches.size(); ++i )
-    that->addHyPatchToTable( data.hyperpatches[i] );
-
+  {
+    if ( i < data.hyperEntries.size() )
+      patchEntries = data.hyperEntries[i];
+    that->addHyPatchToTable( data.hyperpatches[i], patchEntries );
+  }
   // update widgets
   that->myStdWidget->onPhysicalMeshChanged();
   that->myStdWidget->onGeometricMeshChanged();
@@ -2229,8 +2233,14 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
 
   // Hyper Patches
 
+  GEOM::GEOM_Object_var geom = myHyPatchFaceSelector->GetGeomObjectByEntry( getMainShapeEntry() );
+  if ( geom->_is_nil() )
+    geom = myHyPatchFaceSelector->GetGeomObjectByEntry( getShapeEntry() );
+
   h_data.hyperpatches.clear();
-  BLSURFPlugin::THyperPatchList_var patchList = h->GetHyperPatches();
+  h_data.hyperEntries.clear();
+  BLSURFPlugin::THyperPatchList_var               patchList = h->GetHyperPatches( geom );
+  BLSURFPlugin::THyperPatchEntriesList_var patchEntriesList = h->GetHyperPatchShapes();
   for ( CORBA::ULong i = 0; i < patchList->length(); ++i )
   {
     QString tags;
@@ -2239,7 +2249,19 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
       tags += QString::number( patch[j] ) + " ";
     if ( !tags.isEmpty() )
       h_data.hyperpatches.append( tags );
+
+    if ( patchEntriesList->length() == patchList->length() )
+    {
+      QString entries;
+      BLSURFPlugin::THyperPatchEntries& patchEntries = patchEntriesList[i];
+      for ( CORBA::ULong j = 0; j < patchEntries.length(); ++j )
+        entries += patchEntries[j].in() + QString(" ");
+      if ( !entries.isEmpty() )
+        h_data.hyperEntries.append( entries );
+    }
   }
+  if ( h_data.hyperpatches.size() != h_data.hyperEntries.size() )
+    h_data.hyperEntries.clear();
 
   return true;
 }
@@ -2531,8 +2553,10 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
     }
 
     // Hyper-patches
-    BLSURFPlugin::THyperPatchList_var hpl = new BLSURFPlugin::THyperPatchList();
-    hpl->length( h_data.hyperpatches.size() );
+    BLSURFPlugin::THyperPatchList_var         hpl = new BLSURFPlugin::THyperPatchList();
+    BLSURFPlugin::THyperPatchEntriesList_var hpel = new BLSURFPlugin::THyperPatchEntriesList();
+    hpl ->length( h_data.hyperpatches.size() );
+    hpel->length( h_data.hyperEntries.size() );
 
     for ( int i = 0; i < h_data.hyperpatches.size(); ++i )
     {
@@ -2541,9 +2565,22 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
       patch.length( tags.size() );
 
       for ( int j = 0; j < tags.size(); ++j )
-        patch[ j ] = tags[ j ].toDouble();
+        patch[ j ] = tags[ j ].toInt();
+
+      if ( i < h_data.hyperEntries.size() )
+      {
+        QStringList entries = h_data.hyperEntries[i].split(" ",  QString::SkipEmptyParts);
+        BLSURFPlugin::THyperPatchEntries& pe = hpel[ i ];
+        pe.length( entries.size() );
+
+        for ( int j = 0; j < entries.size(); ++j )
+          pe[ j ] = CORBA::string_dup( entries[ j ].toStdString().c_str() );
+      }
     }
-    h->SetHyperPatches( hpl );
+    if ( h_data.hyperEntries.size() == h_data.hyperpatches.size() )
+      h->SetHyperPatchEntries( hpel );
+    else
+      h->SetHyperPatches( hpl );
 
 
   } // try
@@ -2708,8 +2745,16 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
 
   // Hyper-patches
   h_data.hyperpatches.clear();
+  h_data.hyperEntries.clear();
   for ( int row = 0; row < myHyPatchTable->rowCount(); ++row )
-    h_data.hyperpatches.append( myHyPatchTable->item( row, 0 )->text() );
+  {
+    QTableWidgetItem* cell = myHyPatchTable->item( row, 0 );
+    h_data.hyperpatches.append( cell->text() );
+    if ( cell->data( Qt::UserRole ).isValid() )
+      h_data.hyperEntries.append( cell->data( Qt::UserRole ).toString() );
+  }
+  if ( h_data.hyperpatches.size() != h_data.hyperEntries.size() )
+    h_data.hyperEntries.clear();
 
   return guiHyp;
 }
@@ -3462,7 +3507,23 @@ void BLSURFPluginGUI_HypothesisCreator::onHyPatchAdd()
   QStringList tagList = myHyPatchTagsLE->text().split(" ",  QString::SkipEmptyParts);
   if ( tagList.size() > 1 )
   {
-    addHyPatchToTable( myHyPatchTagsLE->text() );
+    LightApp_SelectionMgr* selMrg = SMESHGUI::GetSMESHGUI()->selectionMgr();
+    SALOME_ListIO aList;
+    selMrg->selectedObjects( aList );
+    QString entries;
+    for ( SALOME_ListIteratorOfListIO anIt( aList ); anIt.More(); anIt.Next() )
+    {
+      Handle(SALOME_InteractiveObject) io = anIt.Value();
+      GEOM::GEOM_Object_var go = myHyPatchFaceSelector->GetGeomObjectByEntry( io->getEntry() );
+      if ( !CORBA::is_nil( go ))
+        entries += io->getEntry() + QString(" ");
+      else
+      {
+        entries.clear();
+        break;
+      }
+    }
+    addHyPatchToTable( myHyPatchTagsLE->text(), entries );
     myHyPatchTagsLE->setText("");
   }
 }
@@ -3473,12 +3534,17 @@ void BLSURFPluginGUI_HypothesisCreator::onHyPatchAdd()
  */
 //================================================================================
 
-void BLSURFPluginGUI_HypothesisCreator::addHyPatchToTable(const QString& tags)
+void BLSURFPluginGUI_HypothesisCreator::addHyPatchToTable(const QString& tags,
+                                                          const QString& entries)
 {
   if ( tags.isEmpty() ) return;
 
   QTableWidgetItem* cell = new QTableWidgetItem( tags );
   cell->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled );
+  if ( entries.isEmpty() )
+    cell->setData( Qt::UserRole, QVariant() );
+  else
+    cell->setData( Qt::UserRole, entries );
 
   int row = myHyPatchTable->rowCount();
   myHyPatchTable->insertRow( row );
index 9533eecb05e1615be54812ab29cbf0f0ee7e4e18..2cf2c116eaf35c6ff8b88be013c68f5f11afbd8e 100644 (file)
@@ -186,7 +186,7 @@ typedef struct
   TGroupNameEnfVertexListMap groupNameEnfVertexListMap;
   */
   TPreCadPeriodicityVector preCadPeriodicityVector;
-  QStringList hyperpatches;
+  QStringList hyperpatches, hyperEntries;
   QString myName;
 } BlsurfHypothesisData;
 
@@ -271,7 +271,7 @@ private:
   static LightApp_SelectionMgr* selectionMgr();
   void                avoidSimultaneousSelection(ListOfWidgets &myCustomWidgets) const;
   void                AddPreCadSequenceToVector(BlsurfHypothesisData& h_data, BLSURFPlugin::TPeriodicityList_var preCadFacePeriodicityVector, bool onFace) const;
-  void                addHyPatchToTable(const QString& tags);
+  void                addHyPatchToTable(const QString& tags, const QString& entries);
   bool                hasGeom() const;
 
 private: