1 // Copyright (C) 2004-2010 CEA/DEN, EDF R&D
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.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //=============================================================================
21 // File : GHS3DPlugin_GHS3D.cxx
23 // Author : Edward AGAPOV, modified by Lioka RAZAFINDRAZAKA (CEA) 09/02/2007
25 //=============================================================================
27 #include "GHS3DPlugin_GHS3D.hxx"
28 #include "GHS3DPlugin_Hypothesis.hxx"
31 #include <Basics_Utils.hxx>
33 #include "SMESH_Gen.hxx"
34 #include "SMESH_Mesh.hxx"
35 #include "SMESH_Comment.hxx"
36 #include "SMESH_MesherHelper.hxx"
37 #include "SMESH_MeshEditor.hxx"
39 #include "SMDS_MeshElement.hxx"
40 #include "SMDS_MeshNode.hxx"
41 #include "SMDS_FaceOfNodes.hxx"
42 #include "SMDS_VolumeOfNodes.hxx"
44 #include <StdMeshers_QuadToTriaAdaptor.hxx>
45 #include <StdMeshers_ViscousLayers.hxx>
47 #include <BRepAdaptor_Surface.hxx>
48 #include <BRepBndLib.hxx>
49 #include <BRepClass3d_SolidClassifier.hxx>
50 #include <BRepTools.hxx>
51 #include <BRep_Tool.hxx>
52 #include <Bnd_Box.hxx>
53 #include <GeomAPI_ProjectPointOnSurf.hxx>
54 #include <OSD_File.hxx>
55 #include <Precision.hxx>
56 #include <Quantity_Parameter.hxx>
57 #include <Standard_ProgramError.hxx>
58 #include <Standard_ErrorHandler.hxx>
59 #include <Standard_Failure.hxx>
61 #include <TopExp_Explorer.hxx>
62 #include <TopTools_IndexedMapOfShape.hxx>
63 #include <TopTools_ListIteratorOfListOfShape.hxx>
65 //#include <BRepClass_FaceClassifier.hxx>
66 #include <TopTools_MapOfShape.hxx>
67 #include <BRepGProp.hxx>
68 #include <GProp_GProps.hxx>
70 #include "utilities.h"
75 #include <sys/sysinfo.h>
80 //#include <Standard_Stream.hxx>
83 #define castToNode(n) static_cast<const SMDS_MeshNode *>( n );
104 typedef const list<const SMDS_MeshFace*> TTriaList;
106 static void removeFile( const TCollection_AsciiString& fileName )
109 OSD_File( fileName ).Remove();
111 catch ( Standard_ProgramError ) {
112 MESSAGE("Can't remove file: " << fileName.ToCString() << " ; file does not exist or permission denied");
116 //=============================================================================
120 //=============================================================================
122 GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D(int hypId, int studyId, SMESH_Gen* gen)
123 : SMESH_3D_Algo(hypId, studyId, gen)
125 MESSAGE("GHS3DPlugin_GHS3D::GHS3DPlugin_GHS3D");
127 _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
128 _onlyUnaryInput = false; // Compute() will be called on a compound of solids
131 _compatibleHypothesis.push_back("GHS3D_Parameters");
132 _compatibleHypothesis.push_back( StdMeshers_ViscousLayers::GetHypType() );
133 _requireShape = false; // can work without shape
136 //=============================================================================
140 //=============================================================================
142 GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D()
144 MESSAGE("GHS3DPlugin_GHS3D::~GHS3DPlugin_GHS3D");
147 //=============================================================================
151 //=============================================================================
153 bool GHS3DPlugin_GHS3D::CheckHypothesis ( SMESH_Mesh& aMesh,
154 const TopoDS_Shape& aShape,
155 Hypothesis_Status& aStatus )
157 aStatus = SMESH_Hypothesis::HYP_OK;
160 _viscousLayersHyp = 0;
163 const list <const SMESHDS_Hypothesis * >& hyps =
164 GetUsedHypothesis(aMesh, aShape, /*ignoreAuxiliary=*/false);
165 list <const SMESHDS_Hypothesis* >::const_iterator h = hyps.begin();
166 for ( ; h != hyps.end(); ++h )
169 _hyp = dynamic_cast< const GHS3DPlugin_Hypothesis*> ( *h );
170 if ( !_viscousLayersHyp )
171 _viscousLayersHyp = dynamic_cast< const StdMeshers_ViscousLayers*> ( *h );
174 _keepFiles = _hyp->GetKeepFiles();
179 //=======================================================================
180 //function : findShape
182 //=======================================================================
184 static TopoDS_Shape findShape(const SMDS_MeshNode *aNode[],
186 const TopoDS_Shape shape[],
189 TopAbs_State * state = 0)
192 int j, iShape, nbNode = 4;
194 for ( j=0; j<nbNode; j++ ) {
195 gp_XYZ p ( aNode[j]->X(), aNode[j]->Y(), aNode[j]->Z() );
196 if ( aNode[j]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE ) {
203 BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
204 if (state) *state = SC.State();
205 if ( SC.State() != TopAbs_IN || aShape.IsNull() || aShape.ShapeType() != TopAbs_SOLID) {
206 for (iShape = 0; iShape < nShape; iShape++) {
207 aShape = shape[iShape];
208 if ( !( aPnt.X() < box[iShape][0] || box[iShape][1] < aPnt.X() ||
209 aPnt.Y() < box[iShape][2] || box[iShape][3] < aPnt.Y() ||
210 aPnt.Z() < box[iShape][4] || box[iShape][5] < aPnt.Z()) ) {
211 BRepClass3d_SolidClassifier SC (aShape, aPnt, Precision::Confusion());
212 if (state) *state = SC.State();
213 if (SC.State() == TopAbs_IN)
221 //=======================================================================
222 //function : readMapIntLine
224 //=======================================================================
226 static char* readMapIntLine(char* ptr, int tab[]) {
228 std::cout << std::endl;
230 for ( int i=0; i<17; i++ ) {
231 intVal = strtol(ptr, &ptr, 10);
238 //=======================================================================
239 //function : countShape
241 //=======================================================================
243 // template < class Mesh, class Shape >
244 // static int countShape( Mesh* mesh, Shape shape ) {
245 // TopExp_Explorer expShape ( mesh->ShapeToMesh(), shape );
247 // for ( ; expShape.More(); expShape.Next() ) {
253 //=======================================================================
254 //function : writeFaces
256 //=======================================================================
258 static bool writeFaces (ofstream & theFile,
259 const SMESH_ProxyMesh& theMesh,
260 const TopoDS_Shape& theShape,
261 const map <int,int> & theSmdsToGhs3dIdMap)
265 // NB_ELEMS DUMMY_INT
266 // Loop from 1 to NB_ELEMS
267 // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT
270 const SMESHDS_SubMesh* theSubMesh;
271 const SMDS_MeshElement* aFace;
272 const char* space = " ";
273 const int dummyint = 0;
274 map<int,int>::const_iterator itOnMap;
275 SMDS_ElemIteratorPtr itOnSubMesh, itOnSubFace;
276 int nbNodes, aSmdsID;
278 // count triangles bound to geometry
281 TopTools_IndexedMapOfShape facesMap;
282 TopExp::MapShapes( theShape, TopAbs_FACE, facesMap );
284 for ( int i = 1; i <= facesMap.Extent(); ++i )
285 if (( theSubMesh = theMesh.GetSubMesh( facesMap(i))))
286 nbTriangles += theSubMesh->NbElements();
288 std::cout << " " << facesMap.Extent() << " shapes of 2D dimension" << std::endl;
289 std::cout << std::endl;
291 theFile << space << nbTriangles << space << dummyint << std::endl;
293 for ( int i = 1; i <= facesMap.Extent(); i++ )
295 aShape = facesMap(i);
296 theSubMesh = theMesh.GetSubMesh(aShape);
297 if ( !theSubMesh ) continue;
298 itOnSubMesh = theSubMesh->GetElements();
299 while ( itOnSubMesh->more() )
301 aFace = itOnSubMesh->next();
302 nbNodes = aFace->NbNodes();
304 theFile << space << nbNodes;
306 itOnSubFace = aFace->nodesIterator();
307 while ( itOnSubFace->more() ) {
309 aSmdsID = itOnSubFace->next()->GetID();
310 itOnMap = theSmdsToGhs3dIdMap.find( aSmdsID );
311 // if ( itOnMap == theSmdsToGhs3dIdMap.end() ) {
312 // cout << "not found node: " << aSmdsID << endl;
315 ASSERT( itOnMap != theSmdsToGhs3dIdMap.end() );
317 theFile << space << (*itOnMap).second;
320 // (NB_NODES + 1) times: DUMMY_INT
321 for ( int j=0; j<=nbNodes; j++)
322 theFile << space << dummyint;
324 theFile << std::endl;
331 //=======================================================================
332 //function : writeFaces
333 //purpose : Write Faces in case if generate 3D mesh w/o geometry
334 //=======================================================================
336 static bool writeFaces (ofstream & theFile,
337 const SMESH_ProxyMesh& theMesh,
338 vector <const SMDS_MeshNode*> & theNodeByGhs3dId)
342 // NB_ELEMS DUMMY_INT
343 // Loop from 1 to NB_ELEMS
344 // NB_NODES NODE_NB_1 NODE_NB_2 ... (NB_NODES + 1) times: DUMMY_INT
346 int nbNodes, nbTriangles = 0;
347 map< const SMDS_MeshNode*,int >::iterator it;
348 SMDS_ElemIteratorPtr nodeIt;
349 const SMDS_MeshElement* elem;
351 const char* space = " ";
352 const int dummyint = 0;
355 nbTriangles = theMesh.NbFaces();
357 if ( nbTriangles == 0 )
360 std::cout << "The initial 2D mesh contains " << nbTriangles << " faces and ";
362 // NB_ELEMS DUMMY_INT
363 theFile << space << nbTriangles << space << dummyint << std::endl;
366 map<const SMDS_MeshNode*,int> aNodeToGhs3dIdMap;
368 // Loop from 1 to NB_ELEMS
370 SMDS_ElemIteratorPtr eIt = theMesh.GetFaces();
371 while ( eIt->more() )
375 nbNodes = elem->NbNodes();
376 theFile << space << nbNodes;
378 // NODE_NB_1 NODE_NB_2 ...
379 nodeIt = elem->nodesIterator();
380 while ( nodeIt->more() )
383 const SMDS_MeshNode* node = castToNode( nodeIt->next() );
384 int newId = aNodeToGhs3dIdMap.size() + 1; // ghs3d ids count from 1
385 it = aNodeToGhs3dIdMap.insert( make_pair( node, newId )).first;
386 theFile << space << it->second;
389 // (NB_NODES + 1) times: DUMMY_INT
390 for ( int i=0; i<=nbNodes; i++)
391 theFile << space << dummyint;
392 theFile << std::endl;
395 // put nodes to theNodeByGhs3dId vector
396 theNodeByGhs3dId.resize( aNodeToGhs3dIdMap.size() );
397 map<const SMDS_MeshNode*,int>::const_iterator n2id = aNodeToGhs3dIdMap.begin();
398 for ( ; n2id != aNodeToGhs3dIdMap.end(); ++ n2id)
400 theNodeByGhs3dId[ n2id->second - 1 ] = n2id->first; // ghs3d ids count from 1
406 //=======================================================================
407 //function : writePoints
409 //=======================================================================
411 static bool writePoints (ofstream & theFile,
412 SMESH_MesherHelper& theHelper,
413 map <int,int> & theSmdsToGhs3dIdMap,
414 map <int,const SMDS_MeshNode*> & theGhs3dIdToNodeMap,
415 map<vector<double>,double> & theEnforcedVertices)
420 // Loop from 1 to NB_NODES
423 SMESHDS_Mesh * theMesh = theHelper.GetMeshDS();
424 int nbNodes = theMesh->NbNodes();
427 int nbEnforcedVertices = theEnforcedVertices.size();
429 // Issue 020674: EDF 870 SMESH: Mesh generated by Netgen not usable by GHS3D
430 // The problem is in nodes on degenerated edges, we need to skip them
431 if ( theHelper.HasDegeneratedEdges() )
433 // here we decrease total nb of nodes by nb of nodes on degenerated edges
435 for (TopExp_Explorer e(theMesh->ShapeToMesh(), TopAbs_EDGE ); e.More(); e.Next())
437 SMESH_subMesh* sm = theHelper.GetMesh()->GetSubMesh( e.Current() );
438 if ( checkedSM.insert( sm->GetId() ).second && theHelper.IsDegenShape(sm->GetId() )) {
439 if ( sm->GetSubMeshDS() )
440 nbNodes -= sm->GetSubMeshDS()->NbNodes();
444 const char* space = " ";
445 const int dummyint = 0;
448 SMDS_NodeIteratorPtr it = theMesh->nodesIterator();
449 const SMDS_MeshNode* node;
452 std::cout << std::endl;
453 std::cout << "The initial 2D mesh contains :" << std::endl;
454 std::cout << " " << nbNodes << " nodes" << std::endl;
455 if (nbEnforcedVertices > 0) {
456 std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
458 std::cout << std::endl;
459 std::cout << "Start writing in 'points' file ..." << std::endl;
460 theFile << space << nbNodes << std::endl;
462 // Loop from 1 to NB_NODES
467 if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_EDGE &&
468 theHelper.IsDegenShape( node->getshapeId() )) // Issue 020674
471 theSmdsToGhs3dIdMap.insert( make_pair( node->GetID(), aGhs3dID ));
472 theGhs3dIdToNodeMap.insert( make_pair( aGhs3dID, node ));
477 << space << node->X()
478 << space << node->Y()
479 << space << node->Z()
480 << space << dummyint;
482 theFile << std::endl;
486 // Iterate over the enforced vertices
487 GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
488 const TopoDS_Shape shapeToMesh = theMesh->ShapeToMesh();
489 for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
490 double x = vertexIt->first[0];
491 double y = vertexIt->first[1];
492 double z = vertexIt->first[2];
493 // Test if point is inside shape to mesh
494 gp_Pnt myPoint(x,y,z);
495 BRepClass3d_SolidClassifier scl(shapeToMesh);
496 scl.Perform(myPoint, 1e-7);
497 TopAbs_State result = scl.State();
498 if ( result == TopAbs_IN ) {
499 MESSAGE("Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second);
500 // X Y Z PHY_SIZE DUMMY_INT
505 << space << vertexIt->second
506 << space << dummyint;
508 theFile << std::endl;
511 MESSAGE("Enforced vertex (" << x << "," << y <<"," << z << ") is not inside the geometry: it was not added ");
515 std::cout << std::endl;
516 std::cout << "End writing in 'points' file." << std::endl;
521 //=======================================================================
522 //function : writePoints
524 //=======================================================================
526 static bool writePoints (ofstream & theFile,
527 SMESH_Mesh * theMesh,
528 const vector <const SMDS_MeshNode*> & theNodeByGhs3dId,
529 map<vector<double>,double> & theEnforcedVertices)
534 // Loop from 1 to NB_NODES
537 int nbNodes = theNodeByGhs3dId.size();
541 int nbEnforcedVertices = theEnforcedVertices.size();
543 const char* space = " ";
544 const int dummyint = 0;
546 const SMDS_MeshNode* node;
549 std::cout << std::endl;
550 std::cout << "The initial 2D mesh contains :" << std::endl;
551 std::cout << " " << nbNodes << " nodes" << std::endl;
552 std::cout << " " << nbEnforcedVertices << " enforced vertices" << std::endl;
553 std::cout << std::endl;
554 std::cout << "Start writing in 'points' file ..." << std::endl;
555 theFile << space << nbNodes << std::endl;
557 // Loop from 1 to NB_NODES
559 vector<const SMDS_MeshNode*>::const_iterator nodeIt = theNodeByGhs3dId.begin();
560 vector<const SMDS_MeshNode*>::const_iterator after = theNodeByGhs3dId.end();
561 for ( ; nodeIt != after; ++nodeIt )
567 << space << node->X()
568 << space << node->Y()
569 << space << node->Z()
570 << space << dummyint;
572 theFile << std::endl;
576 // Iterate over the enforced vertices
577 GHS3DPlugin_Hypothesis::TEnforcedVertexValues::const_iterator vertexIt;
578 auto_ptr< SMESH_ElementSearcher > pntCls ( SMESH_MeshEditor( theMesh ).GetElementSearcher());
579 for(vertexIt = theEnforcedVertices.begin() ; vertexIt != theEnforcedVertices.end() ; ++vertexIt) {
580 double x = vertexIt->first[0];
581 double y = vertexIt->first[1];
582 double z = vertexIt->first[2];
583 // Test if point is inside shape to mesh
584 gp_Pnt myPoint(x,y,z);
585 TopAbs_State result = pntCls->GetPointState( myPoint );
586 if ( result == TopAbs_IN ) {
587 std::cout << "Adding enforced vertex (" << x << "," << y <<"," << z << ") = " << vertexIt->second << std::endl;
589 // X Y Z PHY_SIZE DUMMY_INT
594 << space << vertexIt->second
595 << space << dummyint;
597 theFile << std::endl;
600 std::cout << std::endl;
601 std::cout << "End writing in 'points' file." << std::endl;
606 //================================================================================
608 * \brief returns true if a triangle defined by the nodes is a temporary face on a
609 * side facet of pyramid and defines sub-domian inside the pyramid
611 //================================================================================
613 static bool isTmpFace(const SMDS_MeshNode* node1,
614 const SMDS_MeshNode* node2,
615 const SMDS_MeshNode* node3)
617 // find a pyramid sharing the 3 nodes
618 //const SMDS_MeshElement* pyram = 0;
619 SMDS_ElemIteratorPtr vIt1 = node1->GetInverseElementIterator(SMDSAbs_Volume);
620 while ( vIt1->more() )
622 const SMDS_MeshElement* pyram = vIt1->next();
623 if ( pyram->NbCornerNodes() != 5 ) continue;
625 if ( (i2 = pyram->GetNodeIndex( node2 )) >= 0 &&
626 (i3 = pyram->GetNodeIndex( node3 )) >= 0 )
628 // Triangle defines sub-domian inside the pyramid if it's
629 // normal points out of the pyram
631 // make i2 and i3 hold indices of base nodes of the pyram while
632 // keeping the nodes order in the triangle
635 i2 = i3, i3 = pyram->GetNodeIndex( node1 );
636 else if ( i3 == iApex )
637 i3 = i2, i2 = pyram->GetNodeIndex( node1 );
639 int i3base = (i2+1) % 4; // next index after i2 within the pyramid base
640 return ( i3base != i3 );
646 //=======================================================================
647 //function : findShapeID
648 //purpose : find the solid corresponding to GHS3D sub-domain following
649 // the technique proposed in GHS3D manual (available within
650 // ghs3d installation) in chapter "B.4 Subdomain (sub-region) assignment".
651 // In brief: normal of the triangle defined by the given nodes
652 // points out of the domain it is associated to
653 //=======================================================================
655 static int findShapeID(SMESH_Mesh& mesh,
656 const SMDS_MeshNode* node1,
657 const SMDS_MeshNode* node2,
658 const SMDS_MeshNode* node3,
659 const bool toMeshHoles)
661 const int invalidID = 0;
662 SMESHDS_Mesh* meshDS = mesh.GetMeshDS();
664 // face the nodes belong to
665 const SMDS_MeshElement * face = meshDS->FindFace(node1,node2,node3);
667 return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID;
669 std::cout << "bnd face " << face->GetID() << " - ";
671 // geom face the face assigned to
672 SMESH_MeshEditor editor(&mesh);
673 int geomFaceID = editor.FindShape( face );
675 return isTmpFace(node1, node2, node3) ? HOLE_ID : invalidID;
676 TopoDS_Shape shape = meshDS->IndexToShape( geomFaceID );
677 if ( shape.IsNull() || shape.ShapeType() != TopAbs_FACE )
679 TopoDS_Face geomFace = TopoDS::Face( shape );
681 // solids bounded by geom face
682 TopTools_IndexedMapOfShape solids, shells;
683 TopTools_ListIteratorOfListOfShape ansIt = mesh.GetAncestors(geomFace);
684 for ( ; ansIt.More(); ansIt.Next() ) {
685 switch ( ansIt.Value().ShapeType() ) {
687 solids.Add( ansIt.Value() ); break;
689 shells.Add( ansIt.Value() ); break;
693 // analyse found solids
694 if ( solids.Extent() == 0 || shells.Extent() == 0)
697 const TopoDS_Solid& solid1 = TopoDS::Solid( solids(1) );
698 if ( solids.Extent() == 1 )
701 return meshDS->ShapeToIndex( solid1 );
703 // - Are we at a hole boundary face?
704 if ( shells(1).IsSame( BRepTools::OuterShell( solid1 )) )
705 { // - No, but maybe a hole is bound by two shapes? Does shells(1) touches another shell?
707 TopExp_Explorer eExp( shells(1), TopAbs_EDGE );
708 // check if any edge of shells(1) belongs to another shell
709 for ( ; eExp.More() && !touch; eExp.Next() ) {
710 ansIt = mesh.GetAncestors( eExp.Current() );
711 for ( ; ansIt.More() && !touch; ansIt.Next() ) {
712 if ( ansIt.Value().ShapeType() == TopAbs_SHELL )
713 touch = ( !ansIt.Value().IsSame( shells(1) ));
717 return meshDS->ShapeToIndex( solid1 );
720 // find orientation of geom face within the first solid
721 TopExp_Explorer fExp( solid1, TopAbs_FACE );
722 for ( ; fExp.More(); fExp.Next() )
723 if ( geomFace.IsSame( fExp.Current() )) {
724 geomFace = TopoDS::Face( fExp.Current() );
728 return invalidID; // face not found
730 // normale to triangle
731 gp_Pnt node1Pnt ( node1->X(), node1->Y(), node1->Z() );
732 gp_Pnt node2Pnt ( node2->X(), node2->Y(), node2->Z() );
733 gp_Pnt node3Pnt ( node3->X(), node3->Y(), node3->Z() );
734 gp_Vec vec12( node1Pnt, node2Pnt );
735 gp_Vec vec13( node1Pnt, node3Pnt );
736 gp_Vec meshNormal = vec12 ^ vec13;
737 if ( meshNormal.SquareMagnitude() < DBL_MIN )
740 // get normale to geomFace at any node
741 bool geomNormalOK = false;
743 const SMDS_MeshNode* nodes[3] = { node1, node2, node3 };
744 SMESH_MesherHelper helper( mesh ); helper.SetSubShape( geomFace );
745 for ( int i = 0; !geomNormalOK && i < 3; ++i )
747 // find UV of i-th node on geomFace
748 const SMDS_MeshNode* nNotOnSeamEdge = 0;
749 if ( helper.IsSeamShape( nodes[i]->getshapeId() ))
750 if ( helper.IsSeamShape( nodes[(i+1)%3]->getshapeId() ))
751 nNotOnSeamEdge = nodes[(i+2)%3];
753 nNotOnSeamEdge = nodes[(i+1)%3];
755 gp_XY uv = helper.GetNodeUV( geomFace, nodes[i], nNotOnSeamEdge, &uvOK );
756 // check that uv is correct
759 TopoDS_Shape nodeShape = helper.GetSubShapeByNode( nodes[i], meshDS );
760 if ( !nodeShape.IsNull() )
761 switch ( nodeShape.ShapeType() )
763 case TopAbs_FACE: tol = BRep_Tool::Tolerance( TopoDS::Face( nodeShape )); break;
764 case TopAbs_EDGE: tol = BRep_Tool::Tolerance( TopoDS::Edge( nodeShape )); break;
765 case TopAbs_VERTEX: tol = BRep_Tool::Tolerance( TopoDS::Vertex( nodeShape )); break;
768 gp_Pnt nodePnt ( nodes[i]->X(), nodes[i]->Y(), nodes[i]->Z() );
769 BRepAdaptor_Surface surface( geomFace );
770 uvOK = ( nodePnt.Distance( surface.Value( uv.X(), uv.Y() )) < 2 * tol );
772 // normale to geomFace at UV
774 surface.D1( uv.X(), uv.Y(), nodePnt, du, dv );
775 geomNormal = du ^ dv;
776 if ( geomFace.Orientation() == TopAbs_REVERSED )
777 geomNormal.Reverse();
778 geomNormalOK = ( geomNormal.SquareMagnitude() > DBL_MIN * 1e3 );
786 bool isReverse = ( meshNormal * geomNormal ) < 0;
788 return meshDS->ShapeToIndex( solid1 );
790 if ( solids.Extent() == 1 )
791 return HOLE_ID; // we are inside a hole
793 return meshDS->ShapeToIndex( solids(2) );
796 //=======================================================================
797 //function : readResultFile
799 //=======================================================================
801 static bool readResultFile(const int fileOpen,
803 const char* fileName,
806 TopoDS_Shape tabShape[],
809 map <int,const SMDS_MeshNode*>& theGhs3dIdToNodeMap,
811 int nbEnforcedVertices)
813 MESSAGE("GHS3DPlugin_GHS3D::readResultFile()");
814 Kernel_Utils::Localizer loc;
822 SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS();
825 int nbElems, nbNodes, nbInputNodes;
826 int nodeId/*, triangleId*/;
828 int ID, shapeID, ghs3dShapeID;
831 nbShape ? theMeshDS->ShapeToIndex( tabShape[0] ) : theMeshDS->ShapeToIndex( theMeshDS->ShapeToMesh() );
833 int *tab, *tabID, *nodeID, *nodeAssigne;
835 const SMDS_MeshNode **node;
838 //tabID = new int[nbShape];
840 coord = new double[3];
841 node = new const SMDS_MeshNode*[4];
844 SMDS_MeshNode * aNewNode;
845 map <int,const SMDS_MeshNode*>::iterator itOnNode;
846 SMDS_MeshElement* aTet;
851 // Read the file state
852 fileStat = fstat(fileOpen, &status);
853 length = status.st_size;
855 // Mapping the result file into memory
857 HANDLE fd = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ,
858 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
859 HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY,
860 0, (DWORD)length, NULL);
861 ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 );
863 ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0);
867 ptr = readMapIntLine(ptr, tab);
872 nbInputNodes = tab[2];
874 nodeAssigne = new int[ nbNodes+1 ];
877 aSolid = tabShape[0];
879 // Reading the nodeId
880 for (int i=0; i < 4*nbElems; i++)
881 nodeId = strtol(ptr, &ptr, 10);
883 MESSAGE("nbInputNodes: "<<nbInputNodes);
884 MESSAGE("nbEnforcedVertices: "<<nbEnforcedVertices);
885 // Reading the nodeCoor and update the nodeMap
886 for (int iNode=1; iNode <= nbNodes; iNode++) {
887 for (int iCoor=0; iCoor < 3; iCoor++)
888 coord[ iCoor ] = strtod(ptr, &ptr);
889 nodeAssigne[ iNode ] = 1;
890 if ( iNode > (nbInputNodes-nbEnforcedVertices) ) {
891 // Creating SMESH nodes
892 // - for enforced vertices
893 // - for vertices of forced edges
895 nodeAssigne[ iNode ] = 0;
896 aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] );
897 theGhs3dIdToNodeMap.insert(theGhs3dIdToNodeMap.end(), make_pair( iNode, aNewNode ));
901 // Reading the number of triangles which corresponds to the number of sub-domains
902 nbTriangle = strtol(ptr, &ptr, 10);
904 tabID = new int[nbTriangle];
905 for (int i=0; i < nbTriangle; i++) {
907 // find the solid corresponding to GHS3D sub-domain following
908 // the technique proposed in GHS3D manual in chapter
909 // "B.4 Subdomain (sub-region) assignment"
910 int nodeId1 = strtol(ptr, &ptr, 10);
911 int nodeId2 = strtol(ptr, &ptr, 10);
912 int nodeId3 = strtol(ptr, &ptr, 10);
913 if ( nbTriangle > 1 ) {
914 const SMDS_MeshNode* n1 = theGhs3dIdToNodeMap[ nodeId1 ];
915 const SMDS_MeshNode* n2 = theGhs3dIdToNodeMap[ nodeId2 ];
916 const SMDS_MeshNode* n3 = theGhs3dIdToNodeMap[ nodeId3 ];
919 tabID[i] = findShapeID( theMesh, n1, n2, n3, toMeshHoles );
920 // -- 0020330: Pb with ghs3d as a submesh
921 // check that found shape is to be meshed
922 if ( tabID[i] > 0 ) {
923 const TopoDS_Shape& foundShape = theMeshDS->IndexToShape( tabID[i] );
924 bool isToBeMeshed = false;
925 for ( int iS = 0; !isToBeMeshed && iS < nbShape; ++iS )
926 isToBeMeshed = foundShape.IsSame( tabShape[ iS ]);
930 // END -- 0020330: Pb with ghs3d as a submesh
932 std::cout << i+1 << " subdomain: findShapeID() returns " << tabID[i] << std::endl;
935 catch ( Standard_Failure & ex)
938 std::cout << i+1 << " subdomain: Exception caugt: " << ex.GetMessageString() << std::endl;
943 std::cout << i+1 << " subdomain: unknown exception caught " << std::endl;
951 if ( nbTriangle <= nbShape ) // no holes
952 toMeshHoles = true; // not avoid creating tetras in holes
954 // Associating the tetrahedrons to the shapes
955 shapeID = compoundID;
956 for (int iElem = 0; iElem < nbElems; iElem++) {
957 for (int iNode = 0; iNode < 4; iNode++) {
958 ID = strtol(tetraPtr, &tetraPtr, 10);
959 itOnNode = theGhs3dIdToNodeMap.find(ID);
960 node[ iNode ] = itOnNode->second;
961 nodeID[ iNode ] = ID;
963 // We always run GHS3D with "to mesh holes"==TRUE but we must not create
964 // tetras within holes depending on hypo option,
965 // so we first check if aTet is inside a hole and then create it
966 //aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
967 if ( nbTriangle > 1 ) {
968 shapeID = HOLE_ID; // negative shapeID means not to create tetras if !toMeshHoles
969 ghs3dShapeID = strtol(shapePtr, &shapePtr, 10) - IdShapeRef;
970 if ( tabID[ ghs3dShapeID ] == 0 ) {
972 aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape, &state);
973 if ( toMeshHoles || state == TopAbs_IN )
974 shapeID = theMeshDS->ShapeToIndex( aSolid );
975 tabID[ ghs3dShapeID ] = shapeID;
978 shapeID = tabID[ ghs3dShapeID ];
980 else if ( nbShape > 1 ) {
981 // Case where nbTriangle == 1 while nbShape == 2 encountered
982 // with compound of 2 boxes and "To mesh holes"==False,
983 // so there are no subdomains specified for each tetrahedron.
984 // Try to guess a solid by a node already bound to shape
986 for ( int i=0; i<4 && shapeID==0; i++ ) {
987 if ( nodeAssigne[ nodeID[i] ] == 1 &&
988 node[i]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE &&
989 node[i]->getshapeId() > 1 )
991 shapeID = node[i]->getshapeId();
995 aSolid = findShape(node, aSolid, tabShape, tabBox, nbShape);
996 shapeID = theMeshDS->ShapeToIndex( aSolid );
999 // set new nodes and tetrahedron onto the shape
1000 for ( int i=0; i<4; i++ ) {
1001 if ( nodeAssigne[ nodeID[i] ] == 0 ) {
1002 if ( shapeID != HOLE_ID )
1003 theMeshDS->SetNodeInVolume( node[i], shapeID );
1004 nodeAssigne[ nodeID[i] ] = shapeID;
1007 if ( toMeshHoles || shapeID != HOLE_ID ) {
1008 aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
1009 theMeshDS->SetMeshElementOnShape( aTet, shapeID );
1012 shapeIDs.insert( shapeID );
1015 // Remove nodes of tetras inside holes if !toMeshHoles
1016 if ( !toMeshHoles ) {
1017 itOnNode = theGhs3dIdToNodeMap.find( nbInputNodes );
1018 for ( ; itOnNode != theGhs3dIdToNodeMap.end(); ++itOnNode) {
1019 ID = itOnNode->first;
1020 if ( nodeAssigne[ ID ] == HOLE_ID )
1021 theMeshDS->RemoveFreeNode( itOnNode->second, 0 );
1026 cout << nbElems << " tetrahedrons have been associated to " << nbShape << " shapes" << endl;
1028 UnmapViewOfFile(mapPtr);
1029 CloseHandle(hMapObject);
1032 munmap(mapPtr, length);
1041 delete [] nodeAssigne;
1045 if ( shapeIDs.size() != nbShape ) {
1046 std::cout << "Only " << shapeIDs.size() << " solids of " << nbShape << " found" << std::endl;
1047 for (int i=0; i<nbShape; i++) {
1048 shapeID = theMeshDS->ShapeToIndex( tabShape[i] );
1049 if ( shapeIDs.find( shapeID ) == shapeIDs.end() )
1050 std::cout << " Solid #" << shapeID << " not found" << std::endl;
1058 //=======================================================================
1059 //function : readResultFile
1061 //=======================================================================
1063 static bool readResultFile(const int fileOpen,
1065 const char* fileName,
1067 SMESH_Mesh& theMesh,
1068 TopoDS_Shape aSolid,
1069 vector <const SMDS_MeshNode*>& theNodeByGhs3dId,
1070 int nbEnforcedVertices)
1072 SMESHDS_Mesh* theMeshDS = theMesh.GetMeshDS();
1074 Kernel_Utils::Localizer loc;
1083 int nbElems, nbNodes, nbInputNodes;
1084 int nodeId, triangleId;
1090 const SMDS_MeshNode **node;
1093 coord = new double[3];
1094 node = new const SMDS_MeshNode*[4];
1096 SMDS_MeshNode * aNewNode;
1097 map <int,const SMDS_MeshNode*>::iterator IdNode;
1098 SMDS_MeshElement* aTet;
1100 // Read the file state
1101 fileStat = fstat(fileOpen, &status);
1102 length = status.st_size;
1104 // Mapping the result file into memory
1106 HANDLE fd = CreateFile(fileName, GENERIC_READ, FILE_SHARE_READ,
1107 NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
1108 HANDLE hMapObject = CreateFileMapping(fd, NULL, PAGE_READONLY,
1109 0, (DWORD)length, NULL);
1110 ptr = ( char* ) MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0 );
1112 ptr = (char *) mmap(0,length,PROT_READ,MAP_PRIVATE,fileOpen,0);
1116 ptr = readMapIntLine(ptr, tab);
1121 nbInputNodes = tab[2];
1123 theNodeByGhs3dId.resize( nbNodes );
1125 // Reading the nodeId
1126 for (int i=0; i < 4*nbElems; i++)
1127 nodeId = strtol(ptr, &ptr, 10);
1129 // Issue 0020682. Avoid creating nodes and tetras at place where
1130 // volumic elements already exist
1131 SMESH_ElementSearcher* elemSearcher = 0;
1132 vector< const SMDS_MeshElement* > foundVolumes;
1133 if ( theMesh.NbVolumes() > 0 )
1134 elemSearcher = SMESH_MeshEditor( &theMesh ).GetElementSearcher();
1136 // Reading the nodeCoord and update the nodeMap
1137 shapeID = theMeshDS->ShapeToIndex( aSolid );
1138 for (int iNode=0; iNode < nbNodes; iNode++) {
1139 for (int iCoor=0; iCoor < 3; iCoor++)
1140 coord[ iCoor ] = strtod(ptr, &ptr);
1141 if ((iNode+1) > (nbInputNodes-nbEnforcedVertices)) {
1142 // Issue 0020682. Avoid creating nodes and tetras at place where
1143 // volumic elements already exist
1144 if ( elemSearcher &&
1145 elemSearcher->FindElementsByPoint( gp_Pnt(coord[0],coord[1],coord[2]),
1146 SMDSAbs_Volume, foundVolumes ))
1148 theNodeByGhs3dId[ iNode ] = 0;
1152 aNewNode = theMeshDS->AddNode( coord[0],coord[1],coord[2] );
1153 theMeshDS->SetNodeInVolume( aNewNode, shapeID );
1154 theNodeByGhs3dId[ iNode ] = aNewNode;
1159 // Reading the triangles
1160 nbTriangle = strtol(ptr, &ptr, 10);
1162 for (int i=0; i < 3*nbTriangle; i++)
1163 triangleId = strtol(ptr, &ptr, 10);
1167 // Associating the tetrahedrons to the shapes
1168 for (int iElem = 0; iElem < nbElems; iElem++) {
1169 for (int iNode = 0; iNode < 4; iNode++) {
1170 ID = strtol(tetraPtr, &tetraPtr, 10);
1171 node[ iNode ] = theNodeByGhs3dId[ ID-1 ];
1175 // Issue 0020682. Avoid creating nodes and tetras at place where
1176 // volumic elements already exist
1177 if ( !node[1] || !node[0] || !node[2] || !node[3] )
1179 if ( elemSearcher->FindElementsByPoint(( SMESH_MeshEditor::TNodeXYZ(node[0]) +
1180 SMESH_MeshEditor::TNodeXYZ(node[1]) +
1181 SMESH_MeshEditor::TNodeXYZ(node[2]) +
1182 SMESH_MeshEditor::TNodeXYZ(node[3]) ) / 4.,
1183 SMDSAbs_Volume, foundVolumes ))
1186 aTet = theMeshDS->AddVolume( node[1], node[0], node[2], node[3] );
1187 shapeID = theMeshDS->ShapeToIndex( aSolid );
1188 theMeshDS->SetMeshElementOnShape( aTet, shapeID );
1191 cout << nbElems << " tetrahedrons have been associated to " << nbTriangle << " shapes" << endl;
1193 UnmapViewOfFile(mapPtr);
1194 CloseHandle(hMapObject);
1197 munmap(mapPtr, length);
1208 //=============================================================================
1210 *Here we are going to use the GHS3D mesher
1212 //=============================================================================
1214 bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh,
1215 const TopoDS_Shape& theShape)
1218 //SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
1220 // we count the number of shapes
1221 // _nbShape = countShape( meshDS, TopAbs_SOLID ); -- 0020330: Pb with ghs3d as a submesh
1223 TopExp_Explorer expBox ( theShape, TopAbs_SOLID );
1224 for ( ; expBox.More(); expBox.Next() )
1227 // create bounding box for every shape inside the compound
1230 TopoDS_Shape* tabShape;
1232 tabShape = new TopoDS_Shape[_nbShape];
1233 tabBox = new double*[_nbShape];
1234 for (int i=0; i<_nbShape; i++)
1235 tabBox[i] = new double[6];
1236 Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
1238 for (expBox.ReInit(); expBox.More(); expBox.Next()) {
1239 tabShape[iShape] = expBox.Current();
1240 Bnd_Box BoundingBox;
1241 BRepBndLib::Add(expBox.Current(), BoundingBox);
1242 BoundingBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);
1243 tabBox[iShape][0] = Xmin; tabBox[iShape][1] = Xmax;
1244 tabBox[iShape][2] = Ymin; tabBox[iShape][3] = Ymax;
1245 tabBox[iShape][4] = Zmin; tabBox[iShape][5] = Zmax;
1249 // a unique working file name
1250 // to avoid access to the same files by eg different users
1251 TCollection_AsciiString aGenericName
1252 = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
1254 TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
1255 TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
1256 aFacesFileName = aGenericName + ".faces"; // in faces
1257 aPointsFileName = aGenericName + ".points"; // in points
1258 aResultFileName = aGenericName + ".noboite";// out points and volumes
1259 aBadResFileName = aGenericName + ".boite"; // out bad result
1260 aBbResFileName = aGenericName + ".bb"; // out vertex stepsize
1261 aLogFileName = aGenericName + ".log"; // log
1263 // -----------------
1265 // -----------------
1267 ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out);
1268 ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
1271 aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
1273 INFOS( "Can't write into " << aFacesFileName);
1274 return error(SMESH_Comment("Can't write into ") << aFacesFileName);
1276 map <int,int> aSmdsToGhs3dIdMap;
1277 map <int,const SMDS_MeshNode*> aGhs3dIdToNodeMap;
1278 map<vector<double>,double> enforcedVertices;
1279 int nbEnforcedVertices = 0;
1281 enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
1282 nbEnforcedVertices = enforcedVertices.size();
1287 SMESH_MesherHelper helper( theMesh );
1288 helper.SetSubShape( theShape );
1291 SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
1293 // make prisms on quadrangles
1294 if ( theMesh.NbQuadrangles() > 0 )
1296 vector<SMESH_ProxyMesh::Ptr> components;
1297 for (expBox.ReInit(); expBox.More(); expBox.Next())
1299 if ( _viscousLayersHyp )
1301 proxyMesh = _viscousLayersHyp->Compute( theMesh, expBox.Current() );
1305 StdMeshers_QuadToTriaAdaptor* q2t = new StdMeshers_QuadToTriaAdaptor;
1306 q2t->Compute( theMesh, expBox.Current(), proxyMesh.get() );
1307 components.push_back( SMESH_ProxyMesh::Ptr( q2t ));
1309 proxyMesh.reset( new SMESH_ProxyMesh( components ));
1311 // build viscous layers
1312 else if ( _viscousLayersHyp )
1314 proxyMesh = _viscousLayersHyp->Compute( theMesh, theShape );
1319 Ok = (writePoints( aPointsFile, helper, aSmdsToGhs3dIdMap, aGhs3dIdToNodeMap, enforcedVertices)
1321 writeFaces ( aFacesFile, *proxyMesh, theShape, aSmdsToGhs3dIdMap ));
1324 // Write aSmdsToGhs3dIdMap to temp file
1325 TCollection_AsciiString aSmdsToGhs3dIdMapFileName;
1326 aSmdsToGhs3dIdMapFileName = aGenericName + ".ids"; // ids relation
1327 ofstream aIdsFile ( aSmdsToGhs3dIdMapFileName.ToCString() , ios::out);
1329 aIdsFile.rdbuf()->is_open();
1331 INFOS( "Can't write into " << aSmdsToGhs3dIdMapFileName);
1332 return error(SMESH_Comment("Can't write into ") << aSmdsToGhs3dIdMapFileName);
1334 aIdsFile << "Smds Ghs3d" << std::endl;
1335 map <int,int>::const_iterator myit;
1336 for (myit=aSmdsToGhs3dIdMap.begin() ; myit != aSmdsToGhs3dIdMap.end() ; ++myit) {
1337 aIdsFile << myit->first << " " << myit->second << std::endl;
1341 aPointsFile.close();
1345 if ( !_keepFiles ) {
1346 removeFile( aFacesFileName );
1347 removeFile( aPointsFileName );
1348 removeFile( aSmdsToGhs3dIdMapFileName );
1350 return error(COMPERR_BAD_INPUT_MESH);
1352 removeFile( aResultFileName ); // needed for boundary recovery module usage
1354 // -----------------
1356 // -----------------
1358 TCollection_AsciiString cmd( (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp ).c_str() );
1359 cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
1360 cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
1362 std::cout << std::endl;
1363 std::cout << "Ghs3d execution..." << std::endl;
1364 std::cout << cmd << std::endl;
1366 system( cmd.ToCString() ); // run
1368 std::cout << std::endl;
1369 std::cout << "End of Ghs3d execution !" << std::endl;
1375 // Mapping the result file
1378 fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
1379 if ( fileOpen < 0 ) {
1380 std::cout << std::endl;
1381 std::cout << "Can't open the " << aResultFileName.ToCString() << " GHS3D output file" << std::endl;
1382 std::cout << "Log: " << aLogFileName << std::endl;
1387 _hyp ? _hyp->GetToMeshHoles(true) : GHS3DPlugin_Hypothesis::DefaultMeshHoles();
1388 Ok = readResultFile( fileOpen,
1390 aResultFileName.ToCString(),
1392 theMesh, tabShape, tabBox, _nbShape, aGhs3dIdToNodeMap,
1393 toMeshHoles, nbEnforcedVertices );
1396 // ---------------------
1397 // remove working files
1398 // ---------------------
1403 removeFile( aLogFileName );
1405 else if ( OSD_File( aLogFileName ).Size() > 0 )
1407 // get problem description from the log file
1408 _Ghs2smdsConvertor conv( aGhs3dIdToNodeMap );
1409 storeErrorDescription( aLogFileName, conv );
1413 // the log file is empty
1414 removeFile( aLogFileName );
1415 INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" );
1416 error(COMPERR_ALGO_FAILED, "ghs3d: command not found" );
1419 if ( !_keepFiles ) {
1420 removeFile( aFacesFileName );
1421 removeFile( aPointsFileName );
1422 removeFile( aResultFileName );
1423 removeFile( aBadResFileName );
1424 removeFile( aBbResFileName );
1425 removeFile( aSmdsToGhs3dIdMapFileName );
1427 std::cout << "<" << aResultFileName.ToCString() << "> GHS3D output file ";
1429 std::cout << "not ";
1430 std::cout << "treated !" << std::endl;
1431 std::cout << std::endl;
1433 _nbShape = 0; // re-initializing _nbShape for the next Compute() method call
1440 //=============================================================================
1442 *Here we are going to use the GHS3D mesher w/o geometry
1444 //=============================================================================
1445 bool GHS3DPlugin_GHS3D::Compute(SMESH_Mesh& theMesh,
1446 SMESH_MesherHelper* aHelper)
1448 MESSAGE("GHS3DPlugin_GHS3D::Compute()");
1450 //SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
1451 TopoDS_Shape theShape = aHelper->GetSubShape();
1453 // a unique working file name
1454 // to avoid access to the same files by eg different users
1455 TCollection_AsciiString aGenericName
1456 = (char*) GHS3DPlugin_Hypothesis::GetFileName(_hyp).c_str();
1458 TCollection_AsciiString aFacesFileName, aPointsFileName, aResultFileName;
1459 TCollection_AsciiString aBadResFileName, aBbResFileName, aLogFileName;
1460 aFacesFileName = aGenericName + ".faces"; // in faces
1461 aPointsFileName = aGenericName + ".points"; // in points
1462 aResultFileName = aGenericName + ".noboite";// out points and volumes
1463 aBadResFileName = aGenericName + ".boite"; // out bad result
1464 aBbResFileName = aGenericName + ".bb"; // out vertex stepsize
1465 aLogFileName = aGenericName + ".log"; // log
1467 // -----------------
1469 // -----------------
1471 ofstream aFacesFile ( aFacesFileName.ToCString() , ios::out);
1472 ofstream aPointsFile ( aPointsFileName.ToCString() , ios::out);
1474 aFacesFile.rdbuf()->is_open() && aPointsFile.rdbuf()->is_open();
1477 return error( SMESH_Comment("Can't write into ") << aPointsFileName);
1479 GHS3DPlugin_Hypothesis::TEnforcedVertexValues enforcedVertices;
1480 int nbEnforcedVertices = 0;
1482 enforcedVertices = GHS3DPlugin_Hypothesis::GetEnforcedVertices(_hyp);
1483 nbEnforcedVertices = enforcedVertices.size();
1488 vector <const SMDS_MeshNode*> aNodeByGhs3dId;
1490 SMESH_ProxyMesh::Ptr proxyMesh( new SMESH_ProxyMesh( theMesh ));
1491 if ( theMesh.NbQuadrangles() > 0 )
1493 StdMeshers_QuadToTriaAdaptor* aQuad2Trias = new StdMeshers_QuadToTriaAdaptor;
1494 aQuad2Trias->Compute( theMesh );
1495 proxyMesh.reset( aQuad2Trias );
1498 Ok = (writeFaces ( aFacesFile, *proxyMesh, aNodeByGhs3dId ) &&
1499 writePoints( aPointsFile, &theMesh, aNodeByGhs3dId,enforcedVertices));
1502 aPointsFile.close();
1505 if ( !_keepFiles ) {
1506 removeFile( aFacesFileName );
1507 removeFile( aPointsFileName );
1509 return error(COMPERR_BAD_INPUT_MESH);
1511 removeFile( aResultFileName ); // needed for boundary recovery module usage
1513 // -----------------
1515 // -----------------
1517 TCollection_AsciiString cmd =
1518 (char*)GHS3DPlugin_Hypothesis::CommandToRun( _hyp, false ).c_str();
1519 cmd += TCollection_AsciiString(" -f ") + aGenericName; // file to read
1520 cmd += TCollection_AsciiString(" 1>" ) + aLogFileName; // dump into file
1522 system( cmd.ToCString() ); // run
1528 fileOpen = open( aResultFileName.ToCString(), O_RDONLY);
1529 if ( fileOpen < 0 ) {
1530 std::cout << std::endl;
1531 std::cout << "Error when opening the " << aResultFileName.ToCString() << " file" << std::endl;
1532 std::cout << "Log: " << aLogFileName << std::endl;
1533 std::cout << std::endl;
1537 Ok = readResultFile( fileOpen,
1539 aResultFileName.ToCString(),
1541 theMesh, theShape ,aNodeByGhs3dId, nbEnforcedVertices );
1544 // ---------------------
1545 // remove working files
1546 // ---------------------
1551 removeFile( aLogFileName );
1553 else if ( OSD_File( aLogFileName ).Size() > 0 )
1555 // get problem description from the log file
1556 _Ghs2smdsConvertor conv( aNodeByGhs3dId );
1557 storeErrorDescription( aLogFileName, conv );
1560 // the log file is empty
1561 removeFile( aLogFileName );
1562 INFOS( "GHS3D Error, command '" << cmd.ToCString() << "' failed" );
1563 error(COMPERR_ALGO_FAILED, "ghs3d: command not found" );
1568 removeFile( aFacesFileName );
1569 removeFile( aPointsFileName );
1570 removeFile( aResultFileName );
1571 removeFile( aBadResFileName );
1572 removeFile( aBbResFileName );
1578 //================================================================================
1580 * \brief Provide human readable text by error code reported by ghs3d
1582 //================================================================================
1584 static string translateError(const int errNum)
1588 return "The surface mesh includes a face of type other than edge, "
1589 "triangle or quadrilateral. This face type is not supported.";
1591 return "Not enough memory for the face table.";
1593 return "Not enough memory.";
1595 return "Not enough memory.";
1597 return "Face is ignored.";
1599 return "End of file. Some data are missing in the file.";
1601 return "Read error on the file. There are wrong data in the file.";
1603 return "the metric file is inadequate (dimension other than 3).";
1605 return "the metric file is inadequate (values not per vertices).";
1607 return "the metric file contains more than one field.";
1609 return "the number of values in the \".bb\" (metric file) is incompatible with the expected"
1610 "value of number of mesh vertices in the \".noboite\" file.";
1612 return "Too many sub-domains.";
1614 return "the number of vertices is negative or null.";
1616 return "the number of faces is negative or null.";
1618 return "A face has a null vertex.";
1620 return "incompatible data.";
1622 return "the number of vertices is negative or null.";
1624 return "the number of vertices is negative or null (in the \".mesh\" file).";
1626 return "the number of faces is negative or null.";
1628 return "A face appears more than once in the input surface mesh.";
1630 return "An edge appears more than once in the input surface mesh.";
1632 return "A face has a vertex negative or null.";
1634 return "NOT ENOUGH MEMORY.";
1636 return "Not enough available memory.";
1638 return "Some initial points cannot be inserted. The surface mesh is probably very bad "
1639 "in terms of quality or the input list of points is wrong.";
1641 return "Some vertices are too close to one another or coincident.";
1643 return "Some vertices are too close to one another or coincident.";
1645 return "A vertex cannot be inserted.";
1647 return "There are at least two points considered as coincident.";
1649 return "Some vertices are too close to one another or coincident.";
1651 return "The surface mesh regeneration step has failed.";
1653 return "Constrained edge cannot be enforced.";
1655 return "Constrained face cannot be enforced.";
1657 return "Missing faces.";
1659 return "No guess to start the definition of the connected component(s).";
1661 return "The surface mesh includes at least one hole. The domain is not well defined.";
1663 return "Impossible to define a component.";
1665 return "The surface edge intersects another surface edge.";
1667 return "The surface edge intersects the surface face.";
1669 return "One boundary point lies within a surface face.";
1671 return "One surface edge intersects a surface face.";
1673 return "One boundary point lies within a surface edge.";
1675 return "Insufficient memory ressources detected due to a bad quality surface mesh leading "
1676 "to too many swaps.";
1678 return "Edge is unique (i.e., bounds a hole in the surface).";
1680 return "Presumably, the surface mesh is not compatible with the domain being processed.";
1682 return "Too many components, too many sub-domain.";
1684 return "The surface mesh includes at least one hole. "
1685 "Therefore there is no domain properly defined.";
1687 return "Statistics.";
1689 return "Statistics.";
1691 return "Warning, it is dramatically tedious to enforce the boundary items.";
1693 return "Not enough memory at this time, nevertheless, the program continues. "
1694 "The expected mesh will be correct but not really as large as required.";
1696 return "see above error code, resulting quality may be poor.";
1698 return "Not enough memory at this time, nevertheless, the program continues (warning).";
1700 return "Unknown face type.";
1703 return "End of file. Some data are missing in the file.";
1705 return "A too small volume element is detected.";
1707 return "There exists at least a null or negative volume element.";
1709 return "There exist null or negative volume elements.";
1711 return "A too small volume element is detected. A face is considered being degenerated.";
1713 return "Some element is suspected to be very bad shaped or wrong.";
1715 return "A too bad quality face is detected. This face is considered degenerated.";
1717 return "A too bad quality face is detected. This face is degenerated.";
1719 return "Presumably, the surface mesh is not compatible with the domain being processed.";
1721 return "Abnormal error occured, contact hotline.";
1723 return "Not enough memory for the face table.";
1725 return "The algorithm cannot run further. "
1726 "The surface mesh is probably very bad in terms of quality.";
1728 return "Bad vertex number.";
1733 //================================================================================
1735 * \brief Retrieve from a string given number of integers
1737 //================================================================================
1739 static char* getIds( char* ptr, int nbIds, vector<int>& ids )
1742 ids.reserve( nbIds );
1745 while ( !isdigit( *ptr )) ++ptr;
1746 if ( ptr[-1] == '-' ) --ptr;
1747 ids.push_back( strtol( ptr, &ptr, 10 ));
1753 //================================================================================
1755 * \brief Retrieve problem description form a log file
1756 * \retval bool - always false
1758 //================================================================================
1760 bool GHS3DPlugin_GHS3D::storeErrorDescription(const TCollection_AsciiString& logFile,
1761 const _Ghs2smdsConvertor & toSmdsConvertor )
1765 int file = ::_open (logFile.ToCString(), _O_RDONLY|_O_BINARY);
1767 int file = ::open (logFile.ToCString(), O_RDONLY);
1770 return error( SMESH_Comment("See ") << logFile << " for problem description");
1773 // struct stat status;
1774 // fstat(file, &status);
1775 // size_t length = status.st_size;
1776 off_t length = lseek( file, 0, SEEK_END);
1777 lseek( file, 0, SEEK_SET);
1780 vector< char > buf( length );
1781 int nBytesRead = ::read (file, & buf[0], length);
1783 char* ptr = & buf[0];
1784 char* bufEnd = ptr + nBytesRead;
1786 SMESH_Comment errDescription;
1788 enum { NODE = 1, EDGE, TRIA, VOL, ID = 1 };
1790 // look for errors "ERR #"
1792 set<string> foundErrorStr; // to avoid reporting same error several times
1793 set<int> elemErrorNums; // not to report different types of errors with bad elements
1794 while ( ++ptr < bufEnd )
1796 if ( strncmp( ptr, "ERR ", 4 ) != 0 )
1799 list<const SMDS_MeshElement*> badElems;
1800 vector<int> nodeIds;
1804 int errNum = strtol(ptr, &ptr, 10);
1805 switch ( errNum ) { // we treat errors enumerated in [SALOME platform 0019316] issue
1807 // The face number (numfac) with vertices (f 1, f 2, f 3) has a null vertex.
1808 ptr = getIds(ptr, NODE, nodeIds);
1809 ptr = getIds(ptr, TRIA, nodeIds);
1810 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1812 case 1000: // ERR 1000 : 1 3 2
1813 // Face (f 1, f 2, f 3) appears more than once in the input surface mesh.
1814 ptr = getIds(ptr, TRIA, nodeIds);
1815 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1818 // Edge (e1, e2) appears more than once in the input surface mesh
1819 ptr = getIds(ptr, EDGE, nodeIds);
1820 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1823 // Face (f 1, f 2, f 3) has a vertex negative or null
1824 ptr = getIds(ptr, TRIA, nodeIds);
1825 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1828 // Vertex v1 and vertex v2 are too close to one another or coincident (warning).
1829 ptr = getIds(ptr, NODE, nodeIds);
1830 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1831 ptr = getIds(ptr, NODE, nodeIds);
1832 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1835 // Vertex v1 cannot be inserted (warning).
1836 ptr = getIds(ptr, NODE, nodeIds);
1837 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1840 // There are at least two points whose distance is dist, i.e., considered as coincident
1841 case 2103: // ERR 2103 : 16 WITH 3
1842 // Vertex v1 and vertex v2 are too close to one another or coincident (warning).
1843 ptr = getIds(ptr, NODE, nodeIds);
1844 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1845 ptr = getIds(ptr, NODE, nodeIds);
1846 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1849 // Constrained edge (e1, e2) cannot be enforced (warning).
1850 ptr = getIds(ptr, EDGE, nodeIds);
1851 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1854 // Constrained face (f 1, f 2, f 3) cannot be enforced
1855 ptr = getIds(ptr, TRIA, nodeIds);
1856 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1858 case 3103: // ERR 3103 : 1 2 WITH 7 3
1859 // The surface edge (e1, e2) intersects another surface edge (e3, e4)
1860 ptr = getIds(ptr, EDGE, nodeIds);
1861 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1862 ptr = getIds(ptr, EDGE, nodeIds);
1863 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1865 case 3104: // ERR 3104 : 9 10 WITH 1 2 3
1866 // The surface edge (e1, e2) intersects the surface face (f 1, f 2, f 3)
1867 ptr = getIds(ptr, EDGE, nodeIds);
1868 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1869 ptr = getIds(ptr, TRIA, nodeIds);
1870 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1872 case 3105: // ERR 3105 : 8 IN 2 3 5
1873 // One boundary point (say p1) lies within a surface face (f 1, f 2, f 3)
1874 ptr = getIds(ptr, NODE, nodeIds);
1875 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1876 ptr = getIds(ptr, TRIA, nodeIds);
1877 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1880 // One surface edge (say e1, e2) intersects a surface face (f 1, f 2, f 3)
1881 ptr = getIds(ptr, EDGE, nodeIds);
1882 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1883 ptr = getIds(ptr, TRIA, nodeIds);
1884 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1886 case 3107: // ERR 3107 : 2 IN 4 1
1887 // One boundary point (say p1) lies within a surface edge (e1, e2) (stop).
1888 ptr = getIds(ptr, NODE, nodeIds);
1889 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1890 ptr = getIds(ptr, EDGE, nodeIds);
1891 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1893 case 3109: // ERR 3109 : EDGE 5 6 UNIQUE
1894 // Edge (e1, e2) is unique (i.e., bounds a hole in the surface)
1895 ptr = getIds(ptr, EDGE, nodeIds);
1896 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1898 case 9000: // ERR 9000
1899 // ELEMENT 261 WITH VERTICES : 7 396 -8 242
1900 // VOLUME : -1.11325045E+11 W.R.T. EPSILON 0.
1901 // A too small volume element is detected. Are reported the index of the element,
1902 // its four vertex indices, its volume and the tolerance threshold value
1903 ptr = getIds(ptr, ID, nodeIds);
1904 ptr = getIds(ptr, VOL, nodeIds);
1905 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1906 // even if all nodes found, volume it most probably invisible,
1907 // add its faces to demenstrate it anyhow
1909 vector<int> faceNodes( nodeIds.begin(), --nodeIds.end() ); // 012
1910 badElems.push_back( toSmdsConvertor.getElement(faceNodes));
1911 faceNodes[2] = nodeIds[3]; // 013
1912 badElems.push_back( toSmdsConvertor.getElement(faceNodes));
1913 faceNodes[1] = nodeIds[2]; // 023
1914 badElems.push_back( toSmdsConvertor.getElement(faceNodes));
1915 faceNodes[0] = nodeIds[1]; // 123
1916 badElems.push_back( toSmdsConvertor.getElement(faceNodes));
1919 case 9001: // ERR 9001
1920 // %% NUMBER OF NEGATIVE VOLUME TETS : 1
1921 // %% THE LARGEST NEGATIVE TET : 1.75376581E+11
1922 // %% NUMBER OF NULL VOLUME TETS : 0
1923 // There exists at least a null or negative volume element
1926 // There exist n null or negative volume elements
1929 // A too small volume element is detected
1932 // A too bad quality face is detected. This face is considered degenerated,
1933 // its index, its three vertex indices together with its quality value are reported
1934 break; // same as next
1935 case 9112: // ERR 9112
1936 // FACE 2 WITH VERTICES : 4 2 5
1937 // SMALL INRADIUS : 0.
1938 // A too bad quality face is detected. This face is degenerated,
1939 // its index, its three vertex indices together with its inradius are reported
1940 ptr = getIds(ptr, ID, nodeIds);
1941 ptr = getIds(ptr, TRIA, nodeIds);
1942 badElems.push_back( toSmdsConvertor.getElement(nodeIds));
1943 // add triangle edges as it most probably has zero area and hence invisible
1945 vector<int> edgeNodes(2);
1946 edgeNodes[0] = nodeIds[0]; edgeNodes[1] = nodeIds[1]; // 0-1
1947 badElems.push_back( toSmdsConvertor.getElement(edgeNodes));
1948 edgeNodes[1] = nodeIds[2]; // 0-2
1949 badElems.push_back( toSmdsConvertor.getElement(edgeNodes));
1950 edgeNodes[0] = nodeIds[1]; // 1-2
1951 badElems.push_back( toSmdsConvertor.getElement(edgeNodes));
1956 bool isNewError = foundErrorStr.insert( string( errBeg, ptr )).second;
1958 continue; // not to report same error several times
1960 // const SMDS_MeshElement* nullElem = 0;
1961 // bool allElemsOk = ( find( badElems.begin(), badElems.end(), nullElem) == badElems.end());
1963 // if ( allElemsOk && !badElems.empty() && !elemErrorNums.empty() ) {
1964 // bool oneMoreErrorType = elemErrorNums.insert( errNum ).second;
1965 // if ( oneMoreErrorType )
1966 // continue; // not to report different types of errors with bad elements
1969 // store bad elements
1970 //if ( allElemsOk ) {
1971 list<const SMDS_MeshElement*>::iterator elem = badElems.begin();
1972 for ( ; elem != badElems.end(); ++elem )
1973 addBadInputElement( *elem );
1977 string text = translateError( errNum );
1978 if ( errDescription.find( text ) == text.npos ) {
1979 if ( !errDescription.empty() )
1980 errDescription << "\n";
1981 errDescription << text;
1986 if ( errDescription.empty() ) { // no errors found
1987 char msg[] = "connection to server failed";
1988 if ( search( &buf[0], bufEnd, msg, msg + strlen(msg)) != bufEnd )
1989 errDescription << "Licence problems.";
1992 if ( errDescription.empty() )
1993 errDescription << "See " << logFile << " for problem description";
1995 errDescription << "\nSee " << logFile << " for more information";
1997 return error( errDescription );
2000 //================================================================================
2002 * \brief Creates _Ghs2smdsConvertor
2004 //================================================================================
2006 _Ghs2smdsConvertor::_Ghs2smdsConvertor( const map <int,const SMDS_MeshNode*> & ghs2NodeMap)
2007 :_ghs2NodeMap( & ghs2NodeMap ), _nodeByGhsId( 0 )
2011 //================================================================================
2013 * \brief Creates _Ghs2smdsConvertor
2015 //================================================================================
2017 _Ghs2smdsConvertor::_Ghs2smdsConvertor( const vector <const SMDS_MeshNode*> & nodeByGhsId)
2018 : _ghs2NodeMap( 0 ), _nodeByGhsId( &nodeByGhsId )
2022 //================================================================================
2024 * \brief Return SMDS element by ids of GHS3D nodes
2026 //================================================================================
2028 const SMDS_MeshElement* _Ghs2smdsConvertor::getElement(const vector<int>& ghsNodes) const
2030 size_t nbNodes = ghsNodes.size();
2031 vector<const SMDS_MeshNode*> nodes( nbNodes, 0 );
2032 for ( size_t i = 0; i < nbNodes; ++i ) {
2033 int ghsNode = ghsNodes[ i ];
2034 if ( _ghs2NodeMap ) {
2035 map <int,const SMDS_MeshNode*>::const_iterator in = _ghs2NodeMap->find( ghsNode);
2036 if ( in == _ghs2NodeMap->end() )
2038 nodes[ i ] = in->second;
2041 if ( ghsNode < 1 || ghsNode > _nodeByGhsId->size() )
2043 nodes[ i ] = (*_nodeByGhsId)[ ghsNode-1 ];
2049 if ( nbNodes == 2 ) {
2050 const SMDS_MeshElement* edge= SMDS_Mesh::FindEdge( nodes[0], nodes[1] );
2052 edge = new SMDS_LinearEdge( nodes[0], nodes[1] );
2055 if ( nbNodes == 3 ) {
2056 const SMDS_MeshElement* face = SMDS_Mesh::FindFace( nodes );
2058 face = new SMDS_FaceOfNodes( nodes[0], nodes[1], nodes[2] );
2062 return new SMDS_VolumeOfNodes( nodes[0], nodes[1], nodes[2], nodes[3] );
2068 //=============================================================================
2072 //=============================================================================
2073 bool GHS3DPlugin_GHS3D::Evaluate(SMESH_Mesh& aMesh,
2074 const TopoDS_Shape& aShape,
2075 MapShapeNbElems& aResMap)
2077 int nbtri = 0, nbqua = 0;
2078 double fullArea = 0.0;
2079 for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) {
2080 TopoDS_Face F = TopoDS::Face( exp.Current() );
2081 SMESH_subMesh *sm = aMesh.GetSubMesh(F);
2082 MapShapeNbElemsItr anIt = aResMap.find(sm);
2083 if( anIt==aResMap.end() ) {
2084 SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
2085 smError.reset( new SMESH_ComputeError(COMPERR_ALGO_FAILED,
2086 "Submesh can not be evaluated",this));
2089 std::vector<int> aVec = (*anIt).second;
2090 nbtri += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
2091 nbqua += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
2093 BRepGProp::SurfaceProperties(F,G);
2094 double anArea = G.Mass();
2098 // collect info from edges
2099 int nb0d_e = 0, nb1d_e = 0;
2100 bool IsQuadratic = false;
2101 bool IsFirst = true;
2102 TopTools_MapOfShape tmpMap;
2103 for (TopExp_Explorer exp(aShape, TopAbs_EDGE); exp.More(); exp.Next()) {
2104 TopoDS_Edge E = TopoDS::Edge(exp.Current());
2105 if( tmpMap.Contains(E) )
2108 SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
2109 MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
2110 std::vector<int> aVec = (*anIt).second;
2111 nb0d_e += aVec[SMDSEntity_Node];
2112 nb1d_e += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
2114 IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
2120 double ELen = sqrt(2.* ( fullArea/(nbtri+nbqua*2) ) / sqrt(3.0) );
2123 BRepGProp::VolumeProperties(aShape,G);
2124 double aVolume = G.Mass();
2125 double tetrVol = 0.1179*ELen*ELen*ELen;
2126 double CoeffQuality = 0.9;
2127 int nbVols = int(aVolume/tetrVol/CoeffQuality);
2128 int nb1d_f = (nbtri*3 + nbqua*4 - nb1d_e) / 2;
2129 int nb1d_in = (int) ( nbVols*6 - nb1d_e - nb1d_f ) / 5;
2130 std::vector<int> aVec(SMDSEntity_Last);
2131 for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aVec[i]=0;
2133 aVec[SMDSEntity_Node] = nb1d_in/6 + 1 + nb1d_in;
2134 aVec[SMDSEntity_Quad_Tetra] = nbVols - nbqua*2;
2135 aVec[SMDSEntity_Quad_Pyramid] = nbqua;
2138 aVec[SMDSEntity_Node] = nb1d_in/6 + 1;
2139 aVec[SMDSEntity_Tetra] = nbVols - nbqua*2;
2140 aVec[SMDSEntity_Pyramid] = nbqua;
2142 SMESH_subMesh *sm = aMesh.GetSubMesh(aShape);
2143 aResMap.insert(std::make_pair(sm,aVec));