From 42491f3cb5447af200a225c414ff12be011afdfc Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 16 May 2013 16:58:08 +0000 Subject: [PATCH] 0022098: EDF 2036 SMESH: Create groups from none conected parts of a mesh +#include "SMESH_MeshAlgos.hxx" --- .../StdMeshers_CompositeHexa_3D.cxx | 7 +-- src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx | 8 ++-- src/StdMeshers/StdMeshers_Penta_3D.cxx | 5 ++- src/StdMeshers/StdMeshers_ProjectionUtils.cxx | 7 +-- .../StdMeshers_QuadToTriaAdaptor.cxx | 43 +++++++++++++------ src/StdMeshers/StdMeshers_ViscousLayers.cxx | 17 ++++---- 6 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx b/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx index 0fac6d131..30b645a62 100644 --- a/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx @@ -32,6 +32,7 @@ #include "SMESH_Comment.hxx" #include "SMESH_ComputeError.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_MeshAlgos.hxx" #include "SMESH_MesherHelper.hxx" #include "SMESH_subMesh.hxx" @@ -962,10 +963,10 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh ) // TIDSortedElemSet emptySet, avoidSet; avoidSet.insert( firstQuad ); - firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet); + firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet); while ( firstQuad && !faceSubMesh->Contains( firstQuad )) { avoidSet.insert( firstQuad ); - firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet); + firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet); } if ( !firstQuad || !faceSubMesh->Contains( firstQuad )) return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()")); @@ -995,7 +996,7 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh ) { // next face avoidSet.clear(); avoidSet.insert( quad ); - quad = SMESH_MeshEditor::FindFaceInSet( n1down, n1up, emptySet, avoidSet ); + quad = SMESH_MeshAlgos::FindFaceInSet( n1down, n1up, emptySet, avoidSet ); if ( !quad || quad->NbNodes() % 4 > 0) return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()")); diff --git a/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx b/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx index a80c2debd..e316d2971 100644 --- a/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx +++ b/src/StdMeshers/StdMeshers_HexaFromSkin_3D.cxx @@ -26,11 +26,11 @@ #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeTool.hxx" #include "SMESH_Block.hxx" +#include "SMESH_MeshAlgos.hxx" #include "SMESH_MesherHelper.hxx" #include -//#include "utilities.h" #include // Define error message and _MYDEBUG_ if needed @@ -635,7 +635,7 @@ namespace const SMDS_MeshNode* n1down = side.getNode( 0, y-1 ); const SMDS_MeshNode* n2down = side.getNode( 1, y-1 ); avoidSet.clear(); avoidSet.insert( firstQuad ); - firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet, + firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet, &i1down, &i2down); if ( !isQuadrangle( firstQuad )) return BAD_MESH_ERR; @@ -648,7 +648,7 @@ namespace x = 1; while ( ++x < nbX ) { - const SMDS_MeshElement* quad = SMESH_MeshEditor::FindFaceInSet( n2up, n2down, emptySet, + const SMDS_MeshElement* quad = SMESH_MeshAlgos::FindFaceInSet( n2up, n2down, emptySet, avoidSet, &i2up, &i2down); if ( !isQuadrangle( quad )) return BAD_MESH_ERR; @@ -942,7 +942,7 @@ namespace while ( !isCornerNode( n2 ) ) { avoidSet.clear(); avoidSet.insert( quad ); - quad = SMESH_MeshEditor::FindFaceInSet( n1, n2, emptySet, avoidSet, &i1, &i2 ); + quad = SMESH_MeshAlgos::FindFaceInSet( n1, n2, emptySet, avoidSet, &i1, &i2 ); if ( !isQuadrangle( quad )) return BAD_MESH_ERR; diff --git a/src/StdMeshers/StdMeshers_Penta_3D.cxx b/src/StdMeshers/StdMeshers_Penta_3D.cxx index 85697faaf..3db3f2dd9 100644 --- a/src/StdMeshers/StdMeshers_Penta_3D.cxx +++ b/src/StdMeshers/StdMeshers_Penta_3D.cxx @@ -34,11 +34,12 @@ #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeTool.hxx" #include "SMESHDS_SubMesh.hxx" +#include "SMESH_Comment.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_MeshAlgos.hxx" #include "SMESH_MesherHelper.hxx" #include "SMESH_subMesh.hxx" #include "SMESH_subMeshEventListener.hxx" -#include "SMESH_Comment.hxx" #include #include @@ -1533,7 +1534,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, const SMDS_MeshElement* face = 0; do { // look for a face by 2 nodes - face = SMESH_MeshEditor::FindFaceInSet( n1, n2, allFaces, foundFaces ); + face = SMESH_MeshAlgos::FindFaceInSet( n1, n2, allFaces, foundFaces ); if ( face ) { int nbFaceNodes = face->NbNodes(); if ( (!myCreateQuadratic && nbFaceNodes>4) || diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index 25bc38a4a..129e8ae48 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -41,6 +41,7 @@ #include "SMESH_MesherHelper.hxx" #include "SMESH_subMesh.hxx" #include "SMESH_subMeshEventListener.hxx" +#include "SMESH_MeshAlgos.hxx" #include "utilities.h" @@ -1876,12 +1877,12 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1, TIDSortedElemSet inSet, notInSet; const SMDS_MeshElement* f1 = - SMESH_MeshEditor::FindFaceInSet( vNode, eNode, inSet, notInSet ); + SMESH_MeshAlgos::FindFaceInSet( vNode, eNode, inSet, notInSet ); if ( !f1 ) RETURN_BAD_RESULT("The first face on seam not found"); notInSet.insert( f1 ); const SMDS_MeshElement* f2 = - SMESH_MeshEditor::FindFaceInSet( vNode, eNode, inSet, notInSet ); + SMESH_MeshAlgos::FindFaceInSet( vNode, eNode, inSet, notInSet ); if ( !f2 ) RETURN_BAD_RESULT("The second face on seam not found"); // select a face with less UV of vNode @@ -1924,7 +1925,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1, for ( int i = 0; i < nbNodes; ++i ) { const SMDS_MeshNode* n1 = faceToKeep->GetNode( i ); const SMDS_MeshNode* n2 = faceToKeep->GetNode(( i+1 ) % nbNodes ); - f1 = SMESH_MeshEditor::FindFaceInSet( n1, n2, inSet, notInSet ); + f1 = SMESH_MeshAlgos::FindFaceInSet( n1, n2, inSet, notInSet ); if ( f1 ) elems.insert( f1 ); } diff --git a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx index 959c85263..c69fa9e7a 100644 --- a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx +++ b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx @@ -26,10 +26,11 @@ #include "SMDS_SetIterator.hxx" +#include "SMESHDS_GroupBase.hxx" #include "SMESH_Algo.hxx" -#include "SMESH_MesherHelper.hxx" #include "SMESH_Group.hxx" -#include "SMESHDS_GroupBase.hxx" +#include "SMESH_MeshAlgos.hxx" +#include "SMESH_MesherHelper.hxx" #include #include @@ -149,8 +150,8 @@ namespace TIDSortedElemSet emptySet, avoidSet; int i1, i2; while ( const SMDS_MeshElement* f = - SMESH_MeshEditor::FindFaceInSet( baseNodes[0], baseNodes[1], - emptySet, avoidSet, &i1, &i2 )) + SMESH_MeshAlgos::FindFaceInSet( baseNodes[0], baseNodes[1], + emptySet, avoidSet, &i1, &i2 )) { avoidSet.insert( f ); @@ -542,7 +543,7 @@ bool StdMeshers_QuadToTriaAdaptor::CheckIntersection (const gp_Pnt& P, const SMDS_MeshElement* NotCheckedFace) { if ( !myElemSearcher ) - myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); + myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *aMesh.GetMeshDS() ); SMESH_ElementSearcher* searcher = const_cast(myElemSearcher); //SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); @@ -730,9 +731,9 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh, if ( myElemSearcher ) delete myElemSearcher; if ( aProxyMesh ) - myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher( aProxyMesh->GetFaces(aShape)); + myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS, aProxyMesh->GetFaces(aShape)); else - myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); + myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS ); const SMESHDS_SubMesh * aSubMeshDSFace; Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5); @@ -879,7 +880,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh, delete myElemSearcher; myElemSearcher = - SMESH_MeshEditor(&aMesh).GetElementSearcher( aProxyMesh->GetFaces(aShape)); + SMESH_MeshAlgos::GetElementSearcher( *meshDS, aProxyMesh->GetFaces(aShape)); } } } @@ -937,13 +938,13 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh) helper.IsQuadraticSubMesh(aMesh.GetShapeToMesh()); helper.SetElementsOnShape( true ); - if ( !myElemSearcher ) - myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); - SMESH_ElementSearcher* searcher = const_cast(myElemSearcher); - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); SMESH_ProxyMesh::SubMesh* prxSubMesh = getProxySubMesh(); + if ( !myElemSearcher ) + myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS ); + SMESH_ElementSearcher* searcher = const_cast(myElemSearcher); + SMDS_FaceIteratorPtr fIt = meshDS->facesIterator(/*idInceasingOrder=*/true); while( fIt->more()) { @@ -1098,7 +1099,21 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh) // if the face belong to the group of skinFaces, do not build a pyramid outside if (groupDS && groupDS->Contains(face)) + { intersected[0] = false; + } + else if ( intersected[0] && intersected[1] ) // check if one of pyramids is in a hole + { + gp_Pnt P ( PC.XYZ() + tmpDir.XYZ() * 0.5 * PC.Distance( intPnt[0] )); + if ( searcher->GetPointState( P ) == TopAbs_OUT ) + intersected[0] = false; + else + { + P = ( PC.XYZ() - tmpDir.XYZ() * 0.5 * PC.Distance( intPnt[1] )); + if ( searcher->GetPointState( P ) == TopAbs_OUT ) + intersected[1] = false; + } + } // Create one or two pyramids @@ -1150,7 +1165,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& int i, j, k, myShapeID = myPyramids[0]->GetNode(4)->getshapeId(); if ( myElemSearcher ) delete myElemSearcher; - myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); + myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS ); SMESH_ElementSearcher* searcher = const_cast(myElemSearcher); set nodesToMove; @@ -1181,7 +1196,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& while ( vIt->more() ) { const SMDS_MeshElement* PrmJ = vIt->next(); - if ( SMESH_Algo::GetCommonNodes( PrmI, PrmJ ).size() > 1 ) + if ( SMESH_MeshAlgos::GetCommonNodes( PrmI, PrmJ ).size() > 1 ) checkedPyrams.insert( PrmJ ); } } diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index cacab8913..61365b4d6 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -36,6 +36,7 @@ #include "SMESH_Gen.hxx" #include "SMESH_Group.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_MeshAlgos.hxx" #include "SMESH_MesherHelper.hxx" #include "SMESH_ProxyMesh.hxx" #include "SMESH_subMesh.hxx" @@ -2067,9 +2068,9 @@ bool _ViscousBuilder::inflate(_SolidData& data) // Limit inflation step size by geometry size found by itersecting // normals of _LayerEdge's with mesh faces double geomSize = Precision::Infinite(), intersecDist; - SMESH_MeshEditor editor( _mesh ); auto_ptr searcher - ( editor.GetElementSearcher( data._proxyMesh->GetFaces( data._solid )) ); + ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), + data._proxyMesh->GetFaces( data._solid )) ); for ( unsigned i = 0; i < data._edges.size(); ++i ) { if ( data._edges[i]->IsOnEdge() ) continue; @@ -2265,9 +2266,9 @@ bool _ViscousBuilder::smoothAndCheck(_SolidData& data, // Check if the last segments of _LayerEdge intersects 2D elements; // checked elements are either temporary faces or faces on surfaces w/o the layers - SMESH_MeshEditor editor( _mesh ); auto_ptr searcher - ( editor.GetElementSearcher( data._proxyMesh->GetFaces( data._solid )) ); + ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), + data._proxyMesh->GetFaces( data._solid )) ); distToIntersection = Precision::Infinite(); double dist; @@ -2627,10 +2628,10 @@ bool _ViscousBuilder::updateNormals( _SolidData& data, // 1) to find and fix intersection // 2) to check that no new intersection appears as result of 1) - SMESH_MeshEditor editor( _mesh ); SMDS_ElemIteratorPtr fIt( new SMDS_ElementVectorIterator( tmpFaces.begin(), tmpFaces.end())); - auto_ptr searcher ( editor.GetElementSearcher( fIt )); + auto_ptr searcher + ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), fIt )); // 1) Find intersections double dist; @@ -3958,8 +3959,8 @@ void _ViscousBuilder::fixBadFaces(const TopoDS_Face& F, SMESH_MesherHelper& help const SMDS_MeshNode* n1 = badTrias[iTia]->GetNode( iSide ); const SMDS_MeshNode* n2 = badTrias[iTia]->GetNode(( iSide+1 ) % 3 ); trias [iSide].first = badTrias[iTia]; - trias [iSide].second = SMESH_MeshEditor::FindFaceInSet( n1, n2, emptySet, involvedFaces, - & i1, & i2 ); + trias [iSide].second = SMESH_MeshAlgos::FindFaceInSet( n1, n2, emptySet, involvedFaces, + & i1, & i2 ); if ( ! trias[iSide].second || trias[iSide].second->NbCornerNodes() != 3 ) continue; -- 2.30.2