1 // Copyright (C) 2012-2015 ALNEOS
2 // Copyright (C) 2016 EDF R&D
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.alneos.com/ or email : contact@alneos.fr
20 #include "GMSHPlugin_Mesher.hxx"
21 #include "GMSHPlugin_Hypothesis_2D.hxx"
23 #include <SMDS_FaceOfNodes.hxx>
24 #include <SMDS_MeshElement.hxx>
25 #include <SMDS_MeshNode.hxx>
26 #include <SMESHDS_Mesh.hxx>
27 #include <SMESH_Block.hxx>
28 #include <SMESH_Comment.hxx>
29 #include <SMESH_ComputeError.hxx>
30 #include <SMESH_File.hxx>
31 #include <SMESH_Gen_i.hxx>
32 #include <SMESH_Mesh.hxx>
33 #include <SMESH_MesherHelper.hxx>
34 #include <SMESH_subMesh.hxx>
35 #include <utilities.h>
40 #include <BRep_Tool.hxx>
41 #include <Bnd_B3d.hxx>
42 #include <GCPnts_AbscissaPoint.hxx>
43 #include <GeomAdaptor_Curve.hxx>
44 #include <NCollection_Map.hxx>
45 #include <OSD_File.hxx>
46 #include <OSD_Path.hxx>
47 #include <Standard_ErrorHandler.hxx>
48 #include <Standard_ProgramError.hxx>
49 #include <TCollection_AsciiString.hxx>
51 #include <TopExp_Explorer.hxx>
52 #include <TopTools_DataMapIteratorOfDataMapOfShapeInteger.hxx>
53 #include <TopTools_DataMapIteratorOfDataMapOfShapeShape.hxx>
54 #include <TopTools_DataMapOfShapeInteger.hxx>
55 #include <TopTools_DataMapOfShapeShape.hxx>
56 #include <TopTools_ListIteratorOfListOfShape.hxx>
57 #include <TopTools_MapOfShape.hxx>
62 //=============================================================================
66 //=============================================================================
68 GMSHPlugin_Mesher::GMSHPlugin_Mesher (SMESH_Mesh* mesh,
69 const TopoDS_Shape& aShape)
73 // il faudra peut être mettre un truc par defaut si l'utilisateur ne rentre rien en para
74 //defaultParameters();
77 //void GMSHPlugin_Mesher::defaultParameters(){}
79 void GMSHPlugin_Mesher::SetParameters(const GMSHPlugin_Hypothesis* hyp)
83 _algo2d = hyp->Get2DAlgo();
84 _algo3d = hyp->Get3DAlgo();
85 _recomb2DAlgo = hyp->GetRecomb2DAlgo();
86 _recombineAll = hyp->GetRecombineAll();
87 _subdivAlgo = hyp->GetSubdivAlgo();
88 _remeshAlgo = hyp->GetRemeshAlgo();
89 _remeshPara = hyp->GetRemeshPara();
90 _smouthSteps = hyp->GetSmouthSteps();
91 _sizeFactor = hyp->GetSizeFactor();
92 _minSize = hyp->GetMinSize();
93 _maxSize = hyp->GetMaxSize();
94 _secondOrder = hyp->GetSecondOrder();
95 _useIncomplElem = hyp->GetUseIncomplElem();
96 _is2d = hyp->GetIs2d();
97 _studyId = hyp->GetStudyId();
98 _compounds = hyp->GetCompoundOnEntries();
105 _recombineAll = false;
113 _secondOrder = false;
114 _useIncomplElem = true;
119 //================================================================================
121 * \brief Set Gmsh Options
123 //================================================================================
125 void GMSHPlugin_Mesher::SetGmshOptions()
127 MESSAGE("GMSHPlugin_Mesher::SetGmshOptions");
129 printf("We chose _algo2d %d \n", _algo2d );
130 printf("We chose _algo3d %d \n", _algo3d );
131 printf("We chose _recomb2DAlgo %d \n", _recomb2DAlgo );
132 printf("We chose _recombineAll %d \n", (_recombineAll)?1:0);
133 printf("We chose _subdivAlgo %d \n", _subdivAlgo );
134 printf("We chose _remeshAlgo %d \n", _remeshAlgo );
135 printf("We chose _remeshPara %d \n", _remeshPara );
136 printf("We chose _smouthSteps %e \n", _smouthSteps );
137 printf("We chose _sizeFactor %e \n", _sizeFactor );
138 printf("We chose _minSize %e \n", _minSize );
139 printf("We chose _maxSize %e \n", _maxSize );
140 printf("We chose _secondOrder %d \n", (_secondOrder)?1:0);
141 printf("We chose _useIncomplElem %d \n", (_useIncomplElem)?1:0);
142 printf("We are in dimension %d \n", (_is2d)?2:3);
145 std::map <int,double> mapAlgo2d;
146 mapAlgo2d[0]=2; mapAlgo2d[1]=1; mapAlgo2d[2]=5; mapAlgo2d[3]=6; mapAlgo2d[4]=8;
147 std::map <int,double> mapAlgo3d;
148 mapAlgo3d[0]=1; mapAlgo3d[1]=4; mapAlgo3d[2]=5; mapAlgo3d[3]=6; mapAlgo3d[4]=7; mapAlgo3d[4]=9;
151 ok = GmshSetOption("Mesh", "Algorithm" , mapAlgo2d[_algo2d]) ;
155 ok = GmshSetOption("Mesh", "Algorithm3D" , mapAlgo2d[_algo3d]) ;
158 ok = GmshSetOption("Mesh", "RecombinationAlgorithm" , (double)_recomb2DAlgo) ;
160 ok = GmshSetOption("Mesh", "RecombineAll" , (_recombineAll)?1.:0.) ;
162 ok = GmshSetOption("Mesh", "SubdivisionAlgorithm" , (double)_subdivAlgo) ;
164 ok = GmshSetOption("Mesh", "RemeshAlgorithm" , (double)_remeshAlgo) ;
166 ok = GmshSetOption("Mesh", "RemeshParametrization" , (double)_remeshPara) ;
168 ok = GmshSetOption("Mesh", "Smoothing" , (double)_smouthSteps) ;
170 ok = GmshSetOption("Mesh", "CharacteristicLengthFactor", _sizeFactor) ;
172 ok = GmshSetOption("Mesh", "CharacteristicLengthMin" , _minSize) ;
174 ok = GmshSetOption("Mesh", "CharacteristicLengthMax" , _maxSize) ;
176 ok = GmshSetOption("Mesh", "ElementOrder" , (_secondOrder)?2.:1.) ;
180 ok = GmshSetOption("Mesh", "SecondOrderIncomplete" ,(_useIncomplElem)?1.:0.);
185 //================================================================================
187 * \brief Create and add Compounds into GModel _gModel.
189 //================================================================================
191 void GMSHPlugin_Mesher::CreateGmshCompounds()
193 MESSAGE("GMSHPlugin_Mesher::CreateGmshCompounds");
195 SMESH_Gen_i* smeshGen_i = SMESH_Gen_i::GetSMESHGen();
196 CORBA::Object_var anObject = smeshGen_i->GetNS()->Resolve("/myStudyManager");
197 SALOMEDS::StudyManager_var aStudyMgr = SALOMEDS::StudyManager::_narrow(anObject);
198 SALOMEDS::Study_var myStudy = aStudyMgr->GetStudyByID(_studyId);
200 OCC_Internals* occgeo = _gModel->getOCCInternals();
202 for(std::set<std::string>::const_iterator its = _compounds.begin();its != _compounds.end(); ++its )
204 GEOM::GEOM_Object_var aGeomObj;
205 TopoDS_Shape geomShape = TopoDS_Shape();
206 SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( (*its).c_str() );
207 SALOMEDS::GenericAttribute_var anAttr;
208 if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR"))
210 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
211 CORBA::String_var aVal = anIOR->Value();
212 CORBA::Object_var obj = myStudy->ConvertIORToObject(aVal);
213 aGeomObj = GEOM::GEOM_Object::_narrow(obj);
215 if ( !aGeomObj->_is_nil() )
216 geomShape = smeshGen_i->GeomObjectToShape( aGeomObj.in() );
218 TopAbs_ShapeEnum geomType = geomShape.ShapeType();
219 if (geomShape.ShapeType() == TopAbs_COMPOUND)// voir s'il ne faut pas mettre une erreur dans le cas contraire
221 MESSAGE("shapeType == TopAbs_COMPOUND");
222 TopoDS_Iterator it(geomShape);
223 TopAbs_ShapeEnum shapeType = it.Value().ShapeType();
225 if (shapeType == TopAbs_EDGE)
227 MESSAGE(" shapeType == TopAbs_EDGE :");
228 int num = _gModel->getNumEdges()+1;
229 Curve *curve = CreateCurve(num, MSH_SEGM_COMPOUND, 1, NULL, NULL, -1, -1, 0., 1.);
230 for (it; it.More(); it.Next())
232 TopoDS_Shape topoShape = it.Value();
233 ASSERT(topoShape.ShapeType() == shapeType);
234 curve->compound.push_back(occgeo->addEdgeToModel(_gModel, (TopoDS_Edge&)topoShape)->tag());
236 Tree_Add(_gModel->getGEOInternals()->Curves, &curve);
237 //_gModel->importGEOInternals();
240 else if (shapeType == TopAbs_FACE)
242 MESSAGE(" shapeType == TopAbs_FACE :");
243 int num = _gModel->getNumFaces()+1;
244 Surface *surface = CreateSurface(num, MSH_SURF_COMPOUND);
245 for (it; it.More(); it.Next())
247 TopoDS_Shape topoShape = it.Value();
248 ASSERT(topoShape.ShapeType() == shapeType);
249 surface->compound.push_back(occgeo->addFaceToModel(_gModel, (TopoDS_Face&)topoShape)->tag());
251 Tree_Add(_gModel->getGEOInternals()->Surfaces, &surface);
252 _gModel->getGEOInternals()->synchronize(_gModel);
258 //================================================================================
260 * \brief Write mesh from GModel instance to SMESH instance
262 //================================================================================
264 void GMSHPlugin_Mesher::FillSMesh()
266 MESSAGE("GMSHPlugin_Mesher::FillSMesh");
267 // GET MESH FROM SMESH
268 SMESHDS_Mesh* meshDS = _mesh->GetMeshDS();
271 for(GModel::viter it = _gModel->firstVertex(); it != _gModel->lastVertex(); ++it){
272 GVertex *gVertex = *it;
274 // GET topoVertex CORRESPONDING TO gVertex
275 TopoDS_Vertex topoVertex = *((TopoDS_Vertex*)gVertex->getNativePtr());
277 if (gVertex->getVisibility() == 0) // belongs to a compound
279 SMESH_subMesh* sm = _mesh->GetSubMesh(topoVertex);
280 sm->SetIsAlwaysComputed(true); // prevent from displaying errors
284 // FILL SMESH FOR topoVertex
286 for(unsigned int i = 0; i < gVertex->mesh_vertices.size(); i++)
288 MVertex *v = gVertex->mesh_vertices[i];
289 if(v->getIndex() >= 0)
291 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
292 meshDS->SetNodeOnVertex( node, topoVertex );
296 for(unsigned int i = 0; i < gVertex->getNumMeshElements(); i++)
298 MElement *e = gVertex->getMeshElement(i);
299 std::vector<MVertex*> verts;
300 e->getVertices(verts);
301 ASSERT(verts.size()==1);
302 SMDS_Mesh0DElement* zeroDElement = 0;
303 // WE DONT ADD 0D ELEMENTS because it does not follow the salome meshers philosophy
304 //zeroDElement = meshDS->Add0DElementWithID(verts[0]->getNum(),e->getNum());
305 //meshDS->SetMeshElementOnShape(zeroDElement, topoVertex);
310 for(GModel::eiter it = _gModel->firstEdge(); it != _gModel->lastEdge(); ++it){
313 // GET topoEdge CORRESPONDING TO gEdge (map if compound)
314 TopoDS_Edge topoEdge;
315 std::map<GEdge*,TopoDS_Edge> topoEdges;
317 if(gEdge->geomType() != GEntity::CompoundCurve)
319 topoEdge = *((TopoDS_Edge*)gEdge->getNativePtr());
320 if (gEdge->getVisibility() == 0) // belongs to a compound
322 SMESH_subMesh* sm = _mesh->GetSubMesh(topoEdge);
323 sm->SetIsAlwaysComputed(true); // prevent from displaying errors
329 // compound case, map construction GEdge/TopoDS_Edge
330 std::vector<GEdge*> gEdges = ((GEdgeCompound*)gEdge)->getCompounds();
331 for(std::vector<GEdge*>::const_iterator itv = gEdges.begin();itv != gEdges.end(); ++itv)
333 topoEdges.insert( pair<GEdge*,TopoDS_Edge>(*itv,*((TopoDS_Edge*)(*itv)->getNativePtr())) );
337 // FILL SMESH FOR topoEdge
339 for(unsigned int i = 0; i < gEdge->mesh_vertices.size(); i++)
341 MVertex *v = gEdge->mesh_vertices[i];
342 if(v->getIndex() >= 0)
344 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
346 if (topoEdges.size() != 0)
348 // get back corresponding topoEdge in compound case
350 SPoint3 point = v->point();
351 float distmin = std::numeric_limits<float>::max();
352 for(map<GEdge*,TopoDS_Edge>::const_iterator itm=topoEdges.begin();itm != topoEdges.end(); itm++)
354 SBoundingBox3d bounds = (*itm).first->bounds();
355 float dist = DistBoundingBox(bounds,point);
358 topoEdge = (*itm).second;
366 meshDS->SetNodeOnEdge( node, topoEdge );
370 for(unsigned int i = 0; i < gEdge->getNumMeshElements(); i++)
372 MElement *e = gEdge->getMeshElement(i);
373 std::vector<MVertex*> verts;
374 e->getVertices(verts);
375 SMDS_MeshEdge* edge = 0;
377 if (topoEdges.size() !=0)
379 // get back corresponding topoEdge in compound case
381 SPoint3 point = e->barycenter();
382 float distmin = std::numeric_limits<float>::max();
383 for(map<GEdge*,TopoDS_Edge>::const_iterator itm=topoEdges.begin();itm != topoEdges.end(); itm++)
385 SBoundingBox3d bounds = (*itm).first->bounds();
386 float dist = DistBoundingBox(bounds,point);
389 topoEdge = (*itm).second;
397 // if a node wasn't set, it is assigned here
398 for (unsigned j = 0; j < verts.size(); j++)
400 if(verts[j]->onWhat()->getVisibility() == 0)
402 SMDS_MeshNode *node = meshDS->AddNodeWithID(verts[i]->x(),verts[j]->y(),verts[j]->z(),verts[j]->getNum());
403 meshDS->SetNodeOnEdge( node, topoEdge );
404 verts[j]->setEntity(gEdge);
408 switch (verts.size())
411 edge = meshDS->AddEdgeWithID(verts[0]->getNum(),
412 verts[1]->getNum(),e->getNum());
415 edge = meshDS->AddEdgeWithID(verts[0]->getNum(),
417 verts[2]->getNum(),e->getNum());
423 meshDS->SetMeshElementOnShape(edge, topoEdge);
428 for(GModel::fiter it = _gModel->firstFace(); it != _gModel->lastFace(); ++it){
431 // GET topoFace CORRESPONDING TO gFace (map if compound)
432 TopoDS_Face topoFace;
433 std::map<GFace*,TopoDS_Face> topoFaces;
435 if(gFace->geomType() != GEntity::CompoundSurface)
437 topoFace = *((TopoDS_Face*)gFace->getNativePtr());
438 if (gFace->getVisibility() == 0) // belongs to a compound
440 SMESH_subMesh* sm = _mesh->GetSubMesh(topoFace);
441 sm->SetIsAlwaysComputed(true); // prevent from displaying errors
447 // compound case, map construction GFace/TopoDS_Face
448 std::list<GFace*> gFaces = ((GFaceCompound*)gFace)->getCompounds();
449 for(std::list<GFace*>::const_iterator itl = gFaces.begin();itl != gFaces.end(); ++itl)
451 topoFaces.insert( pair<GFace*,TopoDS_Face>(*itl,*((TopoDS_Face*)(*itl)->getNativePtr())) );
455 // FILL SMESH FOR topoFace
457 for(unsigned int i = 0; i < gFace->mesh_vertices.size(); i++)
459 MVertex *v = gFace->mesh_vertices[i];
460 if(v->getIndex() >= 0)
462 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
464 if (topoFaces.size() != 0)
466 // get back corresponding topoFace in compound case
468 SPoint3 point = v->point();
469 float distmin = std::numeric_limits<float>::max();
470 for(map<GFace*,TopoDS_Face>::const_iterator itm=topoFaces.begin();itm != topoFaces.end(); itm++)
472 SBoundingBox3d bounds = (*itm).first->bounds();
473 float dist = DistBoundingBox(bounds,point);
476 topoFace = (*itm).second;
484 meshDS->SetNodeOnFace( node, topoFace );
488 for(unsigned int i = 0; i < gFace->getNumMeshElements(); i++)
490 MElement *e = gFace->getMeshElement(i);
491 std::vector<MVertex*> verts;
492 e->getVertices(verts);
493 SMDS_MeshFace* face = 0;
495 if (topoFaces.size() !=0)
497 // get back corresponding topoFace in compound case
499 SPoint3 point = e->barycenter();
500 float distmin = std::numeric_limits<float>::max();
501 for(map<GFace*,TopoDS_Face>::const_iterator itm=topoFaces.begin();itm != topoFaces.end(); itm++)
503 SBoundingBox3d bounds = (*itm).first->bounds();
504 float dist = DistBoundingBox(bounds,point);
507 topoFace = (*itm).second;
515 // if a node wasn't set, it is assigned here
516 for (unsigned j = 0; j < verts.size(); j++)
518 if(verts[j]->onWhat()->getVisibility() == 0)
520 SMDS_MeshNode *node = meshDS->AddNodeWithID(verts[j]->x(),verts[j]->y(),verts[j]->z(),verts[j]->getNum());
521 meshDS->SetNodeOnFace( node, topoFace );
522 verts[i]->setEntity(gFace);
525 switch (verts.size())
528 face = meshDS->AddFaceWithID(verts[0]->getNum(),
530 verts[2]->getNum(),e->getNum());
533 face = meshDS->AddFaceWithID(verts[0]->getNum(),
536 verts[3]->getNum(),e->getNum());
539 face = meshDS->AddFaceWithID(verts[0]->getNum(),
544 verts[5]->getNum(),e->getNum());
547 face = meshDS->AddFaceWithID(verts[0]->getNum(),
554 verts[7]->getNum(),e->getNum());
557 face = meshDS->AddFaceWithID(verts[0]->getNum(),
565 verts[8]->getNum(),e->getNum());
571 meshDS->SetMeshElementOnShape(face, topoFace);
576 for(GModel::riter it = _gModel->firstRegion(); it != _gModel->lastRegion(); ++it){
577 GRegion *gRegion = *it;
578 if (gRegion->getVisibility() == 0)
581 // GET topoSolid CORRESPONDING TO gRegion
582 TopoDS_Solid topoSolid = *((TopoDS_Solid*)gRegion->getNativePtr());
584 //printf("volume %d (%d) contains %d elements\n", meshDS->ShapeToIndex(topoSolid), gRegion->tag(), gRegion->getNumMeshElements());
585 // FILL SMESH FOR topoSolid
588 for(unsigned int i = 0; i < gRegion->mesh_vertices.size(); i++)
590 MVertex *v = gRegion->mesh_vertices[i];
591 if(v->getIndex() >= 0)
593 SMDS_MeshNode *node = meshDS->AddNodeWithID(v->x(),v->y(),v->z(),v->getNum());
594 meshDS->SetNodeInVolume( node, topoSolid );
599 for(unsigned int i = 0; i < gRegion->getNumMeshElements(); i++)
601 MElement *e = gRegion->getMeshElement(i);
602 std::vector<MVertex*> verts;
603 e->getVertices(verts);
604 SMDS_MeshVolume* volume = 0;
605 switch (verts.size()){
607 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
610 verts[3]->getNum(),e->getNum());
613 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
617 verts[4]->getNum(),e->getNum());
620 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
625 verts[4]->getNum(),e->getNum());
628 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
635 verts[5]->getNum(),e->getNum());
638 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
647 verts[9]->getNum(),e->getNum());
650 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
662 verts[9]->getNum(),e->getNum());
664 case 14: // same as case 13, because no pyra14 in smesh
665 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
677 verts[9]->getNum(),e->getNum());
680 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
694 verts[10]->getNum(),e->getNum());
696 case 18: // same as case 15, because no penta18 in smesh
697 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
711 verts[10]->getNum(),e->getNum());
714 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
733 verts[12]->getNum(),e->getNum());
736 volume = meshDS->AddVolumeWithID(verts[0]->getNum(),
769 meshDS->SetMeshElementOnShape(volume, topoSolid);
776 //================================================================================
778 * \brief Find if SPoint point is in SBoundingBox3d bounds
780 //================================================================================
782 float GMSHPlugin_Mesher::DistBoundingBox(SBoundingBox3d& bounds,SPoint3& point)
784 SPoint3 min = bounds.min();
785 SPoint3 max = bounds.max();
789 if (point.x() < min.x())
790 x = min.x()-point.x();
791 else if (point.x() > max.x())
792 x = point.x()-max.x();
796 if (point.y() < min.y())
797 y = min.y()-point.y();
798 else if (point.y() > max.y())
799 y = point.y()-max.y();
803 if (point.z() < min.z())
804 z = min.z()-point.z();
805 else if (point.z() > max.z())
806 z = point.z()-max.z();
810 return sqrt(x*x+y*y+z*z);
812 //================================================================================
814 * \brief Reimplemented GmshMessage call. Actions done if errors occurs
815 * during gmsh meshing. We define here what to display and what to do.
817 //================================================================================
818 void GMSHPlugin_Mesher::mymsg::operator()(std::string level, std::string msg)
820 //MESSAGE("level="<< level.c_str() << ", msg=" << msg.c_str()<< "\n");
821 printf("level=%s msg=%s\n", level.c_str(), msg.c_str());
823 if(level == "Fatal" || level == "Error")
825 std::ostringstream oss;
826 if (level == "Fatal")
827 oss << "Fatal error during Generation of Gmsh Mesh\n";
829 oss << "Error during Generation of Gmsh Mesh\n";
830 oss << " " << msg.c_str() << "\n";
831 GEntity *e = _gModel->getCurrentMeshEntity();
834 oss << " error occurred while meshing entity:\n" <<
835 " tag=" << e->tag() << "\n" <<
836 " dimension=" << e->dim() << "\n" <<
837 " native pointer=" << e->getNativePtr();
838 //if(e->geomType() != GEntity::CompoundCurve and e->geomType() != GEntity::CompoundSurface)
840 //SMESH_subMesh *sm = _mesh->GetSubMesh(*((TopoDS_Shape*)e->getNativePtr()));
841 //SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
842 //SMESH_Comment comment;
843 //comment << SMESH_Comment(oss.str);
844 //std::string str = oss.str();
845 //smError.reset( new SMESH_ComputeError( str ));
847 // plutot que de faire de la merde ici, on pourait simplement
848 // remplir une liste pour dire sur quelles entités gmsh se plante
849 // (puis faire le fillsmesh)
850 // puis faire une nouvelle routine qui réécrit les messages d'erreur
851 // probleme : gmsh peut planté en Fatal, dans ce cas pas de fillsmesh
854 if (level == "Fatal")
856 CTX::instance()->lock = 0;
860 printf(oss.str().c_str());
864 //=============================================================================
866 * Here we are going to use the GMSH mesher
868 //=============================================================================
870 bool GMSHPlugin_Mesher::Compute()
872 MESSAGE("GMSHPlugin_Mesher::Compute");
878 _gModel = new GModel();
880 GmshSetMessageHandler(&msg);
881 _gModel->importOCCShape((void*)&_shape);
882 if (_compounds.size() > 0) CreateGmshCompounds();
883 MESSAGE("GModel::Mesh");
886 _gModel->mesh((_is2d)?2:3);
887 #ifdef WITH_SMESH_CANCEL_COMPUTE
891 catch (std::string& str)
899 MESSAGE("Unrecoverable error during Generation of Gmsh Mesh");
904 if (_compounds.size() > 0) _gModel->setCompoundVisibility();
909 MESSAGE("GMSHPlugin_Mesher::Compute:End");