From: skl Date: Mon, 26 May 2008 07:27:50 +0000 (+0000) Subject: Updated for NPAL15716. X-Git-Tag: V4_1_3~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0a178ce702e55cbc2da65f3db9982e7d950ee495;p=plugins%2Fnetgenplugin.git Updated for NPAL15716. --- diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx index 66e3b95..2469705 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx @@ -38,6 +38,7 @@ #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_MesherHelper.hxx" +#include "StdMeshers_QuadToTriaAdaptor.hxx" #include #include @@ -179,6 +180,9 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, map< int, int* >::iterator shId_ngId; list< int > degenNgIds; + StdMeshers_QuadToTriaAdaptor Adaptor; + Adaptor.Compute(aMesh,aShape); + for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) { const TopoDS_Shape& aShapeFace = exp.Current(); @@ -195,20 +199,43 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, if ( !elem ) return error( COMPERR_BAD_INPUT_MESH, "Null element encounters"); bool isTraingle = ( elem->NbNodes()==3 || (_quadraticMesh && elem->NbNodes()==6 )); - if ( !isTraingle ) - return error( COMPERR_BAD_INPUT_MESH, - SMESH_Comment("Not triangle element ")<GetID()); - // keep a triangle - triangles.push_back( elem ); - isReversed.push_back( isRev ); - // put elem nodes to nodeToNetgenID map - SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(myTool->IsMedium(node)) - continue; - nodeToNetgenID.insert( make_pair( node, invalid_ID )); + if ( !isTraingle ) { + //return error( COMPERR_BAD_INPUT_MESH, + // SMESH_Comment("Not triangle element ")<GetID()); + // using adaptor + std::list faces = Adaptor.GetTriangles(elem); + if(faces.size()==0) { + return error( COMPERR_BAD_INPUT_MESH, + SMESH_Comment("Not triangles in adaptor for element ")<GetID()); + } + std::list::iterator itf = faces.begin(); + for(; itf!=faces.end(); itf++ ) { + triangles.push_back( (*itf) ); + isReversed.push_back( isRev ); + // put triange's nodes to nodeToNetgenID map + SMDS_ElemIteratorPtr triangleNodesIt = (*itf)->nodesIterator(); + while ( triangleNodesIt->more() ) { + const SMDS_MeshNode * node = + static_cast(triangleNodesIt->next()); + if(myTool->IsMedium(node)) + continue; + nodeToNetgenID.insert( make_pair( node, invalid_ID )); + } + } + } + else { + // keep a triangle + triangles.push_back( elem ); + isReversed.push_back( isRev ); + // put elem nodes to nodeToNetgenID map + SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator(); + while ( triangleNodesIt->more() ) { + const SMDS_MeshNode * node = + static_cast(triangleNodesIt->next()); + if(myTool->IsMedium(node)) + continue; + nodeToNetgenID.insert( make_pair( node, invalid_ID )); + } } #ifdef _DEBUG_ // check if a trainge is degenerated @@ -413,30 +440,51 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, else if (MeshType == SMESH_MesherHelper::QUADRATIC) _quadraticMesh = true; - SMDS_FaceIteratorPtr iteratorFace = MeshDS->facesIterator(); + StdMeshers_QuadToTriaAdaptor Adaptor; + Adaptor.Compute(aMesh); - while(iteratorFace->more()) - { + SMDS_FaceIteratorPtr iteratorFace = MeshDS->facesIterator(); + while(iteratorFace->more()) { // check element const SMDS_MeshElement* elem = iteratorFace->next(); if ( !elem ) return error( COMPERR_BAD_INPUT_MESH, "Null element encounters"); bool isTraingle = ( elem->NbNodes()==3 || (_quadraticMesh && elem->NbNodes()==6 )); - if ( !isTraingle ) - return error( COMPERR_BAD_INPUT_MESH, - SMESH_Comment("Not triangle element ")<GetID()); - - // keep a triangle - triangles.push_back( elem ); - // put elem nodes to nodeToNetgenID map - SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator(); - while ( triangleNodesIt->more() ) { - const SMDS_MeshNode * node = - static_cast(triangleNodesIt->next()); - if(aHelper->IsMedium(node)) - continue; - - nodeToNetgenID.insert( make_pair( node, invalid_ID )); + if ( !isTraingle ) { + //return error( COMPERR_BAD_INPUT_MESH, + // SMESH_Comment("Not triangle element ")<GetID()); + // using adaptor + std::list faces = Adaptor.GetTriangles(elem); + if(faces.size()==0) { + return error( COMPERR_BAD_INPUT_MESH, + SMESH_Comment("Not triangles in adaptor for element ")<GetID()); + } + std::list::iterator itf = faces.begin(); + for(; itf!=faces.end(); itf++ ) { + triangles.push_back( (*itf) ); + // put triange's nodes to nodeToNetgenID map + SMDS_ElemIteratorPtr triangleNodesIt = (*itf)->nodesIterator(); + while ( triangleNodesIt->more() ) { + const SMDS_MeshNode * node = + static_cast(triangleNodesIt->next()); + if(aHelper->IsMedium(node)) + continue; + nodeToNetgenID.insert( make_pair( node, invalid_ID )); + } + } + } + else { + // keep a triangle + triangles.push_back( elem ); + // put elem nodes to nodeToNetgenID map + SMDS_ElemIteratorPtr triangleNodesIt = elem->nodesIterator(); + while ( triangleNodesIt->more() ) { + const SMDS_MeshNode * node = + static_cast(triangleNodesIt->next()); + if(aHelper->IsMedium(node)) + continue; + nodeToNetgenID.insert( make_pair( node, invalid_ID )); + } } }