]> SALOME platform Git repositories - plugins/ghs3dplugin.git/commitdiff
Salome HOME
merge from branch V5_1_sizemap tag mergeto_V5_1_main_8oct09
authornge <nge>
Thu, 8 Oct 2009 14:24:49 +0000 (14:24 +0000)
committernge <nge>
Thu, 8 Oct 2009 14:24:49 +0000 (14:24 +0000)
idl/GHS3DPlugin_Algorithm.idl
src/GHS3DPlugin_GHS3D.cxx
src/GHS3DPlugin_GHS3D.hxx
src/GHS3DPlugin_Hypothesis.cxx
src/GHS3DPlugin_Hypothesis.hxx
src/GHS3DPlugin_Hypothesis_i.cxx
src/GHS3DPlugin_Hypothesis_i.hxx
src/GUI/GHS3DPluginGUI_HypothesisCreator.cxx
src/GUI/GHS3DPluginGUI_HypothesisCreator.h
src/GUI/GHS3DPlugin_msg_en.ts
src/GUI/Makefile.am

index a402d78e5f863657e5f2dfb94725fcdc608daf2c..4a8a4abd6d4ea3d233a6ea3ea6568b76545ee379 100644 (file)
  */
 module GHS3DPlugin
 {
+  struct GHS3DEnforcedVertex {
+    double x;
+    double y;
+    double z;
+    double size;
+  };
+  
+  typedef sequence<GHS3DEnforcedVertex> GHS3DEnforcedVertexList;
   /*!
    * GHS3DPlugin_GHS3D: interface of "Tetrahedron (GHS3D)" algorithm
    */
@@ -99,11 +107,32 @@ module GHS3DPlugin
      */
     void SetToUseBoundaryRecoveryVersion(in boolean toUse);
     boolean GetToUseBoundaryRecoveryVersion();
+    /*!
+     * Applies finite-element correction by replacing overconstrained elements where
+     * it is possible. The process is cutting first the overconstrained edges and
+     * second the overconstrained facets. This insure that no edges have two boundary
+     * vertices and that no facets have three boundary vertices.
+     */
+    void SetFEMCorrection(in boolean toUseFem);
+    boolean GetFEMCorrection();
+    /*!
+     * To removes initial central point.
+     */
+    void SetToRemoveCentralPoint(in boolean toRemove);
+    boolean GetToRemoveCentralPoint();
     /*!
      * To set hiden/undocumented/advanced options
      */
     void SetTextOption(in string option);
     string GetTextOption();
+    /*!
+     * To set an enforced vertex
+     */
+    void SetEnforcedVertex(in double x, in double y, in double z, in double size);
+    double GetEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+    void RemoveEnforcedVertex(in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+    GHS3DEnforcedVertexList GetEnforcedVertices();
+    void ClearEnforcedVertices();
   };
 };
 
index 0d14603a40c88ba9a67aca63b76cc352ce292781..481b72e4142d7c28b88851a8af2a8261e6e75794 100644 (file)
@@ -27,6 +27,7 @@
 #include "GHS3DPlugin_GHS3D.hxx"
 #include "GHS3DPlugin_Hypothesis.hxx"
 
+
 #include "SMESH_Gen.hxx"
 #include "SMESH_Mesh.hxx"
 #include "SMESH_Comment.hxx"
@@ -78,7 +79,7 @@ using namespace std;
 
 #ifdef _DEBUG_
 #define DUMP(txt) \
-//  cout << txt
+//  std::cout << txt
 #else
 #define DUMP(txt)
 #endif
@@ -208,7 +209,7 @@ static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[],
 
 static char* readMapIntLine(char* ptr, int tab[]) {
   long int intVal;
-  cout << endl;
+  std::cout << std::endl;
 
   for ( int i=0; i<17; i++ ) {
     intVal = strtol(ptr, &ptr, 10);
@@ -262,10 +263,10 @@ static bool writeFaces (ofstream &            theFile,
   int shapeID, nbNodes, aSmdsID;
   bool idFound;
 
-  cout << "    " << theMesh->NbFaces() << " shapes of 2D dimension" << endl;
-  cout << endl;
+  std::cout << "    " << theMesh->NbFaces() << " shapes of 2D dimension" << std::endl;
+  std::cout << std::endl;
 
-  theFile << space << theMesh->NbFaces() << space << dummyint << endl;
+  theFile << space << theMesh->NbFaces() << space << dummyint << std::endl;
 
   TopExp_Explorer expface( theMesh->ShapeToMesh(), TopAbs_FACE );
   for ( int i = 0; expface.More(); expface.Next(), i++ ) {
@@ -311,11 +312,12 @@ static bool writeFaces (ofstream &            theFile,
         for ( int j=0; j<=nbNodes; j++)
           theFile << space << dummyint;
 
-        theFile << endl;
+        theFile << std::endl;
       }
     }
   }
-
+  
+  
   delete [] tabID;
   delete [] tabShape;
 
@@ -362,10 +364,10 @@ static bool writeFaces (ofstream &            theFile,
   if ( nbFaces == 0 )
     return false;
   
-  cout << "The initial 2D mesh contains " << nbFaces << " faces and ";
+  std::cout << "The initial 2D mesh contains " << nbFaces << " faces and ";
 
   // NB_ELEMS DUMMY_INT
-  theFile << space << nbFaces << space << dummyint << endl;
+  theFile << space << nbFaces << space << dummyint << std::endl;
 
   // Loop from 1 to NB_ELEMS
 
@@ -393,7 +395,7 @@ static bool writeFaces (ofstream &            theFile,
     for ( int i=0; i<=nbNodes; i++)
       theFile << space << dummyint;
 
-    theFile << endl;
+    theFile << std::endl;
   }
 
   // put nodes to theNodeByGhs3dId vector
@@ -412,10 +414,11 @@ static bool writeFaces (ofstream &            theFile,
 //purpose  : 
 //=======================================================================
 
-static bool writePoints (ofstream &                       theFile,
-                         SMESHDS_Mesh *                   theMesh,
-                         map <int,int> &                  theSmdsToGhs3dIdMap,
-                         map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap)
+static bool writePoints (ofstream &                                     theFile,
+                         SMESHDS_Mesh *                                 theMesh,
+                         map <int,int> &                                theSmdsToGhs3dIdMap,
+                         map <int,const SMDS_MeshNode*> &               theGhs3dIdToNodeMap,
+                         map<vector<double>,double> & theEnforcedVertices)
 {
   // record structure:
   //
@@ -426,6 +429,7 @@ static bool writePoints (ofstream &                       theFile,
   int nbNodes = theMesh->NbNodes();
   if ( nbNodes == 0 )
     return false;
+  int nbEnforcedVertices = theEnforcedVertices.size();
 
   const char* space    = "  ";
   const int   dummyint = 0;
@@ -435,10 +439,15 @@ static bool writePoints (ofstream &                       theFile,
   const SMDS_MeshNode* node;
 
   // NB_NODES
-  theFile << space << nbNodes << endl;
-  cout << endl;
-  cout << "The initial 2D mesh contains :" << endl;
-  cout << "    " << nbNodes << " vertices" << endl;
+  std::cout << std::endl;
+  std::cout << "The initial 2D mesh contains :" << std::endl;
+  std::cout << "    " << nbNodes << " nodes" << std::endl;
+  if (nbEnforcedVertices > 0) {
+    std::cout << "    " << nbEnforcedVertices << " enforced vertices" << std::endl;
+  }
+  std::cout << std::endl;
+  std::cout << "Start writing in 'points' file ..." << std::endl;
+  theFile << space << nbNodes << std::endl;
 
   // Loop from 1 to NB_NODES
 
@@ -451,13 +460,46 @@ static bool writePoints (ofstream &                       theFile,
 
     // X Y Z DUMMY_INT
     theFile
-      << space << node->X()
-      << space << node->Y()
-      << space << node->Z()
-      << space << dummyint;
+    << space << node->X()
+    << space << node->Y()
+    << space << node->Z()
+    << space << dummyint;
+
+    theFile << std::endl;
 
-    theFile << endl;
   }
+  
+  // Iterate over the enforced vertices
+  GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+  const TopoDS_Shape shapeToMesh = theMesh->ShapeToMesh();
+  for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
+    double x = vertexIt->first[0];
+    double y = vertexIt->first[1];
+    double z = vertexIt->first[2];
+    // Test if point is inside shape to mesh
+    gp_Pnt myPoint(x,y,z);
+    BRepClass3d_SolidClassifier scl(shapeToMesh);
+    scl.Perform(myPoint, 1e-7);
+    TopAbs_State result = scl.State();
+    if ( result == TopAbs_IN ) {
+        MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second);
+        // X Y Z PHY_SIZE DUMMY_INT
+        theFile
+        << space << x
+        << space << y
+        << space << z
+        << space << vertexIt->second
+        << space << dummyint;
+    
+        theFile << std::endl;
+    }
+    else
+        MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
+  }
+  
+  
+  std::cout << std::endl;
+  std::cout << "End writing in 'points' file." << std::endl;
 
   return true;
 }
@@ -467,29 +509,37 @@ static bool writePoints (ofstream &                       theFile,
 //purpose  : 
 //=======================================================================
 
-static bool writePoints (ofstream &                            theFile,
-                         SMESHDS_Mesh *                        theMesh,
-                         const vector <const SMDS_MeshNode*> & theNodeByGhs3dId)
+static bool writePoints (ofstream &                                     theFile,
+                         SMESHDS_Mesh *                                 theMesh,
+                         const vector <const SMDS_MeshNode*> &          theNodeByGhs3dId,
+                         map<vector<double>,double> & theEnforcedVertices)
 {
   // record structure:
   //
   // NB_NODES
   // Loop from 1 to NB_NODES
   //   X Y Z DUMMY_INT
-
+  
   //int nbNodes = theMesh->NbNodes();
   int nbNodes = theNodeByGhs3dId.size();
   if ( nbNodes == 0 )
     return false;
 
+  int nbEnforcedVertices = theEnforcedVertices.size();
+
   const char* space    = "  ";
   const int   dummyint = 0;
 
   const SMDS_MeshNode* node;
 
   // NB_NODES
-  theFile << space << nbNodes << endl;
-  cout << nbNodes << " nodes" << endl;
+  std::cout << std::endl;
+  std::cout << "The initial 2D mesh contains :" << std::endl;
+  std::cout << "    " << nbNodes << " nodes" << std::endl;
+  std::cout << "    " << nbEnforcedVertices << " enforced vertices" << std::endl;
+  std::cout << std::endl;
+  std::cout << "Start writing in 'points' file ..." << std::endl;
+  theFile << space << nbNodes << std::endl;
 
   // Loop from 1 to NB_NODES
 
@@ -501,13 +551,43 @@ static bool writePoints (ofstream &                            theFile,
 
     // X Y Z DUMMY_INT
     theFile
-      << space << node->X()
-      << space << node->Y()
-      << space << node->Z()
-      << space << dummyint;
+    << space << node->X()
+    << space << node->Y()
+    << space << node->Z()
+    << space << dummyint;
 
-    theFile << endl;
+    theFile << std::endl;
+
+  }
+  
+  // Iterate over the enforced vertices
+  GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
+  const TopoDS_Shape shapeToMesh = theMesh->ShapeToMesh();
+  for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
+    double x = vertexIt->first[0];
+    double y = vertexIt->first[1];
+    double z = vertexIt->first[2];
+    // Test if point is inside shape to mesh
+    gp_Pnt myPoint(x,y,z);
+    BRepClass3d_SolidClassifier scl(shapeToMesh);
+    scl.Perform(myPoint, 1e-7);
+    TopAbs_State result = scl.State();
+    if ( result == TopAbs_IN ) {
+        std::cout << "Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second << std::endl;
+
+        // X Y Z PHY_SIZE DUMMY_INT
+        theFile
+        << space << x
+        << space << y
+        << space << z
+        << space << vertexIt->second
+        << space << dummyint;
+    
+        theFile << std::endl;
+    }
   }
+  std::cout << std::endl;
+  std::cout << "End writing in 'points' file." << std::endl;
 
   return true;
 }
@@ -661,8 +741,10 @@ static bool readResultFile(const int                       fileOpen,
                            double**                        tabBox,
                            const int                       nbShape,
                            map <int,const SMDS_MeshNode*>& theGhs3dIdToNodeMap,
-                           bool                            toMeshHoles)
+                           bool                            toMeshHoles,
+                           int                             nbEnforcedVertices)
 {
+  MESSAGE("GHS3DPlugin_GHS3D::readResultFile()");
   struct stat status;
   size_t      length;
 
@@ -731,12 +813,18 @@ static bool readResultFile(const int                       fileOpen,
   for (int i=0; i < 4*nbElems; i++)
     nodeId = strtol(ptr, &ptr, 10);
 
+  MESSAGE("nbInputNodes: "<<nbInputNodes);
+  MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
   // Reading the nodeCoor and update the nodeMap
   for (int iNode=1; iNode <= nbNodes; iNode++) {
     for (int iCoor=0; iCoor < 3; iCoor++)
       coord[ iCoor ] = strtod(ptr, &ptr);
     nodeAssigne[ iNode ] = 1;
-    if ( iNode > nbInputNodes ) {
+    if ( iNode > (nbInputNodes-nbEnforcedVertices) ) {
+      // Creating SMESH nodes
+      // - for enforced vertices
+      // - for vertices of forced edges
+      // - for ghs3d nodes
       nodeAssigne[ iNode ] = 0;
       aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] );
       theGhs3dIdToNodeMap.insert(theGhs3dIdToNodeMap.end(), make_pair( iNode, aNewNode ));
@@ -774,7 +862,7 @@ static bool readResultFile(const int                       fileOpen,
         }
         // END -- 0020330: Pb with ghs3d as a submesh
 #ifdef _DEBUG_
-        cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << endl;
+        std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl;
 #endif
       } catch ( Standard_Failure ) {
       } catch (...) {}
@@ -877,11 +965,11 @@ static bool readResultFile(const int                       fileOpen,
 
 #ifdef _DEBUG_
   if ( shapeIDs.size() != nbShape ) {
-    cout << "Only " << shapeIDs.size() << " solids of " << nbShape << " found" << endl;
+    std::cout << "Only " << shapeIDs.size() << " solids of " << nbShape << " found" << std::endl;
     for (int i=0; i<nbShape; i++) {
       shapeID = theMeshDS->ShapeToIndex( tabShape[i] );
       if ( shapeIDs.find( shapeID ) == shapeIDs.end() )
-        cout << "  Solid #" << shapeID << " not found" << endl;
+        std::cout << "  Solid #" << shapeID << " not found" << std::endl;
     }
   }
 #endif
@@ -900,7 +988,8 @@ static bool readResultFile(const int                      fileOpen,
 #endif
                            SMESHDS_Mesh*                  theMeshDS,
                            TopoDS_Shape                   aSolid,
-                           vector <const SMDS_MeshNode*>& theNodeByGhs3dId) {
+                           vector <const SMDS_MeshNode*>& theNodeByGhs3dId,
+                           int                            nbEnforcedVertices) {
 
   struct stat  status;
   size_t       length;
@@ -961,7 +1050,7 @@ static bool readResultFile(const int                      fileOpen,
   for (int iNode=0; iNode < nbNodes; iNode++) {
     for (int iCoor=0; iCoor < 3; iCoor++)
       coord[ iCoor ] = strtod(ptr, &ptr);
-    if ((iNode+1) > nbInputNodes) {
+    if ((iNode+1) > (nbInputNodes-nbEnforcedVertices)) {
       aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] );
       theMeshDS->SetNodeInVolume( aNewNode, shapeID );
       theNodeByGhs3dId[ iNode ] = aNewNode;
@@ -1075,8 +1164,16 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   }
   map <int,int> aSmdsToGhs3dIdMap;
   map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
-
-  Ok = writePoints( aPointsFile, meshDS, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap ) &&
+  map<vector<double>,double> enforcedVertices;
+  int nbEnforcedVertices = 0;
+  try {
+    enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
+    nbEnforcedVertices = enforcedVertices.size();
+  }
+  catch(...) {
+  }
+  
+  Ok = writePoints( aPointsFile, meshDS, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, enforcedVertices) &&
        writeFaces ( aFacesFile,  meshDS, aSmdsToGhs3dIdMap );
 
   aFacesFile.close();
@@ -1099,14 +1196,14 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   cmd += TCollection_AsciiString(" -f ") + aGenericName;  // file to read
   cmd += TCollection_AsciiString(" 1>" ) + aLogFileName;  // dump into file
 
-  cout << endl;
-  cout << "Ghs3d execution..." << endl;
-  cout << cmd << endl;
+  std::cout << std::endl;
+  std::cout << "Ghs3d execution..." << std::endl;
+  std::cout << cmd << std::endl;
 
   system( cmd.ToCString() ); // run
 
-  cout << endl;
-  cout << "End of Ghs3d execution !" << endl;
+  std::cout << std::endl;
+  std::cout << "End of Ghs3d execution !" << std::endl;
 
   // --------------
   // read a result
@@ -1117,9 +1214,9 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   int fileOpen;
   fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
   if ( fileOpen < 0 ) {
-    cout << endl;
-    cout << "Can't open the " << aResultFileName.ToCString() << " GHS3D output file" << endl;
-    cout << "Log: " << aLogFileName << endl;
+    std::cout << std::endl;
+    std::cout << "Can't open the " << aResultFileName.ToCString() << " GHS3D output file" << std::endl;
+    std::cout << "Log: " << aLogFileName << std::endl;
     Ok = false;
   }
   else {
@@ -1130,7 +1227,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
                          aResultFileName.ToCString(),
 #endif
                          theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
-                         toMeshHoles );
+                         toMeshHoles, nbEnforcedVertices );
   }
 
   // ---------------------
@@ -1163,11 +1260,11 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
     removeFile( aBadResFileName );
     removeFile( aBbResFileName );
   }
-  cout << "<" << aResultFileName.ToCString() << "> GHS3D output file ";
+  std::cout << "<" << aResultFileName.ToCString() << "> GHS3D output file ";
   if ( !Ok )
-    cout << "not ";
-  cout << "treated !" << endl;
-  cout << endl;
+    std::cout << "not ";
+  std::cout << "treated !" << std::endl;
+  std::cout << std::endl;
 
   _nbShape = 0;    // re-initializing _nbShape for the next Compute() method call
   delete [] tabShape;
@@ -1214,11 +1311,20 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 
   if (!Ok)
     return error( SMESH_Comment("Can't write into ") << aPointsFileName);
+  
+  GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices;
+  int nbEnforcedVertices = 0;
+  try {
+    enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
+    nbEnforcedVertices = enforcedVertices.size();
+  }
+  catch(...) {
+  }
 
   vector <const SMDS_MeshNode*> aNodeByGhs3dId;
 
   Ok = (writeFaces ( aFacesFile, meshDS, aNodeByGhs3dId ) &&
-        writePoints( aPointsFile, meshDS, aNodeByGhs3dId));
+        writePoints( aPointsFile, meshDS, aNodeByGhs3dId,enforcedVertices));
   
   aFacesFile.close();
   aPointsFile.close();
@@ -1249,10 +1355,10 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
   int fileOpen;
   fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
   if ( fileOpen < 0 ) {
-    cout << endl;
-    cout << "Error when opening the " << aResultFileName.ToCString() << " file" << endl;
-    cout << "Log: " << aLogFileName << endl;
-    cout << endl;
+    std::cout << std::endl;
+    std::cout << "Error when opening the " << aResultFileName.ToCString() << " file" << std::endl;
+    std::cout << "Log: " << aLogFileName << std::endl;
+    std::cout << std::endl;
     Ok = false;
   }
   else {
@@ -1260,7 +1366,7 @@ bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh&         theMesh,
 #ifdef WNT
                          aResultFileName.ToCString(),
 #endif
-                         meshDS, theShape ,aNodeByGhs3dId );
+                         meshDS, theShape ,aNodeByGhs3dId, nbEnforcedVertices );
   }
   
   // ---------------------
@@ -1866,3 +1972,4 @@ bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh,
 
   return true;
 }
+
index 865243e41845201d46fda1e68d0846084653e344..fdcded78528766751db0a51181436ccee5368bcb 100644 (file)
@@ -51,7 +51,7 @@ public:
                        const TopoDS_Shape& aShape);
 
   virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
-                       MapShapeNbElems& aResMap);
+                        MapShapeNbElems& aResMap);
 
   virtual bool Compute(SMESH_Mesh&         theMesh,
                        SMESH_MesherHelper* aHelper);
index 2a0096efae0908ee42c53a4a6876eb1a31ea634d..04644bc75abb7f82136a78ba89dcf084bb0d7c8b 100644 (file)
 //=======================================================================
 
 GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
-  : SMESH_Hypothesis(hypId, studyId, gen)
+  : SMESH_Hypothesis(hypId, studyId, gen),
+  myToMeshHoles(DefaultMeshHoles()),
+  myMaximumMemory(-1),
+  myInitialMemory(-1),
+  myOptimizationLevel(DefaultOptimizationLevel()),
+  myWorkingDirectory(DefaultWorkingDirectory()),
+  myKeepFiles(DefaultKeepFiles()),
+  myVerboseLevel(DefaultVerboseLevel()),
+  myToCreateNewNodes(DefaultToCreateNewNodes()),
+  myToUseBoundaryRecoveryVersion(DefaultToUseBoundaryRecoveryVersion()),
+  myToUseFemCorrection(DefaultToUseFEMCorrection()),
+  myToRemoveCentralPoint(DefaultToRemoveCentralPoint()),
+  myEnforcedVertices(DefaultEnforcedVertices())
 {
   _name = "GHS3D_Parameters";
   _param_algo_dim = 3;
-
-  myToMeshHoles                  = DefaultMeshHoles();        
-  myMaximumMemory                = -1;//DefaultMaximumMemory();    
-  myInitialMemory                = -1;//DefaultInitialMemory();    
-  myOptimizationLevel            = DefaultOptimizationLevel();
-  myWorkingDirectory             = DefaultWorkingDirectory(); 
-  myKeepFiles                    = DefaultKeepFiles();
-  myVerboseLevel                 = DefaultVerboseLevel();
-  myToCreateNewNodes             = DefaultToCreateNewNodes();
-  myToUseBoundaryRecoveryVersion = DefaultToUseBoundaryRecoveryVersion();
 }
 
 //=======================================================================
@@ -147,7 +149,7 @@ GHS3DPlugin_Hypothesis::OptimizationLevel GHS3DPlugin_Hypothesis::GetOptimizatio
 //function : SetWorkingDirectory
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const string& path)
+void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const std::string& path)
 {
   if ( myWorkingDirectory != path ) {
     myWorkingDirectory = path;
@@ -159,7 +161,7 @@ void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const string& path)
 //function : GetWorkingDirectory
 //=======================================================================
 
-string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const
+std::string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const
 {
   return myWorkingDirectory;
 }
@@ -248,11 +250,53 @@ bool GHS3DPlugin_Hypothesis::GetToUseBoundaryRecoveryVersion() const
   return myToUseBoundaryRecoveryVersion;
 }
 
+//=======================================================================
+//function : SetFEMCorrection
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetFEMCorrection(bool toUseFem)
+{
+  if ( myToUseFemCorrection != toUseFem ) {
+    myToUseFemCorrection = toUseFem;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//=======================================================================
+//function : GetFEMCorrection
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::GetFEMCorrection() const
+{
+  return myToUseFemCorrection;
+}
+
+//=======================================================================
+//function : SetToRemoveCentralPoint
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetToRemoveCentralPoint(bool toRemove)
+{
+  if ( myToRemoveCentralPoint != toRemove ) {
+    myToRemoveCentralPoint = toRemove;
+    NotifySubMeshesHypothesisModification();
+  }
+}
+
+//=======================================================================
+//function : GetToRemoveCentralPoint
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::GetToRemoveCentralPoint() const
+{
+  return myToRemoveCentralPoint;
+}
+
 //=======================================================================
 //function : SetTextOption
 //=======================================================================
 
-void GHS3DPlugin_Hypothesis::SetTextOption(const string& option)
+void GHS3DPlugin_Hypothesis::SetTextOption(const std::string& option)
 {
   if ( myTextOption != option ) {
     myTextOption = option;
@@ -264,11 +308,73 @@ void GHS3DPlugin_Hypothesis::SetTextOption(const string& option)
 //function : GetTextOption
 //=======================================================================
 
-string GHS3DPlugin_Hypothesis::GetTextOption() const
+std::string GHS3DPlugin_Hypothesis::GetTextOption() const
 {
   return myTextOption;
 }
 
+//=======================================================================
+//function : SetEnforcedVertex
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetEnforcedVertex(double x, double y, double z, double size)
+{
+  std::vector<double> coord(3);
+  coord[0] = x;
+  coord[1] = y;
+  coord[2] = z;
+  myEnforcedVertices[coord] = size;
+  NotifySubMeshesHypothesisModification();
+}
+
+//=======================================================================
+//function : GetEnforcedVertex
+//=======================================================================
+
+double GHS3DPlugin_Hypothesis::GetEnforcedVertex(double x, double y, double z)
+  throw (std::invalid_argument)
+{
+  std::vector<double> coord(3);
+  coord[0] = x;
+  coord[1] = y;
+  coord[2] = z;
+  if (myEnforcedVertices.count(coord)>0)
+    return myEnforcedVertices[coord];
+  std::ostringstream msg ;
+  msg << "No enforced vertex at " << x << ", " << y << ", " << z;
+  throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : RemoveEnforcedVertex
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(double x, double y, double z)
+  throw (std::invalid_argument)
+{
+    std::vector<double> coord(3);
+    coord[0] = x;
+    coord[1] = y;
+    coord[2] = z;
+    TEnforcedVertexValues::iterator it = myEnforcedVertices.find(coord);
+    if (it != myEnforcedVertices.end()) {
+        myEnforcedVertices.erase(it);
+        NotifySubMeshesHypothesisModification();
+        return;
+    }
+    std::ostringstream msg ;
+    msg << "No enforced vertex at " << x << ", " << y << ", " << z;
+    throw std::invalid_argument(msg.str());
+}
+
+//=======================================================================
+//function : ClearEnforcedVertices
+//=======================================================================
+void GHS3DPlugin_Hypothesis::ClearEnforcedVertices()
+{
+    myEnforcedVertices.clear();
+    NotifySubMeshesHypothesisModification();
+}
 
 //=======================================================================
 //function : DefaultMeshHoles
@@ -296,7 +402,7 @@ short  GHS3DPlugin_Hypothesis::DefaultMaximumMemory()
   int err = sysinfo( &si );
   if ( err == 0 ) {
     int ramMB = si.totalram * si.mem_unit / 1024 / 1024;
-    return (short) ( 0.7 * ramMB );
+    return (int) ( 0.7 * ramMB );
   }
 #else
   // See http://msdn.microsoft.com/en-us/library/aa366589.aspx
@@ -335,7 +441,7 @@ short  GHS3DPlugin_Hypothesis::DefaultOptimizationLevel()
 //function : DefaultWorkingDirectory
 //=======================================================================
 
-string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory()
+std::string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory()
 {
   TCollection_AsciiString aTmpDir;
 
@@ -389,11 +495,39 @@ bool GHS3DPlugin_Hypothesis::DefaultToUseBoundaryRecoveryVersion()
   return false;
 }
 
+//=======================================================================
+//function : DefaultToUseFEMCorrection
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::DefaultToUseFEMCorrection()
+{
+  return false;
+}
+
+//=======================================================================
+//function : DefaultToRemoveCentralPoint
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::DefaultToRemoveCentralPoint()
+{
+  return false;
+}
+
+//=======================================================================
+//function : DefaultEnforcedVertices
+//=======================================================================
+
+GHS3DPlugin_Hypothesis::TEnforcedVertexValues GHS3DPlugin_Hypothesis::DefaultEnforcedVertices()
+{
+  return GHS3DPlugin_Hypothesis::TEnforcedVertexValues();
+}
+
+
 //=======================================================================
 //function : SaveTo
 //=======================================================================
 
-ostream & GHS3DPlugin_Hypothesis::SaveTo(ostream & save)
+std::ostream & GHS3DPlugin_Hypothesis::SaveTo(std::ostream & save)
 {
   save << (int) myToMeshHoles                 << " ";
   save << myMaximumMemory                     << " ";
@@ -404,7 +538,25 @@ ostream & GHS3DPlugin_Hypothesis::SaveTo(ostream & save)
   save << myVerboseLevel                      << " ";
   save << (int)myToCreateNewNodes             << " ";
   save << (int)myToUseBoundaryRecoveryVersion << " ";
+  save << (int)myToUseFemCorrection           << " ";
+  save << (int)myToRemoveCentralPoint         << " ";
+  save << "__OPTIONS_BEGIN__ ";
   save << myTextOption                        << " ";
+  save << " __OPTIONS_END__ ";
+  
+
+  TEnforcedVertexValues::iterator it  = myEnforcedVertices.begin();
+  if (it != myEnforcedVertices.end()) {
+    save << "__ENFORCED_VERTICES_BEGIN__ ";
+    for ( ; it != myEnforcedVertices.end(); ++it ) {
+        save << it->first[0] << " "
+             << it->first[1] << " "
+             << it->first[2] << " "
+             << it->second << " ";
+    }
+    save << "__ENFORCED_VERTICES_END__ ";
+  }
+
   return save;
 }
 
@@ -412,87 +564,162 @@ ostream & GHS3DPlugin_Hypothesis::SaveTo(ostream & save)
 //function : LoadFrom
 //=======================================================================
 
-istream & GHS3DPlugin_Hypothesis::LoadFrom(istream & load)
-{
-  bool isOK = true;
-  int i;
-
-  isOK = (load >> i);
-  if (isOK)
-    myToMeshHoles = i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> i);
-  if (isOK)
-    myMaximumMemory = i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> i);
-  if (isOK)
-    myInitialMemory = i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> i);
-  if (isOK)
-    myOptimizationLevel = i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> myWorkingDirectory);
-  if (isOK) {
-    if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
-      myKeepFiles = false;
-      myWorkingDirectory.clear();
+std::istream & GHS3DPlugin_Hypothesis::LoadFrom(std::istream & load)
+{
+    bool isOK = true;
+    int i;
+    
+    isOK = (load >> i);
+    if (isOK)
+        myToMeshHoles = i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myMaximumMemory = i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myInitialMemory = i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myOptimizationLevel = i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> myWorkingDirectory);
+    if (isOK) {
+        if ( myWorkingDirectory == "0") { // myWorkingDirectory was empty
+            myKeepFiles = false;
+            myWorkingDirectory.clear();
+        }
+        else if ( myWorkingDirectory == "1" ) {
+            myKeepFiles = true;
+            myWorkingDirectory.clear();
+        }
     }
-    else if ( myWorkingDirectory == "1" ) {
-      myKeepFiles = true;
-      myWorkingDirectory.clear();
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    if ( !myWorkingDirectory.empty() ) {
+        isOK = (load >> i);
+        if (isOK)
+            myKeepFiles = i;
+        else
+            load.clear(ios::badbit | load.rdstate());
     }
-  }
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  if ( !myWorkingDirectory.empty() ) {
+    
     isOK = (load >> i);
     if (isOK)
-      myKeepFiles = i;
+        myVerboseLevel = (short) i;
     else
-      load.clear(ios::badbit | load.rdstate());
-  }
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myToCreateNewNodes = (bool) i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myToUseBoundaryRecoveryVersion = (bool) i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myToUseFemCorrection = (bool) i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+    isOK = (load >> i);
+    if (isOK)
+        myToRemoveCentralPoint = (bool) i;
+    else
+        load.clear(ios::badbit | load.rdstate());
+    
+//     isOK = (load >> myTextOption);
+//     while (isOK) {
+//         std::string txt;
+//         if (load >> txt) {
+//             myTextOption += " ";
+//             myTextOption += txt;
+//         }
+//         else
+//             isOK = false;
+//     }
+//     //   else
+//     //     load.clear(ios::badbit | load.rdstate());
+
+    
+    std::string separator;
+    bool hasOptions = false;
+    bool hasEnforcedVertices = false;
+    isOK = (load >> separator);
+
+    if (isOK)
+        if (separator == "__OPTIONS_BEGIN__")
+            hasOptions = true;
+        else if (separator == "__ENFORCED_VERTICES_BEGIN__")
+            hasEnforcedVertices = true;
+    
+    if (hasOptions) {
+        std::string txt;
+        isOK = (load >> myTextOption);
+        while (isOK) {
+            if (myTextOption == "__OPTIONS_END__") {
+                isOK = false;
+                break;
+            }
+            if (load >> txt) {
+                if (txt == "__OPTIONS_END__") {
+                    isOK = false;
+                    break;
+                }
+                myTextOption += " ";
+                myTextOption += txt;
+            }
+            else
+                isOK = false;
+        }
+    }
 
-  isOK = (load >> i);
-  if (isOK)
-    myVerboseLevel = (short) i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> i);
-  if (isOK)
-    myToCreateNewNodes = (bool) i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> i);
-  if (isOK)
-    myToUseBoundaryRecoveryVersion = (bool) i;
-  else
-    load.clear(ios::badbit | load.rdstate());
-
-  isOK = (load >> myTextOption);
-  while (isOK) {
-    string txt;
-    if (load >> txt) {
-      myTextOption += " ";
-      myTextOption += txt;
+    if (hasOptions) {
+        isOK = (load >> separator);
+        if (isOK)
+            if (separator == "__ENFORCED_VERTICES_BEGIN__")
+                hasEnforcedVertices = true;
+    }
+
+    if (hasEnforcedVertices) {
+        std::string txt;
+        double x,y,z,size;
+        while (isOK) {
+            isOK = (load >> txt);
+            if (isOK) {
+                if (txt == "__ENFORCED_VERTICES_END__") {
+                    isOK = false;
+                    break;
+                }
+                x = atof(txt.c_str());
+                isOK = (load >> y >> z >> size);
+            }
+            if (isOK) {
+                std::vector<double> coord;
+                coord.push_back(x);
+                coord.push_back(y);
+                coord.push_back(z);
+                myEnforcedVertices[ coord ] = size;
+            }
+        }
     }
-    else
-      isOK = false;
-  }
-//   else
-//     load.clear(ios::badbit | load.rdstate());
 
   return load;
 }
@@ -525,18 +752,20 @@ bool GHS3DPlugin_Hypothesis::SetParametersByDefaults(const TDefaults&  /*dflts*/
  */
 //================================================================================
 
-string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
+std::string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
                                             const bool                    hasShapeToMesh)
 {
   TCollection_AsciiString cmd( "ghs3d" );
   // check if any option is overridden by hyp->myTextOption
-  bool m = hyp ? ( hyp->myTextOption.find("-m") == string::npos ) : true;
-  bool M = hyp ? ( hyp->myTextOption.find("-M") == string::npos ) : true;
-  bool c = hyp ? ( hyp->myTextOption.find("-c") == string::npos ) : true;
-  bool o = hyp ? ( hyp->myTextOption.find("-o") == string::npos ) : true;
-  bool p0= hyp ? ( hyp->myTextOption.find("-p0")== string::npos ) : true;
-  bool C = hyp ? ( hyp->myTextOption.find("-C") == string::npos ) : true;
-  bool v = hyp ? ( hyp->myTextOption.find("-v") == string::npos ) : true;
+  bool m   = hyp ? ( hyp->myTextOption.find("-m")  == std::string::npos ) : true;
+  bool M   = hyp ? ( hyp->myTextOption.find("-M")  == std::string::npos ) : true;
+  bool c   = hyp ? ( hyp->myTextOption.find("-c")  == std::string::npos ) : true;
+  bool o   = hyp ? ( hyp->myTextOption.find("-o")  == std::string::npos ) : true;
+  bool p0  = hyp ? ( hyp->myTextOption.find("-p0") == std::string::npos ) : true;
+  bool C   = hyp ? ( hyp->myTextOption.find("-C")  == std::string::npos ) : true;
+  bool v   = hyp ? ( hyp->myTextOption.find("-v")  == std::string::npos ) : true;
+  bool fem = hyp ? ( hyp->myTextOption.find("-FEM")== std::string::npos ) : true;
+  bool rem = hyp ? ( hyp->myTextOption.find("-no_initial_central_point")== std::string::npos ) : true;
 
   // if use boundary recovery version, few options are allowed
   bool useBndRecovery = !C;
@@ -580,8 +809,8 @@ string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
 
   // optimization level
   if ( o && hyp && !useBndRecovery ) {
-    if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 4 ) {
-      char* level[] = { "none" , "light" , "standard" , "strong" };
+    if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 5 ) {
+      char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
       cmd += " -o ";
       cmd += level[ hyp->myOptimizationLevel ];
     }
@@ -603,6 +832,16 @@ string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
     cmd += " -C";
   }
 
+  // to use FEM correction
+  if ( fem && hyp && hyp->myToUseFemCorrection) {
+    cmd += " -FEM";
+  }
+
+  // to remove initial central point.
+  if ( rem && hyp && hyp->myToRemoveCentralPoint) {
+    cmd += " -no_initial_central_point";
+  }
+
   // options as text
   if ( hyp && !hyp->myTextOption.empty() ) {
     cmd += " ";
@@ -622,9 +861,9 @@ string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp,
  */
 //================================================================================
 
-string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp)
+std::string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp)
 {
-  string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory();
+  std::string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory();
   const char lastChar = *aTmpDir.rbegin();
 #ifdef WIN32
     if(lastChar != '\\') aTmpDir+='\\';
@@ -640,3 +879,16 @@ string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp)
 
   return aGenericName.ToCString();
 }
+
+
+//================================================================================
+/*!
+* \brief Return the enforced vertices
+*/
+//================================================================================
+
+GHS3DPlugin_Hypothesis::TEnforcedVertexValues GHS3DPlugin_Hypothesis::GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp)
+{
+    return hyp ? hyp->_GetEnforcedVertices():DefaultEnforcedVertices();
+}
+
index 1c59739768c7a29236797cf27d7ec38f76458a9f..119bcd51c0d6636886c06724aeafa54793d99c55 100644 (file)
 #include "GHS3DPlugin_Defs.hxx"
 
 #include <SMESH_Hypothesis.hxx>
+#include <utilities.h>
 
-using namespace std;
+#include <stdexcept>
+#include <map>
+#include <vector>
+#include <cstdio>
 
 class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis: public SMESH_Hypothesis
 {
@@ -53,16 +57,16 @@ public:
   void SetInitialMemory(short MB);
   short GetInitialMemory() const;
   /*!
-   * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium
+   * Optimization level: 0-none, 1-light, 2-medium, 3-standard+, 4-strong. Default is medium
    */
-  enum OptimizationLevel { None = 0, Light, Medium, Strong };
+  enum OptimizationLevel { None = 0, Light, Medium, StandardPlus, Strong };
   void SetOptimizationLevel(OptimizationLevel level);
   OptimizationLevel GetOptimizationLevel() const;
   /*!
    * Path to working directory
    */
-  void SetWorkingDirectory(const string& path);
-  string GetWorkingDirectory() const;
+  void SetWorkingDirectory(const std::string& path);
+  std::string GetWorkingDirectory() const;
   /*!
    * To keep working files or remove them. Log file remains in case of errors anyway.
    */
@@ -91,21 +95,46 @@ public:
    */
   void SetToUseBoundaryRecoveryVersion(bool toUse);
   bool GetToUseBoundaryRecoveryVersion() const;
+  /*!
+   * Applies finite-element correction by replacing overconstrained elements where
+   * it is possible. The process is cutting first the overconstrained edges and
+   * second the overconstrained facets. This insure that no edges have two boundary
+   * vertices and that no facets have three boundary vertices.
+   */
+  void SetFEMCorrection(bool toUseFem);
+  bool GetFEMCorrection() const;
+  /*!
+   * To removes initial central point.
+   */
+  void SetToRemoveCentralPoint(bool toRemove);
+  bool GetToRemoveCentralPoint() const;
   /*!
    * To set hiden/undocumented/advanced options
    */
-  void SetTextOption(const string& option);
-  string GetTextOption() const;
+  void SetTextOption(const std::string& option);
+  std::string GetTextOption() const;
+  /*!
+   * To set an enforced vertex
+   */
+  typedef std::map<std::vector<double>,double> TEnforcedVertexValues;
+  void SetEnforcedVertex(double x, double y, double z, double size);
+  double GetEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
+  void RemoveEnforcedVertex(double x, double y, double z) throw (std::invalid_argument);
+  const TEnforcedVertexValues _GetEnforcedVertices() const { return myEnforcedVertices; }
+  void ClearEnforcedVertices();
 
   static bool   DefaultMeshHoles();
   static short  DefaultMaximumMemory();
   static short  DefaultInitialMemory();
   static short  DefaultOptimizationLevel();
-  static string DefaultWorkingDirectory();
+  static std::string DefaultWorkingDirectory();
   static bool   DefaultKeepFiles();
   static short  DefaultVerboseLevel();
   static bool   DefaultToCreateNewNodes();
   static bool   DefaultToUseBoundaryRecoveryVersion();
+  static bool   DefaultToUseFEMCorrection();
+  static bool   DefaultToRemoveCentralPoint();
+  static TEnforcedVertexValues DefaultEnforcedVertices();
 
   /*!
    * \brief Return command to run ghs3d mesher excluding file prefix (-f)
@@ -116,12 +145,16 @@ public:
    * \brief Return a unique file name
    */
   static std::string GetFileName(const GHS3DPlugin_Hypothesis* hyp);
+  /*!
+   * \brief Return the enforced vertices
+   */
+  static TEnforcedVertexValues GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp);
 
   // Persistence
-  virtual ostream & SaveTo(ostream & save);
-  virtual istream & LoadFrom(istream & load);
-  friend GHS3DPLUGIN_EXPORT ostream & operator <<(ostream & save, GHS3DPlugin_Hypothesis & hyp);
-  friend GHS3DPLUGIN_EXPORT istream & operator >>(istream & load, GHS3DPlugin_Hypothesis & hyp);
+  virtual std::ostream & SaveTo(std::ostream & save);
+  virtual std::istream & LoadFrom(std::istream & load);
+  friend GHS3DPLUGIN_EXPORT std::ostream & operator <<(std::ostream & save, GHS3DPlugin_Hypothesis & hyp);
+  friend GHS3DPLUGIN_EXPORT std::istream & operator >>(std::istream & load, GHS3DPlugin_Hypothesis & hyp);
 
   /*!
    * \brief Does nothing
@@ -140,11 +173,14 @@ private:
   short  myInitialMemory;
   short  myOptimizationLevel;
   bool   myKeepFiles;
-  string myWorkingDirectory;
+  std::string myWorkingDirectory;
   short  myVerboseLevel;
   bool   myToCreateNewNodes;
   bool   myToUseBoundaryRecoveryVersion;
-  string myTextOption;
+  bool   myToUseFemCorrection;
+  bool   myToRemoveCentralPoint;
+  std::string myTextOption;
+  TEnforcedVertexValues myEnforcedVertices;
   
 };
 
index 3cec323eb9dc175fd694cd74b171a0f381e2add5..570f96bbe670ecc8fa3c1c07b269e1a3c4744f95 100644 (file)
@@ -273,6 +273,48 @@ CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToUseBoundaryRecoveryVersion()
   return this->GetImpl()->GetToUseBoundaryRecoveryVersion();
 }
 
+//=======================================================================
+//function : SetFEMCorrection
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetFEMCorrection(CORBA::Boolean toUseFem)
+{
+  ASSERT(myBaseImpl);
+  this->GetImpl()->SetFEMCorrection(toUseFem);
+  SMESH::TPythonDump() << _this() << ".SetFEMCorrection( " << toUseFem << " )";
+}
+
+//=======================================================================
+//function : GetFEMCorrection
+//=======================================================================
+
+CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetFEMCorrection()
+{
+  ASSERT(myBaseImpl);
+  return this->GetImpl()->GetFEMCorrection();
+}
+
+//=======================================================================
+//function : SetToRemoveCentralPoint
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetToRemoveCentralPoint(CORBA::Boolean toRemove)
+{
+  ASSERT(myBaseImpl);
+  this->GetImpl()->SetToRemoveCentralPoint(toRemove);
+  SMESH::TPythonDump() << _this() << ".SetToRemoveCentralPoint( " << toRemove << " )";
+}
+
+//=======================================================================
+//function : GetToRemoveCentralPoint
+//=======================================================================
+
+CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToRemoveCentralPoint()
+{
+  ASSERT(myBaseImpl);
+  return this->GetImpl()->GetToRemoveCentralPoint();
+}
+
 //=======================================================================
 //function : SetTextOption
 //=======================================================================
@@ -294,6 +336,105 @@ char* GHS3DPlugin_Hypothesis_i::GetTextOption()
   return CORBA::string_dup( this->GetImpl()->GetTextOption().c_str() );
 }
 
+//=======================================================================
+//function : SetEnforcedVertex
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size)
+{
+  ASSERT(myBaseImpl);
+  this->GetImpl()->SetEnforcedVertex(x,y,z,size);
+  SMESH::TPythonDump() << _this() << ".SetEnforcedVertex( " << x << ", " << y << ", " << z << ", " << size  << " )";
+}
+
+//=======================================================================
+//function : GetEnforcedVertex
+//=======================================================================
+
+CORBA::Double GHS3DPlugin_Hypothesis_i::GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
+  throw (SALOME::SALOME_Exception)
+{
+  ASSERT(myBaseImpl);
+  try {
+    return this->GetImpl()->GetEnforcedVertex(x,y,z);
+  }
+  catch (const std::invalid_argument& ex) {
+    SALOME::ExceptionStruct ExDescription;
+    ExDescription.text = ex.what();
+    ExDescription.type = SALOME::BAD_PARAM;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::GetEnforcedVertex(x,y,z)";
+    ExDescription.lineNumber = 0;
+    throw SALOME::SALOME_Exception(ExDescription);
+  }
+  catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+  return 0;
+}
+
+//=======================================================================
+//function : GetEnforcedVertices
+//=======================================================================
+
+GHS3DPlugin::GHS3DEnforcedVertexList* GHS3DPlugin_Hypothesis_i::GetEnforcedVertices()
+{
+  ASSERT(myBaseImpl);
+  GHS3DPlugin::GHS3DEnforcedVertexList_var result = new GHS3DPlugin::GHS3DEnforcedVertexList();
+
+  const ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues sizeMaps = this->GetImpl()->_GetEnforcedVertices();
+  int size = sizeMaps.size();
+  result->length( size );
+
+  ::GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator it;
+  int i = 0;
+  for (it = sizeMaps.begin() ; it != sizeMaps.end(); it++ ) {
+    GHS3DPlugin::GHS3DEnforcedVertex_var myVertex = new GHS3DPlugin::GHS3DEnforcedVertex();
+    myVertex->x = it->first[0];
+    myVertex->y = it->first[1];
+    myVertex->z = it->first[2];
+    myVertex->size = it->second;
+    result[i]=myVertex;
+    i++;
+    }
+
+  return result._retn();
+}
+
+//=======================================================================
+//function : RemoveEnforcedVertex
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z)
+  throw (SALOME::SALOME_Exception)
+{
+  ASSERT(myBaseImpl);
+  try {
+    this->GetImpl()->RemoveEnforcedVertex(x,y,z);
+    SMESH::TPythonDump() << _this() << ".RemoveEnforcedVertex( " << x << ", " << y << ", " << z << " )";
+  }
+  catch (const std::invalid_argument& ex) {
+    SALOME::ExceptionStruct ExDescription;
+    ExDescription.text = ex.what();
+    ExDescription.type = SALOME::BAD_PARAM;
+    ExDescription.sourceFile = "GHS3DPlugin_Hypothesis::RemoveEnforcedVertex(x,y,z)";
+    ExDescription.lineNumber = 0;
+    throw SALOME::SALOME_Exception(ExDescription);
+  }
+  catch (SALOME_Exception& ex) {
+    THROW_SALOME_CORBA_EXCEPTION( ex.what() ,SALOME::BAD_PARAM );
+  }
+}
+
+//=======================================================================
+//function : ClearEnforcedVertices
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::ClearEnforcedVertices()
+{
+  ASSERT(myBaseImpl);
+  this->GetImpl()->ClearEnforcedVertices();
+}
+
 //=============================================================================
 /*!
  *  Get implementation
index 60704e4ae1509556cfbf625997c7b65d89922f01..fa70cb5b961e4382e95286ae50f802a6a3cd4465 100644 (file)
@@ -102,11 +102,32 @@ class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i:
    */
   void SetToUseBoundaryRecoveryVersion(CORBA::Boolean toUse);
   CORBA::Boolean GetToUseBoundaryRecoveryVersion();
+  /*!
+   * Applies finite-element correction by replacing overconstrained elements where
+   * it is possible. The process is cutting first the overconstrained edges and
+   * second the overconstrained facets. This insure that no edges have two boundary
+   * vertices and that no facets have three boundary vertices.
+   */
+  void SetFEMCorrection(CORBA::Boolean toUseFem);
+  CORBA::Boolean GetFEMCorrection();
+  /*!
+   * To removes initial central point.
+   */
+  void SetToRemoveCentralPoint(CORBA::Boolean toRemove);
+  CORBA::Boolean GetToRemoveCentralPoint();
   /*!
    * To set hiden/undocumented/advanced options
    */
   void SetTextOption(const char* option);
   char* GetTextOption();
+  /*!
+   * To set an enforced vertex
+   */
+  void SetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size);
+  CORBA::Double GetEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
+  void RemoveEnforcedVertex(CORBA::Double x, CORBA::Double y, CORBA::Double z) throw (SALOME::SALOME_Exception);
+  GHS3DPlugin::GHS3DEnforcedVertexList* GetEnforcedVertices();
+  void ClearEnforcedVertices();
 
   // Get implementation
   ::GHS3DPlugin_Hypothesis* GetImpl();
index 97b4775e82e77a9b9e21621561c6bca87d04ed7b..1bc6f576feb2e79271eab5fae8f887a4c346f90b 100644 (file)
 #include <SMESHGUI_Utils.h>
 #include <SMESHGUI_HypothesesUtils.h>
 
-#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
-
-#include <SUIT_MessageBox.h>
 #include <SUIT_Session.h>
-#include <SUIT_FileDlg.h>
+#include <SUIT_MessageBox.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_FileDlg.h>
 #include <SalomeApp_Tools.h>
+#include <SalomeApp_TypeFilter.h>
 
-#include <QLabel>
 #include <QComboBox>
+#include <QLabel>
 #include <QFrame>
-#include <QGridLayout>
 #include <QVBoxLayout>
+#include <QGridLayout>
 #include <QLineEdit>
 #include <QCheckBox>
 #include <QTabWidget>
 #include <QPushButton>
 #include <QFileInfo>
 
+#include <QTableWidget>
+#include <QStandardItemModel>
+#include <QStandardItem>
+#include <QHeaderView>
+#include <QModelIndexList>
+
+#include <stdexcept>
+#include <utilities.h>
+
+// tabs
 enum {
   STD_TAB = 0,
-  ADV_TAB
+  ADV_TAB,
+  ENF_VER_TAB
+};
+
+// Enforced vertices array columns
+enum {
+  ENF_VER_X_COLUMN = 0,
+  ENF_VER_Y_COLUMN,
+  ENF_VER_Z_COLUMN,
+  ENF_VER_SIZE_COLUMN,
+  ENF_VER_NB_COLUMNS
+};
+
+// Enforced vertices inputs
+enum {
+  ENF_VER_BTNS = 0,
+  ENF_VER_X_COORD,
+  ENF_VER_Y_COORD,
+  ENF_VER_Z_COORD,
+  ENF_VER_SIZE,
+  ENF_VER_VERTEX_BTN,
+  ENF_VER_SEPARATOR,
+  ENF_VER_REMOVE_BTN,
 };
 
 namespace {
@@ -87,6 +118,59 @@ namespace {
   }
 }
 
+class QDoubleValidator;
+
+//
+// BEGIN DoubleLineEditDelegate
+//
+
+DoubleLineEditDelegate::DoubleLineEditDelegate(QObject *parent)
+    : QItemDelegate(parent)
+{
+}
+
+QWidget *DoubleLineEditDelegate::createEditor(QWidget *parent,
+    const QStyleOptionViewItem &/* option */,
+    const QModelIndex &/* index */) const
+{
+    QLineEdit *editor = new QLineEdit(parent);
+    editor->setValidator(new QDoubleValidator(parent));
+
+    return editor;
+}
+
+void DoubleLineEditDelegate::setEditorData(QWidget *editor,
+                                    const QModelIndex &index) const
+{
+    QString value = index.model()->data(index, Qt::EditRole).toString();
+
+    QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
+    lineEdit->setText(value);
+}
+
+void DoubleLineEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+                                    const QModelIndex &index) const
+{
+    QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
+    bool ok;
+    double value = lineEdit->text().toDouble(&ok);
+
+    if (ok) {
+        model->setData(index, value, Qt::EditRole);
+        MESSAGE("Value " << value << " was set at index(" << index.row() << "," << index.column() << ")");
+    }
+}
+
+void DoubleLineEditDelegate::updateEditorGeometry(QWidget *editor,
+    const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
+{
+    editor->setGeometry(option.rect);
+}
+
+//
+// END DoubleLineEditDelegate
+//
+
 GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType )
 : SMESHGUI_GenericHypothesisCreator( theHypType )
 {
@@ -132,7 +216,7 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
   aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
 
   QStringList types;
-  types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STRONG" );
+  types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
   myOptimizationLevelCombo->addItems( types );
 
   aStdLayout->setRowStretch( row, 5 );
@@ -173,31 +257,88 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
 
   myToCreateNewNodesCheck = new QCheckBox( tr( "TO_ADD_NODES" ), myAdvGroup );
   
+  myRemoveInitialCentralPointCheck = new QCheckBox( tr( "NO_INITIAL_CENTRAL_POINT" ), myAdvGroup );
+  
   myBoundaryRecoveryCheck = new QCheckBox( tr( "RECOVERY_VERSION" ), myAdvGroup );
+  
+  myFEMCorrectionCheck = new QCheckBox( tr( "FEM_CORRECTION" ), myAdvGroup );
 
   QLabel* aTextOptionLabel = new QLabel( tr( "TEXT_OPTION" ), myAdvGroup );
   myTextOption = new QLineEdit( myAdvGroup );
 
-  anAdvLayout->addWidget( myMaximumMemoryCheck,    0, 0, 1, 1 );
-  anAdvLayout->addWidget( myMaximumMemorySpin,     0, 1, 1, 1 );
-  anAdvLayout->addWidget( aMegabyteLabel,          0, 2, 1, 1 );
-  anAdvLayout->addWidget( myInitialMemoryCheck,    1, 0, 1, 1 );
-  anAdvLayout->addWidget( myInitialMemorySpin,     1, 1, 1, 1 );
-  anAdvLayout->addWidget( aMegabyteLabel2,         1, 2, 1, 1 );
-  anAdvLayout->addWidget( aWorkinDirLabel,         2, 0, 1, 1 );
-  anAdvLayout->addWidget( myWorkingDir,            2, 1, 1, 2 );
-  anAdvLayout->addWidget( dirBtn,                  2, 3, 1, 1 );
-  anAdvLayout->addWidget( myKeepFiles,             3, 0, 1, 4 );
-  anAdvLayout->addWidget( aVerboseLevelLabel,      4, 0, 1, 1 );
-  anAdvLayout->addWidget( myVerboseLevelSpin,      4, 1, 1, 1 );
-  anAdvLayout->addWidget( myToCreateNewNodesCheck, 5, 0, 1, 4 );
-  anAdvLayout->addWidget( myBoundaryRecoveryCheck, 6, 0, 1, 4 );
-  anAdvLayout->addWidget( aTextOptionLabel,        7, 0, 1, 1 );
-  anAdvLayout->addWidget( myTextOption,            7, 1, 1, 2 );
-
+  anAdvLayout->addWidget( myMaximumMemoryCheck,             0, 0, 1, 1 );
+  anAdvLayout->addWidget( myMaximumMemorySpin,              0, 1, 1, 1 );
+  anAdvLayout->addWidget( aMegabyteLabel,                   0, 2, 1, 1 );
+  anAdvLayout->addWidget( myInitialMemoryCheck,             1, 0, 1, 1 );
+  anAdvLayout->addWidget( myInitialMemorySpin,              1, 1, 1, 1 );
+  anAdvLayout->addWidget( aMegabyteLabel2,                  1, 2, 1, 1 );
+  anAdvLayout->addWidget( aWorkinDirLabel,                  2, 0, 1, 1 );
+  anAdvLayout->addWidget( myWorkingDir,                     2, 1, 1, 2 );
+  anAdvLayout->addWidget( dirBtn,                           2, 3, 1, 1 );
+  anAdvLayout->addWidget( myKeepFiles,                      3, 0, 1, 4 );
+  anAdvLayout->addWidget( aVerboseLevelLabel,               4, 0, 1, 1 );
+  anAdvLayout->addWidget( myVerboseLevelSpin,               4, 1, 1, 1 );
+  anAdvLayout->addWidget( myToCreateNewNodesCheck,          5, 0, 1, 4 );
+  anAdvLayout->addWidget( myRemoveInitialCentralPointCheck, 6, 0, 1, 4 );
+  anAdvLayout->addWidget( myBoundaryRecoveryCheck,          7, 0, 1, 4 );
+  anAdvLayout->addWidget( myFEMCorrectionCheck,             8, 0, 1, 4 );
+  anAdvLayout->addWidget( aTextOptionLabel,                 9, 0, 1, 1 );
+  anAdvLayout->addWidget( myTextOption,                     9, 1, 1, 2 );
+
+  // Size Maps parameters
+  myEnfGroup = new QWidget();
+  QGridLayout* anSmpLayout = new QGridLayout(myEnfGroup);
+  
+  mySmpModel = new QStandardItemModel(0, ENF_VER_NB_COLUMNS);
+  myEnforcedTableView = new QTableView(myEnfGroup);
+  myEnforcedTableView->setModel(mySmpModel);
+  myEnforcedTableView->setSortingEnabled(true);
+  myEnforcedTableView->setItemDelegateForColumn(ENF_VER_SIZE_COLUMN,new DoubleLineEditDelegate(this));
+  anSmpLayout->addWidget(myEnforcedTableView, 1, 0, 9, 1);
+  QStringList enforcedHeaders;
+  enforcedHeaders << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) << tr( "GHS3D_ENF_VER_SIZE_COLUMN" ); 
+  mySmpModel->setHorizontalHeaderLabels(enforcedHeaders);
+  myEnforcedTableView->setAlternatingRowColors(true);
+  myEnforcedTableView->verticalHeader()->hide();
+  myEnforcedTableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+  
+  QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup );
+  anSmpLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1);
+  myXCoord = new QLineEdit(myEnfGroup);
+  myXCoord->setValidator(new QDoubleValidator(myEnfGroup));
+  anSmpLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1);
+  QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup );
+  anSmpLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1);
+  myYCoord = new QLineEdit(myEnfGroup);
+  myYCoord->setValidator(new QDoubleValidator(myEnfGroup));
+  anSmpLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1);
+  QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup );
+  anSmpLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1);
+  myZCoord = new QLineEdit(myEnfGroup);
+  myZCoord->setValidator(new QDoubleValidator(myEnfGroup));
+  anSmpLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1);
+  QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_VER_SIZE_LABEL" ), myEnfGroup );
+  anSmpLayout->addWidget(mySizeLabel, ENF_VER_SIZE, 1, 1, 1);
+  mySizeValue = new QLineEdit(myEnfGroup);
+  mySizeValue->setValidator(new QDoubleValidator(myEnfGroup));
+  anSmpLayout->addWidget(mySizeValue, ENF_VER_SIZE, 2, 1, 1);
+
+  addVertexButton = new QPushButton(tr("GHS3D_ENF_VER_VERTEX"),myEnfGroup);
+  anSmpLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2);
+  addVertexButton->setEnabled(false);
+
+  QFrame *line = new QFrame(myEnfGroup);
+  line->setFrameShape(QFrame::HLine);
+  line->setFrameShadow(QFrame::Sunken);
+  anSmpLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2);
+
+  removeVertexButton = new QPushButton(tr("GHS3D_ENF_VER_REMOVE"),myEnfGroup);
+  anSmpLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2);
+          
   // add tabs
   tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
   tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
+  tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) );
   tab->setCurrentIndex( STD_TAB );
 
   // connections
@@ -205,10 +346,108 @@ QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
   connect( myInitialMemoryCheck,    SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
   connect( myBoundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
   connect( dirBtn,                  SIGNAL( clicked() ),       this, SLOT( onDirBtnClicked() ) );
+  connect( myXCoord,                SIGNAL( textChanged(const QString&) ),   this, SLOT( checkVertexIsDefined() ) );
+  connect( myYCoord,                SIGNAL( textChanged(const QString&) ),   this, SLOT( checkVertexIsDefined() ) );
+  connect( myZCoord,                SIGNAL( textChanged(const QString&) ),   this, SLOT( checkVertexIsDefined() ) );
+  connect( mySizeValue,             SIGNAL( textChanged(const QString&) ),   this, SLOT( checkVertexIsDefined() ) );
+  connect( this,                    SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
+  connect( addVertexButton,         SIGNAL( clicked() ),       this, SLOT( onVertexBtnClicked() ) );
+  connect( removeVertexButton,      SIGNAL( clicked() ),       this, SLOT( onRemoveVertexBtnClicked() ) );
+  
+
   
   return fr;
 }
 
+bool GHS3DPluginGUI_HypothesisCreator::smpVertexExists(double x, double y, double z) const
+{
+    const int rowCount = mySmpModel->rowCount();
+    for (int i=0 ; i < rowCount ; i++) {
+      double myX = mySmpModel->data(mySmpModel->index(i, ENF_VER_X_COLUMN)).toDouble();
+      if (myX == x) {
+//         MESSAGE("Found x value " << x << " at row " << i);
+        double myY = mySmpModel->data(mySmpModel->index(i, ENF_VER_Y_COLUMN)).toDouble();
+        if (myY == y) {
+//           MESSAGE("Found y value " << y << " at row " << i);
+          double myZ = mySmpModel->data(mySmpModel->index(i, ENF_VER_Z_COLUMN)).toDouble();
+          if (myZ == z) {
+            MESSAGE("Found x value " << x << " at row " << i);
+            MESSAGE("Found y value " << y << " at row " << i);
+            MESSAGE("Found z value " << z << " at row " << i);
+            return true;
+          }
+        }
+      }
+    }
+//     MESSAGE("Not found x,y,z values: " << x << " " << y << " " << z);
+    return false;
+}
+
+bool GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
+{
+  bool val = (!myXCoord->text().isEmpty())&&(!myYCoord->text().isEmpty())&&(!myZCoord->text().isEmpty())&&(!mySizeValue->text().isEmpty());
+  bool isDefined = val;
+  if (val)
+    isDefined = not smpVertexExists(myXCoord->text().toDouble(),myYCoord->text().toDouble(),myZCoord->text().toDouble());
+
+  emit vertexDefined(isDefined);
+  return isDefined;
+}
+
+void GHS3DPluginGUI_HypothesisCreator::onVertexBtnClicked()
+{
+    MESSAGE("GHS3DPluginGUI_HypothesisCreator::onVertexBtnClicked()");
+    const int row = mySmpModel->rowCount() ;
+    double x = myXCoord->text().toDouble();
+    double y = myYCoord->text().toDouble();
+    double z = myZCoord->text().toDouble();
+    double size = mySizeValue->text().toDouble();
+    
+    if (smpVertexExists(x,y,z)) return;
+    
+//     double size = 10.0;
+    // ENF_VER_X_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_X_COLUMN),x);
+    mySmpModel->setItem( row, ENF_VER_X_COLUMN, new QStandardItem(QString::number(x)) );
+    mySmpModel->item( row, ENF_VER_X_COLUMN )->setFlags( Qt::ItemIsSelectable );
+    // ENF_VER_Y_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_Y_COLUMN),y);
+    mySmpModel->setItem( row, ENF_VER_Y_COLUMN, new QStandardItem(QString::number(y)) );
+    mySmpModel->item( row, ENF_VER_Y_COLUMN )->setFlags( Qt::ItemIsSelectable );
+    // ENF_VER_Z_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_Z_COLUMN),z);
+    mySmpModel->setItem( row, ENF_VER_Z_COLUMN, new QStandardItem(QString::number(z)) );
+    mySmpModel->item( row, ENF_VER_Z_COLUMN )->setFlags( Qt::ItemIsSelectable );
+    // ENF_VER_SIZE_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_SIZE_COLUMN),size);
+    mySmpModel->setItem( row, ENF_VER_SIZE_COLUMN, new QStandardItem(QString::number(size,'f')) );
+
+    myEnforcedTableView->clearSelection();
+    myEnforcedTableView->scrollTo( mySmpModel->item( row, ENF_VER_SIZE_COLUMN )->index() );
+    checkVertexIsDefined();
+}
+
+void GHS3DPluginGUI_HypothesisCreator::onRemoveVertexBtnClicked()
+{
+    QList<int> selectedRows;
+    QList<QModelIndex> selectedIndex = myEnforcedTableView->selectionModel()->selectedIndexes();
+    int row;
+    QModelIndex index;
+    foreach( index, selectedIndex ) {
+        row = index.row();
+        if ( !selectedRows.contains( row ) ) 
+        selectedRows.append( row );
+    }
+    qSort( selectedRows );
+    QListIterator<int> it( selectedRows );
+    it.toBack();
+    while ( it.hasPrevious() ) {
+        row = it.previous();
+        MESSAGE("delete row #"<< row);
+        mySmpModel->removeRow(row );
+    }
+    myEnforcedTableView->clearSelection();
+}
 void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
 {
   QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myWorkingDir->text(), QString() );
@@ -224,39 +463,73 @@ void GHS3DPluginGUI_HypothesisCreator::updateWidgets()
   myOptimizationLevelCombo->setEnabled( !myBoundaryRecoveryCheck->isChecked() );
 }
 
-bool GHS3DPluginGUI_HypothesisCreator::checkParams() const
+bool GHS3DPluginGUI_HypothesisCreator::checkParams(QString& msg) const
 {
+  MESSAGE("GHS3DPluginGUI_HypothesisCreator::checkParams");
+
   if ( !QFileInfo( myWorkingDir->text().trimmed() ).isWritable() ) {
     SUIT_MessageBox::warning( dlg(),
                              tr( "SMESH_WRN_WARNING" ),
                              tr( "GHS3D_PERMISSION_DENIED" ) );
     return false;
   }
+
   return true;
 }
 
 void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
 {
+  MESSAGE("GHS3DPluginGUI_HypothesisCreator::retrieveParams");
   GHS3DHypothesisData data;
   readParamsFromHypo( data );
 
   if ( myName )
     myName->setText( data.myName );
   
-  myToMeshHolesCheck      ->setChecked    ( data.myToMeshHoles );
-  myOptimizationLevelCombo->setCurrentIndex( data.myOptimizationLevel );
-  myMaximumMemoryCheck    ->setChecked    ( data.myMaximumMemory > 0 );
-  myMaximumMemorySpin     ->setValue      ( qMax( data.myMaximumMemory,
-                                                 myMaximumMemorySpin->minimum() ));
-  myInitialMemoryCheck    ->setChecked    ( data.myInitialMemory > 0 );
-  myInitialMemorySpin     ->setValue      ( qMax( data.myInitialMemory,
-                                                 myInitialMemorySpin->minimum() ));
-  myWorkingDir            ->setText       ( data.myWorkingDir );
-  myKeepFiles             ->setChecked    ( data.myKeepFiles );
-  myVerboseLevelSpin      ->setValue      ( data.myVerboseLevel );
-  myToCreateNewNodesCheck ->setChecked    ( data.myToCreateNewNodes );
-  myBoundaryRecoveryCheck ->setChecked    ( data.myBoundaryRecovery );
-  myTextOption            ->setText       ( data.myTextOption );
+  myToMeshHolesCheck               ->setChecked    ( data.myToMeshHoles );
+  myOptimizationLevelCombo         ->setCurrentIndex( data.myOptimizationLevel );
+  myMaximumMemoryCheck             ->setChecked    ( data.myMaximumMemory > 0 );
+  myMaximumMemorySpin              ->setValue      ( qMax( data.myMaximumMemory,
+                                                                                        myMaximumMemorySpin->minimum() ));
+  myInitialMemoryCheck             ->setChecked    ( data.myInitialMemory > 0 );
+  myInitialMemorySpin              ->setValue      ( qMax( data.myInitialMemory,
+                                                                                        myInitialMemorySpin->minimum() ));
+  myWorkingDir                     ->setText       ( data.myWorkingDir );
+  myKeepFiles                      ->setChecked    ( data.myKeepFiles );
+  myVerboseLevelSpin               ->setValue      ( data.myVerboseLevel );
+  myToCreateNewNodesCheck          ->setChecked    ( data.myToCreateNewNodes );
+  myRemoveInitialCentralPointCheck ->setChecked    ( data.myRemoveInitialCentralPoint );
+  myBoundaryRecoveryCheck          ->setChecked    ( data.myBoundaryRecovery );
+  myFEMCorrectionCheck             ->setChecked    ( data.myFEMCorrection );
+  myTextOption                     ->setText       ( data.myTextOption );
+
+  TEnforcedVertexValues::const_iterator it;
+  int row = 0;
+  for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
+  {
+    double x = it->at(0);
+    double y = it->at(1);
+    double z = it->at(2);
+    double size = it->at(3);
+    // ENF_VER_X_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_X_COLUMN),x);
+    mySmpModel->setItem( row, ENF_VER_X_COLUMN, new QStandardItem(QString::number(x)) );
+    mySmpModel->item( row, ENF_VER_X_COLUMN )->setFlags( Qt::ItemIsSelectable );
+    // ENF_VER_Y_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_Y_COLUMN),y);
+    mySmpModel->setItem( row, ENF_VER_Y_COLUMN, new QStandardItem(QString::number(y)) );
+    mySmpModel->item( row, ENF_VER_Y_COLUMN )->setFlags( Qt::ItemIsSelectable );
+    // ENF_VER_Z_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_Z_COLUMN),z);
+    mySmpModel->setItem( row, ENF_VER_Z_COLUMN, new QStandardItem(QString::number(z)) );
+    mySmpModel->item( row, ENF_VER_Z_COLUMN )->setFlags( Qt::ItemIsSelectable );
+    // ENF_VER_SIZE_COLUMN
+    mySmpModel->setData(mySmpModel->index(row, ENF_VER_SIZE_COLUMN),size);
+    mySmpModel->setItem( row, ENF_VER_SIZE_COLUMN, new QStandardItem(QString::number(size)) );
+
+    MESSAGE("Row " << row << ": (" << x << ","<< y << ","<< z << ") ="<< size);
+    row++;
+  }
   
   GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
   that->updateWidgets();
@@ -264,68 +537,111 @@ void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
 
 QString GHS3DPluginGUI_HypothesisCreator::storeParams() const
 {
-  GHS3DHypothesisData data;
-  readParamsFromWidgets( data );
-  storeParamsToHypo( data );
-  
-  QString valStr = "";
-
-  if ( !data.myBoundaryRecovery )
-    valStr = "-c " + QString::number( !data.myToMeshHoles );
-
-  if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 4 && !data.myBoundaryRecovery) {
-    char* level[] = { "none" , "light" , "standard" , "strong" };
-    valStr += " -o ";
-    valStr += level[ data.myOptimizationLevel ];
-  }
-  if ( data.myMaximumMemory > 0 ) {
-    valStr += " -m ";
-    valStr += QString::number( data.myMaximumMemory );
-  }
-  if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
-    valStr += " -M ";
-    valStr += QString::number( data.myInitialMemory );
-  }
-  valStr += " -v ";
-  valStr += QString::number( data.myVerboseLevel );
-
-  if ( !data.myToCreateNewNodes )
-    valStr += " -p0";
-
-  if ( data.myBoundaryRecovery )
-    valStr += " -C";
-
-  valStr += " ";
-  valStr += data.myTextOption;
-
+    MESSAGE("GHS3DPluginGUI_HypothesisCreator::storeParams");
+    GHS3DHypothesisData data;
+    readParamsFromWidgets( data );
+    storeParamsToHypo( data );
+    
+    QString valStr = "";
+    
+    if ( !data.myBoundaryRecovery )
+        valStr = "-c " + QString::number( !data.myToMeshHoles );
+    
+    if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 5 && !data.myBoundaryRecovery) {
+        char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
+        valStr += " -o ";
+        valStr += level[ data.myOptimizationLevel ];
+    }
+    if ( data.myMaximumMemory > 0 ) {
+        valStr += " -m ";
+        valStr += QString::number( data.myMaximumMemory );
+    }
+    if ( data.myInitialMemory > 0 && !data.myBoundaryRecovery ) {
+        valStr += " -M ";
+        valStr += QString::number( data.myInitialMemory );
+    }
+    valStr += " -v ";
+    valStr += QString::number( data.myVerboseLevel );
+    
+    if ( !data.myToCreateNewNodes )
+        valStr += " -p0";
+    
+    if ( data.myRemoveInitialCentralPoint )
+        valStr += " -no_initial_central_point";
+    
+    if ( data.myBoundaryRecovery )
+        valStr += " -C";
+    
+    if ( data.myFEMCorrection )
+        valStr += " -FEM";
+    
+    valStr += " ";
+    valStr += data.myTextOption;
+    
+    valStr += " #BEGIN ENFORCED VERTICES#";
+    // Add size map parameters storage
+    for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
+        valStr += " (";
+        double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
+        double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
+        double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
+        double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
+        valStr += QString::number( x );
+        valStr += ",";
+        valStr += QString::number( y );
+        valStr += ",";
+        valStr += QString::number( z );
+        valStr += ")=";
+        valStr += QString::number( size );
+        if (i!=mySmpModel->rowCount()-1)
+            valStr += ";";
+    }
+    valStr += " #END ENFORCED VERTICES#";
+    MESSAGE(valStr.toStdString());
   return valStr;
 }
 
 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const
 {
+  MESSAGE("GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo");
   GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
     GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( initParamsHypothesis() );
 
   HypothesisData* data = SMESH::GetHypothesisData( hypType() );
   h_data.myName = isCreation() && data ? hypName() : "";
 
-  h_data.myToMeshHoles       = h->GetToMeshHoles();
-  h_data.myMaximumMemory     = h->GetMaximumMemory();
-  h_data.myInitialMemory     = h->GetInitialMemory();
-  h_data.myInitialMemory     = h->GetInitialMemory();
-  h_data.myOptimizationLevel = h->GetOptimizationLevel();
-  h_data.myKeepFiles         = h->GetKeepFiles();
-  h_data.myWorkingDir        = h->GetWorkingDirectory();
-  h_data.myVerboseLevel      = h->GetVerboseLevel();
-  h_data.myToCreateNewNodes  = h->GetToCreateNewNodes();
-  h_data.myBoundaryRecovery  = h->GetToUseBoundaryRecoveryVersion();
-  h_data.myTextOption        = h->GetTextOption();
+  h_data.myToMeshHoles                = h->GetToMeshHoles();
+  h_data.myMaximumMemory              = h->GetMaximumMemory();
+  h_data.myInitialMemory              = h->GetInitialMemory();
+  h_data.myInitialMemory              = h->GetInitialMemory();
+  h_data.myOptimizationLevel          = h->GetOptimizationLevel();
+  h_data.myKeepFiles                  = h->GetKeepFiles();
+  h_data.myWorkingDir                 = h->GetWorkingDirectory();
+  h_data.myVerboseLevel               = h->GetVerboseLevel();
+  h_data.myToCreateNewNodes           = h->GetToCreateNewNodes();
+  h_data.myRemoveInitialCentralPoint  = h->GetToRemoveCentralPoint();
+  h_data.myBoundaryRecovery           = h->GetToUseBoundaryRecoveryVersion();
+  h_data.myFEMCorrection              = h->GetFEMCorrection();
+  h_data.myTextOption                 = h->GetTextOption();
   
+  GHS3DPlugin::GHS3DEnforcedVertexList_var vertices = h->GetEnforcedVertices();
+  MESSAGE("vertices->length(): " << vertices->length());
+  h_data.myEnforcedVertices.clear();
+  for (int i=0 ; i<vertices->length() ; i++) {
+    GHS3DEnforcedVertex myVertex;
+    myVertex.push_back(vertices[i].x);
+    myVertex.push_back(vertices[i].y);
+    myVertex.push_back(vertices[i].z);
+    myVertex.push_back(vertices[i].size);
+    MESSAGE("Add enforced vertex ("<< myVertex[0] << ","<< myVertex[1] << ","<< myVertex[2] << ") ="<< myVertex[3]);
+    h_data.myEnforcedVertices.push_back(myVertex);
+  }
   return true;
 }
 
 bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const
 {
+  MESSAGE("GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo");
   GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
     GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
 
@@ -353,10 +669,63 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD
       h->SetVerboseLevel     ( h_data.myVerboseLevel );
     if ( h->GetToCreateNewNodes() != h_data.myToCreateNewNodes )
       h->SetToCreateNewNodes( h_data.myToCreateNewNodes );
+    if ( h->GetToRemoveCentralPoint() != h_data.myRemoveInitialCentralPoint )
+      h->SetToRemoveCentralPoint( h_data.myRemoveInitialCentralPoint );
     if ( h->GetToUseBoundaryRecoveryVersion() != h_data.myBoundaryRecovery )
       h->SetToUseBoundaryRecoveryVersion( h_data.myBoundaryRecovery );
+    if ( h->GetFEMCorrection() != h_data.myFEMCorrection )
+      h->SetFEMCorrection( h_data.myFEMCorrection );
     if ( h->GetTextOption() != h_data.myTextOption )
       h->SetTextOption       ( h_data.myTextOption.toLatin1().constData() );
+    
+    int nbVertex = (int) h_data.myEnforcedVertices.size();
+    GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
+    int nbVertexHyp = vertexHyp->length();
+    
+    MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices");
+    MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp);
+    
+    // Some vertices were removed
+    if (nbVertex < nbVertexHyp) {
+//        if (nbVertex == 0)
+//            h->ClearEnforcedVertices();
+//        else {
+            // iterate over vertices of hypo
+            for(int i = 0 ; i <nbVertexHyp ; i++) {
+                double x = vertexHyp[i].x;
+                double y = vertexHyp[i].y;
+                double z = vertexHyp[i].z;
+                // vertex is removed
+                if (!smpVertexExists(x,y,z))
+                    h->RemoveEnforcedVertex(x,y,z);
+            }
+//        }
+    }
+    
+    TEnforcedVertexValues::const_iterator it;
+    for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
+      double x = it->at(0);
+      double y = it->at(1);
+      double z = it->at(2);
+      double size = it->at(3);
+      MESSAGE("(" << x   << ", "
+                       << y   << ", "
+                       << z   << ") = "
+                       << size  );
+      double mySize;
+      try {
+        mySize = h->GetEnforcedVertex(x,y,z);
+        MESSAGE("Old size: " << mySize);
+        if (mySize != size) {
+          MESSAGE("Setting new size: " << size);
+          h->SetEnforcedVertex(x,y,z,size);
+        }
+      }
+      catch (...) {
+        MESSAGE("Setting new size: " << size);
+        h->SetEnforcedVertex(x,y,z,size);
+      }
+    }
   }
   catch ( const SALOME::SALOME_Exception& ex )
   {
@@ -368,17 +737,34 @@ bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisD
 
 bool GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets( GHS3DHypothesisData& h_data ) const
 {
-  h_data.myName              = myName ? myName->text() : "";
-  h_data.myToMeshHoles       = myToMeshHolesCheck->isChecked();
-  h_data.myMaximumMemory     = myMaximumMemoryCheck->isChecked() ? myMaximumMemorySpin->value() : -1;
-  h_data.myInitialMemory     = myInitialMemoryCheck->isChecked() ? myInitialMemorySpin->value() : -1;
-  h_data.myOptimizationLevel = myOptimizationLevelCombo->currentIndex();
-  h_data.myKeepFiles         = myKeepFiles->isChecked();
-  h_data.myWorkingDir        = myWorkingDir->text().trimmed();
-  h_data.myVerboseLevel      = myVerboseLevelSpin->value();
-  h_data.myToCreateNewNodes  = myToCreateNewNodesCheck->isChecked();
-  h_data.myBoundaryRecovery  = myBoundaryRecoveryCheck->isChecked();
-  h_data.myTextOption        = myTextOption->text();
+  MESSAGE("GHS3DPluginGUI_HypothesisCreator::readParamsFromWidgets");
+  h_data.myName                       = myName ? myName->text() : "";
+  h_data.myToMeshHoles                = myToMeshHolesCheck->isChecked();
+  h_data.myMaximumMemory              = myMaximumMemoryCheck->isChecked() ? myMaximumMemorySpin->value() : -1;
+  h_data.myInitialMemory              = myInitialMemoryCheck->isChecked() ? myInitialMemorySpin->value() : -1;
+  h_data.myOptimizationLevel          = myOptimizationLevelCombo->currentIndex();
+  h_data.myKeepFiles                  = myKeepFiles->isChecked();
+  h_data.myWorkingDir                 = myWorkingDir->text().trimmed();
+  h_data.myVerboseLevel               = myVerboseLevelSpin->value();
+  h_data.myToCreateNewNodes           = myToCreateNewNodesCheck->isChecked();
+  h_data.myRemoveInitialCentralPoint  = myRemoveInitialCentralPointCheck->isChecked();
+  h_data.myBoundaryRecovery           = myBoundaryRecoveryCheck->isChecked();
+  h_data.myFEMCorrection              = myFEMCorrectionCheck->isChecked();
+  h_data.myTextOption                 = myTextOption->text();
+  h_data.myEnforcedVertices.clear();
+
+  for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
+    GHS3DEnforcedVertex myVertex;
+    myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble());
+    myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble());
+    myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble());
+    myVertex.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble());
+    MESSAGE("Add new enforced vertex (" << myVertex[0] << ", "
+                                             << myVertex[1] << ", "
+                                             << myVertex[2] << ") = "
+                                             << myVertex[3]);
+    h_data.myEnforcedVertices.push_back(myVertex);
+  }
 
   return true;
 }
index 87a9c562d9fbd1ad521317d6d4ca70781ba9a713..4cf1809c454d4cf5bbadb2bb06b9494bbd41e537 100644 (file)
 #endif
 
 #include <SMESHGUI_Hypotheses.h>
+// #include <SalomeApp_DoubleSpinBox.h>
+
+#include <QItemDelegate>
+#include <map>
+#include <vector>
+#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
 
 class QWidget;
 class QComboBox;
 class QCheckBox;
 class QLineEdit;
 class QSpinBox;
+class QStandardItemModel;
+class QTableView;
+class QHeaderView;
+class QDoubleSpinBox;
+
+class LightApp_SelectionMgr;
+
+typedef std::vector<double> GHS3DEnforcedVertex;
+typedef std::vector<GHS3DEnforcedVertex> TEnforcedVertexValues;
 
 typedef struct
 {
-  bool    myToMeshHoles;
-  int     myMaximumMemory;
-  int     myInitialMemory;
-  int     myOptimizationLevel;
-  bool    myKeepFiles;
-  QString myWorkingDir;
-  QString myName;
+  bool    myToMeshHoles,myKeepFiles,myToCreateNewNodes,myBoundaryRecovery,myFEMCorrection,myRemoveInitialCentralPoint;
+  int     myMaximumMemory,myInitialMemory,myOptimizationLevel;
+  QString myName,myWorkingDir,myTextOption;
   short   myVerboseLevel;
-  bool    myToCreateNewNodes;
-  bool    myBoundaryRecovery;
-  QString myTextOption;
-
+  TEnforcedVertexValues myEnforcedVertices;
 } GHS3DHypothesisData;
 
 /*!
@@ -69,7 +77,7 @@ public:
   GHS3DPluginGUI_HypothesisCreator( const QString& );
   virtual ~GHS3DPluginGUI_HypothesisCreator();
 
-  virtual bool     checkParams() const;
+  virtual bool     checkParams(QString& msg) const;
   virtual QString  helpPage() const;
 
 protected:
@@ -82,31 +90,71 @@ protected:
   virtual QString  type() const;
 
 protected slots:
-  void             onDirBtnClicked();
-  void             updateWidgets();
+  void                onDirBtnClicked();
+  void                updateWidgets();
+  void                onVertexBtnClicked();
+  void                onRemoveVertexBtnClicked();
+  bool                checkVertexIsDefined();
+
+signals:
+  void                vertexDefined(bool);
 
 private:
-  bool             readParamsFromHypo( GHS3DHypothesisData& ) const;
-  bool             readParamsFromWidgets( GHS3DHypothesisData& ) const;
-  bool             storeParamsToHypo( const GHS3DHypothesisData& ) const;
+  bool                readParamsFromHypo( GHS3DHypothesisData& ) const;
+  bool                readParamsFromWidgets( GHS3DHypothesisData& ) const;
+  bool                storeParamsToHypo( const GHS3DHypothesisData& ) const;
+  bool                smpVertexExists(double, double, double) const;
 
 private:
-  QWidget*         myStdGroup;
-  QLineEdit*       myName;
-  QCheckBox*       myToMeshHolesCheck;
-  QComboBox*       myOptimizationLevelCombo;
-
-  QWidget*         myAdvGroup;
-  QCheckBox*       myMaximumMemoryCheck;
-  QSpinBox*        myMaximumMemorySpin;
-  QCheckBox*       myInitialMemoryCheck;
-  QSpinBox*        myInitialMemorySpin;
-  QLineEdit*       myWorkingDir;
-  QCheckBox*       myKeepFiles;
-  QSpinBox*        myVerboseLevelSpin;
-  QCheckBox*       myToCreateNewNodesCheck;
-  QCheckBox*       myBoundaryRecoveryCheck;
-  QLineEdit*       myTextOption;
+  QWidget*            myStdGroup;
+  QLineEdit*          myName;
+  QCheckBox*          myToMeshHolesCheck;
+  QComboBox*          myOptimizationLevelCombo;
+
+  QWidget*            myAdvGroup;
+  QCheckBox*          myMaximumMemoryCheck;
+  QSpinBox*           myMaximumMemorySpin;
+  QCheckBox*          myInitialMemoryCheck;
+  QSpinBox*           myInitialMemorySpin;
+  QLineEdit*          myWorkingDir;
+  QCheckBox*          myKeepFiles;
+  QSpinBox*           myVerboseLevelSpin;
+  QCheckBox*          myToCreateNewNodesCheck;
+  QCheckBox*          myRemoveInitialCentralPointCheck;
+  QCheckBox*          myBoundaryRecoveryCheck;
+  QCheckBox*          myFEMCorrectionCheck;
+QLineEdit*            myTextOption;
+  
+  QWidget*            myEnfGroup;
+  QStandardItemModel* mySmpModel;
+  QTableView*         myEnforcedTableView;
+  QLineEdit*          myXCoord;
+  QLineEdit*          myYCoord;
+  QLineEdit*          myZCoord;
+  QLineEdit*          mySizeValue;
+  QPushButton*        addVertexButton;
+  QPushButton*        removeVertexButton;
+  
+  LightApp_SelectionMgr*  mySelectionMgr;          /* User shape selection */
+//   SVTK_Selector*          mySelector;
+};
+
+class DoubleLineEditDelegate : public QItemDelegate
+{
+    Q_OBJECT
+
+public:
+    DoubleLineEditDelegate(QObject *parent = 0);
+
+    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
+                        const QModelIndex &index) const;
+
+    void setEditorData(QWidget *editor, const QModelIndex &index) const;
+    void setModelData(QWidget *editor, QAbstractItemModel *model,
+                    const QModelIndex &index) const;
+
+    void updateEditorGeometry(QWidget *editor,
+        const QStyleOptionViewItem &option, const QModelIndex &index) const;
 };
 
 #endif
index cf795b89ecf21a0a1129043f76207c2279f21bd7..5edbd49959160fbfd881483ed38f8cca7f369b9d 100644 (file)
             <source>KEEP_WORKING_FILES</source>
             <translation>To keep working files</translation>
         </message>
+        <message>
+            <source>LEVEL_NONE</source>
+            <translation>None</translation>
+        </message>
         <message>
             <source>LEVEL_LIGHT</source>
             <translation>Light</translation>
@@ -67,8 +71,8 @@
             <translation>Medium (standard)</translation>
         </message>
         <message>
-            <source>LEVEL_NONE</source>
-            <translation>None</translation>
+            <source>LEVEL_STANDARDPLUS</source>
+            <translation>Standard+</translation>
         </message>
         <message>
             <source>LEVEL_STRONG</source>
             <source>MEGABYTE</source>
             <translation>Megabytes</translation>
         </message>
+        <message>
+            <source>NO_INITIAL_CENTRAL_POINT</source>
+            <translation>To remove initial central point</translation>
+        </message>
         <message>
             <source>RECOVERY_VERSION</source>
             <translation>To use boundary recovery version</translation>
         </message>
+        <message>
+            <source>FEM_CORRECTION</source>
+            <translation>To use FEM correction</translation>
+        </message>
         <message>
             <source>SELECT_DIR</source>
             <translation>...</translation>
             <source>WORKING_DIR</source>
             <translation>Working directory</translation>
         </message>
+        <message>
+            <source>GHS3D_ENFORCED_VERTICES</source>
+            <translation>Enforced vertices</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_X_COLUMN</source>
+            <translation>X</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_Y_COLUMN</source>
+            <translation>Y</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_Z_COLUMN</source>
+            <translation>Z</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_SIZE_COLUMN</source>
+            <translation>Size</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_X_LABEL</source>
+            <translation>X:</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_Y_LABEL</source>
+            <translation>Y:</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_Z_LABEL</source>
+            <translation>Z:</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_SIZE_LABEL</source>
+            <translation>Size:</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_VERTEX</source>
+            <translation>Add enforced vertex</translation>
+        </message>
+        <message>
+            <source>GHS3D_ENF_VER_REMOVE</source>
+            <translation>Remove vertex</translation>
+        </message>
     </context>
 </TS>
index 0bf2ab946183832b309406d6a1e495f0232c8d6e..a255ca183f859755f139767fe69d88ab1eb3e09b 100644 (file)
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
 # header files 
-salomeinclude_HEADERS =
+salomeinclude_HEADERS = 
 
 # Libraries targets
 lib_LTLIBRARIES = libGHS3DPluginGUI.la
 
-dist_libGHS3DPluginGUI_la_SOURCES = GHS3DPluginGUI_HypothesisCreator.cxx
+dist_libGHS3DPluginGUI_la_SOURCES = GHS3DPluginGUI_HypothesisCreator.cxx 
 
 MOC_FILES = GHS3DPluginGUI_HypothesisCreator_moc.cxx
 nodist_libGHS3DPluginGUI_la_SOURCES= $(MOC_FILES)