]> SALOME platform Git repositories - plugins/blsurfplugin.git/commitdiff
Salome HOME
Add Attractor:
authorgdd <gdd>
Fri, 20 Feb 2009 18:06:54 +0000 (18:06 +0000)
committergdd <gdd>
Fri, 20 Feb 2009 18:06:54 +0000 (18:06 +0000)
 An attractor is defined with the following pattern:
 ATTRACTOR(xa;ya;za;a;b) where:
 xa;ya;za : coordinates of attractor point
 a        : desired size on attractor point
 b        : distance of influence of attractor

Formula computed is following: R-(R-a)*exp(-(r/b)^2)
with r : distance from attractor

idl/BLSURFPlugin_Algorithm.idl
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis.hxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.hxx

index da90c24dddd09947023bbcb15a5b1b455600fff2..f1be50ddd62ee639e7ec96405192cd3bdc9f0a85 100644 (file)
@@ -165,14 +165,31 @@ module BLSURFPlugin
     /*!
      * SizeMap
      */
-    void SetSizeMapEntry(in string entry,in string sizeMap );
-    string GetSizeMapEntry(in string entry);
-    void UnsetEntry(in string entry);
-    string_array GetSizeMapEntries();
     void SetSizeMapEntries(in string_array sizeMaps);
     void ClearSizeMaps();
-    void SetSizeMap(in GEOM::GEOM_Object GeomObj, in string sizeMap );
-    void UnsetSizeMap(in GEOM::GEOM_Object GeomObj);
+
+    void UnsetEntry(in string entry);
+
+    void         SetSizeMap(in GEOM::GEOM_Object GeomObj, in string sizeMap);
+    void         UnsetSizeMap(in GEOM::GEOM_Object GeomObj);
+    void         SetSizeMapEntry(in string entry, in string sizeMap);
+    string       GetSizeMapEntry(in string entry);
+    string_array GetSizeMapEntries();
+
+    void         SetAttractor(in GEOM::GEOM_Object GeomObj, in string attractor);
+    void         UnsetAttractor(in GEOM::GEOM_Object GeomObj);
+    void         SetAttractorEntry(in string entry, in string attractor);
+    string       GetAttractorEntry(in string entry);
+    string_array GetAttractorEntries();
+
+
+/*
+    void         SetCustomSizeMapEntry(in string entry, in string sizeMap);
+    string       GetCustomSizeMapEntry(in string entry);
+    void         SetCustomSizeMap(in GEOM::GEOM_Object GeomObj, in string sizeMap);
+    void         UnsetCustomSizeMap(in GEOM::GEOM_Object GeomObj);
+    string_array GetCustomSizeMapEntries();
+*/
   };
 };
 
index 6b91509556dcc5e721a3c9298580bbdc1fed4bdd..078dfb8dd160e0f7d9fe5dcf6aabad987e934db8 100644 (file)
@@ -77,6 +77,10 @@ extern "C"{
 
 #include  <GeomSelectionTools.h>
 
+#include <GeomAPI_ProjectPointOnCurve.hxx>
+#include <GeomAPI_ProjectPointOnSurf.hxx>
+#include <gp_XY.hxx>
+#include <gp_XYZ.hxx>
 
 /* ==================================
  * ===========  PYTHON ==============
@@ -350,7 +354,33 @@ status_t size_on_edge(integer edge_id, real t, real *size, void *user_data);
 status_t size_on_vertex(integer vertex_id, real *size, void *user_data);
 
 double my_u_min=1e6,my_v_min=1e6,my_u_max=-1e6,my_v_max=-1e6;
+
+/////////////////////////////////////////////////////////
+gp_XY getUV(const TopoDS_Face& face, const gp_XYZ& point)
+{
+  Handle(Geom_Surface) surface = BRep_Tool::Surface(face);
+  GeomAPI_ProjectPointOnSurf projector( point, surface );
+  if ( !projector.IsDone() || projector.NbPoints()==0 )
+    throw "Can't project";
+
+  Quantity_Parameter u,v;
+  projector.LowerDistanceParameters(u,v);
+  return gp_XY(u,v);
+}
+/////////////////////////////////////////////////////////
+
+/////////////////////////////////////////////////////////
+double getT(const TopoDS_Edge& edge, const gp_XYZ& point)
+{
+  Standard_Real f,l;
+  Handle(Geom_Curve) curve = BRep_Tool::Curve(edge, f,l);
+  GeomAPI_ProjectPointOnCurve projector( point, curve);
+  if ( projector.NbPoints() == 0 )
+    throw;
+  return projector.LowerDistanceParameter();
+}
+/////////////////////////////////////////////////////////
+
 void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsurf_session_t *bls)
 {
   int    _topology      = BLSURFPlugin_Hypothesis::GetDefaultTopology();
@@ -408,40 +438,118 @@ void BLSURFPlugin_BLSURF::SetParameters(const BLSURFPlugin_Hypothesis* hyp, blsu
   blsurf_set_param(bls, "hphy_flag",         to_string(_physicalMesh).c_str());
 //  blsurf_set_param(bls, "hphy_flag",         "2");
   if ((to_string(_physicalMesh))=="2"){
-    MESSAGE("Setting a Size Map");
-    const BLSURFPlugin_Hypothesis::TSizeMap & sizeMaps = hyp->GetSizeMapEntries();
-    BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt;
-    GeomSelectionTools* GeomST;
-    GeomST=new GeomSelectionTools::GeomSelectionTools( SMESH::GetActiveStudyDocument());
-
+    GeomSelectionTools* GeomST = new GeomSelectionTools::GeomSelectionTools( SMESH::GetActiveStudyDocument());
     Face2SizeMap.clear();
     Edge2SizeMap.clear();
     Vertex2SizeMap.clear();
 
+    TopoDS_Shape GeomShape;
+    TopAbs_ShapeEnum GeomType;
+    //
+    // Standard Size Maps
+    //
+    MESSAGE("Setting a Size Map");
+    const BLSURFPlugin_Hypothesis::TSizeMap & sizeMaps = hyp->GetSizeMapEntries();
+    BLSURFPlugin_Hypothesis::TSizeMap::const_iterator smIt;
+
     for ( smIt = sizeMaps.begin(); smIt != sizeMaps.end(); ++smIt ) {
       if ( !smIt->second.empty() ) {
 #ifdef _DEBUG_
         cout << "blsurf_set_sizeMap(): " << smIt->first << " = " << smIt->second << endl;
 #endif 
-        TopoDS_Shape GeomShape=GeomST->entryToShape(smIt->first);
-        TopAbs_ShapeEnum GeomType= GeomShape.ShapeType();
-        if (GeomType==TopAbs_FACE){
-          HasSizeMapOnFace=true;
-          Face2SizeMap[TopoDS::Face(GeomShape)]= smIt->second;
+        GeomShape = GeomST->entryToShape(smIt->first);
+        GeomType  = GeomShape.ShapeType();
+        if (GeomType == TopAbs_FACE){
+          HasSizeMapOnFace = true;
+          Face2SizeMap[TopoDS::Face(GeomShape)] = smIt->second;
         }
-        if (GeomType==TopAbs_EDGE){
-          HasSizeMapOnEdge=true;
-          HasSizeMapOnFace=true;
-          Edge2SizeMap[TopoDS::Edge(GeomShape)]= smIt->second;
+        if (GeomType == TopAbs_EDGE){
+          HasSizeMapOnEdge = true;
+          HasSizeMapOnFace = true;
+          Edge2SizeMap[TopoDS::Edge(GeomShape)] = smIt->second;
         }
-        if (GeomType==TopAbs_VERTEX){
-          HasSizeMapOnVertex=true;
-          HasSizeMapOnEdge=true;
-          HasSizeMapOnFace=true;
-          Vertex2SizeMap[TopoDS::Vertex(GeomShape)]= smIt->second;
+        if (GeomType == TopAbs_VERTEX){
+          HasSizeMapOnVertex = true;
+          HasSizeMapOnEdge   = true;
+          HasSizeMapOnFace   = true;
+          Vertex2SizeMap[TopoDS::Vertex(GeomShape)] = smIt->second;
         }
       }
     }
+
+    //
+    // Attractors
+    //
+    MESSAGE("Setting Attractors");
+    const BLSURFPlugin_Hypothesis::TSizeMap & attractors = hyp->GetAttractorEntries();
+    BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt;
+    for ( atIt = attractors.begin(); atIt != attractors.end(); ++atIt ) {
+      if ( !atIt->second.empty() ) {
+#ifdef _DEBUG_
+        cout << "blsurf_set_attractor(): " << atIt->first << " = " << atIt->second << endl;
+#endif
+        GeomShape = GeomST->entryToShape(atIt->first);
+        GeomType  = GeomShape.ShapeType();
+
+        if (GeomType == TopAbs_FACE){
+          HasSizeMapOnFace = true;
+
+          double xa, ya, za; // Coordinates of attractor point
+          double a, b;       // Attractor parameter
+          int pos1, pos2;
+          // atIt->second has the following pattern:
+          // ATTRACTOR(xa;ya;za;a;b)
+          // where:
+          // xa;ya;za : coordinates of  attractor
+          // a        : desired size on attractor
+          // b        : distance of influence of attractor
+          //
+          // We search the parameters in the string
+          pos1 = atIt->second.find(";");
+          xa = atof(atIt->second.substr(10, pos1-10).c_str());
+          pos2 = atIt->second.find(";", pos1+1);
+          ya = atof(atIt->second.substr(pos1+1, pos2-pos1-1).c_str());
+          pos1 = pos2;
+          pos2 = atIt->second.find(";", pos1+1);
+          za = atof(atIt->second.substr(pos1+1, pos2-pos1-1).c_str());
+          pos1 = pos2;
+          pos2 = atIt->second.find(";", pos1+1);
+          a = atof(atIt->second.substr(pos1+1, pos2-pos1-1).c_str());
+          pos1 = pos2;
+          pos2 = atIt->second.find(")");
+          b = atof(atIt->second.substr(pos1+1, pos2-pos1-1).c_str());
+          
+          // Get the (u,v) values of the attractor on the face
+          gp_XY uvPoint = getUV(TopoDS::Face(GeomShape),gp_XYZ(xa,ya,za));
+          Standard_Real u0 = uvPoint.X();
+          Standard_Real v0 = uvPoint.Y();
+          // We construct the python function
+          ostringstream attractorFunction;
+          attractorFunction << "def f(u,v): return ";
+          attractorFunction << _smp_phy_size << "-(" << _smp_phy_size <<"-" << a << ")";
+          attractorFunction << "*exp(-((u-("<<u0<<"))*(u-("<<u0<<"))+(v-("<<v0<<"))*(v-("<<v0<<")))/(" << b << "*" << b <<"))";  
+
+          cout << "Python function for attractor:" << endl << attractorFunction.str() << endl;
+
+          Face2SizeMap[TopoDS::Face(GeomShape)] = attractorFunction.str();
+        }
+/*
+        if (GeomType == TopAbs_EDGE){
+          HasSizeMapOnEdge = true;
+          HasSizeMapOnFace = true;
+          Edge2SizeMap[TopoDS::Edge(GeomShape)] = atIt->second;
+        }
+        if (GeomType == TopAbs_VERTEX){
+          HasSizeMapOnVertex = true;
+          HasSizeMapOnEdge   = true;
+          HasSizeMapOnFace   = true;
+          Vertex2SizeMap[TopoDS::Vertex(GeomShape)] = atIt->second;
+        }
+*/
+      }
+    }    
+
+
 //    if (HasSizeMapOnFace){
     // In all size map cases (hphy_flag = 2), at least map on face must be defined
     std::cout << "Setting Size Map on FACES " << std::endl;
@@ -526,6 +634,7 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
   Standard_Real v_max;
 */
   int iface = 0;
+  string bad_end = "return"; 
   for (TopExp_Explorer face_iter(aShape,TopAbs_FACE);face_iter.More();face_iter.Next()) {
     TopoDS_Face f=TopoDS::Face(face_iter.Current());
     if (fmap.FindIndex(f) > 0)
@@ -538,6 +647,12 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
     //BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max);
     //std::cout << "BRep_Tool::Surface(f)->Bounds(u_min,u_max,v_min,v_max): " << u_min << ", " << u_max << ", " << v_min << ", " << v_max << std::endl;
     if ((HasSizeMapOnFace) && Face2SizeMap.find(f)!=Face2SizeMap.end()){
+      cout << "Face2SizeMap[f].find(bad_end): " << Face2SizeMap[f].find(bad_end) << endl;
+      cout << "Face2SizeMap[f].size(): " << Face2SizeMap[f].size() << endl;
+      cout << "bad_end.size(): " << bad_end.size() << endl;
+      // check if function ends with "return"
+      if (Face2SizeMap[f].find(bad_end) == (Face2SizeMap[f].size()-bad_end.size()-1))
+        continue;
       // Expr To Python function, verification is performed at validation in GUI
       PyObject * obj = NULL;
       obj= PyRun_String(Face2SizeMap[f].c_str(), Py_file_input, main_dict, NULL);
@@ -564,6 +679,8 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
       double tmin,tmax;
       curves.push_back(BRep_Tool::CurveOnSurface(e, f, tmin, tmax));
       if ((HasSizeMapOnEdge) && Edge2SizeMap.find(e)!=Edge2SizeMap.end()){
+        if (Edge2SizeMap[e].find(bad_end) == (Edge2SizeMap[e].size()-bad_end.size()-1))
+          continue;
         // Expr To Python function, verification is performed at validation in GUI
         PyObject * obj = NULL;
         obj= PyRun_String(Edge2SizeMap[e].c_str(), Py_file_input, main_dict, NULL);
@@ -598,6 +715,8 @@ bool BLSURFPlugin_BLSURF::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
        if(*ip <= 0)
          *ip = pmap.Add(v);
         if ((HasSizeMapOnVertex) && Vertex2SizeMap.find(v)!=Vertex2SizeMap.end()){
+          if (Vertex2SizeMap[v].find(bad_end) == (Vertex2SizeMap[v].size()-bad_end.size()-1))
+            continue;
           // Expr To Python function, verification is performed at validation in GUI
           PyObject * obj = NULL;
           obj= PyRun_String(Vertex2SizeMap[v].c_str(), Py_file_input, main_dict, NULL);
index 58e4a74f7e65a798cfca9fc0a93578a349f6c605..221e48e52260c76e6128cc11b2be6f3fc4333621 100644 (file)
@@ -354,6 +354,24 @@ std::string  BLSURFPlugin_Hypothesis::GetSizeMapEntry(const std::string& entry)
    return "No_Such_Entry";
 }
 
+void  BLSURFPlugin_Hypothesis::SetAttractorEntry(const std::string& entry,const std::string& attractor)
+{
+  if (_attractors[entry].compare(attractor) != 0) {
+    _attractors[entry]=attractor;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+std::string  BLSURFPlugin_Hypothesis::GetAttractorEntry(const std::string& entry)
+{
+ TSizeMap::iterator it  = _attractors.find( entry );
+ if ( it != _attractors.end() )
+   return it->second;
+ else
+   return "No_Such_Entry";
+}
+
+
 void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
 {
  TSizeMap::iterator it  = _sizeMap.find( entry );
@@ -361,14 +379,22 @@ void BLSURFPlugin_Hypothesis::ClearEntry(const std::string& entry)
    _sizeMap.erase(it);
    NotifySubMeshesHypothesisModification();
  }
- else
-   std::cout<<"No_Such_Entry"<<std::endl;
+ else {
+   TSizeMap::iterator itAt  = _attractors.find( entry );
+   if ( itAt != _attractors.end() ) {
+     _attractors.erase(itAt);
+     NotifySubMeshesHypothesisModification();
+   }
+   else
+     std::cout<<"No_Such_Entry"<<std::endl;
+ }
 }
 
 
 void BLSURFPlugin_Hypothesis::ClearSizeMaps()
 {
   _sizeMap.clear();
+  _attractors.clear();
 }
 
 
@@ -411,6 +437,16 @@ std::ostream & BLSURFPlugin_Hypothesis::SaveTo(std::ostream & save)
     }
     save << " " << "__SIZEMAP_END__";
   }
+
+  TSizeMap::iterator it_at  = _attractors.begin();
+  if (it_at != _attractors.end()) {
+    save << " " << "__ATTRACTORS_BEGIN__";
+    for ( ; it_at != _attractors.end(); ++it_at ) {
+        save << " " << it_at->first
+             << " " << it_at->second << "%#"; // "%#" is a mark of value end
+    }
+    save << " " << "__ATTRACTORS_END__";
+  }
   
   
   return save;
@@ -510,6 +546,7 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
   std::string option_or_sm;
   bool hasOptions = false;
   bool hasSizeMap = false;
+  bool hasAttractor = false;
 
   isOK = (load >> option_or_sm);
   if (isOK)
@@ -517,6 +554,8 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
       hasOptions = true;
     else if (option_or_sm == "__SIZEMAP_BEGIN__")
       hasSizeMap = true;
+    else if (option_or_sm == "__ATTRACTORS_BEGIN__")
+      hasAttractor = true;
 
   std::string optName, optValue;
   while (isOK && hasOptions) {
@@ -549,8 +588,11 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
 
   if (hasOptions) {
     isOK = (load >> option_or_sm);
-    if (isOK && option_or_sm == "__SIZEMAP_BEGIN__")
-      hasSizeMap = true;
+    if (isOK)
+      if (option_or_sm == "__SIZEMAP_BEGIN__")
+        hasSizeMap = true;
+      else if (option_or_sm == "__ATTRACTORS_BEGIN__")
+        hasAttractor = true;
   }
 
   std::string smEntry, smValue;
@@ -582,6 +624,41 @@ std::istream & BLSURFPlugin_Hypothesis::LoadFrom(std::istream & load)
     }
   }
 
+  if (hasSizeMap) {
+    isOK = (load >> option_or_sm);
+    if (isOK && option_or_sm == "__ATTRACTORS_BEGIN__")
+      hasAttractor = true;
+  }
+
+  std::string atEntry, atValue;
+  while (isOK && hasAttractor) {
+    isOK = (load >> atEntry);
+    if (isOK) {
+      if (atEntry == "__ATTRACTORS_END__")
+        break;
+      isOK = (load >> atValue);
+    }
+    if (isOK) {
+      std::string & value3 = _attractors[ atEntry ];
+      value3 = atValue;
+      int len3= value3.size();
+      // continue reading until "%#" encountered
+      while ( value3[len3-1] != '#' || value3[len3-2] != '%' )
+      {
+        isOK = (load >> atValue);
+        if (isOK) {
+          value3 += " ";
+          value3 += atValue;
+          len3 = value3.size();
+        }
+        else {
+          break;
+        }
+      }
+      value3[ len3-2 ] = '\0'; //cut off "%#"
+    }
+  }
+
   return load;
 }
 
index fe30639fb4674634415e1678cff1aace36e20cb1..1898545aa793d582183e0528d344d9b7b175af0d 100644 (file)
@@ -96,15 +96,28 @@ public:
   void SetVerbosity(int theVal);
   int GetVerbosity() const { return _verb; }
   
+  void ClearEntry(const std::string& entry);
+  void ClearSizeMaps();  
 
   typedef std::map<std::string,std::string> TSizeMap;
+
   void SetSizeMapEntry(const std::string& entry,const std::string& sizeMap );
   std::string  GetSizeMapEntry(const std::string& entry);
-  void ClearEntry(const std::string& entry);
-  void ClearSizeMaps();  
-
   const TSizeMap& GetSizeMapEntries() const { return _sizeMap; }  
 
+
+  void SetAttractorEntry(const std::string& entry,const std::string& attractor );
+  std::string GetAttractorEntry(const std::string& entry);
+  const TSizeMap& GetAttractorEntries() const { return _attractors; };
+
+
+/*
+  void SetCustomSizeMapEntry(const std::string& entry,const std::string& sizeMap );
+  std::string  GetCustomSizeMapEntry(const std::string& entry);
+  void UnsetCustomSizeMap(const std::string& entry);
+  const TSizeMap& GetCustomSizeMapEntries() const { return _customSizeMap; }
+ */
+
   static Topology      GetDefaultTopology();
   static PhysicalMesh  GetDefaultPhysicalMesh();
   static double        GetDefaultPhySize();
@@ -162,6 +175,10 @@ private:
   TOptionValues _option2value;
   TOptionNames  _doubleOptions, _charOptions;
   TSizeMap      _sizeMap;
+  TSizeMap      _attractors;
+/*
+  TSizeMap      _customSizeMap;
+*/
 };
 
 #endif
index 846ad2ff3c4d819c6eaa52faa9caca5175ccd5e3..6046d23d0e6ff79b01e53f7bd558f73914778bbc 100644 (file)
@@ -538,6 +538,37 @@ void BLSURFPlugin_Hypothesis_i::SetSizeMapEntry(const char* entry,const char* si
                          << entry << ", '" << sizeMap << "' )";
 }
 
+//=============================================================================
+
+void BLSURFPlugin_Hypothesis_i::SetAttractorEntry(const char* entry,const char* attractor )
+  throw (SALOME::SALOME_Exception)
+{
+  ASSERT(myBaseImpl);
+  std::cout << "ENGINE : SETATTRACTOR START ENTRY : " << entry << std::endl;
+  bool valueChanged = false;
+  try {
+    valueChanged = ( this->GetImpl()->GetAttractorEntry(entry) != attractor );
+    if ( valueChanged )
+      this->GetImpl()->SetAttractorEntry(entry, attractor);
+  }
+  catch (const std::invalid_argument& ex) {
+    SALOME::ExceptionStruct ExDescription;
+    ExDescription.text = ex.what();
+    ExDescription.type = SALOME::BAD_PARAM;
+    ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::SetAttractorEntry(entry,attractor)";
+    ExDescription.lineNumber = 0;
+    throw SALOME::SALOME_Exception(ExDescription);
+  }
+  catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+  std::cout << "ENGINE : SETATTRACTOR END ENTRY : " << entry << std::endl;
+  if ( valueChanged )
+    SMESH::TPythonDump() << _this() << ".SetAttractor("
+                         << entry << ", '" << attractor << "' )";
+}
+
+
 //=============================================================================
                                                              
 char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry) 
@@ -557,19 +588,42 @@ char* BLSURFPlugin_Hypothesis_i::GetSizeMapEntry(const char* entry)
   }
   catch (SALOME_Exception& ex) {
     THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
-  }                             
+  }
   return 0;
 }
 
 //=============================================================================
-                                                            
+
+char* BLSURFPlugin_Hypothesis_i::GetAttractorEntry(const char* entry)
+  throw (SALOME::SALOME_Exception)
+{
+  ASSERT(myBaseImpl);
+  try {
+    return CORBA::string_dup( this->GetImpl()->GetAttractorEntry(entry).c_str());
+  }
+  catch (const std::invalid_argument& ex) {
+    SALOME::ExceptionStruct ExDescription;
+    ExDescription.text = ex.what();
+    ExDescription.type = SALOME::BAD_PARAM;
+    ExDescription.sourceFile = "BLSURFPlugin_Hypothesis::GetAttractorEntry(name)";
+    ExDescription.lineNumber = 0;
+    throw SALOME::SALOME_Exception(ExDescription);
+  }
+  catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+  return 0;
+}
+
+//=============================================================================
+
 void BLSURFPlugin_Hypothesis_i::UnsetEntry(const char* entry)
 {
-  ASSERT(myBaseImpl);                                                                             
-  this->GetImpl()->ClearEntry(entry);                                                       
-  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";                    
-}                                                                                                 
-  
+  ASSERT(myBaseImpl); 
+  this->GetImpl()->ClearEntry(entry);
+//  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry << " )";
+}
+
 //=============================================================================
 
 BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
@@ -592,6 +646,28 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetSizeMapEntries()
   return result._retn();
 }
 
+//=============================================================================                   
+
+BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetAttractorEntries()
+{
+  ASSERT(myBaseImpl);
+  BLSURFPlugin::string_array_var result = new BLSURFPlugin::string_array();
+
+  const ::BLSURFPlugin_Hypothesis::TSizeMap & attractors= this->GetImpl()->GetAttractorEntries();
+  result->length( attractors.size() );
+
+  ::BLSURFPlugin_Hypothesis::TSizeMap::const_iterator atIt = attractors.begin();
+  for ( int i = 0 ; atIt != attractors.end(); ++atIt, ++i ) {
+    string entry_attractor = atIt->first;
+    if ( !atIt->second.empty() ) {
+      entry_attractor += "|";
+      entry_attractor += atIt->second;
+    }
+    result[i] = CORBA::string_dup(entry_attractor.c_str());
+  }
+  return result._retn();
+}
+
 //=============================================================================                   
                                                                                                   
 void BLSURFPlugin_Hypothesis_i::SetSizeMapEntries(const BLSURFPlugin::string_array& sizeMaps)        
@@ -644,9 +720,60 @@ void BLSURFPlugin_Hypothesis_i::UnsetSizeMap(const GEOM::GEOM_Object_ptr GeomObj
   std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl;
   std::cout << "IDL : UNSETSIZEMAP ( "<< entry << ")" << std::endl;
   UnsetEntry( entry.c_str());
+  SMESH::TPythonDump() << _this() << ".UnsetSizeMap( " << entry.c_str() << " )";
 }
 
 
+void BLSURFPlugin_Hypothesis_i::SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor)
+{
+  ASSERT(myBaseImpl);
+  string entry;
+  entry=GeomObj->GetStudyEntry();
+  std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl;
+  std::cout << "IDL : SETATTRACTOR ( "<< entry << " , " << attractor << ")" <<  std::endl;
+  SetAttractorEntry( entry.c_str(),attractor);
+}
+
+void BLSURFPlugin_Hypothesis_i::UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj)
+{
+  ASSERT(myBaseImpl);
+  string entry;
+  entry=GeomObj->GetStudyEntry();
+  std::cout << "IDL : GetName : " << GeomObj->GetName() << std::endl;
+  std::cout << "IDL : UNSETATTRACTOR ( "<< entry << ")" << std::endl;
+  UnsetEntry( entry.c_str());
+  SMESH::TPythonDump() << _this() << ".UnsetAttractor( " << entry.c_str() << " )";
+}
+
+
+
+
+/*
+void BLSURFPlugin_Hypothesis_i::SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap)
+{}
+
+void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj)
+{}
+
+void BLSURFPlugin_Hypothesis_i::SetCustomSizeMapEntry(const char* entry,const char* sizeMap )  throw (SALOME::SALOME_Exception)
+{}
+
+char* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntry(const char* entry)  throw (SALOME::SALOME_Exception)
+{}
+
+void BLSURFPlugin_Hypothesis_i::UnsetCustomSizeMapEntry(const char* entry)
+{
+  ASSERT(myBaseImpl);
+  this->GetImpl()->UnsetCustomSizeMap(entry);
+  SMESH::TPythonDump() << _this() << ".UnsetCustomSizeMap( " << entry << " )";
+}
+
+
+BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
+{}
+
+*/
+
      
 //=============================================================================
 /*!
index 5c7329df46880670a3e8ba790372b4a225a33846..c0af1f490beeb7c687ce2b4caf20750a9d09a714 100644 (file)
@@ -115,6 +115,30 @@ class BLSURFPlugin_Hypothesis_i:
 
   void ClearSizeMaps();
 
+
+  void SetAttractor(GEOM::GEOM_Object_ptr GeomObj, const char* attractor);
+
+  void UnsetAttractor(GEOM::GEOM_Object_ptr GeomObj);
+
+  void SetAttractorEntry(const char* entry,const char* attractor )  throw (SALOME::SALOME_Exception);
+
+  char* GetAttractorEntry(const char* entry)  throw (SALOME::SALOME_Exception);
+
+  BLSURFPlugin::string_array* GetAttractorEntries();
+
+
+/*
+  void SetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj, const char* sizeMap);
+
+  void UnsetCustomSizeMap(GEOM::GEOM_Object_ptr GeomObj);
+
+  void SetCustomSizeMapEntry(const char* entry,const char* sizeMap )  throw (SALOME::SALOME_Exception);
+
+  char* GetCustomSizeMapEntry(const char* entry)  throw (SALOME::SALOME_Exception);
+
+  BLSURFPlugin::string_array* GetCustomSizeMapEntries();
+*/
+
   // Get implementation
   ::BLSURFPlugin_Hypothesis* GetImpl();