]> SALOME platform Git repositories - plugins/hexoticplugin.git/commitdiff
Salome HOME
Merge from BR_size_maps
authorrnc <rnc@opencascade.com>
Thu, 22 Aug 2013 11:25:45 +0000 (11:25 +0000)
committerrnc <rnc@opencascade.com>
Thu, 22 Aug 2013 11:25:45 +0000 (11:25 +0000)
17 files changed:
adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4 [new file with mode: 0644]
configure.ac
doc/salome/examples/hexoticdemo.py
doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_example.png [new file with mode: 0644]
doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_parameters.png [new file with mode: 0644]
doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png
doc/salome/gui/HexoticPLUGIN/input/hexotic_hypo.doc
doc/salome/gui/HexoticPLUGIN/input/hexoticplugin_python_interface.doc
idl/HexoticPlugin_Algorithm.idl
src/GUI/Makefile.am
src/HexoticPlugin/HexoticPLUGINBuilder.py
src/HexoticPlugin/HexoticPlugin_Hexotic.cxx
src/HexoticPlugin/HexoticPlugin_Hexotic.hxx
src/HexoticPlugin/HexoticPlugin_Hypothesis.cxx
src/HexoticPlugin/HexoticPlugin_Hypothesis.hxx
src/HexoticPlugin/HexoticPlugin_Hypothesis_i.cxx
src/HexoticPlugin/HexoticPlugin_Hypothesis_i.hxx

diff --git a/adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4 b/adm_local/unix/config_files/check_MESHGEMS_CADSURF.m4
new file mode 100644 (file)
index 0000000..c4ce3a5
--- /dev/null
@@ -0,0 +1,129 @@
+dnl Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+dnl
+dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+dnl
+
+dnl  File   : check_MESHGEMS_CADSURF.m4
+dnl  Author : Gilles DAVID, Open CASCADE S.A.S (gilles.david@opencascade.com)
+dnl
+AC_DEFUN([CHECK_MESHGEMS_CADSURF],[
+
+AC_REQUIRE([AC_PROG_CXX])dnl
+AC_REQUIRE([AC_PROG_CXXCPP])dnl
+
+AC_CHECKING([for MeshGems-CADSurf commercial product])
+
+AC_LANG_SAVE
+AC_LANG_CPLUSPLUS
+
+MESHGEMS_CADSURF_INCLUDES=""
+MESHGEMS_CADSURF_LIBS=""
+
+AC_ARG_WITH([meshgems],
+           [  --with-meshgems=DIR       root directory path of MeshGems-CADSurf installation])
+
+CADSURF_ok=no
+
+if test "$with-meshgems" != "no" ; then
+  if test "$with-meshgems" == "yes" || test "$with-meshgems" == "auto"; then
+    MESHGEMS_CADSURF_HOME=""
+  else
+    MESHGEMS_CADSURF_HOME="$with_meshgems"
+  fi
+
+  if test "$MESHGEMS_CADSURF_HOME" == "" ; then
+    if test "x$MESHGEMS_CADSURFHOME" != "x" ; then
+      MESHGEMS_CADSURF_HOME=$MESHGEMS_CADSURFHOME
+    fi
+    if test "x$CADSURFHOME" != "x" ; then
+      MESHGEMS_CADSURF_HOME=$CADSURFHOME
+    fi
+    if test "x$MESHGEMSHOME" != "x" ; then
+      MESHGEMS_CADSURF_HOME=$MESHGEMSHOME
+    fi
+  fi
+
+  if test "x$MESHGEMS_CADSURF_HOME" != "x"; then
+
+    echo
+    echo -------------------------------------------------
+    echo You are about to choose to use somehow the
+    echo MeshGems-CADSurf commercial product to generate 2D mesh.
+    echo
+
+    LOCAL_INCLUDES="-I$MESHGEMS_CADSURF_HOME/include"
+    LOCAL_LIBS="-L$MESHGEMS_CADSURF_HOME/lib/Linux"
+    archtest="$(`which arch`)"
+    if test "x$archtest" = "x" ; then
+      archtest="`uname -m`"
+    fi
+    if test $archtest = "x86_64" ; then
+        LOCAL_LIBS="-L$MESHGEMS_CADSURF_HOME/lib/Linux_64"
+    fi
+    LOCAL_LIBS="${LOCAL_LIBS} -lmeshgems -lmg-cadsurf -lmg-precad"
+
+    CPPFLAGS_old="$CPPFLAGS"
+    CXXFLAGS_old="$CXXFLAGS"
+    CPPFLAGS="$LOCAL_INCLUDES $CPPFLAGS"
+    CXXFLAGS="$LOCAL_INCLUDES $CXXFLAGS"
+
+    AC_MSG_CHECKING([for MeshGems-CADSurf header file])
+
+    AC_CHECK_HEADER([meshgems/meshgems.h],[CADSURF_ok=yes],[CADSURF_ok=no])
+    AC_CHECK_HEADER([meshgems/cadsurf.h],[CADSURF_ok=yes],[CADSURF_ok=no])
+
+    if test "x$CADSURF_ok" == "xyes"; then
+
+      AC_MSG_CHECKING([for MeshGems-CADSurf library])
+
+      LIBS_old="$LIBS"
+      LIBS="-L. $LOCAL_LIBS $LIBS"
+
+      AC_TRY_LINK(
+extern "C" {
+#include "meshgems/meshgems.h"
+},  context_new(),
+       CADSURF_ok=yes,CADSURF_ok=no
+       )
+
+      LIBS="$LIBS_old"
+
+      AC_MSG_RESULT([$CADSURF_ok])
+    fi
+
+    CPPFLAGS="$CPPFLAGS_old"
+    CXXFLAGS="$CXXFLAGS_old"
+
+  fi
+fi
+
+if test "x$CADSURF_ok" == xno ; then
+  AC_MSG_RESULT([for MeshGems-CADSurf: no])
+  AC_MSG_WARN([MeshGems-CADSurf includes or libraries are not found or are not properly installed])
+  AC_MSG_WARN([Cannot build without MeshGems-CADSurf. Use --with_meshgems option to define MeshGems installation.])
+else
+  MESHGEMS_CADSURF_INCLUDES=$LOCAL_INCLUDES
+  MESHGEMS_CADSURF_LIBS=$LOCAL_LIBS
+  AC_MSG_RESULT([for MeshGems-CADSurf: yes])
+fi
+
+AC_SUBST(MESHGEMS_CADSURF_INCLUDES)
+AC_SUBST(MESHGEMS_CADSURF_LIBS)
+
+AC_LANG_RESTORE
+
+])dnl
index b943258c3202de16503d43f50d8720d854e5c4a1..6eb4fc9a94995d0f91a3f04975e3abd33eb76090 100644 (file)
@@ -316,14 +316,6 @@ echo
 
 CHECK_HTML_GENERATORS
 
-echo
-echo ---------------------------------------------
-echo Testing Hexotic
-echo ---------------------------------------------
-echo
-
-CHECK_HEXOTIC
-
 echo
 echo ---------------------------------------------
 echo Testing Kernel
index 188663b35f628670569d05755ea5495426522673..bf02fc8344c784d10ff467d4d50c8356f4013b38 100644 (file)
@@ -24,10 +24,25 @@ BLSURF.SetGeometricMesh( 1 )
 # create a Hexotic algorithm for volumes
 HEXOTIC = hexoticMesh.Hexahedron(algo=smeshBuilder.Hexotic)
 
-# compute the mesh
-hexoticMesh.Compute()
+## compute the mesh
+#hexoticMesh.Compute()
 
 # Change the level of subdivision
 HEXOTIC.SetMinMaxHexes(4, 8)
 
+## compute the mesh
+#hexoticMesh.Compute()
+
+# Local size
+
+# Get the sphere skin
+faces = geompy.SubShapeAll(sphere, geompy.ShapeType["FACE"])
+
+# Set a local size on the face
+HEXOTIC.SetMinMaxSize(10, 20)
+HEXOTIC.SetSizeMap(faces[0], 10)
+
+# compute the mesh
+hexoticMesh.Compute()
+
 # End of script
diff --git a/doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_example.png b/doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_example.png
new file mode 100644 (file)
index 0000000..84bcc51
Binary files /dev/null and b/doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_example.png differ
diff --git a/doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_parameters.png b/doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_parameters.png
new file mode 100644 (file)
index 0000000..7ab11e5
Binary files /dev/null and b/doc/salome/gui/HexoticPLUGIN/images/hexotic_local_size_parameters.png differ
index a91e133d48ed6f6b559c7b23f1be084ead3e11bb..7b95e9767053c7c211f464760b38cb8a76acd041 100644 (file)
Binary files a/doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png and b/doc/salome/gui/HexoticPLUGIN/images/hexotic_parameters.png differ
index 168ddaea05c9b059e2e0f24bf6ffb01825c06da7..3e5df461ecd63ca89d31996653687f82101e386d 100644 (file)
@@ -6,6 +6,8 @@
 algorithm. This algorithm is a commercial software.
 \n To get a licence, visit http://www.distene.com/en/corp/eval-distene.html
 
+\section hexotic_general_parameters General parameters
+
 \image html hexotic_parameters.png
 
 <ul>
@@ -55,4 +57,21 @@ Parameters by default).</li>
 This allows to avoid the reconstruction of the GMF file from the SMESH structure and can improve the global computation time.
 
 <br><b>See Also</b> a sample TUI Script of the \ref tui_hexotic "creation of an Hexotic mesh"
+
+\section hexotic_local_size_parameters Local size
+
+The local size allows you to drive locally the density of the 3D mesh. 
+The area where the mesh has to be refined is given as a geometrical shape.
+
+\image html hexotic_local_size_parameters.png
+<ul>
+<li><b>Selection field (Shape)</b> - Area where the hexaedral mesh has to be refined. You can select any kind of shape (vertex, edge, face, solid, ...). The shape can be a subshape of the main shape or not.</li>
+<li><b>Local size</b> - Expected size of the hexahedral mesh in (Solid) or near the given shape</li>
+<li><b>Add button</b> - Add the local size to the list of local sizes (showed on the left)</li>
+<li><b>Remove button</b> - Remove a local size frome the list, select the local size in the list and press <i>Remove</i> </li>
+</ul>
+
+\note The local size will only influence the density towards a locally denser mesh. If the required density is coarser than the one determined automatically by the global size parameters 
+(min size, max size, min level, max level), it will be ignored and the default density will be used.
 */
index 86f0800464d5946610da95ff16c85397820d7bbd..b71eec5d71871a7717414d47d784dd87c1adce7a 100644 (file)
@@ -24,6 +24,11 @@ Below you can see an example of usage of the HexoticPLUGINBuilder Python API for
 
 \image html hexotic_basic_subdivisions_4_8.png Left: Hexotic mesh without hypothesis, right: Hexotic mesh with an hypothesis defined by minl=4 and maxl=8
 
+\subsection tui_local_size Local size
+
+\image html hexotic_local_size_example.png Example of use of a local size on the skin of a sphere
+
+
 \ref tui_hexotic "Back to top"
 
 \section tui_hexotic_sd_mode Effect of the sub-domain mode
index b11968669b91e64f5072f72032927f2450932e19..cd9851e86275859ee6af8f9bcea0f95ac71a96e4 100644 (file)
 #define _SMESH_HexoticALGORITHM_IDL_
 
 #include "SMESH_Hypothesis.idl"
+#include "GEOM_Gen.idl"
 
 /*!
  * HexoticPlugin: interfaces to Hexotic related hypotheses and algorithms
  */
 module HexoticPlugin
-{    
+{
+  /*!
+   * Type definitions for the size maps
+   */
+  struct HexoticPluginSizeMap {
+  string entry;
+  double size;
+  };
+  
+  typedef sequence<HexoticPluginSizeMap> HexoticPluginSizeMapsList;  
+
   /*!
    * HexoticPlugin_Hexotic: interface of Hexotic algorithm
    */
@@ -79,6 +90,13 @@ module HexoticPlugin
 
     void SetHexoticMaxMemory(in long value);
     long GetHexoticMaxMemory();
+
+    void SetSizeMapEntry(in string entry, 
+                         in double size);
+    void SetSizeMap(in GEOM::GEOM_Object GeomObj, 
+                    in double size);
+    void ClearSizeMaps();
+    HexoticPluginSizeMapsList GetSizeMaps();
   };
 };
 
index aca5544ad2cbe81caf4597ed20bdcaa19eddad5c..377b2834cd913e5b524d175f8188d5b01e10d79a 100644 (file)
@@ -81,8 +81,7 @@ libHexoticPluginGUI_la_LDFLAGS =                         \
 nodist_salomeres_DATA =                \
        HexoticPLUGIN_images.qm \
        HexoticPLUGIN_msg_en.qm \
-       HexoticPLUGIN_msg_fr.qm \
-       HexoticPLUGIN_msg_ja.qm
+       HexoticPLUGIN_msg_fr.qm
 
 SUBDIRS = resources
 
index b23978cbdb22e07c79d776df73a166a03459aa14..f2127b1e26180fdeabb1ec05604024d878db4652 100644 (file)
@@ -86,6 +86,20 @@ class Hexotic_Algorithm(Mesh_Algorithm):
         self.Parameters().SetMinSize(min)
         self.Parameters().SetMaxSize(max)
         return self.Parameters()
+         
+    ## Sets a size map
+    #  @param theObject geometrical object to assign local size to
+    #  @param theSize local size on the given object
+    #  @return hypothesis object
+    def SetSizeMap(self, theObject, theSize):
+        AssureGeomPublished( self.mesh, theObject )
+        self.Parameters().SetSizeMap(theObject, theSize)
+        return self.Parameters()
+      
+    ## Clears all size maps : this is meant to be used only by the dump
+    def ClearSizeMaps(self):
+        self.Parameters().ClearSizeMaps()
+        return self.Parameters()
 
     ## (OBSOLETE) Defines "MinMaxQuad" hypothesis to give three hexotic parameters
     #  @param min minimal level of recursive partitioning on the initial octree cube
index bdaa99c5f4154fc0e94831b87c6d42d02732853b..406870479b8494d0288dad6e27c7d8139c7a14be 100644 (file)
 #include <TopExp_Explorer.hxx>
 #include <TopTools_MapOfShape.hxx>
 #include <TopoDS.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Lin.hxx>
+#include <GCPnts_UniformAbscissa.hxx>
+#include <IntCurvesFace_Intersector.hxx>
+#include <BRepMesh_IncrementalMesh.hxx>
+#include <Poly_Triangulation.hxx>
+#include <gp_Ax3.hxx>
 
 #include <Basics_Utils.hxx>
+#include "GEOMImpl_Types.hxx"
+#include "GEOM_wrap.hxx"
 
 static void removeFile( const TCollection_AsciiString& fileName )
 {
@@ -100,6 +109,16 @@ HexoticPlugin_Hexotic::HexoticPlugin_Hexotic(int hypId, int studyId, SMESH_Gen*
   _blsurfHypo = NULL;
 #endif
   _compute_canceled = false;
+  
+  // Copy of what is done in BLSURFPLugin TODO : share the code
+  smeshGen_i = SMESH_Gen_i::GetSMESHGen();
+  CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
+  SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
+  
+  myStudy = NULL;
+  myStudy = aStudyMgr->GetStudyByID(_studyId);
+  if (myStudy)
+    MESSAGE("myStudy->StudyId() = " << myStudy->StudyId());
 }
 
 //=============================================================================
@@ -821,6 +840,7 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) {
     _hexoticVerbosity = hyp->GetHexoticVerbosity();
     _hexoticMaxMemory = hyp->GetHexoticMaxMemory();
     _hexoticSdMode = hyp->GetHexoticSdMode();
+    _sizeMaps = hyp->GetSizeMaps();
   }
   else {
     cout << std::endl;
@@ -838,6 +858,7 @@ void HexoticPlugin_Hexotic::SetParameters(const HexoticPlugin_Hypothesis* hyp) {
     _hexoticVerbosity = hyp->GetDefaultHexoticVerbosity();
     _hexoticMaxMemory = hyp->GetDefaultHexoticMaxMemory();
     _hexoticSdMode = hyp->GetDefaultHexoticSdMode();
+    _sizeMaps = hyp->GetDefaultHexoticSizeMaps();
   }
 }
 
@@ -901,7 +922,8 @@ static TCollection_AsciiString getSuffix()
 //================================================================================
 
 std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiString& Hexotic_In,
-                                                     const TCollection_AsciiString& Hexotic_Out) const
+                                                     const TCollection_AsciiString& Hexotic_Out,
+                                                     const TCollection_AsciiString& Hexotic_SizeMap_Prefix) const
 {
   cout << std::endl;
   cout << "Hexotic execution..." << std::endl;
@@ -919,16 +941,17 @@ std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiStri
   cout << "    " << _name << " Working directory = \"" << _hexoticWorkingDirectory << "\"" << std::endl;
   cout << "    " << _name << " Sub. Dom mode = " << _hexoticSdMode << std::endl;
 
-  TCollection_AsciiString run_Hexotic( "hexotic" );
+  TCollection_AsciiString run_Hexotic( "mg-hexa.exe" );
 
-  TCollection_AsciiString minl = " -minl ", maxl = " -maxl ", angle = " -ra ";
-  TCollection_AsciiString mins = " -mins ", maxs = " -maxs ";
-  TCollection_AsciiString in   = " -in ",   out  = " -out ";
-  TCollection_AsciiString ignoreRidges = " -nr ", invalideElements = " -inv ";
-  TCollection_AsciiString subdom = " -sd ", sharp = " -sharp ";
-  TCollection_AsciiString proc = " -nproc ";
-  TCollection_AsciiString verb = " -v ";
-  TCollection_AsciiString maxmem = " -m ";
+  TCollection_AsciiString minl = " --min_level ", maxl = " --max_level ", angle = " --ridge_angle ";
+  TCollection_AsciiString mins = " --min_size ", maxs = " --max_size ";
+  TCollection_AsciiString in   = " --in ",   out  = " --out ";
+  TCollection_AsciiString sizeMap = " --read_sizemap ";
+  TCollection_AsciiString ignoreRidges = " --compute_ridges no ", invalideElements = " --allow_invalid_elements yes ";
+  TCollection_AsciiString subdom = " --components ";
+  TCollection_AsciiString proc = " --max_number_of_threads ";
+  TCollection_AsciiString verb = " --verbose ";
+  TCollection_AsciiString maxmem = " --max_memory ";
 
   TCollection_AsciiString minLevel, maxLevel, minSize, maxSize, sharpAngle, mode, nbproc, verbosity, maxMemory;
   minLevel = _hexesMinLevel;
@@ -936,7 +959,22 @@ std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiStri
   minSize = _hexesMinSize;
   maxSize = _hexesMaxSize;
   sharpAngle = _hexoticSharpAngleThreshold;
-  mode = _hexoticSdMode;
+  // Mode translation for mg-tetra 1.1
+  switch ( _hexoticSdMode )
+  {
+    case 1:
+      mode = "outside_skin_only";
+      break;
+    case 2:
+      mode = "outside_components";
+      break;
+    case 3:
+      mode = "all";
+      break;
+    case 4:
+      mode = "all --manifold_geometry no";
+      break;
+  }
   nbproc = _hexoticNbProc;
   verbosity = _hexoticVerbosity;
   maxMemory = _hexoticMaxMemory;
@@ -961,6 +999,9 @@ std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiStri
 
   if (_hexoticSharpAngleThreshold > 0)
     run_Hexotic +=  angle + sharpAngle;
+  
+  if (_sizeMaps.begin() != _sizeMaps.end())
+    run_Hexotic += sizeMap + Hexotic_SizeMap_Prefix;
 
   run_Hexotic += in + Hexotic_In + out + Hexotic_Out;
   run_Hexotic += subdom + mode;
@@ -971,6 +1012,386 @@ std::string HexoticPlugin_Hexotic::getHexoticCommand(const TCollection_AsciiStri
   return run_Hexotic.ToCString();
 }
 
+// TODO : this is a duplication of some code found in BLSURFPlugin_BLSURF find a proper
+// way to share it
+TopoDS_Shape HexoticPlugin_Hexotic::entryToShape(std::string entry)
+{
+  MESSAGE("HexoticPlugin_Hexotic::entryToShape "<<entry );
+  GEOM::GEOM_Object_var aGeomObj;
+  TopoDS_Shape S = TopoDS_Shape();
+  SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( entry.c_str() );
+  if (!aSObj->_is_nil()) {
+    CORBA::Object_var obj = aSObj->GetObject();
+    aGeomObj = GEOM::GEOM_Object::_narrow(obj);
+    aSObj->UnRegister();
+  }
+  if ( !aGeomObj->_is_nil() )
+    S = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
+  return S;
+}
+
+//================================================================================
+/*!
+ * \brief Produces a .mesh file with the size maps informations to give to Hexotic
+ */
+//================================================================================
+std::vector<std::string> HexoticPlugin_Hexotic::writeSizeMapFile( std::string sizeMapPrefix )
+{
+  HexoticPlugin_Hypothesis::THexoticSizeMaps::iterator it ;
+  
+  // The GMF driver will be used to write the size map file
+  DriverGMF_Write aWriter;
+  aWriter.SetSizeMapPrefix( sizeMapPrefix ); 
+  
+  std::vector<Control_Pnt> points;
+  // Iterate on the size maps
+  for (it=_sizeMaps.begin(); it!=_sizeMaps.end(); it++)
+  {
+    // Step 1 : Get the GEOM object entry and the size 
+    // from the _sizeMaps infos
+    std::string anEntry = it->first;
+    double aLocalSize = it->second;
+    TopoDS_Shape aShape = entryToShape( anEntry );
+    
+    // Step 2 : Create the points
+    createControlPoints( aShape, aLocalSize, points );
+  }
+  // Write the .mesh size map file
+  aWriter.PerformSizeMap(points); 
+  return aWriter.GetSizeMapFiles();
+}
+
+//================================================================================
+/*!
+ * \brief Fills a vector of points from which a size map input file can be written
+ */
+//================================================================================
+void HexoticPlugin_Hexotic::createControlPoints( const TopoDS_Shape& aShape, 
+                                                 const double& theSize, 
+                                                 std::vector<Control_Pnt>& thePoints )
+{ 
+  if ( aShape.ShapeType() == TopAbs_VERTEX )
+  {
+    gp_Pnt aPnt = BRep_Tool::Pnt( TopoDS::Vertex(aShape) );
+    Control_Pnt aControl_Pnt( aPnt, theSize );
+    thePoints.push_back( aControl_Pnt );
+  }
+  if ( aShape.ShapeType() == TopAbs_EDGE )
+  {
+    createPointsSampleFromEdge( aShape, theSize, thePoints );  
+  }
+  else if ( aShape.ShapeType() == TopAbs_WIRE )
+  {
+    TopExp_Explorer Ex;
+    for (Ex.Init(aShape,TopAbs_EDGE); Ex.More(); Ex.Next()) 
+    {
+      createPointsSampleFromEdge( Ex.Current(), theSize, thePoints );
+    } 
+  }
+  else if ( aShape.ShapeType() ==  TopAbs_FACE )
+  {
+    createPointsSampleFromFace( aShape, theSize, thePoints ); 
+  }
+  else if ( aShape.ShapeType() ==  TopAbs_SOLID )
+  {
+    createPointsSampleFromSolid( aShape, theSize, thePoints ); 
+  }
+  else if ( aShape.ShapeType() == TopAbs_COMPOUND )
+  {
+    TopoDS_Iterator it( aShape );
+    for(; it.More(); it.Next())
+    {
+      createControlPoints( it.Value(), theSize, thePoints );
+    }
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Fills a vector of points with point samples approximately 
+ * \brief spaced with a given size
+ */
+//================================================================================
+void HexoticPlugin_Hexotic::createPointsSampleFromEdge( const TopoDS_Shape& aShape, 
+                                                        const double& theSize, 
+                                                        std::vector<Control_Pnt>& thePoints )
+{
+  double step = theSize;
+  double first, last;  
+  Handle( Geom_Curve ) aCurve = BRep_Tool::Curve( TopoDS::Edge( aShape ), first, last );
+  GeomAdaptor_Curve C ( aCurve );
+  GCPnts_UniformAbscissa DiscretisationAlgo(C, step , first, last, Precision::Confusion());
+  int nbPoints = DiscretisationAlgo.NbPoints();
+  
+  for ( int i = 1; i <= nbPoints; i++ )
+  {
+    double param = DiscretisationAlgo.Parameter( i );
+    Control_Pnt aPnt;
+    aCurve->D0( param, aPnt );
+    aPnt.SetSize(theSize);
+    thePoints.push_back( aPnt );
+  }  
+}
+
+//================================================================================
+/*!
+ * \brief Fills a vector of points with point samples approximately 
+ * \brief spaced with a given size
+ */
+//================================================================================
+void HexoticPlugin_Hexotic::createPointsSampleFromFace( const TopoDS_Shape& aShape, 
+                                                        const double& theSize, 
+                                                        std::vector<Control_Pnt>& thePoints )
+{
+  BRepMesh_IncrementalMesh M(aShape, 0.01, Standard_True);
+  TopLoc_Location aLocation;
+  TopoDS_Face aFace = TopoDS::Face(aShape);
+  Handle(Geom_Surface) aSurf = BRep_Tool::Surface (aFace, aLocation);
+  Handle(Poly_Triangulation) aTri = BRep_Tool::Triangulation (aFace, aLocation);
+  
+  // Get triangles
+  int nbTriangles = aTri->NbTriangles();
+  Poly_Array1OfTriangle triangles(1,nbTriangles);
+  triangles=aTri->Triangles();
+  
+  // GetNodes
+  int nbNodes = aTri->NbNodes();
+  TColgp_Array1OfPnt nodes(1,nbNodes);
+  nodes = aTri->Nodes();
+
+  // Iterate on triangles and subdivide them
+  for(int i=1; i<=nbTriangles; i++)
+  {
+     Poly_Triangle aTriangle = triangles.Value(i);
+     gp_Pnt p1 = nodes.Value(aTriangle.Value(1));
+     gp_Pnt p2 = nodes.Value(aTriangle.Value(2));
+     gp_Pnt p3 = nodes.Value(aTriangle.Value(3));
+     
+     subdivideTriangle(p1, p2, p3, theSize, thePoints);  
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Fills a vector of points with point samples approximately 
+ * \brief spaced with a given size
+ */
+//================================================================================
+void HexoticPlugin_Hexotic::createPointsSampleFromSolid( const TopoDS_Shape& aShape, 
+                                                         const double& theSize, 
+                                                         std::vector<Control_Pnt>& thePoints )
+{
+  // Compute the bounding box
+  double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
+  Bnd_Box B;               
+  BRepBndLib::Add(aShape, B);
+  B.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
+  
+  // Create the points
+  double step = theSize;
+  
+  for ( double x=Xmin; x-Xmax<Precision::Confusion(); x=x+step )
+  {
+    for ( double y=Ymin; y-Ymax<Precision::Confusion(); y=y+step )
+    {
+      // Step1 : generate the Zmin -> Zmax line
+      gp_Pnt startPnt(x, y, Zmin);
+      gp_Pnt endPnt(x, y, Zmax);
+      gp_Vec aVec(startPnt, endPnt);
+      gp_Lin aLine(startPnt, aVec);
+      double endParam = Zmax - Zmin;
+      
+      // Step2 : for each face of aShape:
+      std::set<double> intersections;
+      std::set<double>::iterator it = intersections.begin();
+      
+      TopExp_Explorer Ex;
+      for (Ex.Init(aShape,TopAbs_FACE); Ex.More(); Ex.Next()) 
+      { 
+        // check if there is an intersection
+        IntCurvesFace_Intersector anIntersector(TopoDS::Face(Ex.Current()), Precision::Confusion());
+        anIntersector.Perform(aLine, 0, endParam);
+        
+        // get the intersection's parameter and store it
+        int nbPoints = anIntersector.NbPnt();
+        for(int i = 0 ; i < nbPoints ; i++ )
+        {
+          it = intersections.insert( it, anIntersector.WParameter(i+1) );
+        }
+      }
+      // Step3 : go through the line chunk by chunk 
+      if ( intersections.begin() != intersections.end() )
+      {
+        std::set<double>::iterator intersectionsIterator=intersections.begin();
+        double first = *intersectionsIterator;
+        intersectionsIterator++;
+        bool innerPoints = true; 
+        for ( ; intersectionsIterator!=intersections.end() ; intersectionsIterator++ )
+        {
+          double second = *intersectionsIterator;
+          if ( innerPoints )
+          {
+            // If the last chunk was outside of the shape or this is the first chunk
+            // add the points in the range [first, second] to the points vector
+            double localStep = (second -first) / ceil( (second - first) / step );
+            for ( double z = Zmin + first; z < Zmin + second; z = z + localStep )
+            {
+              thePoints.push_back(Control_Pnt( x, y, z, theSize ));
+            }
+            thePoints.push_back(Control_Pnt( x, y, Zmin + second, theSize ));
+          }
+          first = second;
+          innerPoints = !innerPoints;
+        }
+      }
+    }
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Subdivides a triangle until it reaches a certain size (recursive function)
+ */
+//================================================================================
+void HexoticPlugin_Hexotic::subdivideTriangle( const gp_Pnt& p1, 
+                                               const gp_Pnt& p2, 
+                                               const gp_Pnt& p3, 
+                                               const double& theSize, 
+                                               std::vector<Control_Pnt>& thePoints)
+{
+  // Size threshold to stop subdividing
+  // This value ensures that two control points are distant no more than 2*theSize
+  // as shown below
+  //
+  // The greater distance D of the mass center M to each Edge is 1/3 * Median 
+  // and Median < sqrt(3/4) * a  where a is the greater side (by using Apollonius' thorem). 
+  // So D < 1/3 * sqrt(3/4) * a and if a < sqrt(3) * S then D < S/2
+  // and the distance between two mass centers of two neighbouring triangles 
+  // sharing an edge is < 2 * 1/2 * S = S
+  // If the traingles share a Vertex and no Edge the distance of the mass centers 
+  // to the Vertices is 2*D < S so the mass centers are distant of less than 2*S 
+  
+  double threshold = sqrt( 3 ) * theSize;
+  
+  if ( (p1.Distance(p2) > threshold ||
+        p2.Distance(p3) > threshold ||
+        p3.Distance(p1) > threshold))
+  { 
+    std::vector<gp_Pnt> midPoints = computePointsForSplitting(p1, p2, p3);
+    subdivideTriangle( midPoints[0], midPoints[1], midPoints[2], theSize, thePoints );
+    subdivideTriangle( midPoints[0], p2, midPoints[1], theSize, thePoints );
+    subdivideTriangle( midPoints[2], midPoints[1], p3, theSize, thePoints );
+    subdivideTriangle( p1, midPoints[0], midPoints[2], theSize, thePoints );
+  }
+  else
+  {
+    double x = (p1.X() + p2.X() + p3.X()) / 3 ;
+    double y = (p1.Y() + p2.Y() + p3.Y()) / 3 ;
+    double z = (p1.Z() + p2.Z() + p3.Z()) / 3 ;
+    
+    Control_Pnt massCenter( x ,y ,z, theSize );
+    thePoints.push_back( massCenter );
+  }
+}
+
+//================================================================================
+/*!
+ * \brief Returns the appropriate points for splitting a triangle
+ * \brief the tangency points of the incircle are used in order to have mostly
+ * \brief well-shaped sub-triangles
+ */
+//================================================================================
+std::vector<gp_Pnt> HexoticPlugin_Hexotic::computePointsForSplitting( const gp_Pnt& p1, 
+                                                                      const gp_Pnt& p2, 
+                                                                      const gp_Pnt& p3 )
+{
+  std::vector<gp_Pnt> midPoints;
+  //Change coordinates
+  gp_Trsf Trsf_1;            // Identity transformation
+  gp_Ax3 reference_system(gp::Origin(), gp::DZ(), gp::DX());   // OXY
+  gp_Vec Vx(p1, p3);
+  gp_Vec Vaux(p1, p2);
+  gp_Dir Dx(Vx);
+  gp_Dir Daux(Vaux);
+  gp_Dir Dz = Dx.Crossed(Daux);
+  gp_Ax3 current_system(p1, Dz, Dx);
+  
+  Trsf_1.SetTransformation( reference_system, current_system );
+  
+  gp_Pnt A = p1.Transformed(Trsf_1);
+  gp_Pnt B = p2.Transformed(Trsf_1);
+  gp_Pnt C = p3.Transformed(Trsf_1);
+  
+  double a =  B.Distance(C) ;
+  double b =  A.Distance(C) ;
+  double c =  B.Distance(A) ;
+  
+  // Incenter coordinates
+  // see http://mathworld.wolfram.com/Incenter.html
+  double Xi = ( b*B.X() + c*C.X() ) / ( a + b + c );
+  double Yi = ( b*B.Y() ) / ( a + b + c );
+  gp_Pnt Center(Xi, Yi, 0);
+  
+  // Calculate the tangency points of the incircle
+  gp_Pnt T1 = tangencyPoint( A, B, Center);
+  gp_Pnt T2 = tangencyPoint( B, C, Center);
+  gp_Pnt T3 = tangencyPoint( C, A, Center);
+  
+  gp_Pnt p1_2 = T1.Transformed(Trsf_1.Inverted());
+  gp_Pnt p2_3 = T2.Transformed(Trsf_1.Inverted());
+  gp_Pnt p3_1 = T3.Transformed(Trsf_1.Inverted());
+
+  midPoints.push_back(p1_2);
+  midPoints.push_back(p2_3);
+  midPoints.push_back(p3_1);
+  
+  return midPoints;
+}
+
+//================================================================================
+/*!
+ * \brief Computes the tangency points of the circle of center Center with
+ * \brief the straight line (p1 p2)
+ */
+//================================================================================
+gp_Pnt HexoticPlugin_Hexotic::tangencyPoint(const gp_Pnt& p1,
+                                            const gp_Pnt& p2,
+                                            const gp_Pnt& Center)
+{
+  double Xt = 0;
+  double Yt = 0;
+  
+  // The tangency point is the intersection of the straight line (p1 p2)
+  // and the straight line (Center T) which is orthogonal to (p1 p2)
+  if ( fabs(p1.X() - p2.X()) <= Precision::Confusion() )
+  {
+    Xt=p1.X();     // T is on (p1 p2)
+    Yt=Center.Y(); // (Center T) is orthogonal to (p1 p2)
+  }
+  else if ( fabs(p1.Y() - p2.Y()) <= Precision::Confusion() )
+  {
+    Yt=p1.Y();     // T is on (p1 p2) 
+    Xt=Center.X(); // (Center T) is orthogonal to (p1 p2)
+  }
+  else
+  {
+    // First straight line coefficients (equation y=a*x+b)
+    double a = (p2.Y() - p1.Y()) / (p2.X() - p1.X())  ;
+    double b = p1.Y() - a*p1.X();         // p1 is on this straight line
+    
+    // Second straight line coefficients (equation y=c*x+d)
+    double c = -1 / a;                    // The 2 lines are orthogonal
+    double d = Center.Y() - c*Center.X(); // Center is on this straight line
+    
+    Xt = (d - b) / (a - c);
+    Yt = a*Xt + b;
+  }
+  
+  return gp_Pnt( Xt, Yt, 0 );
+}
+
 //=============================================================================
 /*!
  * Here we are going to use the Hexotic mesher
@@ -1047,7 +1468,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh&          aMesh,
 #else
     if ( aTmpDir.Value(aTmpDir.Length()) != '/' ) aTmpDir += '/';
 #endif
-    TCollection_AsciiString Hexotic_In(""), Hexotic_Out;
+    TCollection_AsciiString Hexotic_In(""), Hexotic_Out, Hexotic_SizeMap_Prefix;
     TCollection_AsciiString modeFile_In( "chmod 666 " ), modeFile_Out( "chmod 666 " );
     TCollection_AsciiString aLogFileName = aTmpDir + "Hexotic"+getSuffix()+".log";    // log
 
@@ -1076,9 +1497,11 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh&          aMesh,
     }
 #endif
     
-
-    std::string run_Hexotic = getHexoticCommand(Hexotic_In, Hexotic_Out);
-    run_Hexotic += std::string(" 1 > ") + aLogFileName.ToCString();  // dump into file
+    Hexotic_SizeMap_Prefix = aTmpDir + "Hexotic_SizeMap" + getSuffix();
+    std::vector<std::string> sizeMapFiles = writeSizeMapFile( Hexotic_SizeMap_Prefix.ToCString() );
+    
+    std::string run_Hexotic = getHexoticCommand(Hexotic_In, Hexotic_Out, Hexotic_SizeMap_Prefix);
+    run_Hexotic += std::string(" 1> ") + aLogFileName.ToCString();  // dump into file
 
     cout << std::endl;
     cout << "Hexotic command : " << run_Hexotic << std::endl;
@@ -1121,13 +1544,17 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh&          aMesh,
       if (myError)
 */
         hexahedraMessage = "success";
-       removeFile(Hexotic_Out);
-       removeFile(Hexotic_In);
-       removeFile(aLogFileName);
+        removeFile(Hexotic_Out);
+        removeFile(Hexotic_In);
+        removeFile(aLogFileName);
+        for( int i=0; i<sizeMapFiles.size(); i++)
+        {
+          removeFile( TCollection_AsciiString( sizeMapFiles[i].c_str() ) );
+        }
       }
       else {
-        hexahedraMessage = "failed";
-    }
+        hexahedraMessage = "failed"; 
+      }
     }
     else {
       hexahedraMessage = "failed";
@@ -1198,7 +1625,7 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel
   SetParameters(_hypothesis);
 
   TCollection_AsciiString aTmpDir = getTmpDir();
-  TCollection_AsciiString Hexotic_In, Hexotic_Out;
+  TCollection_AsciiString Hexotic_In, Hexotic_Out, Hexotic_SizeMap_Prefix;
   TCollection_AsciiString modeFile_In( "chmod 666 " ), modeFile_Out( "chmod 666 " );
   TCollection_AsciiString aLogFileName = aTmpDir + "Hexotic"+getSuffix()+".log";    // log
 
@@ -1207,9 +1634,13 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel
 
   Hexotic_In  = aTmpDir + "Hexotic"+getSuffix()+"_In.mesh";
   Hexotic_Out = aTmpDir + "Hexotic"+getSuffix()+"_Out.mesh";
+  Hexotic_SizeMap_Prefix = aTmpDir + "Hexotic_SizeMap";
+  
+  std::vector<std::string> sizeMapFiles = writeSizeMapFile( Hexotic_SizeMap_Prefix.ToCString() );
 
-  std::string run_Hexotic = getHexoticCommand(Hexotic_In, Hexotic_Out);
-  run_Hexotic += std::string(" 1 > ") + aLogFileName.ToCString();  // dump into file
+  std::string run_Hexotic = getHexoticCommand(Hexotic_In, Hexotic_Out, Hexotic_SizeMap_Prefix);
+  run_Hexotic += std::string(" 1> ") + aLogFileName.ToCString();  // dump into file
 
   removeHexoticFiles(Hexotic_In, Hexotic_Out);
 
@@ -1296,6 +1727,10 @@ bool HexoticPlugin_Hexotic::Compute(SMESH_Mesh & aMesh, SMESH_MesherHelper* aHel
   removeFile(Hexotic_Out);
   removeFile(Hexotic_In);
   removeFile(aLogFileName);
+  for( int i=0; i<sizeMapFiles.size(); i++)
+  {
+    removeFile( TCollection_AsciiString(sizeMapFiles[i].c_str()) );
+  }
   return Ok;
 /*
   return myError->IsOK();
index fdbb1c9d7ccc70acd5686761d1c98f12fabd0f31..03baf34027a85259efb60bd632989cc1e30fb3bd 100644 (file)
@@ -26,6 +26,7 @@
 #define _HexoticPlugin_Hexotic_HXX_
 
 #include "HexoticPlugin_Defs.hxx"
+#include "HexoticPlugin_Hypothesis.hxx"
 
 #include "SMESH_Algo.hxx"
 #include "SMESH_Mesh.hxx"
 
 #include <string>
 
+#include "DriverGMF_Read.hxx"
+#include "DriverGMF_Write.hxx"
+
+#include CORBA_CLIENT_HEADER(GEOM_Gen)
+#include <SMESH_Gen_i.hxx>
+
 class SMESH_Mesh;
 class HexoticPlugin_Hypothesis;
 class TCollection_AsciiString;
+class gp_Pnt;
 
 class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hexotic: public SMESH_3D_Algo
 {
@@ -76,7 +84,42 @@ protected:
 private:
 
   std::string getHexoticCommand(const TCollection_AsciiString& Hexotic_In,
-                                const TCollection_AsciiString& Hexotic_Out) const;
+                                const TCollection_AsciiString& Hexotic_Out,
+                                const TCollection_AsciiString& Hexotic_Sol) const;
+  
+  GEOM::GEOM_Object_var entryToGeomObj(std::string entry);
+  TopoDS_Shape     entryToShape(std::string entry);
+
+  std::vector<std::string> writeSizeMapFile(std::string fileName);
+  
+  // Functions to get sample point from shapes
+  void createControlPoints( const TopoDS_Shape& theShape, 
+                            const double& theSize, 
+                            std::vector< Control_Pnt >& thePoints );
+  void createPointsSampleFromEdge( const TopoDS_Shape& aShape, 
+                                   const double& theSize, 
+                                   std::vector<Control_Pnt>& thePoints );
+  void createPointsSampleFromFace( const TopoDS_Shape& aShape, 
+                                   const double& theSize, 
+                                   std::vector<Control_Pnt>& thePoints );
+  void createPointsSampleFromSolid( const TopoDS_Shape& aShape, 
+                                    const double& theSize, 
+                                    std::vector<Control_Pnt>& thePoints );
+  
+  // Some functions for surface sampling
+  void subdivideTriangle( const gp_Pnt& p1, 
+                          const gp_Pnt& p2, 
+                          const gp_Pnt& p3, 
+                          const double& theSize, 
+                          std::vector<Control_Pnt>& thePoints );
+  
+  std::vector<gp_Pnt> computePointsForSplitting( const gp_Pnt& p1, 
+                                                 const gp_Pnt& p2, 
+                                                 const gp_Pnt& p3 );
+  gp_Pnt tangencyPoint(const gp_Pnt& p1, 
+                       const gp_Pnt& p2, 
+                       const gp_Pnt& Center);
+  
 
   int  _iShape;
   int  _nbShape;
@@ -93,6 +136,7 @@ private:
   int _hexoticVerbosity;
   int _hexoticMaxMemory;
   int _hexoticSdMode;
+  HexoticPlugin_Hypothesis::THexoticSizeMaps _sizeMaps;
   SMDS_MeshNode** _tabNode;
   
 #ifdef WITH_BLSURFPLUGIN
@@ -102,6 +146,10 @@ private:
 #ifdef WITH_SMESH_CANCEL_COMPUTE
   volatile bool _compute_canceled;
 #endif
+  
+  SALOMEDS::Study_var myStudy;
+  SMESH_Gen_i*        smeshGen_i;
+
 };
 
 #endif
index 13c5dcd0199999fdf636db977572593377ccafd2..df82d2c32fac9a1b7f9de054bf89c3340d5ac568 100644 (file)
@@ -46,7 +46,8 @@ HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis (int hypId, int studyId,
     _hexoticWorkingDirectory( GetDefaultHexoticWorkingDirectory() ),
     _hexoticSdMode(GetDefaultHexoticSdMode()),
     _hexoticVerbosity(GetDefaultHexoticVerbosity()),
-    _hexoticMaxMemory(GetDefaultHexoticMaxMemory())
+    _hexoticMaxMemory(GetDefaultHexoticMaxMemory()),
+    _sizeMaps(GetDefaultHexoticSizeMaps())
 {
   MESSAGE("HexoticPlugin_Hypothesis::HexoticPlugin_Hypothesis");
   _name = "Hexotic_Parameters";
@@ -125,7 +126,7 @@ void HexoticPlugin_Hypothesis::SetHexoticWorkingDirectory(const std::string& pat
 
 void HexoticPlugin_Hypothesis::SetHexoticSdMode(int theVal) {
   if (theVal != _hexoticSdMode) {
-         _hexoticSdMode = theVal;
+    _hexoticSdMode = theVal;
     NotifySubMeshesHypothesisModification();
   }
 }
@@ -144,6 +145,35 @@ void HexoticPlugin_Hypothesis::SetHexoticMaxMemory(int theVal) {
   }
 }
 
+bool HexoticPlugin_Hypothesis::AddSizeMap(std::string theEntry, double theSize) {
+  THexoticSizeMaps::iterator it;
+  it=_sizeMaps.find(theEntry);
+  if( it == _sizeMaps.end() ) // If no size map is defined on the given object
+  {
+    _sizeMaps[theEntry] = theSize;
+    MESSAGE("NEW size map, entry :"<<theEntry<<", size : "<<theSize);
+    NotifySubMeshesHypothesisModification();
+    return true;
+  }
+  else if( it->second != theSize ) // If a size map exists with a different size value
+  {
+    it->second = theSize;
+    MESSAGE("MODIFIED size map, entry :"<<theEntry<<"with size : "<<theSize);
+    NotifySubMeshesHypothesisModification();
+    return true;
+  }
+  else
+  {
+    MESSAGE("NO size map added")
+    return false; // No size map added
+  }
+}
+
+void HexoticPlugin_Hypothesis::ClearSizeMaps()
+{
+  _sizeMaps.clear();
+}
+
 //=============================================================================
 /*!
  *  
@@ -347,4 +377,9 @@ int HexoticPlugin_Hypothesis::GetDefaultHexoticMaxMemory()
   return 2048;
 }
 
+HexoticPlugin_Hypothesis::THexoticSizeMaps HexoticPlugin_Hypothesis::GetDefaultHexoticSizeMaps()
+{
+  return THexoticSizeMaps();
+}
+
 
index 35e6d208b825e41328ea25076cf7db1480774433..6dd9941540ee861c97216b4c8bff72a73013bc48 100644 (file)
 #include "SMESH_Hypothesis.hxx"
 #include "Utils_SALOME_Exception.hxx"
 
+#include <map>
+
+// class HexoticSizeMap
+// {
+// public:
+//   SizeMap(const TopoDS_Shape& theShape, double theSize)
+//   {
+//     shape=theShape;
+//     size=theSize;
+//   };
+//   TopoDS_Shape shape;
+//   double size;
+// }
 //  Parameters for work of Hexotic
 //
 
@@ -74,9 +87,18 @@ public:
 
   void SetHexoticMaxMemory(int theVal);
   int GetHexoticMaxMemory() const { return _hexoticMaxMemory; }
+  
+  // Size Maps
+  typedef std::map<std::string,double> THexoticSizeMaps;
+  
+  // For the GUI HexoticPluginGUI_HypothesisCreator::storeParamToHypo
+  THexoticSizeMaps GetSizeMaps() const { return _sizeMaps; }; 
+  void ClearSizeMaps();
+  
+  // Add one size map to the collection of size maps (user interface)
+  bool AddSizeMap(std::string theEntry, double theSize);
 
   // the parameters default values 
-
   static int GetDefaultHexesMinLevel();
   static int GetDefaultHexesMaxLevel();
   static double GetDefaultMinSize();
@@ -89,6 +111,7 @@ public:
   static int GetDefaultHexoticSdMode();
   static int GetDefaultHexoticVerbosity();
   static int GetDefaultHexoticMaxMemory();
+  static THexoticSizeMaps GetDefaultHexoticSizeMaps();
 
   // Persistence
   virtual std::ostream& SaveTo(std::ostream& save);
@@ -122,6 +145,7 @@ private:
   int    _hexoticSdMode;
   int    _hexoticVerbosity;
   int    _hexoticMaxMemory;
+  THexoticSizeMaps _sizeMaps;
   std::string _hexoticWorkingDirectory ;
 };
 
index 1de1fec18aad962e63310597e0c409f8f648face..b2b500997882510d39311f4b911b8bf87fffda98 100644 (file)
@@ -215,6 +215,49 @@ void HexoticPlugin_Hypothesis_i::SetHexoticMaxMemory (CORBA::Long theValue)
     SMESH::TPythonDump() << _this() << ".SetHexoticMaxMemory( " << theValue << " )";
 }
 
+HexoticPlugin::HexoticPluginSizeMapsList* HexoticPlugin_Hypothesis_i::GetSizeMaps ()
+{
+  // Get the std::map < string entry, double size >
+  HexoticPlugin::HexoticPluginSizeMapsList_var result = new HexoticPlugin::HexoticPluginSizeMapsList();
+  const ::HexoticPlugin_Hypothesis::THexoticSizeMaps sizeMaps = this->GetImpl()->GetSizeMaps();
+  result->length( sizeMaps.size() );
+  
+  // Write the content into a CORBA sequence of struct{ entry=anEntry; size=aSize; }
+  ::HexoticPlugin_Hypothesis::THexoticSizeMaps::const_iterator it = sizeMaps.begin(); 
+  for ( int i = 0; it != sizeMaps.end(); i++, it++ )
+  {
+    HexoticPlugin::HexoticPluginSizeMap_var aSizeMap = new HexoticPlugin::HexoticPluginSizeMap();
+    aSizeMap->entry = CORBA::string_dup( it->first.c_str() );
+    aSizeMap->size = it->second;
+    result[i] = aSizeMap;
+  }
+  return result._retn();
+}
+
+void HexoticPlugin_Hypothesis_i::SetSizeMapEntry ( const char* theEntry, CORBA::Double theSize )
+{
+  MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMapEntry");
+  std::string anEntry = theEntry;
+  bool valueChanged = this->GetImpl()->AddSizeMap(theEntry, theSize);
+  MESSAGE("valueChanged = "<<valueChanged);
+  if (valueChanged)
+    SMESH::TPythonDump() << _this() << ".SetSizeMap( "<< theEntry << ", " << theSize << " )";
+}
+
+void HexoticPlugin_Hypothesis_i::SetSizeMap (const GEOM::GEOM_Object_ptr theGeomObj, const double theSize)
+{
+  MESSAGE("HexoticPlugin_Hypothesis_i::SetSizeMap");
+  ASSERT(myBaseImpl);
+  std::string entry = theGeomObj->GetStudyEntry();
+  SetSizeMapEntry( entry.c_str(), theSize);
+}
+
+void HexoticPlugin_Hypothesis_i::ClearSizeMaps ()
+{
+  this->GetImpl()->ClearSizeMaps();
+  SMESH::TPythonDump() << _this() << ".ClearSizeMaps()";
+}
+
 //=============================================================================
 /*!
  *  HexoticPlugin_Hypothesis_i::GetHexesMinLevel
index 7c0e5a721c3ec299bf828c673f523fe303206187..d04d7cc51b0e51f5c00a33fe65ed651a750aced8 100644 (file)
@@ -83,6 +83,11 @@ class HEXOTICPLUGIN_EXPORT HexoticPlugin_Hypothesis_i:
 
   void SetHexoticMaxMemory(CORBA::Long theVal);
   CORBA::Long GetHexoticMaxMemory();
+  
+  void SetSizeMapEntry(const char* theEntry, CORBA::Double theSize);
+  void SetSizeMap(GEOM::GEOM_Object_ptr theGeomObj, double theSize);
+  HexoticPlugin::HexoticPluginSizeMapsList* GetSizeMaps ();
+  void ClearSizeMaps();
 
   // Get implementation
   ::HexoticPlugin_Hypothesis* GetImpl();