*/
module GHS3DPlugin
{
+ struct GHS3DEnforcedVertex {
+ double x;
+ double y;
+ double z;
+ double size;
+ };
+
+ typedef sequence<GHS3DEnforcedVertex> GHS3DEnforcedVertexList;
/*!
* GHS3DPlugin_GHS3D: interface of "Tetrahedron (GHS3D)" algorithm
*/
*/
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();
};
};
#include "GHS3DPlugin_GHS3D.hxx"
#include "GHS3DPlugin_Hypothesis.hxx"
+
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_Comment.hxx"
#ifdef _DEBUG_
#define DUMP(txt) \
-// cout << txt
+// std::cout << txt
#else
#define DUMP(txt)
#endif
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);
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++ ) {
for ( int j=0; j<=nbNodes; j++)
theFile << space << dummyint;
- theFile << endl;
+ theFile << std::endl;
}
}
}
-
+
+
delete [] tabID;
delete [] tabShape;
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
for ( int i=0; i<=nbNodes; i++)
theFile << space << dummyint;
- theFile << endl;
+ theFile << std::endl;
}
// put nodes to theNodeByGhs3dId vector
//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:
//
int nbNodes = theMesh->NbNodes();
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 << 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
// 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;
}
//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
// 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;
}
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;
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 ));
}
// 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 (...) {}
#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
#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;
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;
}
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();
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
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 {
aResultFileName.ToCString(),
#endif
theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
- toMeshHoles );
+ toMeshHoles, nbEnforcedVertices );
}
// ---------------------
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;
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();
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 {
#ifdef WNT
aResultFileName.ToCString(),
#endif
- meshDS, theShape ,aNodeByGhs3dId );
+ meshDS, theShape ,aNodeByGhs3dId, nbEnforcedVertices );
}
// ---------------------
return true;
}
+
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);
//=======================================================================
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();
}
//=======================================================================
//function : SetWorkingDirectory
//=======================================================================
-void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const string& path)
+void GHS3DPlugin_Hypothesis::SetWorkingDirectory(const std::string& path)
{
if ( myWorkingDirectory != path ) {
myWorkingDirectory = path;
//function : GetWorkingDirectory
//=======================================================================
-string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const
+std::string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const
{
return myWorkingDirectory;
}
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;
//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
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
//function : DefaultWorkingDirectory
//=======================================================================
-string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory()
+std::string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory()
{
TCollection_AsciiString aTmpDir;
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 << " ";
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;
}
//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;
}
*/
//================================================================================
-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;
// 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 ];
}
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 += " ";
*/
//================================================================================
-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+='\\';
return aGenericName.ToCString();
}
+
+
+//================================================================================
+/*!
+* \brief Return the enforced vertices
+*/
+//================================================================================
+
+GHS3DPlugin_Hypothesis::TEnforcedVertexValues GHS3DPlugin_Hypothesis::GetEnforcedVertices(const GHS3DPlugin_Hypothesis* hyp)
+{
+ return hyp ? hyp->_GetEnforcedVertices():DefaultEnforcedVertices();
+}
+
#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
{
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.
*/
*/
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)
* \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
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;
};
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
//=======================================================================
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
*/
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();
#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 {
}
}
+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 )
{
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 );
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
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() );
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();
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() );
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 )
{
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;
}
#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;
/*!
GHS3DPluginGUI_HypothesisCreator( const QString& );
virtual ~GHS3DPluginGUI_HypothesisCreator();
- virtual bool checkParams() const;
+ virtual bool checkParams(QString& msg) const;
virtual QString helpPage() const;
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
<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>
<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>
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)