1 // Copyright (C) 2012-2013 ALNEOS
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.alneos.com/ or email : contact@alneos.fr
19 #include "GMSHPlugin_Mesher.hxx"
20 #include "GMSHPlugin_Hypothesis_2D.hxx"
22 #include <SMDS_FaceOfNodes.hxx>
23 #include <SMDS_MeshElement.hxx>
24 #include <SMDS_MeshNode.hxx>
25 #include <SMESHDS_Mesh.hxx>
26 #include <SMESH_Block.hxx>
27 #include <SMESH_Comment.hxx>
28 #include <SMESH_ComputeError.hxx>
29 #include <SMESH_File.hxx>
30 #include <SMESH_Gen_i.hxx>
31 #include <SMESH_Mesh.hxx>
32 #include <SMESH_MesherHelper.hxx>
33 #include <SMESH_subMesh.hxx>
34 #include <utilities.h>
39 #include <BRep_Tool.hxx>
40 #include <Bnd_B3d.hxx>
41 #include <GCPnts_AbscissaPoint.hxx>
42 #include <GeomAdaptor_Curve.hxx>
43 #include <NCollection_Map.hxx>
44 #include <OSD_File.hxx>
45 #include <OSD_Path.hxx>
46 #include <Standard_ErrorHandler.hxx>
47 #include <Standard_ProgramError.hxx>
48 #include <TCollection_AsciiString.hxx>
50 #include <TopExp_Explorer.hxx>
51 #include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
52 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
53 #include <TopTools_DataMapOfShapeInteger.hxx>
54 #include <TopTools_DataMapOfShapeShape.hxx>
55 #include <TopTools_ListIteratorOfListOfShape.hxx>
56 #include <TopTools_MapOfShape.hxx>
61 //=============================================================================
65 //=============================================================================
67 GMSHPlugin_Mesher::GMSHPlugin_Mesher (SMESH_Mesh* mesh,
68 const TopoDS_Shape& aShape)
72 // il faudra peut être mettre un truc par defaut si l'utilisateur ne rentre rien en para
73 //defaultParameters();
76 //void GMSHPlugin_Mesher::defaultParameters(){}
78 void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp)
82 _algo2d = hyp->Get2DAlgo();
83 _algo3d = hyp->Get3DAlgo();
84 _recomb2DAlgo = hyp->GetRecomb2DAlgo();
85 _recombineAll = hyp->GetRecombineAll();
86 _subdivAlgo = hyp->GetSubdivAlgo();
87 _remeshAlgo = hyp->GetRemeshAlgo();
88 _remeshPara = hyp->GetRemeshPara();
89 _smouthSteps = hyp->GetSmouthSteps();
90 _sizeFactor = hyp->GetSizeFactor();
91 _minSize = hyp->GetMinSize();
92 _maxSize = hyp->GetMaxSize();
93 _secondOrder = hyp->GetSecondOrder();
94 _useIncomplElem = hyp->GetUseIncomplElem();
95 _is2d = hyp->GetIs2d();
96 _studyId = hyp->GetStudyId();
97 _compounds = hyp->GetCompoundOnEntries();
104 _recombineAll = false;
112 _secondOrder = false;
113 _useIncomplElem = true;
118 //================================================================================
120 * \brief Set Gmsh Options
122 //================================================================================
124 void GMSHPlugin_Mesher::SetGmshOptions()
126 MESSAGE("GMSHPlugin_Mesher::SetGmshOptions");
128 printf("We chose _algo2d %d \n", _algo2d );
129 printf("We chose _algo3d %d \n", _algo3d );
130 printf("We chose _recomb2DAlgo %d \n", _recomb2DAlgo );
131 printf("We chose _recombineAll %d \n", (_recombineAll)?1:0);
132 printf("We chose _subdivAlgo %d \n", _subdivAlgo );
133 printf("We chose _remeshAlgo %d \n", _remeshAlgo );
134 printf("We chose _remeshPara %d \n", _remeshPara );
135 printf("We chose _smouthSteps %e \n", _smouthSteps );
136 printf("We chose _sizeFactor %e \n", _sizeFactor );
137 printf("We chose _minSize %e \n", _minSize );
138 printf("We chose _maxSize %e \n", _maxSize );
139 printf("We chose _secondOrder %d \n", (_secondOrder)?1:0);
140 printf("We chose _useIncomplElem %d \n", (_useIncomplElem)?1:0);
141 printf("We are in dimension %d \n", (_is2d)?2:3);
144 std::map <int,double> mapAlgo2d;
145 mapAlgo2d[0]=2; mapAlgo2d[1]=1; mapAlgo2d[2]=5; mapAlgo2d[3]=6; mapAlgo2d[4]=8;
146 std::map <int,double> mapAlgo3d;
147 mapAlgo3d[0]=1; mapAlgo3d[1]=4; mapAlgo3d[2]=5; mapAlgo3d[3]=6; mapAlgo3d[4]=7; mapAlgo3d[4]=9;
150 ok = GmshSetOption("Mesh", "Algorithm" , mapAlgo2d[_algo2d]) ;
154 ok = GmshSetOption("Mesh", "Algorithm3D" , mapAlgo2d[_algo3d]) ;
157 ok = GmshSetOption("Mesh", "RecombinationAlgorithm" , (double)_recomb2DAlgo) ;
159 ok = GmshSetOption("Mesh", "RecombineAll" , (_recombineAll)?1.:0.) ;
161 ok = GmshSetOption("Mesh", "SubdivisionAlgorithm" , (double)_subdivAlgo) ;
163 ok = GmshSetOption("Mesh", "RemeshAlgorithm" , (double)_remeshAlgo) ;
165 ok = GmshSetOption("Mesh", "RemeshParametrization" , (double)_remeshPara) ;
167 ok = GmshSetOption("Mesh", "Smoothing" , (double)_smouthSteps) ;
169 ok = GmshSetOption("Mesh", "CharacteristicLengthFactor", _sizeFactor) ;
171 ok = GmshSetOption("Mesh", "CharacteristicLengthMin" , _minSize) ;
173 ok = GmshSetOption("Mesh", "CharacteristicLengthMax" , _maxSize) ;
175 ok = GmshSetOption("Mesh", "ElementOrder" , (_secondOrder)?2.:1.) ;
179 ok = GmshSetOption("Mesh", "SecondOrderIncomplete" ,(_useIncomplElem)?1.:0.);
184 //================================================================================
186 * \brief Create and add Compounds into GModel _gModel.
188 //================================================================================
190 void GMSHPlugin_Mesher::CreateGmshCompounds()
192 MESSAGE("GMSHPlugin_Mesher::CreateGmshCompounds");
194 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
195 CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
196 SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
197 SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(_studyId);
199 OCC_Internals* occgeo = _gModel->getOCCInternals();
201 for(std::set<std::string>::const_iterator its = _compounds.begin();its != _compounds.end(); ++its )
203 GEOM::GEOM_Object_var aGeomObj;
204 TopoDS_Shape geomShape = TopoDS_Shape();
205 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( (*its).c_str() );
206 SALOMEDS::GenericAttribute_var anAttr;
207 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR"))
209 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
210 CORBA::String_var aVal = anIOR->Value();
211 CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal);
212 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
214 if ( !aGeomObj->_is_nil() )
215 geomShape = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
217 TopAbs_ShapeEnum geomType = geomShape.ShapeType();
218 if (geomShape.ShapeType() == TopAbs_COMPOUND)// voir s'il ne faut pas mettre une erreur dans le cas contraire
220 //printf("shapeType == TopAbs_COMPOUND\n");
221 TopoDS_Iterator it(geomShape);
222 TopAbs_ShapeEnum shapeType = it.Value().ShapeType();
224 if (shapeType == TopAbs_EDGE)
226 //printf(" shapeType == TopAbs_EDGE :");
227 int num = _gModel->getNumEdges()+1;
228 Curve *curve = Create_Curve(num, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.);
229 for (it; it.More(); it.Next())
231 TopoDS_Shape topoShape = it.Value();
232 ASSERT(topoShape.ShapeType() == shapeType);
233 curve->compound.push_back(occgeo->getOCCEdgeByNativePtr(_gModel, (TopoDS_Edge&)topoShape)->tag());
235 Tree_Add(_gModel->getGEOInternals()->Curves, &curve);
236 _gModel->importGEOInternals();
239 else if (shapeType == TopAbs_FACE)
241 //printf(" shapeType == TopAbs_FACE :");
242 int num = _gModel->getNumFaces()+1;
243 Surface *surface = Create_Surface(num, MSH_SURF_COMPOUND);
244 for (it; it.More(); it.Next())
246 TopoDS_Shape topoShape = it.Value();
247 ASSERT(topoShape.ShapeType() == shapeType);
248 surface->compound.push_back(occgeo->getOCCFaceByNativePtr(_gModel, (TopoDS_Face&)topoShape)->tag());
250 Tree_Add(_gModel->getGEOInternals()->Surfaces, &surface);
251 _gModel->importGEOInternals();
257 //================================================================================
259 * \brief Write mesh from GModel instance to SMESH instance
261 //================================================================================
263 void GMSHPlugin_Mesher::FillSMesh()
265 MESSAGE("GMSHPlugin_Mesher::FillSMesh");
266 // GET MESH FROM SMESH
267 SMESHDS_Mesh* meshDS = _mesh->GetMeshDS();
270 for(GModel::viter it = _gModel->firstVertex(); it != _gModel->lastVertex(); ++it){
271 GVertex *gVertex = *it;
273 // GET topoVertex CORRESPONDING TO gVertex
274 TopoDS_Vertex topoVertex = *((TopoDS_Vertex*)gVertex->getNativePtr());
276 if (gVertex->getVisibility() == 0) // belongs to a compound
278 SMESH_subMesh* sm = _mesh->GetSubMesh(topoVertex);
279 sm->SetIsAlwaysComputed(true); // prevent from displaying errors
283 // FILL SMESH FOR topoVertex
285 for(unsigned int i = 0; i < gVertex->mesh_vertices.size(); i++)
287 MVertex *v = gVertex->mesh_vertices[i];
288 if(v->getIndex() >= 0)
290 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
291 meshDS->SetNodeOnVertex( node, topoVertex );
295 for(unsigned int i = 0; i < gVertex->getNumMeshElements(); i++)
297 MElement *e = gVertex->getMeshElement(i);
298 std::vector<MVertex*> verts;
299 e->getVertices(verts);
300 ASSERT(verts.size()==1);
301 SMDS_Mesh0DElement* zeroDElement = 0;
302 // WE DONT ADD 0D ELEMENTS because it does not follow the salome meshers philosophy
303 //zeroDElement = meshDS->Add0DElementWithID(verts[0]->getNum(),e->getNum());
304 //meshDS->SetMeshElementOnShape(zeroDElement, topoVertex);
309 for(GModel::eiter it = _gModel->firstEdge(); it != _gModel->lastEdge(); ++it){
312 // GET topoEdge CORRESPONDING TO gEdge (map if compound)
313 TopoDS_Edge topoEdge;
314 std::map<GEdge*,TopoDS_Edge> topoEdges;
316 if(gEdge->geomType() != GEntity::CompoundCurve)
318 topoEdge = *((TopoDS_Edge*)gEdge->getNativePtr());
319 if (gEdge->getVisibility() == 0) // belongs to a compound
321 SMESH_subMesh* sm = _mesh->GetSubMesh(topoEdge);
322 sm->SetIsAlwaysComputed(true); // prevent from displaying errors
328 // compound case, map construction GEdge/TopoDS_Edge
329 std::vector<GEdge*> gEdges = ((GEdgeCompound*)gEdge)->getCompounds();
330 for(std::vector<GEdge*>::const_iterator itv = gEdges.begin();itv != gEdges.end(); ++itv)
332 topoEdges.insert( pair<GEdge*,TopoDS_Edge>(*itv,*((TopoDS_Edge*)(*itv)->getNativePtr())) );
336 // FILL SMESH FOR topoEdge
338 for(unsigned int i = 0; i < gEdge->mesh_vertices.size(); i++)
340 MVertex *v = gEdge->mesh_vertices[i];
341 if(v->getIndex() >= 0)
343 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
345 if (topoEdges.size() != 0)
347 // get back corresponding topoEdge in compound case
349 SPoint3 point = v->point();
350 float distmin = std::numeric_limits<float>::max();
351 for(map<GEdge*,TopoDS_Edge>::const_iterator itm=topoEdges.begin();itm != topoEdges.end(); itm++)
353 SBoundingBox3d bounds = (*itm).first->bounds();
354 float dist = DistBoundingBox(bounds,point);
357 topoEdge = (*itm).second;
365 meshDS->SetNodeOnEdge( node, topoEdge );
369 for(unsigned int i = 0; i < gEdge->getNumMeshElements(); i++)
371 MElement *e = gEdge->getMeshElement(i);
372 std::vector<MVertex*> verts;
373 e->getVertices(verts);
374 SMDS_MeshEdge* edge = 0;
376 if (topoEdges.size() !=0)
378 // get back corresponding topoEdge in compound case
380 SPoint3 point = e->barycenter();
381 float distmin = std::numeric_limits<float>::max();
382 for(map<GEdge*,TopoDS_Edge>::const_iterator itm=topoEdges.begin();itm != topoEdges.end(); itm++)
384 SBoundingBox3d bounds = (*itm).first->bounds();
385 float dist = DistBoundingBox(bounds,point);
388 topoEdge = (*itm).second;
396 // if a node wasn't set, it is assigned here
397 for (unsigned j = 0; j < verts.size(); j++)
399 if(verts[j]->onWhat()->getVisibility() == 0)
401 SMDS_MeshNode *node = meshDS->AddNodeWithID(verts[i]->x(),verts[j]->y(),verts[j]->z(),verts[j]->getNum());
402 meshDS->SetNodeOnEdge( node, topoEdge );
403 verts[j]->setEntity(gEdge);
407 switch (verts.size())
410 edge = meshDS->AddEdgeWithID(verts[0]->getNum(),
411 verts[1]->getNum(),e->getNum());
414 edge = meshDS->AddEdgeWithID(verts[0]->getNum(),
416 verts[2]->getNum(),e->getNum());
422 meshDS->SetMeshElementOnShape(edge, topoEdge);
427 for(GModel::fiter it = _gModel->firstFace(); it != _gModel->lastFace(); ++it){
430 // GET topoFace CORRESPONDING TO gFace (map if compound)
431 TopoDS_Face topoFace;
432 std::map<GFace*,TopoDS_Face> topoFaces;
434 if(gFace->geomType() != GEntity::CompoundSurface)
436 topoFace = *((TopoDS_Face*)gFace->getNativePtr());
437 if (gFace->getVisibility() == 0) // belongs to a compound
439 SMESH_subMesh* sm = _mesh->GetSubMesh(topoFace);
440 sm->SetIsAlwaysComputed(true); // prevent from displaying errors
446 // compound case, map construction GFace/TopoDS_Face
447 std::list<GFace*> gFaces = ((GFaceCompound*)gFace)->getCompounds();
448 for(std::list<GFace*>::const_iterator itl = gFaces.begin();itl != gFaces.end(); ++itl)
450 topoFaces.insert( pair<GFace*,TopoDS_Face>(*itl,*((TopoDS_Face*)(*itl)->getNativePtr())) );
454 // FILL SMESH FOR topoFace
456 for(unsigned int i = 0; i < gFace->mesh_vertices.size(); i++)
458 MVertex *v = gFace->mesh_vertices[i];
459 if(v->getIndex() >= 0)
461 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
463 if (topoFaces.size() != 0)
465 // get back corresponding topoFace in compound case
467 SPoint3 point = v->point();
468 float distmin = std::numeric_limits<float>::max();
469 for(map<GFace*,TopoDS_Face>::const_iterator itm=topoFaces.begin();itm != topoFaces.end(); itm++)
471 SBoundingBox3d bounds = (*itm).first->bounds();
472 float dist = DistBoundingBox(bounds,point);
475 topoFace = (*itm).second;
483 meshDS->SetNodeOnFace( node, topoFace );
487 for(unsigned int i = 0; i < gFace->getNumMeshElements(); i++)
489 MElement *e = gFace->getMeshElement(i);
490 std::vector<MVertex*> verts;
491 e->getVertices(verts);
492 SMDS_MeshFace* face = 0;
494 if (topoFaces.size() !=0)
496 // get back corresponding topoFace in compound case
498 SPoint3 point = e->barycenter();
499 float distmin = std::numeric_limits<float>::max();
500 for(map<GFace*,TopoDS_Face>::const_iterator itm=topoFaces.begin();itm != topoFaces.end(); itm++)
502 SBoundingBox3d bounds = (*itm).first->bounds();
503 float dist = DistBoundingBox(bounds,point);
506 topoFace = (*itm).second;
514 // if a node wasn't set, it is assigned here
515 for (unsigned j = 0; j < verts.size(); j++)
517 if(verts[j]->onWhat()->getVisibility() == 0)
519 SMDS_MeshNode *node = meshDS->AddNodeWithID(verts[j]->x(),verts[j]->y(),verts[j]->z(),verts[j]->getNum());
520 meshDS->SetNodeOnFace( node, topoFace );
521 verts[i]->setEntity(gFace);
524 switch (verts.size())
527 face = meshDS->AddFaceWithID(verts[0]->getNum(),
529 verts[2]->getNum(),e->getNum());
532 face = meshDS->AddFaceWithID(verts[0]->getNum(),
535 verts[3]->getNum(),e->getNum());
538 face = meshDS->AddFaceWithID(verts[0]->getNum(),
543 verts[5]->getNum(),e->getNum());
546 face = meshDS->AddFaceWithID(verts[0]->getNum(),
553 verts[7]->getNum(),e->getNum());
556 face = meshDS->AddFaceWithID(verts[0]->getNum(),
564 verts[8]->getNum(),e->getNum());
570 meshDS->SetMeshElementOnShape(face, topoFace);
575 for(GModel::riter it = _gModel->firstRegion(); it != _gModel->lastRegion(); ++it){
576 GRegion *gRegion = *it;
577 if (gRegion->getVisibility() == 0)
580 // GET topoSolid CORRESPONDING TO gRegion
581 TopoDS_Solid topoSolid = *((TopoDS_Solid*)gRegion->getNativePtr());
583 //printf("volume %d (%d) contains %d elements\n", meshDS->ShapeToIndex(topoSolid), gRegion->tag(), gRegion->getNumMeshElements());
584 // FILL SMESH FOR topoSolid
587 for(unsigned int i = 0; i < gRegion->mesh_vertices.size(); i++)
589 MVertex *v = gRegion->mesh_vertices[i];
590 if(v->getIndex() >= 0)
592 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
593 meshDS->SetNodeInVolume( node, topoSolid );
598 for(unsigned int i = 0; i < gRegion->getNumMeshElements(); i++)
600 MElement *e = gRegion->getMeshElement(i);
601 std::vector<MVertex*> verts;
602 e->getVertices(verts);
603 SMDS_MeshVolume* volume = 0;
604 switch (verts.size()){
606 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
609 verts[3]->getNum(),e->getNum());
612 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
616 verts[4]->getNum(),e->getNum());
619 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
624 verts[4]->getNum(),e->getNum());
627 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
634 verts[5]->getNum(),e->getNum());
637 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
646 verts[9]->getNum(),e->getNum());
649 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
661 verts[9]->getNum(),e->getNum());
663 case 14: // same as case 13, because no pyra14 in smesh
664 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
676 verts[9]->getNum(),e->getNum());
679 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
693 verts[10]->getNum(),e->getNum());
695 case 18: // same as case 15, because no penta18 in smesh
696 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
710 verts[10]->getNum(),e->getNum());
713 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
732 verts[12]->getNum(),e->getNum());
735 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
768 meshDS->SetMeshElementOnShape(volume, topoSolid);
775 //================================================================================
777 * \brief Find if SPoint point is in SBoundingBox3d bounds
779 //================================================================================
781 float GMSHPlugin_Mesher::DistBoundingBox(SBoundingBox3d& bounds,SPoint3& point)
783 SPoint3 min = bounds.min();
784 SPoint3 max = bounds.max();
788 if (point.x() < min.x())
789 x = min.x()-point.x();
790 else if (point.x() > max.x())
791 x = point.x()-max.x();
795 if (point.y() < min.y())
796 y = min.y()-point.y();
797 else if (point.y() > max.y())
798 y = point.y()-max.y();
802 if (point.z() < min.z())
803 z = min.z()-point.z();
804 else if (point.z() > max.z())
805 z = point.z()-max.z();
809 return sqrt(x*x+y*y+z*z);
811 //================================================================================
813 * \brief Reimplemented GmshMessage call. Actions done if errors occurs
814 * during gmsh meshing. We define here what to display and what to do.
816 //================================================================================
817 void GMSHPlugin_Mesher::mymsg::operator()(std::string level, std::string msg)
819 //MESSAGE("level="<< level.c_str() << ", msg=" << msg.c_str()<< "\n");
820 printf("level=%s msg=%s\n", level.c_str(), msg.c_str());
822 if(level == "Fatal" || level == "Error")
824 std::ostringstream oss;
825 if (level == "Fatal")
826 oss << "Fatal error during Generation of Gmsh Mesh\n";
828 oss << "Error during Generation of Gmsh Mesh\n";
829 oss << " " << msg.c_str() << "\n";
830 GEntity *e = _gModel->getCurrentMeshEntity();
833 oss << " error occurred while meshing entity:\n" <<
834 " tag=" << e->tag() << "\n" <<
835 " dimension=" << e->dim() << "\n" <<
836 " native pointer=" << e->getNativePtr();
837 //if(e->geomType() != GEntity::CompoundCurve and e->geomType() != GEntity::CompoundSurface)
839 //SMESH_subMesh *sm = _mesh->GetSubMesh(*((TopoDS_Shape*)e->getNativePtr()));
840 //SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
841 //SMESH_Comment comment;
842 //comment << SMESH_Comment(oss.str);
843 //std::string str = oss.str();
844 //smError.reset( new SMESH_ComputeError( str ));
846 // plutot que de faire de la merde ici, on pourait simplement
847 // remplir une liste pour dire sur quelles entités gmsh se plante
848 // (puis faire le fillsmesh)
849 // puis faire une nouvelle routine qui réécrit les messages d'erreur
850 // probleme : gmsh peut planté en Fatal, dans ce cas pas de fillsmesh
853 if (level == "Fatal")
855 CTX::instance()->lock = 0;
859 printf(oss.str().c_str());
863 //=============================================================================
865 * Here we are going to use the GMSH mesher
867 //=============================================================================
869 bool GMSHPlugin_Mesher::Compute()
871 MESSAGE("GMSHPlugin_Mesher::Compute");
877 _gModel = new GModel();
879 GmshSetMessageHandler(&msg);
880 _gModel->importOCCShape((void*)&_shape);
881 if (_compounds.size() > 0) CreateGmshCompounds();
882 MESSAGE("GModel::Mesh");
885 _gModel->mesh((_is2d)?2:3);
886 #ifdef WITH_SMESH_CANCEL_COMPUTE
890 catch (std::string& str)
898 MESSAGE("Unrecoverable error during Generation of Gmsh Mesh");
903 if (_compounds.size() > 0) _gModel->setCompoundVisibility();
908 MESSAGE("GMSHPlugin_Mesher::Compute:End");