*/
//=============================================================================
- GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_3D_Algo(hypId, studyId, gen), _isLibUsed( false )
+ GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, SMESH_Gen* gen)
+ : SMESH_3D_Algo(hypId, gen), _isLibUsed( false )
{
- MESSAGE("GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D");
_name = Name();
_shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
_onlyUnaryInput = false; // Compute() will be called on a compound of solids
TopoDS_Shape GHS3DPlugin_GHS3D::entryToShape(std::string entry)
{
- if ( _study->_is_nil() )
- MESSAGE("GHS3DPlugin_GHS3D::entryToShape "<<entry );
++ if ( SMESH_Gen_i::getStudyServant()->_is_nil() )
+ throw SALOME_Exception("MG-Tetra plugin can't work w/o publishing in the study");
+
GEOM::GEOM_Object_var aGeomObj;
TopoDS_Shape S = TopoDS_Shape();
- SALOMEDS::SObject_var aSObj = _study->FindObjectID( entry.c_str() );
+ SALOMEDS::SObject_var aSObj = SMESH_Gen_i::getStudyServant()->FindObjectID( entry.c_str() );
if (!aSObj->_is_nil() ) {
CORBA::Object_var obj = aSObj->GetObject();
aGeomObj = GEOM::GEOM_Object::_narrow(obj);
class GHS3DPlugin_GHS3D: public SMESH_3D_Algo
{
public:
- GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen);
+
+ GHS3DPlugin_GHS3D(int hypId, SMESH_Gen* gen);
virtual ~GHS3DPlugin_GHS3D();
virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
SMESH_Algo_i( thePOA ),
SMESH_3D_Algo_i( thePOA )
{
- MESSAGE( "GHS3DPlugin_GHS3D_i::GHS3DPlugin_GHS3D_i" );
myBaseImpl = new ::GHS3DPlugin_GHS3D (theGenImpl->GetANewId(),
- theStudyId,
theGenImpl );
}
SMESH::SMESH_Mesh_ptr GHS3DPlugin_GHS3D_i::importGMFMesh(const char* theGMFFileName)
{
- MESSAGE( "GHS3DPlugin_GHS3D_i::importGMFMesh" );
SMESH_Gen_i* smeshGen = SMESH_Gen_i::GetSMESHGen();
SMESH::SMESH_Mesh_ptr theMesh = smeshGen->CreateEmptyMesh();
- smeshGen->RemoveLastFromPythonScript(smeshGen->GetCurrentStudy()->StudyId());
- SALOMEDS::SObject_ptr theSMesh = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(), theMesh);
+ smeshGen->RemoveLastFromPythonScript();
+ SALOMEDS::SObject_ptr theSMesh = smeshGen->ObjectToSObject(theMesh);
#ifdef WINNT
#define SEP '\\'
#else
}
return theMesh;
}
- int theStudyId,
+
+//=============================================================================
+/*!
+ * GHS3DPlugin_Optimizer_i::GHS3DPlugin_Optimizer_i
+ *
+ * Constructor
+ */
+//=============================================================================
+
+GHS3DPlugin_Optimizer_i::GHS3DPlugin_Optimizer_i (PortableServer::POA_ptr thePOA,
- theStudyId,
+ ::SMESH_Gen* theGenImpl )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ SMESH_Algo_i( thePOA ),
+ SMESH_3D_Algo_i( thePOA )
+{
+ myBaseImpl = new ::GHS3DPlugin_Optimizer (theGenImpl->GetANewId(),
+ theGenImpl );
+}
+
virtual SMESH::SMESH_Mesh_ptr importGMFMesh(const char* theGMFFileName);
};
- int theStudyId,
+// ======================================================
+// MG-Tetra Optimization 3d algorithm
+// ======================================================
+class GHS3DPlugin_Optimizer_i:
+ public virtual POA_GHS3DPlugin::GHS3DPlugin_Optimizer,
+ public virtual SMESH_3D_Algo_i
+{
+public:
+ // Constructor
+ GHS3DPlugin_Optimizer_i (PortableServer::POA_ptr thePOA,
+ ::SMESH_Gen* theGenImpl );
+};
+
#endif
: SALOME::GenericObj_i( thePOA ),
SMESH_Hypothesis_i( thePOA )
{
- MESSAGE( "GHS3DPlugin_Hypothesis_i::GHS3DPlugin_Hypothesis_i" );
myBaseImpl = new ::GHS3DPlugin_Hypothesis (theGenImpl->GetANewId(),
- theStudyId,
theGenImpl);
}
bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
throw (SALOME::SALOME_Exception)
{
-// #if GHS3D_VERSION >= 42
return p_SetEnforcedMesh(theSource, theType);
-// #else
-// SALOME::ExceptionStruct ExDescription;
-// ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
-// ExDescription.type = SALOME::BAD_PARAM;
-// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-// ExDescription.lineNumber = 750;
-// throw SALOME::SALOME_Exception(ExDescription);
-// #endif
}
-bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, const char* theName, const char* theGroupName)
+bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource,
+ SMESH::ElementType theType,
+ const char* theName,
+ const char* theGroupName)
throw (SALOME::SALOME_Exception)
{
- MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
ASSERT(myBaseImpl);
-
+
if (CORBA::is_nil( theSource ))
- {
- SALOME::ExceptionStruct ExDescription;
- ExDescription.text = "The source mesh CORBA object is NULL";
- ExDescription.type = SALOME::BAD_PARAM;
- ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
- ExDescription.lineNumber = 840;
- throw SALOME::SALOME_Exception(ExDescription);
- }
-
+ THROW_SALOME_CORBA_EXCEPTION( "The source mesh CORBA object is NULL" ,SALOME::BAD_PARAM );
+
switch (theType) {
- case SMESH::NODE:
- MESSAGE("Required type is NODE");
- break;
- case SMESH::EDGE:
- MESSAGE("Required type is EDGE");
- break;
- case SMESH::FACE:
- MESSAGE("Required type is FACE");
- break;
- default:
- MESSAGE("Incompatible required type: " << theType);
- return false;
+ case SMESH::NODE:
+ case SMESH::EDGE:
+ case SMESH::FACE: break;
+ default:
+ return false;
}
-// MESSAGE("Required type is "<<theType);
SMESH::array_of_ElementType_var types = theSource->GetTypes();
- MESSAGE("Available types:");
- for ( CORBA::ULong i=0;i<types->length();i++){MESSAGE(types[i]);}
if ( types->length() >= 1 && types[types->length()-1] < theType)
{
- MESSAGE("Required type not available");
return false;
-// SALOME::ExceptionStruct ExDescription;
-// ExDescription.text = "The source mesh has bad type";
-// ExDescription.type = SALOME::BAD_PARAM;
-// ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
-// ExDescription.lineNumber = 840;
-// throw SALOME::SALOME_Exception(ExDescription);
}
-
SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
- SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
+ SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(theSource);
SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
--- /dev/null
- GHS3DPlugin_Optimizer::GHS3DPlugin_Optimizer(int hypId, int studyId, SMESH_Gen* gen)
- : SMESH_3D_Algo(hypId, studyId, gen)
+// Copyright (C) 2004-2016 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, or (at your option) any later version.
+//
+// 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_Optimizer.cxx
+// Created : Mon Oct 31 20:05:28 2016
+
+#include "GHS3DPlugin_Optimizer.hxx"
+
+#include "GHS3DPlugin_GHS3D.hxx"
+#include "GHS3DPlugin_OptimizerHypothesis.hxx"
+#include "MG_Tetra_API.hxx"
+
+#include <SMDS_VolumeTool.hxx>
+#include <SMESHDS_Mesh.hxx>
+#include <SMESH_File.hxx>
+#include <SMESH_Mesh.hxx>
+#include <SMESH_MesherHelper.hxx>
+
+#include <TopoDS_Shape.hxx>
+
+//================================================================================
+/*!
+ * \brief Constructor
+ */
+//================================================================================
+
++GHS3DPlugin_Optimizer::GHS3DPlugin_Optimizer(int hypId, SMESH_Gen* gen)
++ : SMESH_3D_Algo(hypId, gen)
+{
+ _name = Name();
+ _compatibleHypothesis.push_back( GHS3DPlugin_OptimizerHypothesis::GetHypType());
+ _requireShape = false; // work without shape only
+}
+
+//================================================================================
+/*!
+ * \brief Get a hypothesis
+ */
+//================================================================================
+
+bool GHS3DPlugin_Optimizer::CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ Hypothesis_Status& aStatus)
+{
+ _hyp = NULL;
+
+ const std::list <const SMESHDS_Hypothesis * >& hyps = GetUsedHypothesis(aMesh, aShape);
+ if ( !hyps.empty() )
+ _hyp = dynamic_cast< const GHS3DPlugin_OptimizerHypothesis* >( hyps.front() );
+
+ aStatus = HYP_OK;
+ return true;
+}
+
+//================================================================================
+/*!
+ * \brief Terminate a process
+ */
+//================================================================================
+
+void GHS3DPlugin_Optimizer::CancelCompute()
+{
+ _computeCanceled = true;
+}
+
+//================================================================================
+/*!
+ * \brief Evaluate nb of elements
+ */
+//================================================================================
+
+bool GHS3DPlugin_Optimizer::Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
+ MapShapeNbElems& aResMap)
+{
+ return false;
+}
+//================================================================================
+/*!
+ * \brief Does nothing
+ */
+//================================================================================
+
+bool GHS3DPlugin_Optimizer::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+{
+ return false;
+}
+
+namespace
+{
+ //================================================================================
+ /*!
+ * \brief Compute average size of tetrahedra araound a node
+ */
+ //================================================================================
+
+ double getSizeAtNode( const SMDS_MeshNode* node )
+ {
+ double size = 0;
+ int nbTet = 0;
+
+ SMDS_VolumeTool vt;
+ vt.SetExternalNormal();
+
+ SMDS_ElemIteratorPtr volIt = node->GetInverseElementIterator(SMDSAbs_Volume);
+ while ( volIt->more() )
+ {
+ const SMDS_MeshElement* vol = volIt->next();
+ if ( vol->GetGeomType() != SMDSGeom_TETRA )
+ continue;
+ double volSize = 0.;
+ int nbLinks = 0;
+ int dN = vol->IsQuadratic() ? 2 : 1;
+ vt.Set( vol );
+ for ( int iF = 0, nbF = vt.NbFaces(); iF < nbF; ++iF )
+ {
+ const SMDS_MeshNode** nodes = vt. GetFaceNodes( iF );
+ for ( int iN = 0, nbN = vt.NbFaceNodes( iF ); iN < nbN; iN += dN )
+ if ( nodes[ iN ] < nodes[ iN + dN ]) // use a link once
+ {
+ volSize += SMESH_TNodeXYZ( nodes[ iN ]).Distance( nodes[ iN + dN ]);
+ ++nbLinks;
+ }
+ }
+ size += volSize / nbLinks;
+ ++nbTet;
+ }
+ return nbTet > 0 ? size/nbTet : 0.;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Write a mesh file and a solution file
+ */
+ //================================================================================
+
+ bool writeGMFFile( MG_Tetra_API* theMGInput,
+ SMESH_MesherHelper* theHelper,
+ const std::string& theMeshFileName,
+ const std::string& theSolFileName )
+ {
+ const int tag = 0;
+
+ int mfile = theMGInput->GmfOpenMesh( theMeshFileName.c_str(), GmfWrite, GMFVERSION,GMFDIMENSION );
+ int sfile = theMGInput->GmfOpenMesh( theSolFileName.c_str(), GmfWrite, GMFVERSION,GMFDIMENSION );
+ if ( !mfile || !sfile )
+ return false;
+
+ // write all nodes and volume size at them
+
+ SMESHDS_Mesh* meshDS = theHelper->GetMeshDS();
+ if ( meshDS->NbNodes() != meshDS->MaxNodeID() )
+ meshDS->compactMesh();
+
+ theMGInput->GmfSetKwd( mfile, GmfVertices, meshDS->NbNodes() );
+ int TypTab[] = { GmfSca };
+ theMGInput->GmfSetKwd( sfile, GmfSolAtVertices, meshDS->NbNodes(), 1, TypTab);
+
+ SMDS_NodeIteratorPtr nodeIt = theHelper->GetMeshDS()->nodesIterator();
+ while ( nodeIt->more() )
+ {
+ const SMDS_MeshNode* node = nodeIt->next();
+ theMGInput->GmfSetLin( mfile, GmfVertices, node->X(), node->Y(), node->Z(), tag );
+
+ double size = getSizeAtNode( node );
+ theMGInput->GmfSetLin( sfile, GmfSolAtVertices, &size );
+ }
+
+ // write all triangles
+
+ theMGInput->GmfSetKwd( mfile, GmfTriangles, meshDS->GetMeshInfo().NbTriangles() );
+ SMDS_ElemIteratorPtr triaIt = meshDS->elementGeomIterator( SMDSGeom_TRIANGLE );
+ while ( triaIt->more() )
+ {
+ const SMDS_MeshElement* tria = triaIt->next();
+ theMGInput->GmfSetLin( mfile, GmfTriangles,
+ tria->GetNode(0)->GetID(),
+ tria->GetNode(1)->GetID(),
+ tria->GetNode(2)->GetID(),
+ tag );
+ }
+
+ // write all tetra
+
+ theMGInput->GmfSetKwd( mfile, GmfTetrahedra, meshDS->GetMeshInfo().NbTetras() );
+ SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA );
+ while ( tetIt->more() )
+ {
+ const SMDS_MeshElement* tet = tetIt->next();
+ theMGInput->GmfSetLin( mfile, GmfTetrahedra,
+ tet->GetNode(0)->GetID(),
+ tet->GetNode(2)->GetID(),
+ tet->GetNode(1)->GetID(),
+ tet->GetNode(3)->GetID(),
+ tag );
+ }
+
+ theMGInput->GmfCloseMesh( mfile );
+ theMGInput->GmfCloseMesh( sfile );
+
+ return true;
+ }
+
+ //================================================================================
+ /*!
+ * \brief Read optimized tetrahedra
+ */
+ //================================================================================
+
+ bool readGMFFile( MG_Tetra_API* theMGOutput,
+ SMESH_MesherHelper* theHelper,
+ const std::string& theMeshFileName )
+ {
+ int ver, dim, tag;
+ int inFile = theMGOutput->GmfOpenMesh( theMeshFileName.c_str(), GmfRead, &ver, &dim);
+ if ( !inFile )
+ return false;
+
+ SMESHDS_Mesh* meshDS = theHelper->GetMeshDS();
+
+ int nbNodes = theMGOutput->GmfStatKwd( inFile, GmfVertices );
+ int nbTet = theMGOutput->GmfStatKwd( inFile, GmfTetrahedra );
+ int nbNodesOld = meshDS->NbNodes();
+ int nbTetOld = meshDS->GetMeshInfo().NbTetras();
+ std::cout << "Optimization input: "
+ << nbNodesOld << " nodes, \t" << nbTetOld << " tetra" << std::endl;
+ std::cout << "Optimization output: "
+ << nbNodes << " nodes, \t" << nbTet << " tetra" << std::endl;
+
+ double x,y,z;
+ int i1, i2, i3, i4;
+ theMGOutput->GmfGotoKwd( inFile, GmfVertices );
+
+ if ( nbNodes == nbNodesOld && nbTet == nbTetOld )
+ {
+ // move nodes
+ SMDS_NodeIteratorPtr nodeIt = theHelper->GetMeshDS()->nodesIterator();
+ while ( nodeIt->more() )
+ {
+ const SMDS_MeshNode* node = nodeIt->next();
+ theMGOutput->GmfGetLin( inFile, GmfVertices, &x, &y, &z, &tag );
+ meshDS->MoveNode( node, x,y,z );
+ }
+
+ // update tetra
+ const SMDS_MeshNode* nodes[ 4 ];
+ theMGOutput->GmfGotoKwd( inFile, GmfTetrahedra );
+ SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA );
+ for ( int i = 0; i < nbTet; ++i )
+ {
+ const SMDS_MeshElement* tet = tetIt->next();
+ theMGOutput->GmfGetLin( inFile, GmfTetrahedra, &i1, &i2, &i3, &i4, &tag);
+ nodes[ 0 ] = meshDS->FindNode( i1 );
+ nodes[ 1 ] = meshDS->FindNode( i3 );
+ nodes[ 2 ] = meshDS->FindNode( i2 );
+ nodes[ 3 ] = meshDS->FindNode( i4 );
+ meshDS->ChangeElementNodes( tet, &nodes[0], 4 );
+ }
+ }
+ else if ( nbNodes >= nbNodesOld ) // tetra added/removed
+ {
+ // move or add nodes
+ for ( int iN = 1; iN <= nbNodes; ++iN )
+ {
+ theMGOutput->GmfGetLin( inFile, GmfVertices, &x, &y, &z, &tag );
+ const SMDS_MeshNode* node = meshDS->FindNode( iN );
+ if ( !node )
+ node = meshDS->AddNode( x,y,z );
+ else
+ meshDS->MoveNode( node, x,y,z );
+ }
+
+ // remove tetrahedra
+ SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA );
+ while ( tetIt->more() )
+ meshDS->RemoveFreeElement( tetIt->next(), /*sm=*/0 );
+
+ // add tetrahedra
+ theMGOutput->GmfGotoKwd( inFile, GmfTetrahedra );
+ for ( int i = 0; i < nbTet; ++i )
+ {
+ theMGOutput->GmfGetLin( inFile, GmfTetrahedra, &i1, &i2, &i3, &i4, &tag);
+ meshDS->AddVolume( meshDS->FindNode( i1 ),
+ meshDS->FindNode( i3 ),
+ meshDS->FindNode( i2 ),
+ meshDS->FindNode( i4 ));
+ }
+ }
+ else if ( nbNodes < nbNodesOld ) // nodes and tetra removed
+ {
+ // unmark nodes
+ SMDS_NodeIteratorPtr nIt = meshDS->nodesIterator();
+ while ( nIt->more() )
+ nIt->next()->setIsMarked( false );
+
+ // remove tetrahedra and mark nodes used by them
+ SMDS_ElemIteratorPtr tetIt = meshDS->elementGeomIterator( SMDSGeom_TETRA );
+ while ( tetIt->more() )
+ {
+ const SMDS_MeshElement* tet = tetIt->next();
+ SMDS_ElemIteratorPtr nIter = tet->nodesIterator();
+ while ( nIter->more() )
+ nIter->next()->setIsMarked( true );
+
+ meshDS->RemoveFreeElement( tet, /*sm=*/0 );
+ }
+
+ // move or add nodes
+ for ( int iN = 1; iN <= nbNodes; ++iN )
+ {
+ theMGOutput->GmfGetLin( inFile, GmfVertices, &x, &y, &z, &tag );
+ const SMDS_MeshNode* node = meshDS->FindNode( iN );
+ if ( !node )
+ node = meshDS->AddNode( x,y,z );
+ else
+ meshDS->MoveNode( node, x,y,z );
+ }
+
+ // add tetrahedra
+ theMGOutput->GmfGotoKwd( inFile, GmfTetrahedra );
+ for ( int i = 0; i < nbTet; ++i )
+ {
+ theMGOutput->GmfGetLin( inFile, GmfTetrahedra, &i1, &i2, &i3, &i4, &tag);
+ meshDS->AddVolume( meshDS->FindNode( i1 ),
+ meshDS->FindNode( i3 ),
+ meshDS->FindNode( i2 ),
+ meshDS->FindNode( i4 ));
+ }
+
+ // remove free marked nodes
+ for ( nIt = meshDS->nodesIterator(); nIt->more(); )
+ {
+ const SMDS_MeshNode* node = nIt->next();
+ if ( node->NbInverseElements() == 0 && node->isMarked() )
+ meshDS->RemoveFreeNode( node, 0 );
+ }
+ }
+
+ // avoid "No mesh elements assigned to a sub-shape" error
+ theHelper->GetMesh()->GetSubMesh( theHelper->GetSubShape() )->SetIsAlwaysComputed( true );
+
+ return true;
+ }
+
+ void getNodeByGhsId( SMESH_Mesh& mesh, std::vector <const SMDS_MeshNode*> & nodeByGhsId )
+ {
+ SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
+ const int nbNodes = meshDS->NbNodes();
+ nodeByGhsId.resize( nbNodes + 1 );
+ SMDS_NodeIteratorPtr nodeIt = meshDS->nodesIterator();
+ while ( nodeIt->more() )
+ {
+ const SMDS_MeshNode* node = nodeIt->next();
+ if ( node->GetID() <= nbNodes )
+ nodeByGhsId[ node->GetID() ] = node;
+#ifdef _DEBUG_
+ else
+ throw SALOME_Exception(LOCALIZED ("bad ID -- not compacted mesh"));
+#endif
+ }
+ }
+
+ void removeFile(const std::string& name)
+ {
+ SMESH_File( name ).remove();
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Optimize an existing tetrahedral mesh
+ */
+//================================================================================
+
+bool GHS3DPlugin_Optimizer::Compute(SMESH_Mesh& theMesh,
+ SMESH_MesherHelper* theHelper)
+{
+ if ( theMesh.NbTetras() == 0 )
+ return error( COMPERR_BAD_INPUT_MESH, "No tetrahedra" );
+ if ( theMesh.NbTetras( ORDER_QUADRATIC ) > 0 )
+ return error( COMPERR_BAD_INPUT_MESH, "Quadratic mesh can't be optimized" );
+ if ( theMesh.NbTriangles() == 0 )
+ return error( COMPERR_BAD_INPUT_MESH, "2D mesh must exist around tetrahedra" );
+
+ std::string aGenericName = GHS3DPlugin_Hypothesis::GetFileName(_hyp);
+ std::string aLogFileName = aGenericName + ".log"; // log
+ std::string aGMFFileName = aGenericName + ".mesh"; // input GMF mesh file
+ std::string aSolFileName = aGenericName + ".sol"; // input size map file
+ std::string aResultFileName = aGenericName + "_Opt.mesh"; // out GMF mesh file
+ std::string aResSolFileName = aGenericName + "_Opt.sol"; // out size map file
+
+ MG_Tetra_API mgTetra( _computeCanceled, _progress );
+
+ bool Ok = writeGMFFile( &mgTetra, theHelper, aGMFFileName, aSolFileName );
+
+ // -----------------
+ // run MG-Tetra mesher
+ // -----------------
+
+ bool logInStandardOutput = _hyp ? _hyp->GetStandardOutputLog() : false;
+ bool removeLogOnSuccess = _hyp ? _hyp->GetRemoveLogOnSuccess() : true;
+ bool keepFiles = _hyp ? _hyp->GetKeepFiles() : false;
+
+ std::string cmd = GHS3DPlugin_OptimizerHypothesis::CommandToRun( _hyp );
+
+ if ( mgTetra.IsExecutable() )
+ {
+ cmd += " --in " + aGMFFileName;
+ cmd += " --out " + aResultFileName;
+ }
+ if ( !logInStandardOutput )
+ {
+ mgTetra.SetLogFile( aLogFileName.c_str() );
+ cmd += " 1>" + aLogFileName; // dump into file
+ }
+ std::cout << std::endl;
+ std::cout << "MG-Tetra execution..." << std::endl;
+ std::cout << cmd << std::endl;
+
+ _computeCanceled = false;
+
+ std::string errStr;
+ Ok = mgTetra.Compute( cmd, errStr ); // run
+
+ if ( logInStandardOutput && mgTetra.IsLibrary() )
+ std::cout << std::endl << mgTetra.GetLog() << std::endl;
+ if ( Ok )
+ std::cout << std::endl << "End of MG-Tetra execution !" << std::endl;
+
+ // --------------
+ // read a result
+ // --------------
+ Ok = Ok && readGMFFile( &mgTetra, theHelper, aResultFileName );
+
+ // ---------------------
+ // remove working files
+ // ---------------------
+ if ( mgTetra.HasLog() )
+ {
+ if( _computeCanceled )
+ error( "interruption initiated by user" );
+ else
+ {
+ // get problem description from the log file
+ std::vector <const SMDS_MeshNode*> nodeByGhsId;
+ getNodeByGhsId( theMesh, nodeByGhsId );
+ _Ghs2smdsConvertor conv( nodeByGhsId, SMESH_ProxyMesh::Ptr( new SMESH_ProxyMesh( theMesh )));
+ error( GHS3DPlugin_GHS3D::getErrorDescription( logInStandardOutput ? 0 : aLogFileName.c_str(),
+ mgTetra.GetLog(), conv, Ok ));
+ }
+ }
+ else {
+ // the log file is empty
+ removeFile( aLogFileName );
+ INFOS( "MG-Tetra Error, " << errStr);
+ error(COMPERR_ALGO_FAILED, errStr);
+ }
+
+ if ( Ok && removeLogOnSuccess )
+ {
+ removeFile( aLogFileName );
+ }
+ if ( !keepFiles )
+ {
+ if ( !Ok && _computeCanceled )
+ removeFile( aLogFileName );
+ removeFile( aGMFFileName );
+ removeFile( aSolFileName );
+ removeFile( aResultFileName );
+ removeFile( aResSolFileName );
+ }
+ return Ok;
+}
+
+
+// double GHS3DPlugin_Optimizer::GetProgress() const
+// {
+// }
--- /dev/null
- GHS3DPlugin_Optimizer(int hypId, int studyId, SMESH_Gen* gen);
+// Copyright (C) 2004-2016 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, or (at your option) any later version.
+//
+// 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_Optimizer.hxx
+// Created : Mon Oct 31 19:58:02 2016
+
+
+#ifndef __GHS3DPlugin_Optimizer_HXX__
+#define __GHS3DPlugin_Optimizer_HXX__
+
+#include <SMESH_Algo.hxx>
+
+class GHS3DPlugin_OptimizerHypothesis;
+
+class GHS3DPlugin_Optimizer: public SMESH_3D_Algo
+{
+public:
++ GHS3DPlugin_Optimizer(int hypId, SMESH_Gen* gen);
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ Hypothesis_Status& aStatus);
+
+ virtual void CancelCompute();
+ bool computeCanceled() { return _computeCanceled; }
+
+ virtual bool Evaluate(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape,
+ MapShapeNbElems& aResMap);
+
+ virtual bool Compute(SMESH_Mesh& theMesh,
+ SMESH_MesherHelper* theHelper);
+ virtual bool Compute(SMESH_Mesh & aMesh,
+ const TopoDS_Shape & aShape);
+
+ static const char* Name() { return "MG-Tetra Optimization"; }
+
+ //virtual double GetProgress() const;
+
+private:
+
+ const GHS3DPlugin_OptimizerHypothesis* _hyp;
+};
+
+
+#endif
--- /dev/null
- int studyId,
+// Copyright (C) 2004-2016 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, or (at your option) any later version.
+//
+// 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_OptimizerHypothesis.cxx
+// Created : Tue Nov 1 17:18:38 2016
+
+#include "GHS3DPlugin_OptimizerHypothesis.hxx"
+
+#include <SMESH_Gen.hxx>
+
+GHS3DPlugin_OptimizerHypothesis::GHS3DPlugin_OptimizerHypothesis(int hypId,
- :GHS3DPlugin_Hypothesis( hypId, studyId, gen ),
+ SMESH_Gen * gen)
++ :GHS3DPlugin_Hypothesis( hypId, gen ),
+ myOptimization( YES ),
+ mySplitOverConstrained( NO ),
+ mySmoothOffSlivers( false ),
+ myMaximalNumberOfThreads( 4 ),
+ myPThreadsMode( NONE )
+{
+ _name = GetHypType();
+ _param_algo_dim = 3;
+}
+
+void GHS3DPlugin_OptimizerHypothesis::SetOptimization( Mode mode )
+{
+ if ( myOptimization != mode )
+ {
+ myOptimization = mode;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+GHS3DPlugin_OptimizerHypothesis::Mode GHS3DPlugin_OptimizerHypothesis::GetOptimization() const
+{
+ return myOptimization;
+}
+
+void GHS3DPlugin_OptimizerHypothesis::SetSplitOverConstrained( Mode mode )
+{
+ if ( mode != mySplitOverConstrained )
+ {
+ mySplitOverConstrained = mode;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+GHS3DPlugin_OptimizerHypothesis::Mode GHS3DPlugin_OptimizerHypothesis::GetSplitOverConstrained() const
+{
+ return mySplitOverConstrained;
+}
+
+void GHS3DPlugin_OptimizerHypothesis::SetSmoothOffSlivers( bool toSmooth )
+{
+ if ( mySmoothOffSlivers != toSmooth )
+ {
+ mySmoothOffSlivers = toSmooth;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+bool GHS3DPlugin_OptimizerHypothesis::GetSmoothOffSlivers() const
+{
+ return mySmoothOffSlivers;
+}
+
+void GHS3DPlugin_OptimizerHypothesis::SetPThreadsMode( PThreadsMode mode )
+{
+ if ( myPThreadsMode != mode )
+ {
+ myPThreadsMode = mode;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+GHS3DPlugin_OptimizerHypothesis::PThreadsMode GHS3DPlugin_OptimizerHypothesis::GetPThreadsMode() const
+{
+ return myPThreadsMode;
+}
+
+void GHS3DPlugin_OptimizerHypothesis::SetMaximalNumberOfThreads( int nb )
+{
+ if ( myMaximalNumberOfThreads != nb )
+ {
+ myMaximalNumberOfThreads = nb;
+ NotifySubMeshesHypothesisModification();
+ }
+}
+
+int GHS3DPlugin_OptimizerHypothesis::GetMaximalNumberOfThreads() const
+{
+ return myMaximalNumberOfThreads;
+}
+
+
+std::ostream & GHS3DPlugin_OptimizerHypothesis::SaveTo(std::ostream & save)
+{
+ save << " " << (int)myOptimization
+ << " " << (int)mySplitOverConstrained
+ << " " << (int)mySmoothOffSlivers
+ << " " << (int)myMaximalNumberOfThreads
+ << " " << (int)myPThreadsMode << " ";
+
+ GHS3DPlugin_Hypothesis::SaveTo( save );
+
+ return save;
+}
+
+std::istream & GHS3DPlugin_OptimizerHypothesis::LoadFrom(std::istream & load)
+{
+ int i;
+
+ if ( load >> i )
+ myOptimization = (Mode) i;
+ if ( load >> i )
+ mySplitOverConstrained = (Mode) i;
+ if ( load >> i )
+ mySmoothOffSlivers = (bool) i;
+ if ( load >> i )
+ myMaximalNumberOfThreads = i;
+ if ( load >> i )
+ myPThreadsMode = (PThreadsMode) i;
+
+ GHS3DPlugin_Hypothesis::LoadFrom( load );
+ return load;
+}
+
+bool GHS3DPlugin_OptimizerHypothesis::SetParametersByMesh(const SMESH_Mesh* theMesh,
+ const TopoDS_Shape& theShape)
+{
+ return false;
+}
+
+bool GHS3DPlugin_OptimizerHypothesis::SetParametersByDefaults(const TDefaults& theDflts,
+ const SMESH_Mesh* theMesh)
+{
+ return false;
+}
+
+std::string GHS3DPlugin_OptimizerHypothesis::CommandToRun(const GHS3DPlugin_OptimizerHypothesis* hyp)
+{
+ SMESH_Comment cmd( GetExeName() );
+
+ if ( hyp )
+ {
+ const char* mode[3] = { "no", "yes", "only" };
+
+ if ( hyp->GetOptimization() >= 0 && hyp->GetOptimization() < 3 )
+ cmd << " --optimisation " << mode[ hyp->GetOptimization() ];
+
+ if ( hyp->myOptimizationLevel >= 0 && hyp->myOptimizationLevel < 5 ) {
+ const char* level[] = { "none" , "light" , "standard" , "standard+" , "strong" };
+ cmd << " --optimisation_level " << level[ hyp->myOptimizationLevel ];
+ }
+
+ if ( hyp->GetSplitOverConstrained() >= 0 && hyp->GetSplitOverConstrained() < 3 )
+ cmd << " --split_overconstrained_elements " << mode[ hyp->GetSplitOverConstrained() ];
+
+ if ( hyp->GetSmoothOffSlivers() )
+ cmd << " --smooth_off_slivers yes";
+
+ switch ( hyp->GetPThreadsMode() ) {
+ case GHS3DPlugin_OptimizerHypothesis::SAFE:
+ cmd << " --pthreads_mode safe"; break;
+ case GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE:
+ cmd << " --pthreads_mode aggressive"; break;
+ default:;
+ }
+
+ if ( hyp->GetMaximalNumberOfThreads() > 0 )
+ cmd << " --max_number_of_threads " << hyp->GetMaximalNumberOfThreads();
+
+ if ( !hyp->myToCreateNewNodes )
+ cmd << " --no_internal_points";
+
+ if ( hyp->myMaximumMemory > 0 )
+ cmd << " --max_memory " << hyp->myMaximumMemory;
+
+ if ( hyp->myInitialMemory > 0 )
+ cmd << " --automatic_memory " << hyp->myInitialMemory;
+
+ cmd << " --verbose " << hyp->myVerboseLevel;
+
+ cmd << " " << hyp->myTextOption;
+ }
+
+ return cmd;
+}
--- /dev/null
- GHS3DPlugin_OptimizerHypothesis(int hypId, int studyId, SMESH_Gen * gen);
+// Copyright (C) 2004-2016 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, or (at your option) any later version.
+//
+// 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_OptimizerHypothesis.hxx
+// Created : Tue Nov 1 17:03:17 2016
+
+#ifndef __GHS3DPlugin_OptimizerHypothesis_HXX__
+#define __GHS3DPlugin_OptimizerHypothesis_HXX__
+
+#include "GHS3DPlugin_Hypothesis.hxx"
+
+
+class GHS3DPlugin_OptimizerHypothesis : public GHS3DPlugin_Hypothesis
+{
+public:
++ GHS3DPlugin_OptimizerHypothesis(int hypId, SMESH_Gen * gen);
+
+ // inherited params:
+ // 1 - create new nodes
+ // 2 - optimization level
+ // 3 - init and max memory
+ // 4 - work dir
+ // 5 - verbosity
+ // 6 - log to file
+ // 7 - keep work files
+ // 8 - remove log file
+ // 9 - advanced options
+
+ enum PThreadsMode { SAFE, AGGRESSIVE, NONE };
+ enum Mode { NO, YES, ONLY };
+
+ void SetOptimization( Mode isOnly );
+ Mode GetOptimization() const;
+
+ void SetSplitOverConstrained( Mode mode );
+ Mode GetSplitOverConstrained() const;
+
+ void SetSmoothOffSlivers( bool toSmooth );
+ bool GetSmoothOffSlivers() const;
+
+ void SetPThreadsMode( PThreadsMode mode );
+ PThreadsMode GetPThreadsMode() const;
+
+ void SetMaximalNumberOfThreads( int nb );
+ int GetMaximalNumberOfThreads() const;
+
+ static const char* GetHypType() { return "MG-Tetra Optimization Parameters"; }
+
+ // Persistence
+ virtual std::ostream & SaveTo(std::ostream & save);
+ virtual std::istream & LoadFrom(std::istream & load);
+
+ /*!
+ * \brief Does nothing
+ */
+ virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape);
+ virtual bool SetParametersByDefaults(const TDefaults& dflts, const SMESH_Mesh* theMesh=0);
+
+ static std::string CommandToRun(const GHS3DPlugin_OptimizerHypothesis* hyp);
+
+private:
+
+ Mode myOptimization; // no, yes, only
+ Mode mySplitOverConstrained; // no, yes, only
+ bool mySmoothOffSlivers;
+ int myMaximalNumberOfThreads;
+ PThreadsMode myPThreadsMode; // safe, aggressive, none
+
+};
+
+#endif
--- /dev/null
- int theStudyId,
+// Copyright (C) 2004-2016 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, or (at your option) any later version.
+//
+// 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_OptimizerHypothesis_i.cxx
+// Created : Tue Nov 1 17:46:39 2016
+
+#include "GHS3DPlugin_OptimizerHypothesis_i.hxx"
+
+#include <SMESH_Gen.hxx>
+#include <SMESH_PythonDump.hxx>
+
+#include <Utils_CorbaException.hxx>
+
+GHS3DPlugin_OptimizerHypothesis_i::
+GHS3DPlugin_OptimizerHypothesis_i (PortableServer::POA_ptr thePOA,
- GHS3DPlugin_Hypothesis_i( thePOA, theStudyId, theGenImpl )
+ ::SMESH_Gen* theGenImpl)
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
- myBaseImpl = new ::GHS3DPlugin_OptimizerHypothesis( id, theStudyId, theGenImpl );
++ GHS3DPlugin_Hypothesis_i( thePOA, theGenImpl )
+{
+ int id = myBaseImpl ? myBaseImpl->GetID() : theGenImpl->GetANewId();
+ if ( myBaseImpl )
+ delete myBaseImpl;
+
++ myBaseImpl = new ::GHS3DPlugin_OptimizerHypothesis( id, theGenImpl );
+}
+
+namespace
+{
+ const char* dumpMode( GHS3DPlugin::Mode mode )
+ {
+ switch( mode ) {
+ case GHS3DPlugin::NO: return "GHS3DPlugin.NO";
+ case GHS3DPlugin::YES: return "GHS3DPlugin.YES";
+ case GHS3DPlugin::ONLY: return "GHS3DPlugin.ONLY";
+ default: return "GHS3DPlugin.NO";
+ }
+ return 0;
+ }
+}
+
+void GHS3DPlugin_OptimizerHypothesis_i::SetOptimization( GHS3DPlugin::Mode mode )
+{
+ if ((int) GetImpl()->GetOptimization() != (int) mode )
+ {
+ GetImpl()->SetOptimization( ::GHS3DPlugin_OptimizerHypothesis::Mode( mode ));
+ SMESH::TPythonDump() << _this() << ".SetOptimization( " << dumpMode( mode ) << " )";
+ }
+}
+
+GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetOptimization()
+{
+ return GHS3DPlugin::Mode( GetImpl()->GetOptimization() );
+}
+
+void GHS3DPlugin_OptimizerHypothesis_i::SetSplitOverConstrained( GHS3DPlugin::Mode mode )
+{
+ if ((int) GetImpl()->GetSplitOverConstrained() != (int) mode )
+ {
+ GetImpl()->SetSplitOverConstrained((::GHS3DPlugin_OptimizerHypothesis::Mode) mode );
+ SMESH::TPythonDump() << _this() << ".SetSplitOverConstrained( " << dumpMode( mode ) << " )";
+ }
+}
+
+GHS3DPlugin::Mode GHS3DPlugin_OptimizerHypothesis_i::GetSplitOverConstrained()
+{
+ return (GHS3DPlugin::Mode) GetImpl()->GetSplitOverConstrained();
+}
+
+void GHS3DPlugin_OptimizerHypothesis_i::SetSmoothOffSlivers( CORBA::Boolean toSmooth )
+{
+ if ( GetImpl()->GetSmoothOffSlivers() != (bool) toSmooth )
+ {
+ GetImpl()->SetSmoothOffSlivers((bool) toSmooth );
+ SMESH::TPythonDump() << _this() << ".SetSmoothOffSlivers( " << toSmooth << " )";
+ }
+}
+
+CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::GetSmoothOffSlivers()
+{
+ return GetImpl()->GetSmoothOffSlivers();
+}
+
+void GHS3DPlugin_OptimizerHypothesis_i::SetPThreadsMode( GHS3DPlugin::PThreadsMode mode )
+{
+ if ((int) GetImpl()->GetPThreadsMode() != (int) mode )
+ {
+ GetImpl()->SetPThreadsMode((::GHS3DPlugin_OptimizerHypothesis::PThreadsMode) mode );
+
+ std::string modeStr;
+ switch( mode ) {
+ case ::GHS3DPlugin_OptimizerHypothesis::SAFE: modeStr = "SAFE"; break;
+ case ::GHS3DPlugin_OptimizerHypothesis::AGGRESSIVE: modeStr = "AGGRESSIVE"; break;
+ default: modeStr = "NONE";
+ }
+ SMESH::TPythonDump() << _this() << ".SetPThreadsMode( GHS3DPlugin." << modeStr << " )";
+ }
+}
+
+GHS3DPlugin::PThreadsMode GHS3DPlugin_OptimizerHypothesis_i::GetPThreadsMode()
+{
+ return (GHS3DPlugin::PThreadsMode) GetImpl()->GetPThreadsMode();
+}
+
+void GHS3DPlugin_OptimizerHypothesis_i::SetMaximalNumberOfThreads( CORBA::Short nb )
+{
+ if ( GetImpl()->GetMaximalNumberOfThreads() != nb )
+ {
+ GetImpl()->SetMaximalNumberOfThreads( nb );
+ SMESH::TPythonDump() << _this() << ".SetMaximalNumberOfThreads( " << nb << " )";
+ }
+}
+
+CORBA::Short GHS3DPlugin_OptimizerHypothesis_i::GetMaximalNumberOfThreads()
+{
+ return (CORBA::Short) GetImpl()->GetMaximalNumberOfThreads();
+}
+
+::GHS3DPlugin_OptimizerHypothesis* GHS3DPlugin_OptimizerHypothesis_i::GetImpl()
+{
+ return (::GHS3DPlugin_OptimizerHypothesis*)myBaseImpl;
+}
+
+CORBA::Boolean GHS3DPlugin_OptimizerHypothesis_i::IsDimSupported( SMESH::Dimension type )
+{
+ return type == SMESH::DIM_3D;
+}
+
+
--- /dev/null
- int theStudyId,
+// Copyright (C) 2004-2016 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, or (at your option) any later version.
+//
+// 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_OptimizerHypothesis_i.hxx
+// Created : Tue Nov 1 17:36:05 2016
+
+#ifndef __GHS3DPlugin_OptimizerHypothesis_i_HXX__
+#define __GHS3DPlugin_OptimizerHypothesis_i_HXX__
+
+#include "GHS3DPlugin_Defs.hxx"
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(GHS3DPlugin_Algorithm)
+
+#include "GHS3DPlugin_OptimizerHypothesis.hxx"
+#include "GHS3DPlugin_Hypothesis_i.hxx"
+#include "SMESH_Hypothesis_i.hxx"
+
+class SMESH_Gen;
+
+// GHS3DPlugin Optimization Parameters hypothesis
+
+class GHS3DPLUGIN_EXPORT GHS3DPlugin_OptimizerHypothesis_i:
+ public virtual POA_GHS3DPlugin::GHS3DPlugin_OptimizerHypothesis,
+ public virtual GHS3DPlugin_Hypothesis_i
+{
+ public:
+ GHS3DPlugin_OptimizerHypothesis_i (PortableServer::POA_ptr thePOA,
+ ::SMESH_Gen* theGenImpl);
+ // inherited params:
+ // 1 - create new nodes
+ // 2 - optimization level
+ // 3 - init and max memory
+ // 4 - work dir
+ // 5 - verbosity
+ // 6 - log to file
+ // 7 - keep work files
+ // 8 - remove log file
+ // 9 - advanced options
+
+ void SetOptimization( GHS3DPlugin::Mode mode );
+ GHS3DPlugin::Mode GetOptimization();
+
+ void SetSplitOverConstrained( GHS3DPlugin::Mode mode );
+ GHS3DPlugin::Mode GetSplitOverConstrained();
+
+ void SetSmoothOffSlivers( CORBA::Boolean toSmooth );
+ CORBA::Boolean GetSmoothOffSlivers();
+
+ void SetPThreadsMode( GHS3DPlugin::PThreadsMode mode );
+ GHS3DPlugin::PThreadsMode GetPThreadsMode();
+
+ void SetMaximalNumberOfThreads( CORBA::Short nb );
+ CORBA::Short GetMaximalNumberOfThreads();
+
+
+ // Get implementation
+ ::GHS3DPlugin_OptimizerHypothesis* GetImpl();
+
+ // Verify whether hypothesis supports given entity type
+ CORBA::Boolean IsDimSupported( SMESH::Dimension type );
+
+};
+
+#endif
int elementType = myEnfMeshConstraint->currentIndex();
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
- _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
+ _PTR(SObject) aSObj;
QString meshEntry = myEnfMeshWdg->GetValue();
- MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
if (selEnfMeshes == 1)
{
- MESSAGE("1 SMESH object selected");
-// myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
-// std::string entry = myEnfMeshWdg->GetValue();
aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
- CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
- if (!CORBA::is_nil(anObj))
+ CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
+ if (!CORBA::is_nil(anObj)) {
-// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
+ }
}
else
{
QStringListIterator meshEntriesIt (meshEntries);
while (meshEntriesIt.hasNext()) {
aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
- CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+ CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj);
if (!CORBA::is_nil(anObj)) {
-// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, groupName);
}
}
// 2. Add new enforced vertex according to h_data
if ( nbEnfMeshListHyp > 0)
h->ClearEnforcedMeshes();
-
+
TEnfMeshList::const_iterator itEnfMesh;
- _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(Study) aStudy = SMESH::getStudy();
for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
TEnfMesh* enfMesh = (*itEnfMesh);