1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 //=============================================================================
24 // File : NETGENPlugin_NETGEN_3D.cxx
25 // Moved here from SMESH_NETGEN_3D.cxx
26 // Created : lundi 27 Janvier 2003
27 // Author : Nadir BOUHAMOU (CEA)
29 //=============================================================================
31 #include "NETGENPlugin_NETGEN_3D.hxx"
33 #include "NETGENPlugin_Hypothesis.hxx"
35 #include <SMDS_MeshElement.hxx>
36 #include <SMDS_MeshNode.hxx>
37 #include <SMESHDS_Mesh.hxx>
38 #include <SMESH_Comment.hxx>
39 #include <SMESH_ControlsDef.hxx>
40 #include <SMESH_Gen.hxx>
41 #include <SMESH_Mesh.hxx>
42 #include <SMESH_MeshEditor.hxx>
43 #include <SMESH_MesherHelper.hxx>
44 #include <SMESH_subMesh.hxx>
45 #include <StdMeshers_MaxElementVolume.hxx>
46 #include <StdMeshers_QuadToTriaAdaptor.hxx>
47 #include <StdMeshers_ViscousLayers.hxx>
49 #include <BRepGProp.hxx>
50 #include <BRep_Tool.hxx>
51 #include <GProp_GProps.hxx>
53 #include <TopExp_Explorer.hxx>
54 #include <TopTools_ListIteratorOfListOfShape.hxx>
57 #include <Standard_Failure.hxx>
58 #include <Standard_ErrorHandler.hxx>
60 #include <utilities.h>
73 #include <occgeom.hpp>
79 extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, MeshingParameters&, int, int);
81 extern int OCCGenerateMesh (OCCGeometry&, Mesh*&, int, int, char*);
83 extern MeshingParameters mparam;
84 extern volatile multithreadt multithread;
86 using namespace nglib;
89 //=============================================================================
93 //=============================================================================
95 NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D(int hypId, int studyId,
97 : SMESH_3D_Algo(hypId, studyId, gen)
99 MESSAGE("NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D");
101 _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
102 _compatibleHypothesis.push_back("MaxElementVolume");
103 _compatibleHypothesis.push_back("NETGEN_Parameters");
104 _compatibleHypothesis.push_back("ViscousLayers");
106 _maxElementVolume = 0.;
108 _hypMaxElementVolume = NULL;
109 _hypParameters = NULL;
110 _viscousLayersHyp = NULL;
112 _requireShape = false; // can work without shape
115 //=============================================================================
119 //=============================================================================
121 NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D()
123 MESSAGE("NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D");
126 //=============================================================================
130 //=============================================================================
132 bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh& aMesh,
133 const TopoDS_Shape& aShape,
134 Hypothesis_Status& aStatus)
136 MESSAGE("NETGENPlugin_NETGEN_3D::CheckHypothesis");
138 _hypMaxElementVolume = NULL;
139 _hypParameters = NULL;
140 _viscousLayersHyp = NULL;
141 _maxElementVolume = DBL_MAX;
143 // for correct work of GetProgress():
144 netgen::multithread.percent = 0.;
145 netgen::multithread.task = "Volume meshing";
146 _optimizationStarted = false;
148 list<const SMESHDS_Hypothesis*>::const_iterator itl;
149 const SMESHDS_Hypothesis* theHyp;
151 const list<const SMESHDS_Hypothesis*>& hyps =
152 GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false);
153 list <const SMESHDS_Hypothesis* >::const_iterator h = hyps.begin();
154 if ( h == hyps.end())
156 aStatus = SMESH_Hypothesis::HYP_OK;
157 return true; // can work with no hypothesis
161 for ( ; h != hyps.end(); ++h )
163 if ( !_hypMaxElementVolume )
164 _hypMaxElementVolume = dynamic_cast< const StdMeshers_MaxElementVolume*> ( *h );
165 if ( !_viscousLayersHyp )
166 _viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h );
167 if ( ! _hypParameters )
168 _hypParameters = dynamic_cast< const NETGENPlugin_Hypothesis*> ( *h );
170 if ( *h != _hypMaxElementVolume &&
171 *h != _viscousLayersHyp &&
172 *h != _hypParameters)
173 aStatus = HYP_INCOMPATIBLE;
175 if ( _hypMaxElementVolume && _hypParameters )
176 aStatus = HYP_INCOMPATIBLE;
178 if ( _hypMaxElementVolume )
179 _maxElementVolume = _hypMaxElementVolume->GetMaxVolume();
181 return aStatus == HYP_OK;
184 //=============================================================================
186 *Here we are going to use the NETGEN mesher
188 //=============================================================================
190 bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
191 const TopoDS_Shape& aShape)
193 netgen::multithread.terminate = 0;
195 SMESHDS_Mesh* meshDS = aMesh.GetMeshDS();
197 SMESH_MesherHelper helper(aMesh);
198 bool _quadraticMesh = helper.IsQuadraticSubMesh(aShape);
199 helper.SetElementsOnShape( true );
201 int Netgen_NbOfNodes = 0;
202 double Netgen_point[3];
203 int Netgen_triangle[3];
205 NETGENPlugin_NetgenLibWrapper ngLib;
206 Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
208 // vector of nodes in which node index == netgen ID
209 vector< const SMDS_MeshNode* > nodeVec;
211 const int invalid_ID = -1;
213 SMESH::Controls::Area areaControl;
214 SMESH::Controls::TSequenceOfXYZ nodesCoords;
216 // maps nodes to ng ID
217 typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
218 typedef TNodeToIDMap::value_type TN2ID;
219 TNodeToIDMap nodeToNetgenID;
221 // find internal shapes
222 NETGENPlugin_Internals internals( aMesh, aShape, /*is3D=*/true );
224 // ---------------------------------
225 // Feed the Netgen with surface mesh
226 // ---------------------------------
228 TopAbs_ShapeEnum mainType = aMesh.GetShapeToMesh().ShapeType();
229 bool checkReverse = ( mainType == TopAbs_COMPOUND || mainType == TopAbs_COMPSOLID );
231 SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
232 if ( _viscousLayersHyp )
234 proxyMesh = _viscousLayersHyp->Compute( aMesh, aShape );
238 if ( aMesh.NbQuadrangles() > 0 )
240 StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor;
241 Adaptor->Compute(aMesh,aShape,proxyMesh.get());
242 proxyMesh.reset( Adaptor );
245 for ( TopExp_Explorer exFa( aShape, TopAbs_FACE ); exFa.More(); exFa.Next())
247 const TopoDS_Shape& aShapeFace = exFa.Current();
248 int faceID = meshDS->ShapeToIndex( aShapeFace );
249 bool isInternalFace = internals.isInternalShape( faceID );
251 if ( checkReverse && !isInternalFace &&
252 helper.NbAncestors(aShapeFace, aMesh, aShape.ShapeType()) > 1 )
253 // IsReversedSubMesh() can work wrong on strongly curved faces,
254 // so we use it as less as possible
255 isRev = helper.IsReversedSubMesh( TopoDS::Face( aShapeFace ));
257 const SMESHDS_SubMesh * aSubMeshDSFace = proxyMesh->GetSubMesh( aShapeFace );
258 if ( !aSubMeshDSFace ) continue;
259 SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
260 while ( iteratorElem->more() ) // loop on elements on a geom face
263 const SMDS_MeshElement* elem = iteratorElem->next();
265 return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
266 if ( elem->NbCornerNodes() != 3 )
267 return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
269 // Add nodes of triangles and triangles them-selves to netgen mesh
271 // add three nodes of triangle
272 bool hasDegen = false;
273 for ( int iN = 0; iN < 3; ++iN )
275 const SMDS_MeshNode* node = elem->GetNode( iN );
276 const int shapeID = node->getshapeId();
277 if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_EDGE &&
278 helper.IsDegenShape( shapeID ))
280 // ignore all nodes on degeneraged edge and use node on its vertex instead
281 TopoDS_Shape vertex = TopoDS_Iterator( meshDS->IndexToShape( shapeID )).Value();
282 node = SMESH_Algo::VertexNode( TopoDS::Vertex( vertex ), meshDS );
285 int& ngID = nodeToNetgenID.insert(TN2ID( node, invalid_ID )).first->second;
286 if ( ngID == invalid_ID )
288 ngID = ++Netgen_NbOfNodes;
289 Netgen_point [ 0 ] = node->X();
290 Netgen_point [ 1 ] = node->Y();
291 Netgen_point [ 2 ] = node->Z();
292 Ng_AddPoint(Netgen_mesh, Netgen_point);
294 Netgen_triangle[ isRev ? 2-iN : iN ] = ngID;
297 if ( hasDegen && (Netgen_triangle[0] == Netgen_triangle[1] ||
298 Netgen_triangle[0] == Netgen_triangle[2] ||
299 Netgen_triangle[2] == Netgen_triangle[1] ))
302 Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle);
304 if ( isInternalFace && !proxyMesh->IsTemporary( elem ))
306 swap( Netgen_triangle[1], Netgen_triangle[2] );
307 Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle);
309 } // loop on elements on a face
310 } // loop on faces of a SOLID or SHELL
312 // insert old nodes into nodeVec
313 nodeVec.resize( nodeToNetgenID.size() + 1, 0 );
314 TNodeToIDMap::iterator n_id = nodeToNetgenID.begin();
315 for ( ; n_id != nodeToNetgenID.end(); ++n_id )
316 nodeVec[ n_id->second ] = n_id->first;
317 nodeToNetgenID.clear();
319 if ( internals.hasInternalVertexInSolid() )
321 netgen::OCCGeometry occgeo;
322 NETGENPlugin_Mesher::AddIntVerticesInSolids( occgeo,
323 (netgen::Mesh&) *Netgen_mesh,
329 // -------------------------
330 // Generate the volume mesh
331 // -------------------------
333 return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, Netgen_mesh));
336 //================================================================================
338 * \brief set parameters and generate the volume mesh
340 //================================================================================
342 bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh,
343 SMESH_MesherHelper& helper,
344 vector< const SMDS_MeshNode* >& nodeVec,
345 Ng_Mesh * Netgen_mesh)
347 netgen::multithread.terminate = 0;
349 netgen::Mesh* ngMesh = (netgen::Mesh*)Netgen_mesh;
350 int Netgen_NbOfNodes = Ng_GetNP(Netgen_mesh);
355 int startWith = netgen::MESHCONST_MESHVOLUME;
356 int endWith = netgen::MESHCONST_OPTVOLUME;
359 NETGENPlugin_Mesher aMesher( &aMesh, helper.GetSubShape(), /*isVolume=*/true );
360 netgen::OCCGeometry occgeo;
362 if ( _hypParameters )
364 aMesher.SetParameters( _hypParameters );
365 if ( !_hypParameters->GetOptimize() )
366 endWith = netgen::MESHCONST_MESHVOLUME;
368 else if ( _hypMaxElementVolume )
370 netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
372 else if ( aMesh.HasShapeToMesh() )
374 aMesher.PrepareOCCgeometry( occgeo, helper.GetSubShape(), aMesh );
375 netgen::mparam.maxh = occgeo.GetBoundingBox().Diam()/2;
379 netgen::Point3d pmin, pmax;
380 ngMesh->GetBox (pmin, pmax);
381 netgen::mparam.maxh = Dist(pmin, pmax)/2;
384 if ( !_hypParameters && aMesh.HasShapeToMesh() )
386 netgen::mparam.minh = aMesher.GetDefaultMinSize( helper.GetSubShape(), netgen::mparam.maxh );
391 #if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
395 ngMesh->CalcLocalH(netgen::mparam.grading);
396 err = netgen::OCCGenerateMesh(occgeo, ngMesh, netgen::mparam, startWith, endWith);
398 ngMesh->CalcLocalH();
399 err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
401 if(netgen::multithread.terminate)
404 error(SMESH_Comment("Error in netgen::OCCGenerateMesh() at ") << netgen::multithread.task);
406 catch (Standard_Failure& ex)
408 SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
409 str << " at " << netgen::multithread.task
410 << ": " << ex.DynamicType()->Name();
411 if ( ex.GetMessageString() && strlen( ex.GetMessageString() ))
412 str << ": " << ex.GetMessageString();
415 catch (netgen::NgException exc)
417 SMESH_Comment str("NgException");
418 if ( strlen( netgen::multithread.task ) > 0 )
419 str << " at " << netgen::multithread.task;
420 str << ": " << exc.What();
425 SMESH_Comment str("Exception in netgen::OCCGenerateMesh()");
426 if ( strlen( netgen::multithread.task ) > 0 )
427 str << " at " << netgen::multithread.task;
431 int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh);
432 int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh);
434 MESSAGE("End of Volume Mesh Generation. err=" << err <<
435 ", nb new nodes: " << Netgen_NbOfNodesNew - Netgen_NbOfNodes <<
436 ", nb tetra: " << Netgen_NbOfTetra);
438 // -------------------------------------------------------------------
439 // Feed back the SMESHDS with the generated Nodes and Volume Elements
440 // -------------------------------------------------------------------
444 SMESH_ComputeErrorPtr ce = NETGENPlugin_Mesher::ReadErrors(nodeVec);
445 if ( ce && !ce->myBadElements.empty() )
449 bool isOK = ( /*status == NG_OK &&*/ Netgen_NbOfTetra > 0 );// get whatever built
452 double Netgen_point[3];
453 int Netgen_tetrahedron[4];
455 // create and insert new nodes into nodeVec
456 nodeVec.resize( Netgen_NbOfNodesNew + 1, 0 );
457 int nodeIndex = Netgen_NbOfNodes + 1;
458 for ( ; nodeIndex <= Netgen_NbOfNodesNew; ++nodeIndex )
460 Ng_GetPoint( Netgen_mesh, nodeIndex, Netgen_point );
461 nodeVec.at(nodeIndex) = helper.AddNode(Netgen_point[0], Netgen_point[1], Netgen_point[2]);
464 // create tetrahedrons
465 for ( int elemIndex = 1; elemIndex <= Netgen_NbOfTetra; ++elemIndex )
467 Ng_GetVolumeElement(Netgen_mesh, elemIndex, Netgen_tetrahedron);
470 helper.AddVolume (nodeVec.at( Netgen_tetrahedron[0] ),
471 nodeVec.at( Netgen_tetrahedron[1] ),
472 nodeVec.at( Netgen_tetrahedron[2] ),
473 nodeVec.at( Netgen_tetrahedron[3] ));
484 //================================================================================
486 * \brief Compute tetrahedral mesh from 2D mesh without geometry
488 //================================================================================
490 bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh,
491 SMESH_MesherHelper* aHelper)
493 const int invalid_ID = -1;
495 netgen::multithread.terminate = 0;
497 SMESH_MesherHelper::MType MeshType = aHelper->IsQuadraticMesh();
498 if ( MeshType == SMESH_MesherHelper::COMP )
499 return error( COMPERR_BAD_INPUT_MESH,
500 SMESH_Comment("Mesh with linear and quadratic elements given"));
502 aHelper->SetIsQuadratic( MeshType == SMESH_MesherHelper::QUADRATIC );
504 // ---------------------------------
505 // Feed the Netgen with surface mesh
506 // ---------------------------------
508 int Netgen_NbOfNodes = 0;
509 int Netgen_param2ndOrder = 0;
510 double Netgen_paramFine = 1.;
511 double Netgen_paramSize = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
513 double Netgen_point[3];
514 int Netgen_triangle[3];
515 int Netgen_tetrahedron[4];
517 NETGENPlugin_NetgenLibWrapper ngLib;
518 Ng_Mesh * Netgen_mesh = ngLib._ngMesh;
520 SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( aMesh ));
521 if ( aMesh.NbQuadrangles() > 0 )
523 StdMeshers_QuadToTriaAdaptor* Adaptor = new StdMeshers_QuadToTriaAdaptor;
524 Adaptor->Compute(aMesh);
525 proxyMesh.reset( Adaptor );
528 // maps nodes to ng ID
529 typedef map< const SMDS_MeshNode*, int, TIDCompare > TNodeToIDMap;
530 typedef TNodeToIDMap::value_type TN2ID;
531 TNodeToIDMap nodeToNetgenID;
533 SMDS_ElemIteratorPtr fIt = proxyMesh->GetFaces();
537 const SMDS_MeshElement* elem = fIt->next();
539 return error( COMPERR_BAD_INPUT_MESH, "Null element encounters");
540 if ( elem->NbCornerNodes() != 3 )
541 return error( COMPERR_BAD_INPUT_MESH, "Not triangle element encounters");
543 // add three nodes of triangle
544 for ( int iN = 0; iN < 3; ++iN )
546 const SMDS_MeshNode* node = elem->GetNode( iN );
547 int& ngID = nodeToNetgenID.insert(TN2ID( node, invalid_ID )).first->second;
548 if ( ngID == invalid_ID )
550 ngID = ++Netgen_NbOfNodes;
551 Netgen_point [ 0 ] = node->X();
552 Netgen_point [ 1 ] = node->Y();
553 Netgen_point [ 2 ] = node->Z();
554 Ng_AddPoint(Netgen_mesh, Netgen_point);
556 Netgen_triangle[ iN ] = ngID;
558 Ng_AddSurfaceElement(Netgen_mesh, NG_TRIG, Netgen_triangle);
560 proxyMesh.reset(); // delete tmp faces
562 // vector of nodes in which node index == netgen ID
563 vector< const SMDS_MeshNode* > nodeVec ( nodeToNetgenID.size() + 1 );
564 // insert old nodes into nodeVec
565 TNodeToIDMap::iterator n_id = nodeToNetgenID.begin();
566 for ( ; n_id != nodeToNetgenID.end(); ++n_id )
567 nodeVec.at( n_id->second ) = n_id->first;
568 nodeToNetgenID.clear();
570 // -------------------------
571 // Generate the volume mesh
572 // -------------------------
574 return ( ngLib._isComputeOk = compute( aMesh, *aHelper, nodeVec, Netgen_mesh));
577 void NETGENPlugin_NETGEN_3D::CancelCompute()
579 SMESH_Algo::CancelCompute();
580 netgen::multithread.terminate = 1;
583 //================================================================================
585 * \brief Return Compute progress
587 //================================================================================
589 double NETGENPlugin_NETGEN_3D::GetProgress() const
592 const char* volMeshing = "Volume meshing";
593 const char* dlnMeshing = "Delaunay meshing";
594 if ( !_optimizationStarted &&
595 ( strncmp( netgen::multithread.task, dlnMeshing, 3 ) == 0 ||
596 strncmp( netgen::multithread.task, volMeshing, 3 ) == 0 ))
598 res = 0.5 * netgen::multithread.percent / 100.; // [0., 0.5]
600 else // different otimizations
602 ((NETGENPlugin_NETGEN_3D*)this)->_optimizationStarted = true;
603 res = 0.5 + 0.5 * SMESH_Algo::GetProgressByTic(); // [0.5, 1.]
608 //=============================================================================
612 //=============================================================================
614 bool NETGENPlugin_NETGEN_3D::Evaluate(SMESH_Mesh& aMesh,
615 const TopoDS_Shape& aShape,
616 MapShapeNbElems& aResMap)
618 int nbtri = 0, nbqua = 0;
619 double fullArea = 0.0;
620 for (TopExp_Explorer expF(aShape, TopAbs_FACE); expF.More(); expF.Next()) {
621 TopoDS_Face F = TopoDS::Face( expF.Current() );
622 SMESH_subMesh *sm = aMesh.GetSubMesh(F);
623 MapShapeNbElemsItr anIt = aResMap.find(sm);
624 if( anIt==aResMap.end() ) {
625 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
626 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,"Submesh can not be evaluated",this));
629 std::vector<int> aVec = (*anIt).second;
630 nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
631 nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
633 BRepGProp::SurfaceProperties(F,G);
634 double anArea = G.Mass();
638 // collect info from edges
639 int nb0d_e = 0, nb1d_e = 0;
640 bool IsQuadratic = false;
642 TopTools_MapOfShape tmpMap;
643 for (TopExp_Explorer expF(aShape, TopAbs_EDGE); expF.More(); expF.Next()) {
644 TopoDS_Edge E = TopoDS::Edge(expF.Current());
645 if( tmpMap.Contains(E) )
648 SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(expF.Current());
649 MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
650 if( anIt==aResMap.end() ) {
651 SMESH_ComputeErrorPtr& smError = aSubMesh->GetComputeError();
652 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
653 "Submesh can not be evaluated",this));
656 std::vector<int> aVec = (*anIt).second;
657 nb0d_e += aVec[SMDSEntity_Node];
658 nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
660 IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
666 double ELen_face = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
667 double ELen_vol = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. );
668 double ELen = Min(ELen_vol,ELen_face*2);
671 BRepGProp::VolumeProperties(aShape,G);
672 double aVolume = G.Mass();
673 double tetrVol = 0.1179*ELen*ELen*ELen;
674 double CoeffQuality = 0.9;
675 int nbVols = int( aVolume/tetrVol/CoeffQuality );
676 int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
677 int nb1d_in = (nbVols*6 - nb1d_e - nb1d_f ) / 5;
678 std::vector<int> aVec(SMDSEntity_Last);
679 for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
681 aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
682 aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;
683 aVec[SMDSEntity_Quad_Pyramid] = nbqua;
686 aVec[SMDSEntity_Node] = nb1d_in/6 + 1;
687 aVec[SMDSEntity_Tetra] = nbVols - nbqua*2;
688 aVec[SMDSEntity_Pyramid] = nbqua;
690 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
691 aResMap.insert(std::make_pair(sm,aVec));