#ifndef _GHS3D_Algorithm_IDL_
#define _GHS3D_Algorithm_IDL_
+#include "SALOME_Exception.idl"
#include "SMESH_Hypothesis.idl"
/*!
{
};
+ /*!
+ * Parameters of "Tetrahedron (GHS3D)" algorithm
+ */
+ interface GHS3DPlugin_Hypothesis : SMESH::SMESH_Hypothesis
+ {
+ /*!
+ * To mesh "holes" in a solid or not. Default is to mesh.
+ */
+ void SetToMeshHoles(in boolean toMesh);
+ boolean GetToMeshHoles();
+ /*!
+ * Maximal size of memory to be used by the algorithm (in Megabytes).
+ * Negative value means not to use this option
+ */
+ void SetMaximumMemory(in short MB);
+ short GetMaximumMemory();
+ /*!
+ * Initial size of memory to be used by the algorithm (in Megabytes) in
+ * automatic memory adjustment mode. Default is zero.
+ * Negative value means not to use this option
+ */
+ void SetInitialMemory(in short MB);
+ short GetInitialMemory();
+ /*!
+ * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium
+ */
+ void SetOptimizationLevel(in short level) raises (SALOME::SALOME_Exception);
+ short GetOptimizationLevel();
+ /*!
+ * Path to working directory
+ */
+ void SetWorkingDirectory(in string path) raises (SALOME::SALOME_Exception);
+ string GetWorkingDirectory();
+ /*!
+ * To keep working files or remove them. Log file remains in case of errors anyway.
+ */
+ void SetKeepFiles(in boolean toKeep);
+ boolean GetKeepFiles();
+ };
};
#endif
<meshers-group name="GHS3D"
resources="GHS3DPlugin"
- server-lib="libGHS3DEngine.so"
- gui-lib="">
+ server-lib="GHS3DEngine"
+ gui-lib="GHS3DPluginGUI">
+ <hypotheses>
+ <hypothesis type="GHS3D_Parameters"
+ label-id="GHS3D Parameters"
+ icon-id="mesh_hypo_ghs3d.png"
+ dim="3"/>
+ </hypotheses>
<algorithms>
<algorithm type="GHS3D_3D"
label-id="Tetrahedron (GHS3D)"
- icon-id="mesh_algo_tetra.png"
+ icon-id="mesh_tree_hypo_ghs3d.png"
input="TRIA,QUAD"
need-geom="false"
+ hypos="GHS3D_Parameters"
dim="3"/>
</algorithms>
</meshers-group>
include $(top_srcdir)/adm_local/unix/make_common_starter.am
dist_salomeres_DATA = \
- GHS3DPlugin.xml
+ GHS3DPlugin.xml \
+ mesh_hypo_ghs3d.png \
+ mesh_tree_hypo_ghs3d.png
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS, L3S, LJLL, MENSI
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//=============================================================================
+// File : GHS3DPlugin_Defs.hxx
+// Author : Alexander A. BORODIN
+
+#ifndef _GHS3DPlugin_DEFS_HXX_
+#define _GHS3DPlugin_DEFS_HXX_
+
+#ifdef WIN32
+ #ifdef GHS3DPLUGIN_EXPORTS
+ #define GHS3DPLUGIN_EXPORT __declspec( dllexport )
+ #else
+ #define GHS3DPLUGIN_EXPORT __declspec( dllimport )
+ #endif
+#else
+ #define GHS3DPLUGIN_EXPORT
+#endif
+
+#endif
using namespace std;
#include "GHS3DPlugin_GHS3D.hxx"
+#include "GHS3DPlugin_Hypothesis.hxx"
+
#include "SMESH_Gen.hxx"
#include "SMESH_Mesh.hxx"
#include "SMESH_Comment.hxx"
_onlyUnaryInput = false; // Compute() will be called on a compound of solids
_iShape=0;
_nbShape=0;
+ _compatibleHypothesis.push_back("GHS3D_Parameters");
}
//=============================================================================
*/
//=============================================================================
-bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
- SMESH_Hypothesis::Hypothesis_Status& aStatus )
+bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ Hypothesis_Status& aStatus )
{
-// MESSAGE("GHS3DPlugin_GHS3D::CheckHypothesis");
aStatus = SMESH_Hypothesis::HYP_OK;
+
+ // there is only one compatible Hypothesis so far
+ _hyp = 0;
+ _keepFiles = false;
+ const list <const SMESHDS_Hypothesis * >& hyps = GetUsedHypothesis(aMesh, aShape);
+ if ( !hyps.empty() )
+ _hyp = static_cast<const GHS3DPlugin_Hypothesis*> ( hyps.front() );
+ if ( _hyp )
+ _keepFiles = _hyp->GetKeepFiles();
+
return true;
}
int nbTriangle;
int ID, shapeID, ghs3dShapeID;
int IdShapeRef = 1;
- int compoundID = theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() );
+ int compoundID =
+ nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() );
int *tab, *tabID, *nodeID, *nodeAssigne;
double *coord;
theMeshDS->SetNodeInVolume( node[i], shapeID );
}
theMeshDS->SetMeshElementOnShape( aTet, shapeID );
- if ( (iElem + 1) == nbElems )
- cout << nbElems << " tetrahedrons have been associated to " << nbShape << " shapes" << endl;
}
+ if ( nbElems )
+ cout << nbElems << " tetrahedrons have been associated to " << nbShape << " shapes" << endl;
munmap(mapPtr, length);
close(fileOpen);
return true;
}
-//=======================================================================
-//function : getTmpDir
-//purpose :
-//=======================================================================
-
-static TCollection_AsciiString getTmpDir()
-{
- TCollection_AsciiString aTmpDir;
-
- char *Tmp_dir = getenv("SALOME_TMP_DIR");
- if(Tmp_dir != NULL) {
- aTmpDir = Tmp_dir;
-#ifdef WIN32
- if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
-#else
- if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
-#endif
- }
- else {
-#ifdef WIN32
- aTmpDir = TCollection_AsciiString("C:\\");
-#else
- aTmpDir = TCollection_AsciiString("/tmp/");
-#endif
- }
- return aTmpDir;
-}
-
//================================================================================
/*!
* \brief Look for a line containing a text in a file
iShape++;
}
- cout << endl;
- cout << "Ghs3d execution..." << endl;
-
- // make a unique working file name
+ // a unique working file name
// to avoid access to the same files by eg different users
-
- TCollection_AsciiString aGenericName, aTmpDir = getTmpDir();
- aGenericName = aTmpDir + "GHS3D_";
-#ifdef WIN32
- aGenericName += GetCurrentProcessId();
-#else
- aGenericName += getpid();
-#endif
- aGenericName += "_";
- aGenericName += meshDS->ShapeToIndex( theShape );
+ TCollection_AsciiString aGenericName
+ = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
#endif
if (!Ok) {
- INFOS( "Can't write into " << aTmpDir.ToCString());
- return error(SMESH_Comment("Can't write into ") << aTmpDir);
+ INFOS( "Can't write into " << aFacesFileName);
+ return error(SMESH_Comment("Can't write into ") << aFacesFileName);
}
map <int,int> aSmdsToGhs3dIdMap;
map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
aPointsFile.close();
if ( ! Ok ) {
- if ( !getenv("GHS3D_KEEP_FILES") ) {
+ if ( !_keepFiles ) {
OSD_File( aFacesFileName ).Remove();
OSD_File( aPointsFileName ).Remove();
}
}
// -----------------
- // run ghs3d mesher WIN32???
+ // run ghs3d mesher
// -----------------
- // ghs3d need to know amount of memory it may use (MB).
- // Default memory is defined at ghs3d installation but it may be not enough,
- // so allow to use about all available memory
-
- TCollection_AsciiString memory;
-#ifndef WIN32
- struct sysinfo si;
- int err = sysinfo( &si );
- if ( err == 0 ) {
- int freeMem = si.totalram * si.mem_unit / 1024 / 1024;
- memory = "-m ";
- memory += int( 0.7 * freeMem );
- }
-#endif
+ TCollection_AsciiString cmd( (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
+ cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
+ cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
- MESSAGE("GHS3DPlugin_GHS3D::Compute");
- TCollection_AsciiString cmd( "ghs3d " ); // command to run
- cmd +=
- memory + // memory
- " -c0 -f " + aGenericName + // file to read
- " 1>" + aLogFileName; // dump into file
+ cout << endl;
+ cout << "Ghs3d execution..." << endl;
+ cout << cmd << endl;
system( cmd.ToCString() ); // run
if ( Ok )
{
- OSD_File( aLogFileName ).Remove();
+ if ( !_keepFiles )
+ OSD_File( aLogFileName ).Remove();
}
else if ( OSD_File( aLogFileName ).Size() > 0 )
{
foundLine.LeftAdjust();
comment << foundLine;
}
- if ( findLineContaing( "%% ERROR",aLogFileName,foundLine))
+ if ( findLineContaing( "%% ERROR",aLogFileName,foundLine) ||
+ findLineContaing( " ERR ",aLogFileName,foundLine))
{
foundLine.LeftAdjust();
comment << foundLine;
}
- if ( findLineContaing( "%% NO SAVING OPERATION",aLogFileName,foundLine))
+ else if ( findLineContaing( "%% NO SAVING OPERATION",aLogFileName,foundLine))
{
comment << "Too many elements generated for a trial version.\n";
}
error(COMPERR_ALGO_FAILED, "ghs3d: command not found" );
}
- if ( !getenv("GHS3D_KEEP_FILES") ) {
+ if ( !_keepFiles ) {
OSD_File( aFacesFileName ).Remove();
OSD_File( aPointsFileName ).Remove();
OSD_File( aResultFileName ).Remove();
SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
TopoDS_Shape theShape = aHelper->GetSubShape();
- // make a unique working file name
+ // a unique working file name
// to avoid access to the same files by eg different users
-
- TCollection_AsciiString aGenericName, aTmpDir = getTmpDir();
- aGenericName = aTmpDir + "GHS3D_";
-#ifdef WIN32
- aGenericName += GetCurrentProcessId();
-#else
- aGenericName += getpid();
-#endif
- aGenericName += "_";
- aGenericName += meshDS->ShapeToIndex( theShape );
+ TCollection_AsciiString aGenericName
+ = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
#endif
if (!Ok)
- return error( SMESH_Comment("Can't write into ") << aTmpDir.ToCString());
+ return error( SMESH_Comment("Can't write into ") << aPointsFileName);
vector <const SMDS_MeshNode*> aNodeByGhs3dId;
aPointsFile.close();
if ( ! Ok ) {
- if ( !getenv("GHS3D_KEEP_FILES") ) {
+ if ( !_keepFiles ) {
OSD_File( aFacesFileName ).Remove();
OSD_File( aPointsFileName ).Remove();
}
}
// -----------------
- // run ghs3d mesher WIN32???
+ // run ghs3d mesher
// -----------------
- // ghs3d need to know amount of memory it may use (MB).
- // Default memory is defined at ghs3d installation but it may be not enough,
- // so allow to use about all available memory
- TCollection_AsciiString memory;
-#ifdef WIN32
- // ????
-#else
- struct sysinfo si;
- int err = sysinfo( &si );
- if ( !err ) {
- int freeMem = si.totalram * si.mem_unit / 1024 / 1024;
- memory = "-m ";
- memory += int( 0.7 * freeMem );
- }
-#endif
-
- TCollection_AsciiString cmd( "ghs3d " ); // command to run
- cmd +=
- memory + // memory
- " -f " + aGenericName + // file to read
- " 1>" + aLogFileName; // dump into file
-
-
+ TCollection_AsciiString cmd( (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
+ cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
+ cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
system( cmd.ToCString() ); // run
if ( Ok )
{
- OSD_File( aLogFileName ).Remove();
+ if ( !_keepFiles )
+ OSD_File( aLogFileName ).Remove();
}
else if ( OSD_File( aLogFileName ).Size() > 0 )
{
foundLine.LeftAdjust();
comment << foundLine;
}
- if ( findLineContaing( "%% ERROR",aLogFileName,foundLine))
+ if ( findLineContaing( "%% ERROR",aLogFileName,foundLine) ||
+ findLineContaing( " ERR ",aLogFileName,foundLine))
{
foundLine.LeftAdjust();
comment << foundLine;
}
- if ( findLineContaing( "%% NO SAVING OPERATION",aLogFileName,foundLine))
+ else if ( findLineContaing( "%% NO SAVING OPERATION",aLogFileName,foundLine))
{
comment << "Too many elements generated for a trial version.\n";
}
error(COMPERR_ALGO_FAILED, "ghs3d: command not found" );
}
- if ( !getenv("GHS3D_KEEP_FILES") )
+ if ( !_keepFiles )
{
OSD_File( aFacesFileName ).Remove();
OSD_File( aPointsFileName ).Remove();
return Ok;
}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-ostream & GHS3DPlugin_GHS3D::SaveTo(ostream & save)
-{
- return save;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-istream & GHS3DPlugin_GHS3D::LoadFrom(istream & load)
-{
- return load;
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-ostream & operator << (ostream & save, GHS3DPlugin_GHS3D & hyp)
-{
- return hyp.SaveTo( save );
-}
-
-//=============================================================================
-/*!
- *
- */
-//=============================================================================
-
-istream & operator >> (istream & load, GHS3DPlugin_GHS3D & hyp)
-{
- return hyp.LoadFrom( load );
-}
#include "SMESH_3D_Algo.hxx"
class SMESH_Mesh;
+class GHS3DPlugin_Hypothesis;
class GHS3DPlugin_GHS3D: public SMESH_3D_Algo
{
GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen);
virtual ~GHS3DPlugin_GHS3D();
- virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape,
- SMESH_Hypothesis::Hypothesis_Status& aStatus);
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ Hypothesis_Status& aStatus);
virtual bool Compute(SMESH_Mesh& aMesh,
- const TopoDS_Shape& aShape);
+ const TopoDS_Shape& aShape);
virtual bool Compute(SMESH_Mesh& theMesh,
SMESH_MesherHelper* aHelper);
- ostream & SaveTo(ostream & save);
- istream & LoadFrom(istream & load);
- friend ostream & operator << (ostream & save, GHS3DPlugin_GHS3D & hyp);
- friend istream & operator >> (istream & load, GHS3DPlugin_GHS3D & hyp);
-
private:
- int _iShape;
- int _nbShape;
+ int _iShape;
+ int _nbShape;
+ bool _keepFiles;
+ const GHS3DPlugin_Hypothesis* _hyp;
};
#endif
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//=============================================================================
+// File : GHS3DPlugin_Hypothesis.cxx
+// Created : Wed Apr 2 12:36:29 2008
+// Author : Edward AGAPOV (eap)
+//=============================================================================
+
+
+#include "GHS3DPlugin_Hypothesis.hxx"
+
+#include <TCollection_AsciiString.hxx>
+
+//=======================================================================
+//function : GHS3DPlugin_Hypothesis
+//=======================================================================
+
+GHS3DPlugin_Hypothesis::GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen)
+ : SMESH_Hypothesis(hypId, studyId, gen)
+{
+ _name = "GHS3D_Parameters";
+ _param_algo_dim = 3;
+
+ myToMeshHoles = DefaultMeshHoles();
+ myMaximumMemory = -1;//DefaultMaximumMemory();
+ myInitialMemory = -1;//DefaultInitialMemory();
+ myOptimizationLevel = DefaultOptimizationLevel();
+ myWorkingDirectory = DefaultWorkingDirectory();
+ myKeepFiles = DefaultKeepFiles();
+}
+
+//=======================================================================
+//function : SetToMeshHoles
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetToMeshHoles(bool toMesh)
+{
+ if ( myToMeshHoles != toMesh ) {
+ myToMeshHoles = toMesh;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetToMeshHoles
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::GetToMeshHoles() const
+{
+ return myToMeshHoles;
+}
+
+//=======================================================================
+//function : SetMaximumMemory
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetMaximumMemory(short MB)
+{
+ if ( myMaximumMemory != MB ) {
+ myMaximumMemory = MB;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetMaximumMemory
+// * automatic memory adjustment mode. Default is zero
+//=======================================================================
+
+short GHS3DPlugin_Hypothesis::GetMaximumMemory() const
+{
+ return myMaximumMemory;
+}
+
+//=======================================================================
+//function : SetInitialMemory
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetInitialMemory(short MB)
+{
+ if ( myInitialMemory != MB ) {
+ myInitialMemory = MB;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetInitialMemory
+//=======================================================================
+
+short GHS3DPlugin_Hypothesis::GetInitialMemory() const
+{
+ return myInitialMemory;
+}
+
+//=======================================================================
+//function : SetOptimizationLevel
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetOptimizationLevel(OptimizationLevel level)
+{
+ if ( myOptimizationLevel != level ) {
+ myOptimizationLevel = level;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetOptimizationLevel
+//=======================================================================
+
+GHS3DPlugin_Hypothesis::OptimizationLevel GHS3DPlugin_Hypothesis::GetOptimizationLevel() const
+{
+ return (OptimizationLevel) myOptimizationLevel;
+}
+
+//=======================================================================
+//function : SetWorkingDirectory
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetWorkingDirectory(string path)
+{
+ if ( myWorkingDirectory != path ) {
+ myWorkingDirectory = path;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetWorkingDirectory
+//=======================================================================
+
+string GHS3DPlugin_Hypothesis::GetWorkingDirectory() const
+{
+ return myWorkingDirectory;
+}
+
+//=======================================================================
+//function : SetKeepFiles
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis::SetKeepFiles(bool toKeep)
+{
+ if ( myKeepFiles != toKeep ) {
+ myKeepFiles = toKeep;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+//=======================================================================
+//function : GetKeepFiles
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::GetKeepFiles() const
+{
+ return myKeepFiles;
+}
+
+//=======================================================================
+//function : DefaultMeshHoles
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::DefaultMeshHoles()
+{
+ return true;
+}
+
+//=======================================================================
+//function : DefaultMaximumMemory
+//=======================================================================
+
+#ifndef WIN32
+#include <sys/sysinfo.h>
+#endif
+
+short GHS3DPlugin_Hypothesis::DefaultMaximumMemory()
+{
+#ifndef WIN32
+ struct sysinfo si;
+ int err = sysinfo( &si );
+ if ( err == 0 ) {
+ int ramMB = si.totalram * si.mem_unit / 1024 / 1024;
+ return (short) ( 0.7 * ramMB );
+ }
+#endif
+ return -1;
+}
+
+//=======================================================================
+//function : DefaultInitialMemory
+//=======================================================================
+
+short GHS3DPlugin_Hypothesis::DefaultInitialMemory()
+{
+ return DefaultMaximumMemory();
+}
+
+//=======================================================================
+//function : DefaultOptimizationLevel
+//=======================================================================
+
+short GHS3DPlugin_Hypothesis::DefaultOptimizationLevel()
+{
+ return Medium;
+}
+
+//=======================================================================
+//function : DefaultWorkingDirectory
+//=======================================================================
+
+string GHS3DPlugin_Hypothesis::DefaultWorkingDirectory()
+{
+ TCollection_AsciiString aTmpDir;
+
+ char *Tmp_dir = getenv("SALOME_TMP_DIR");
+ if(Tmp_dir != NULL) {
+ aTmpDir = Tmp_dir;
+ }
+ else {
+#ifdef WIN32
+ aTmpDir = TCollection_AsciiString("C:\\");
+#else
+ aTmpDir = TCollection_AsciiString("/tmp/");
+#endif
+ }
+ return aTmpDir.ToCString();
+}
+
+//=======================================================================
+//function : DefaultKeepFiles
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::DefaultKeepFiles()
+{
+ return false;
+}
+
+//=======================================================================
+//function : SaveTo
+//=======================================================================
+
+ostream & GHS3DPlugin_Hypothesis::SaveTo(ostream & save)
+{
+ save << (int) myToMeshHoles << " ";
+ save << myMaximumMemory << " ";
+ save << myInitialMemory << " ";
+ save << myOptimizationLevel << " ";
+ save << myWorkingDirectory << " ";
+ save << (int)myKeepFiles << " ";
+ 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();
+ return load;
+ }
+ else if ( myWorkingDirectory == "1" ) {
+ myKeepFiles = true;
+ myWorkingDirectory.clear();
+ return load;
+ }
+ }
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ isOK = (load >> i);
+ if (isOK)
+ myKeepFiles = i;
+ else
+ load.clear(ios::badbit | load.rdstate());
+
+ return load;
+}
+
+//=======================================================================
+//function : SetParametersByMesh
+//=======================================================================
+
+bool GHS3DPlugin_Hypothesis::SetParametersByMesh(const SMESH_Mesh* ,const TopoDS_Shape&)
+{
+ return false;
+}
+
+//================================================================================
+/*!
+ * \brief Return command to run ghs3d mesher excluding file prefix (-f)
+ */
+//================================================================================
+
+string GHS3DPlugin_Hypothesis::CommandToRun(const GHS3DPlugin_Hypothesis* hyp)
+{
+#ifndef WIN32
+ TCollection_AsciiString cmd( "ghs3d" );
+#else
+ TCollection_AsciiString cmd( "ghs3d.exe" );
+#endif
+
+ // ghs3d needs to know amount of memory it may use (MB).
+ // Default memory is defined at ghs3d installation but it may be not enough,
+ // so allow to use about all available memory
+ short aMaximumMemory = hyp ? hyp->myMaximumMemory : -1;
+ cmd += " -m ";
+ if ( aMaximumMemory < 0 )
+ cmd += DefaultMaximumMemory();
+ else
+ cmd += aMaximumMemory;
+ short aInitialMemory = hyp ? hyp->myInitialMemory : -1;
+ cmd += " -M ";
+ if ( aInitialMemory > 0 )
+ cmd += aInitialMemory;
+ else
+ cmd += "100";
+
+ // component to mesh
+ // 0 , all components to be meshed
+ // 1 , only the main ( outermost ) component to be meshed
+ bool aToMeshHoles = hyp ? hyp->myToMeshHoles : DefaultMeshHoles();
+ if ( aToMeshHoles )
+ cmd += " -c 0";
+ else
+ cmd += " -c 1";
+
+ // optimization level
+ short aOptimizationLevel = hyp ? hyp->myOptimizationLevel : DefaultOptimizationLevel();
+ if ( aOptimizationLevel >= 0 && aOptimizationLevel < 4 ) {
+ char* level[] = { "none" , "light" , "standard" , "strong" };
+ cmd += " -o ";
+ cmd += level[ aOptimizationLevel ];
+ }
+
+ return cmd.ToCString();
+}
+
+//================================================================================
+/*!
+ * \brief Return a unique file name
+ */
+//================================================================================
+
+string GHS3DPlugin_Hypothesis::GetFileName(const GHS3DPlugin_Hypothesis* hyp)
+{
+ string aTmpDir = hyp ? hyp->GetWorkingDirectory() : DefaultWorkingDirectory();
+ const char lastChar = *aTmpDir.rbegin();
+#ifdef WIN32
+ if(lastChar != '\\') aTmpDir+='\\';
+#else
+ if(lastChar != '/') aTmpDir+='/';
+#endif
+
+ TCollection_AsciiString aGenericName = (char*)aTmpDir.c_str();
+ aGenericName += "GHS3D_";
+#ifdef WIN32
+ aGenericName += GetCurrentProcessId();
+#else
+ aGenericName += getpid();
+#endif
+ aGenericName += "_";
+ aGenericName += Abs((Standard_Integer) & aGenericName);
+
+ return aGenericName.ToCString();
+}
--- /dev/null
+// GHS3DPlugin : C++ implementation
+//
+// Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+// File : GHS3DPlugin_Hypothesis.hxx
+// Created : Wed Apr 2 12:21:17 2008
+// Author : Edward AGAPOV (eap)
+
+#ifndef GHS3DPlugin_Hypothesis_HeaderFile
+#define GHS3DPlugin_Hypothesis_HeaderFile
+
+#include "GHS3DPlugin_Defs.hxx"
+
+#include <SMESH_Hypothesis.hxx>
+
+using namespace std;
+
+class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis: public SMESH_Hypothesis
+{
+public:
+
+ GHS3DPlugin_Hypothesis(int hypId, int studyId, SMESH_Gen * gen);
+
+ /*!
+ * To mesh "holes" in a solid or not. Default is to mesh.
+ */
+ void SetToMeshHoles(bool toMesh);
+ bool GetToMeshHoles() const;
+ /*!
+ * Maximal size of memory to be used by the algorithm (in Megabytes)
+ */
+ void SetMaximumMemory(short MB);
+ short GetMaximumMemory() const;
+ /*!
+ * Initial size of memory to be used by the algorithm (in Megabytes) in
+ * automatic memory adjustment mode. Default is zero
+ */
+ void SetInitialMemory(short MB);
+ short GetInitialMemory() const;
+ /*!
+ * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium
+ */
+ enum OptimizationLevel { None = 0, Light, Medium, Strong };
+ void SetOptimizationLevel(OptimizationLevel level);
+ OptimizationLevel GetOptimizationLevel() const;
+ /*!
+ * Path to working directory
+ */
+ void SetWorkingDirectory(string path);
+ string GetWorkingDirectory() const;
+ /*!
+ * To keep working files or remove them. Log file remains in case of errors anyway.
+ */
+ void SetKeepFiles(bool toKeep);
+ bool GetKeepFiles() const;
+
+ static bool DefaultMeshHoles();
+ static short DefaultMaximumMemory();
+ static short DefaultInitialMemory();
+ static short DefaultOptimizationLevel();
+ static string DefaultWorkingDirectory();
+ static bool DefaultKeepFiles();
+
+ /*!
+ * \brief Return command to run ghs3d mesher excluding file prefix (-f)
+ */
+ static std::string CommandToRun(const GHS3DPlugin_Hypothesis* hyp);
+ /*!
+ * \brief Return a unique file name
+ */
+ static std::string GetFileName(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);
+
+ /*!
+ * \brief Does nothing
+ * \param theMesh - the built mesh
+ * \param theShape - the geometry of interest
+ * \retval bool - always false
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+
+private:
+
+ bool myToMeshHoles;
+ short myMaximumMemory;
+ short myInitialMemory;
+ short myOptimizationLevel;
+ std::string myWorkingDirectory;
+ bool myKeepFiles;
+};
+
+
+#endif
--- /dev/null
+// File : GHS3DPlugin_Hypothesis_i.cxx
+// Created : Wed Apr 2 13:53:01 2008
+// Author : Edward AGAPOV (eap)
+
+
+#include "GHS3DPlugin_Hypothesis_i.hxx"
+
+#include <SMESH_Gen.hxx>
+#include <SMESH_PythonDump.hxx>
+
+#include <Utils_CorbaException.hxx>
+#include <utilities.h>
+#include <SMESH_Mesh_i.hxx>
+
+//=======================================================================
+//function : GHS3DPlugin_Hypothesis_i
+//=======================================================================
+
+GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl)
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA )
+{
+ MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
+ myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
+ theStudyId,
+ theGenImpl);
+}
+
+//=======================================================================
+//function : ~GHS3DPlugin_Hypothesis_i
+//=======================================================================
+
+GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i()
+{
+ MESSAGE( "GHS3DPlugin_Hypothesis_i::~GHS3DPlugin_Hypothesis_i" );
+}
+
+//=======================================================================
+//function : SetToMeshHoles
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetToMeshHoles(CORBA::Boolean toMesh)
+{
+ ASSERT(myBaseImpl);
+ this->GetImpl()->SetToMeshHoles(toMesh);
+ SMESH::TPythonDump() << _this() << ".SetToMeshHoles( " << toMesh << " )";
+}
+
+//=======================================================================
+//function : GetToMeshHoles
+//=======================================================================
+
+CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetToMeshHoles()
+{
+ ASSERT(myBaseImpl);
+ return this->GetImpl()->GetToMeshHoles();
+}
+
+//=======================================================================
+//function : SetMaximumMemory
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetMaximumMemory(CORBA::Short MB)
+{
+ ASSERT(myBaseImpl);
+ this->GetImpl()->SetMaximumMemory(MB);
+ SMESH::TPythonDump() << _this() << ".SetMaximumMemory( " << MB << " )";
+}
+
+//=======================================================================
+//function : GetMaximumMemory
+//=======================================================================
+
+CORBA::Short GHS3DPlugin_Hypothesis_i::GetMaximumMemory()
+{
+ ASSERT(myBaseImpl);
+ return this->GetImpl()->GetMaximumMemory();
+}
+
+//=======================================================================
+//function : SetInitialMemory
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetInitialMemory(CORBA::Short MB)
+{
+ ASSERT(myBaseImpl);
+ this->GetImpl()->SetInitialMemory(MB);
+ SMESH::TPythonDump() << _this() << ".SetInitialMemory( " << MB << " )";
+}
+
+//=======================================================================
+//function : GetInitialMemory
+//=======================================================================
+
+CORBA::Short GHS3DPlugin_Hypothesis_i::GetInitialMemory()
+{
+ ASSERT(myBaseImpl);
+ return this->GetImpl()->GetInitialMemory();
+}
+
+//=======================================================================
+//function : SetOptimizationLevel
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetOptimizationLevel(CORBA::Short level)
+ throw ( SALOME::SALOME_Exception )
+{
+ ::GHS3DPlugin_Hypothesis::OptimizationLevel l =
+ (::GHS3DPlugin_Hypothesis::OptimizationLevel) level;
+ if ( l < ::GHS3DPlugin_Hypothesis::None ||
+ l > ::GHS3DPlugin_Hypothesis::Strong )
+ THROW_SALOME_CORBA_EXCEPTION( "Invalid optimization level",SALOME::BAD_PARAM );
+
+ ASSERT(myBaseImpl);
+ this->GetImpl()->SetOptimizationLevel(l);
+ SMESH::TPythonDump() << _this() << ".SetOptimizationLevel( " << level << " )";
+}
+
+//=======================================================================
+//function : GetOptimizationLevel
+//=======================================================================
+
+CORBA::Short GHS3DPlugin_Hypothesis_i::GetOptimizationLevel()
+{
+ ASSERT(myBaseImpl);
+ return this->GetImpl()->GetOptimizationLevel();
+}
+
+//=======================================================================
+//function : SetWorkingDirectory
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception )
+{
+ if (!path )
+ THROW_SALOME_CORBA_EXCEPTION( "Null working directory",SALOME::BAD_PARAM );
+
+ string file(path);
+ const char lastChar = *file.rbegin();
+#ifdef WIN32
+ if ( lastChar != '\\' ) file += '\\';
+#else
+ if ( lastChar != '/' ) file += '/';
+#endif
+ file += "GHS3D.log";
+ SMESH_Mesh_i::PrepareForWriting (file.c_str());
+
+ ASSERT(myBaseImpl);
+ this->GetImpl()->SetWorkingDirectory(path);
+ SMESH::TPythonDump() << _this() << ".SetWorkingDirectory( '" << path << "' )";
+}
+
+//=======================================================================
+//function : GetWorkingDirectory
+//=======================================================================
+
+char* GHS3DPlugin_Hypothesis_i::GetWorkingDirectory()
+{
+ ASSERT(myBaseImpl);
+ return CORBA::string_dup( this->GetImpl()->GetWorkingDirectory().c_str() );
+}
+
+//=======================================================================
+//function : SetKeepFiles
+//=======================================================================
+
+void GHS3DPlugin_Hypothesis_i::SetKeepFiles(CORBA::Boolean toKeep)
+{
+ ASSERT(myBaseImpl);
+ this->GetImpl()->SetKeepFiles(toKeep);
+ SMESH::TPythonDump() << _this() << ".SetKeepFiles( " << toKeep << " )";
+}
+
+//=======================================================================
+//function : GetKeepFiles
+//=======================================================================
+
+CORBA::Boolean GHS3DPlugin_Hypothesis_i::GetKeepFiles()
+{
+ ASSERT(myBaseImpl);
+ return this->GetImpl()->GetKeepFiles();
+}
+
+//=============================================================================
+/*!
+ * GHS3DPlugin_Hypothesis_i::GetImpl
+ *
+ * Get implementation
+ */
+//=============================================================================
+
+::GHS3DPlugin_Hypothesis* GHS3DPlugin_Hypothesis_i::GetImpl()
+{
+ return (::GHS3DPlugin_Hypothesis*)myBaseImpl;
+}
+
+//================================================================================
+/*!
+ * \brief Verify whether hypothesis supports given entity type
+ * \param type - dimension (see SMESH::Dimension enumeration)
+ * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise
+ *
+ * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration)
+ */
+//================================================================================
+
+CORBA::Boolean GHS3DPlugin_Hypothesis_i::IsDimSupported( SMESH::Dimension type )
+{
+ return type == SMESH::DIM_3D;
+}
+
--- /dev/null
+// GHS3DPlugin : C++ implementation
+//
+// Copyright (C) 2006 OPEN CASCADE, CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+// File : GHS3DPlugin_Hypothesis_i.hxx
+// Date : 03/04/2006
+// Project : SALOME
+
+#ifndef _GHS3DPlugin_Hypothesis_i_HXX_
+#define _GHS3DPlugin_Hypothesis_i_HXX_
+
+#include "GHS3DPlugin_Defs.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
+
+#include "SMESH_Hypothesis_i.hxx"
+#include "GHS3DPlugin_Hypothesis.hxx"
+
+class SMESH_Gen;
+
+// GHS3DPlugin parameters hypothesis
+
+class GHS3DPLUGIN_EXPORT GHS3DPlugin_Hypothesis_i:
+ public virtual POA_GHS3DPlugin::GHS3DPlugin_Hypothesis,
+ public virtual SMESH_Hypothesis_i
+{
+ public:
+ // Constructor
+ GHS3DPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl);
+ // Destructor
+ virtual ~GHS3DPlugin_Hypothesis_i();
+
+ /*!
+ * To mesh "holes" in a solid or not. Default is to mesh.
+ */
+ void SetToMeshHoles(CORBA::Boolean toMesh);
+ CORBA::Boolean GetToMeshHoles();
+ /*!
+ * Maximal size of memory to be used by the algorithm (in Megabytes)
+ */
+ void SetMaximumMemory(CORBA::Short MB);
+ CORBA::Short GetMaximumMemory();
+ /*!
+ * Initial size of memory to be used by the algorithm (in Megabytes) in
+ * automatic memory adjustment mode. Default is zero
+ */
+ void SetInitialMemory(CORBA::Short MB);
+ CORBA::Short GetInitialMemory();
+ /*!
+ * Optimization level: 0-none, 1-light, 2-medium, 3-strong. Default is medium
+ */
+ void SetOptimizationLevel(CORBA::Short level) throw ( SALOME::SALOME_Exception );
+ CORBA::Short GetOptimizationLevel();
+ /*!
+ * Path to working directory
+ */
+ void SetWorkingDirectory(const char* path) throw ( SALOME::SALOME_Exception );
+ char* GetWorkingDirectory();
+ /*!
+ * To keep working files or remove them. Log file remains in case of errors anyway.
+ */
+ void SetKeepFiles(CORBA::Boolean toKeep);
+ CORBA::Boolean GetKeepFiles();
+
+ // Get implementation
+ ::GHS3DPlugin_Hypothesis* GetImpl();
+
+ // Verify whether hypothesis supports given entity type
+ CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+};
+
+#endif
#include "utilities.h"
#include "GHS3DPlugin_GHS3D_i.hxx"
+#include "GHS3DPlugin_Hypothesis_i.hxx"
template <class T> class GHS3DPlugin_Creator_i:public HypothesisCreator_i<T>
{
// Hypotheses
- // Algorithms
+ // Algorithm
if (strcmp(aHypName, "GHS3D_3D") == 0)
aCreator = new GHS3DPlugin_Creator_i<GHS3DPlugin_GHS3D_i>;
+ // Hypothesis
+ else if (strcmp(aHypName, "GHS3D_Parameters") == 0)
+ aCreator = new GHS3DPlugin_Creator_i<GHS3DPlugin_Hypothesis_i>;
else ;
return aCreator;
--- /dev/null
+// GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin
+//
+// Copyright (C) 2003 CEA
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : GHS3DPluginGUI_HypothesisCreator.cxx
+// Author : Michael Zorin
+// Module : GHS3DPlugin
+// $Header:
+
+#include "GHS3DPluginGUI_HypothesisCreator.h"
+
+#include <SMESHGUI_Utils.h>
+#include <SMESHGUI_HypothesesUtils.h>
+
+#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
+
+#include <QtxComboBox.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Session.h>
+#include <SUIT_FileDlg.h>
+#include <SalomeApp_Tools.h>
+
+#include <qlabel.h>
+#include <qgroupbox.h>
+#include <qframe.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qpixmap.h>
+#include <qtabbar.h>
+#include <qspinbox.h>
+#include <qpushbutton.h>
+#include <qfiledialog.h>
+#include <qfileinfo.h>
+//#include <qapplication.h>
+
+enum {
+ STD_TAB = 0,
+ ADV_TAB
+};
+
+namespace {
+
+#ifndef WIN32
+#include <sys/sysinfo.h>
+#endif
+
+ int maxAvailableMemory()
+ {
+#ifndef WIN32
+ struct sysinfo si;
+ int err = sysinfo( &si );
+ if ( err == 0 ) {
+ int totMB =
+ si.totalram * si.mem_unit / 1024 / 1024 +
+ si.totalswap * si.mem_unit / 1024 / 1024 ;
+ return (int) ( 0.7 * totMB );
+ }
+#endif
+ return 100000;
+ }
+}
+
+GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType )
+: SMESHGUI_GenericHypothesisCreator( theHypType )
+{
+}
+
+GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator()
+{
+}
+
+QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
+{
+ QFrame* fr = new QFrame( 0, "myframe" );
+ QVBoxLayout* lay = new QVBoxLayout( fr, 5, 0 );
+
+ // tab
+ QTabBar* tab = new QTabBar( fr, "QTabBar");
+ tab->setShape( QTabBar::RoundedAbove );
+ tab->insertTab( new QTab( tr( "SMESH_ARGUMENTS")), STD_TAB);
+ tab->insertTab( new QTab( tr( "GHS3D_ADV_ARGS")), ADV_TAB);
+ lay->addWidget( tab );
+
+ // basic parameters
+ myStdGroup = new QGroupBox( 2, Qt::Horizontal, fr, "myStdGroup" );
+ myStdGroup->layout()->setSpacing( 6 );
+ myStdGroup->layout()->setMargin( 11 );
+ lay->addWidget( myStdGroup );
+
+ myName = 0;
+ if( isCreation() )
+ {
+ new QLabel( tr( "SMESH_NAME" ), myStdGroup );
+ myName = new QLineEdit( myStdGroup );
+ }
+
+ myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup );
+ myStdGroup->addSpace(0);
+
+ new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup );
+ myOptimizationLevelCombo = new QtxComboBox( myStdGroup );
+ QStringList types;
+ types.append( QObject::tr( "LEVEL_NONE" ) );
+ types.append( QObject::tr( "LEVEL_LIGHT" ) );
+ types.append( QObject::tr( "LEVEL_MEDIUM" ) );
+ types.append( QObject::tr( "LEVEL_STRONG" ) );
+ myOptimizationLevelCombo->insertStringList( types );
+
+ // advanced parameters
+ myAdvGroup = new QGroupBox( 3, Qt::Horizontal, fr, "myAdvGroup" );
+ lay->addWidget( myAdvGroup );
+
+ myMaximumMemoryCheck = new QCheckBox( tr("MAX_MEMORY_SIZE"), myAdvGroup );
+
+ myMaximumMemorySpin = new QSpinBox( myAdvGroup );
+ myMaximumMemorySpin->setMinValue( 20 );
+ myMaximumMemorySpin->setMaxValue( maxAvailableMemory() );
+ myMaximumMemorySpin->setLineStep( 10 );
+ new QLabel( tr("MEGABYTE"), myAdvGroup);
+
+ myInitialMemoryCheck = new QCheckBox( tr("INIT_MEMORY_SIZE"), myAdvGroup );
+
+ myInitialMemorySpin = new QSpinBox( myAdvGroup );
+ myInitialMemorySpin->setMinValue( 20 );
+ myInitialMemorySpin->setMaxValue( maxAvailableMemory() );
+ myInitialMemorySpin->setLineStep( 10 );
+ new QLabel( tr("MEGABYTE"), myAdvGroup);
+
+ new QLabel( tr( "WORKING_DIR" ), myAdvGroup );
+ QPushButton* dirBtn = new QPushButton( tr( "SELECT_DIR"), myAdvGroup, "dirBtn");
+ myWorkingDir = new QLineEdit( myAdvGroup, "myWorkingDir");
+ myWorkingDir->setReadOnly( true );
+
+ myKeepFiles = new QCheckBox( tr( "KEEP_WORKING_FILES" ), myAdvGroup );
+
+ connect( tab, SIGNAL( selected(int) ), this, SLOT( onTabSelected(int) ) );
+ connect( myMaximumMemoryCheck, SIGNAL( toggled(bool) ), this, SLOT( onMemCheckToggled(bool) ));
+ connect( myInitialMemoryCheck, SIGNAL( toggled(bool) ), this, SLOT( onMemCheckToggled(bool) ));
+ connect( dirBtn, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
+
+ return fr;
+}
+
+void GHS3DPluginGUI_HypothesisCreator::onTabSelected(int tab)
+{
+ if ( tab == STD_TAB ) {
+ myAdvGroup->hide();
+ myStdGroup->show();
+ }
+ else {
+ myStdGroup->hide();
+ myAdvGroup->show();
+ }
+// qApp->processEvents();
+ dlg()->adjustSize();
+}
+
+void GHS3DPluginGUI_HypothesisCreator::onMemCheckToggled(bool on)
+{
+ if ( sender() == myMaximumMemoryCheck )
+ myMaximumMemorySpin->setEnabled( on );
+ else
+ myInitialMemorySpin->setEnabled( on );
+}
+
+void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
+{
+ QString dir = SUIT_FileDlg::getExistingDirectory(dlg(),QString::null, QString::null );
+ if ( dir )
+ myWorkingDir->setText( dir );
+}
+
+
+bool GHS3DPluginGUI_HypothesisCreator::checkParams() const
+{
+ if ( !QFileInfo( myWorkingDir->text() ).isWritable() ) {
+ SUIT_MessageBox::warn1(dlg(),
+ QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("GHS3D_PERMISSION_DENIED"),
+ QObject::tr("SMESH_BUT_OK"));
+ return false;
+ }
+ return true;
+}
+
+void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
+{
+ GHS3DHypothesisData data;
+ readParamsFromHypo( data );
+
+ if( myName )
+ myName->setText( data.myName );
+
+ myToMeshHolesCheck ->setChecked ( data.myToMeshHoles );
+ myOptimizationLevelCombo->setCurrentItem( data.myOptimizationLevel );
+ myMaximumMemoryCheck ->setChecked ( data.myMaximumMemory > 0 );
+ myMaximumMemorySpin ->setValue ( std::max( data.myMaximumMemory, myMaximumMemorySpin->minValue() ));
+ myInitialMemoryCheck ->setChecked ( data.myInitialMemory > 0 );
+ myInitialMemorySpin ->setValue ( std::max( data.myInitialMemory, myInitialMemorySpin->minValue() ));
+ myWorkingDir ->setText ( data.myWorkingDir );
+ myKeepFiles ->setChecked ( data.myKeepFiles );
+
+ myMaximumMemorySpin->setEnabled( myMaximumMemoryCheck->isChecked() );
+ myInitialMemorySpin->setEnabled( myInitialMemoryCheck->isChecked() );
+}
+
+QString GHS3DPluginGUI_HypothesisCreator::storeParams() const
+{
+ GHS3DHypothesisData data;
+ readParamsFromWidgets( data );
+ storeParamsToHypo( data );
+
+ QString valStr = " -c " + QString::number( !data.myToMeshHoles );
+ if ( data.myOptimizationLevel >= 0 && data.myOptimizationLevel < 4 ) {
+ char* level[] = { "none" , "light" , "standard" , "strong" };
+ valStr += " -o ";
+ valStr += level[ data.myOptimizationLevel ];
+ }
+
+ return valStr;
+}
+
+bool GHS3DPluginGUI_HypothesisCreator::readParamsFromHypo( GHS3DHypothesisData& h_data ) const
+{
+ 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();
+
+ return true;
+}
+
+bool GHS3DPluginGUI_HypothesisCreator::storeParamsToHypo( const GHS3DHypothesisData& h_data ) const
+{
+ GHS3DPlugin::GHS3DPlugin_Hypothesis_var h =
+ GHS3DPlugin::GHS3DPlugin_Hypothesis::_narrow( hypothesis() );
+
+ bool ok = true;
+ try
+ {
+ if( isCreation() )
+ SMESH::SetName( SMESH::FindSObject( h ), h_data.myName.latin1() );
+
+ h->SetToMeshHoles ( h_data.myToMeshHoles );
+ h->SetMaximumMemory ( h_data.myMaximumMemory );
+ h->SetInitialMemory ( h_data.myInitialMemory );
+ h->SetInitialMemory ( h_data.myInitialMemory );
+ h->SetOptimizationLevel( h_data.myOptimizationLevel );
+ h->SetKeepFiles ( h_data.myKeepFiles );
+ h->SetWorkingDirectory ( h_data.myWorkingDir );
+ }
+ catch(const SALOME::SALOME_Exception& ex)
+ {
+ SalomeApp_Tools::QtCatchCorbaException(ex);
+ ok = false;
+ }
+ return ok;
+}
+
+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->currentItem();
+ h_data.myKeepFiles = myKeepFiles->isChecked();
+ h_data.myWorkingDir = myWorkingDir->text();
+
+ return true;
+}
+
+QString GHS3DPluginGUI_HypothesisCreator::caption() const
+{
+ return tr( "GHS3D_TITLE" );
+}
+
+QPixmap GHS3DPluginGUI_HypothesisCreator::icon() const
+{
+ QString hypIconName = tr( QString("ICON_DLG_GHS3D_PARAMETERS" ));
+ return SUIT_Session::session()->resourceMgr()->loadPixmap( "GHS3DPlugin", hypIconName );
+}
+
+QString GHS3DPluginGUI_HypothesisCreator::type() const
+{
+ return tr( "GHS3D_HYPOTHESIS" );
+}
+
+QString GHS3DPluginGUI_HypothesisCreator::helpPage() const
+{
+ return "ghs3d_hypo_page.html";
+}
+
+//=============================================================================
+/*! GetHypothesisCreator
+ *
+ */
+//=============================================================================
+extern "C"
+{
+ GHS3DPLUGIN_EXPORT
+ SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType )
+ {
+ if( aHypType=="GHS3D_Parameters" )
+ return new GHS3DPluginGUI_HypothesisCreator( aHypType );
+ return 0;
+ }
+}
--- /dev/null
+// GHS3DPlugin GUI: GUI for plugged-in mesher GHS3DPlugin
+//
+// Copyright (C) 2003 CEA
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : GHS3DPluginGUI_HypothesisCreator.h
+// Author : Michael Zorin
+// Module : GHS3DPlugin
+
+#ifndef GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
+#define GHS3DPLUGINGUI_HypothesisCreator_HeaderFile
+
+#include "../GHS3DPlugin_Defs.hxx"
+#include <SMESHGUI_Hypotheses.h>
+
+class QtxComboBox;
+class QCheckBox;
+class QLineEdit;
+class QSpinBox;
+
+typedef struct
+{
+ bool myToMeshHoles;
+ int myMaximumMemory;
+ int myInitialMemory;
+ int myOptimizationLevel;
+ bool myKeepFiles;
+ QString myWorkingDir;
+ QString myName;
+} GHS3DHypothesisData;
+
+/*!
+ * \brief Class for creation of GHS3D2D and GHS3D3D hypotheses
+*/
+class GHS3DPLUGIN_EXPORT GHS3DPluginGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator
+{
+ Q_OBJECT
+
+public:
+ GHS3DPluginGUI_HypothesisCreator( const QString& );
+ virtual ~GHS3DPluginGUI_HypothesisCreator();
+
+ virtual bool checkParams() const;
+ virtual QString helpPage() const;
+
+protected:
+ virtual QFrame* buildFrame ();
+ virtual void retrieveParams() const;
+ virtual QString storeParams () const;
+
+ virtual QString caption() const;
+ virtual QPixmap icon() const;
+ virtual QString type() const;
+
+protected slots:
+
+ void onTabSelected(int);
+ void onMemCheckToggled(bool);
+ void onDirBtnClicked();
+
+private:
+ bool readParamsFromHypo( GHS3DHypothesisData& ) const;
+ bool readParamsFromWidgets( GHS3DHypothesisData& ) const;
+ bool storeParamsToHypo( const GHS3DHypothesisData& ) const;
+
+private:
+
+ QGroupBox* myStdGroup;
+ QLineEdit* myName;
+ QCheckBox* myToMeshHolesCheck;
+ QtxComboBox* myOptimizationLevelCombo;
+
+ QGroupBox* myAdvGroup;
+ QCheckBox* myMaximumMemoryCheck;
+ QSpinBox* myMaximumMemorySpin;
+ QCheckBox* myInitialMemoryCheck;
+ QSpinBox* myInitialMemorySpin;
+ QLineEdit* myWorkingDir;
+ QCheckBox* myKeepFiles;
+};
+
+#endif
--- /dev/null
+# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# This is a Qt message file in .po format. Each msgid starts with
+# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
+# would be translated to "Pub", not "Foo::Pub".
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n"
+"PO-Revision-Date: 2004-03-30 17:24+0400\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+
+#-----------------------------------------------------------
+# ObjectBrowser
+#-----------------------------------------------------------
+
+msgid "ICON_SMESH_TREE_ALGO_GHS3D_3D"
+msgstr "mesh_tree_hypo_ghs3d.png"
+
+msgid "ICON_SMESH_TREE_HYPO_GHS3D_Parameters"
+msgstr "mesh_tree_hypo_ghs3d.png"
+
+#-----------------------------------------------------------
+# Hypothesis
+#-----------------------------------------------------------
+
+msgid "ICON_DLG_GHS3D_PARAMETERS"
+msgstr "mesh_hypo_ghs3d.png"
+
--- /dev/null
+# Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS, L3S, LJLL, MENSI
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# This is a Qt message file in .po format. Each msgid starts with
+# a scope. This scope should *NOT* be translated - eg. "Foo::Bar"
+# would be translated to "Pub", not "Foo::Pub".
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n"
+"PO-Revision-Date: YYYY-MM-DD\n"
+"Last-Translator: FULLNAME <EMAIL@ADDRESS>\n"
+"Content-Type: text/plain; charset=iso-8859-1\n"
+
+
+msgid "GHS3D_STD_ARGS"
+msgstr "Parameters"
+
+msgid "GHS3D_ADV_ARGS"
+msgstr "Advanced"
+
+msgid "GHS3D_TO_MESH_HOLES"
+msgstr "To mesh holes"
+
+msgid "GHS3D_OPTIMIZATIOL_LEVEL"
+msgstr "Optimization level"
+
+msgid "LEVEL_NONE"
+msgstr "None"
+
+msgid "LEVEL_LIGHT"
+msgstr "Light"
+
+msgid "LEVEL_MEDIUM"
+msgstr "Medium (standard)"
+
+msgid "LEVEL_STRONG"
+msgstr "Strong"
+
+msgid "MAX_MEMORY_SIZE"
+msgstr "Maximum memory size"
+
+msgid "INIT_MEMORY_SIZE"
+msgstr "Initial memory size"
+
+msgid "MEGABYTE"
+msgstr "Megabytes"
+
+msgid "WORKING_DIR"
+msgstr "Working directory"
+
+msgid "GHS3D_PERMISSION_DENIED"
+msgstr "Working directory is not writable"
+
+msgid "SELECT_DIR"
+msgstr "..."
+
+msgid "KEEP_WORKING_FILES"
+msgstr "To keep working files"
+
+msgid ""
+msgstr ""
+
+
+msgid "GHS3D_HYPOTHESIS"
+msgstr "GHS3D"
+
+msgid "GHS3D_TITLE"
+msgstr "Hypothesis Construction"
--- /dev/null
+# Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+# -* Makefile *-
+#
+# Author : Edward AGAPOV (OCC)
+# Modified by : Alexander BORODIN (OCN) - autotools usage
+# Module : GHS3DPLUGIN
+# Date : 10/01/2004
+#
+#
+
+include $(top_srcdir)/adm_local/unix/make_common_starter.am
+
+# header files
+salomeinclude_HEADERS =
+
+# Libraries targets
+lib_LTLIBRARIES = libGHS3DPluginGUI.la
+
+dist_libGHS3DPluginGUI_la_SOURCES = GHS3DPluginGUI_HypothesisCreator.cxx
+
+MOC_FILES = GHS3DPluginGUI_HypothesisCreator_moc.cxx
+nodist_libGHS3DPluginGUI_la_SOURCES= $(MOC_FILES)
+
+libGHS3DPluginGUI_la_CPPFLAGS = \
+ $(QT_INCLUDES) \
+ $(KERNEL_CXXFLAGS) \
+ $(GUI_CXXFLAGS) \
+ $(GEOM_CXXFLAGS) \
+ $(MED_CXXFLAGS) \
+ $(SMESH_CXXFLAGS) \
+ $(BOOST_CPPFLAGS) \
+ $(CORBA_CXXFLAGS) \
+ $(CORBA_INCLUDES) \
+ $(CAS_CPPFLAGS) \
+ -I$(top_builddir)/idl \
+ -I$(top_builddir)/salome_adm/unix
+
+libGHS3DPluginGUI_la_LDFLAGS = \
+ ../../idl/libSalomeIDLGHS3DPLUGIN.la \
+ $(SMESH_LDFLAGS) -lSMESH \
+ $(CAS_KERNEL)
+
+# resources files
+nodist_salomeres_DATA= \
+ GHS3DPlugin_images.qm \
+ GHS3DPlugin_msg_en.qm
include $(top_srcdir)/adm_local/unix/make_common_starter.am
+if GHS3DPLUGIN_ENABLE_GUI
+ SUBDIRS = GUI
+endif
+
# header files
salomeinclude_HEADERS =
dist_libGHS3DEngine_la_SOURCES = \
GHS3DPlugin_GHS3D.cxx \
GHS3DPlugin_GHS3D_i.cxx \
- GHS3DPlugin_i.cxx
+ GHS3DPlugin_i.cxx \
+ GHS3DPlugin_Hypothesis.cxx \
+ GHS3DPlugin_Hypothesis_i.cxx
-libGHS3DEngine_la_CPPFLAGS = \
- $(KERNEL_CXXFLAGS) \
- $(GUI_CXXFLAGS) \
- $(GEOM_CXXFLAGS) \
- $(SMESH_CXXFLAGS) \
- $(BOOST_CPPFLAGS) \
- $(CORBA_CXXFLAGS) \
- $(CORBA_INCLUDES) \
- $(CAS_CPPFLAGS) \
+libGHS3DEngine_la_CPPFLAGS = \
+ $(KERNEL_CXXFLAGS) \
+ $(GEOM_CXXFLAGS) \
+ $(MED_CXXFLAGS) \
+ $(SMESH_CXXFLAGS) \
+ $(BOOST_CPPFLAGS) \
+ $(CORBA_CXXFLAGS) \
+ $(CORBA_INCLUDES) \
+ $(CAS_CPPFLAGS) \
-I$(top_builddir)/idl \
-I$(top_builddir)/salome_adm/unix
libGHS3DEngine_la_LDFLAGS = \
../idl/libSalomeIDLGHS3DPLUGIN.la \
- $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine \
+ $(SMESH_LDFLAGS) -lSMESHimpl -lSMESHEngine
$(KERNEL_LDFLAGS) -lSalomeGenericObj
-
-# resources files
-nodist_salomeres_DATA = GHS3DPlugin_icons.qm