0022098: EDF 2036 SMESH: Create groups from none conected parts of a mesh

+#include "SMESH_MeshAlgos.hxx"
This commit is contained in:
eap 2013-05-16 16:58:08 +00:00
parent f2160ad9de
commit 42491f3cb5
6 changed files with 54 additions and 35 deletions

View File

@ -32,6 +32,7 @@
#include "SMESH_Comment.hxx" #include "SMESH_Comment.hxx"
#include "SMESH_ComputeError.hxx" #include "SMESH_ComputeError.hxx"
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MesherHelper.hxx" #include "SMESH_MesherHelper.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
@ -962,10 +963,10 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
// //
TIDSortedElemSet emptySet, avoidSet; TIDSortedElemSet emptySet, avoidSet;
avoidSet.insert( firstQuad ); avoidSet.insert( firstQuad );
firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet); firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet);
while ( firstQuad && !faceSubMesh->Contains( firstQuad )) { while ( firstQuad && !faceSubMesh->Contains( firstQuad )) {
avoidSet.insert( 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 )) if ( !firstQuad || !faceSubMesh->Contains( firstQuad ))
return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()")); return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()"));
@ -995,7 +996,7 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
{ {
// next face // next face
avoidSet.clear(); avoidSet.insert( quad ); 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) if ( !quad || quad->NbNodes() % 4 > 0)
return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()")); return error(ERR_LI("Error in _QuadFaceGrid::LoadGrid()"));

View File

@ -26,11 +26,11 @@
#include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_VolumeTool.hxx" #include "SMDS_VolumeTool.hxx"
#include "SMESH_Block.hxx" #include "SMESH_Block.hxx"
#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MesherHelper.hxx" #include "SMESH_MesherHelper.hxx"
#include <gp_Ax2.hxx> #include <gp_Ax2.hxx>
//#include "utilities.h"
#include <limits> #include <limits>
// Define error message and _MYDEBUG_ if needed // Define error message and _MYDEBUG_ if needed
@ -635,7 +635,7 @@ namespace
const SMDS_MeshNode* n1down = side.getNode( 0, y-1 ); const SMDS_MeshNode* n1down = side.getNode( 0, y-1 );
const SMDS_MeshNode* n2down = side.getNode( 1, y-1 ); const SMDS_MeshNode* n2down = side.getNode( 1, y-1 );
avoidSet.clear(); avoidSet.insert( firstQuad ); avoidSet.clear(); avoidSet.insert( firstQuad );
firstQuad = SMESH_MeshEditor::FindFaceInSet( n1down, n2down, emptySet, avoidSet, firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet,
&i1down, &i2down); &i1down, &i2down);
if ( !isQuadrangle( firstQuad )) if ( !isQuadrangle( firstQuad ))
return BAD_MESH_ERR; return BAD_MESH_ERR;
@ -648,7 +648,7 @@ namespace
x = 1; x = 1;
while ( ++x < nbX ) 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); avoidSet, &i2up, &i2down);
if ( !isQuadrangle( quad )) if ( !isQuadrangle( quad ))
return BAD_MESH_ERR; return BAD_MESH_ERR;
@ -942,7 +942,7 @@ namespace
while ( !isCornerNode( n2 ) ) while ( !isCornerNode( n2 ) )
{ {
avoidSet.clear(); avoidSet.insert( quad ); 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 )) if ( !isQuadrangle( quad ))
return BAD_MESH_ERR; return BAD_MESH_ERR;

View File

@ -34,11 +34,12 @@
#include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeOfNodes.hxx"
#include "SMDS_VolumeTool.hxx" #include "SMDS_VolumeTool.hxx"
#include "SMESHDS_SubMesh.hxx" #include "SMESHDS_SubMesh.hxx"
#include "SMESH_Comment.hxx"
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MesherHelper.hxx" #include "SMESH_MesherHelper.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx" #include "SMESH_subMeshEventListener.hxx"
#include "SMESH_Comment.hxx"
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
@ -1533,7 +1534,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes,
const SMDS_MeshElement* face = 0; const SMDS_MeshElement* face = 0;
do { do {
// look for a face by 2 nodes // 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 ) { if ( face ) {
int nbFaceNodes = face->NbNodes(); int nbFaceNodes = face->NbNodes();
if ( (!myCreateQuadratic && nbFaceNodes>4) || if ( (!myCreateQuadratic && nbFaceNodes>4) ||

View File

@ -41,6 +41,7 @@
#include "SMESH_MesherHelper.hxx" #include "SMESH_MesherHelper.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx" #include "SMESH_subMeshEventListener.hxx"
#include "SMESH_MeshAlgos.hxx"
#include "utilities.h" #include "utilities.h"
@ -1876,12 +1877,12 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
TIDSortedElemSet inSet, notInSet; TIDSortedElemSet inSet, notInSet;
const SMDS_MeshElement* f1 = 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"); if ( !f1 ) RETURN_BAD_RESULT("The first face on seam not found");
notInSet.insert( f1 ); notInSet.insert( f1 );
const SMDS_MeshElement* f2 = 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"); if ( !f2 ) RETURN_BAD_RESULT("The second face on seam not found");
// select a face with less UV of vNode // select a face with less UV of vNode
@ -1924,7 +1925,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
for ( int i = 0; i < nbNodes; ++i ) { for ( int i = 0; i < nbNodes; ++i ) {
const SMDS_MeshNode* n1 = faceToKeep->GetNode( i ); const SMDS_MeshNode* n1 = faceToKeep->GetNode( i );
const SMDS_MeshNode* n2 = faceToKeep->GetNode(( i+1 ) % nbNodes ); 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 ) if ( f1 )
elems.insert( f1 ); elems.insert( f1 );
} }

View File

@ -26,10 +26,11 @@
#include "SMDS_SetIterator.hxx" #include "SMDS_SetIterator.hxx"
#include "SMESH_Algo.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_Group.hxx"
#include "SMESHDS_GroupBase.hxx" #include "SMESHDS_GroupBase.hxx"
#include "SMESH_Algo.hxx"
#include "SMESH_Group.hxx"
#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MesherHelper.hxx"
#include <IntAna_IntConicQuad.hxx> #include <IntAna_IntConicQuad.hxx>
#include <IntAna_Quadric.hxx> #include <IntAna_Quadric.hxx>
@ -149,8 +150,8 @@ namespace
TIDSortedElemSet emptySet, avoidSet; TIDSortedElemSet emptySet, avoidSet;
int i1, i2; int i1, i2;
while ( const SMDS_MeshElement* f = while ( const SMDS_MeshElement* f =
SMESH_MeshEditor::FindFaceInSet( baseNodes[0], baseNodes[1], SMESH_MeshAlgos::FindFaceInSet( baseNodes[0], baseNodes[1],
emptySet, avoidSet, &i1, &i2 )) emptySet, avoidSet, &i1, &i2 ))
{ {
avoidSet.insert( f ); avoidSet.insert( f );
@ -542,7 +543,7 @@ bool StdMeshers_QuadToTriaAdaptor::CheckIntersection (const gp_Pnt& P,
const SMDS_MeshElement* NotCheckedFace) const SMDS_MeshElement* NotCheckedFace)
{ {
if ( !myElemSearcher ) if ( !myElemSearcher )
myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *aMesh.GetMeshDS() );
SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher); SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
//SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); //SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
@ -730,9 +731,9 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh,
if ( myElemSearcher ) delete myElemSearcher; if ( myElemSearcher ) delete myElemSearcher;
if ( aProxyMesh ) if ( aProxyMesh )
myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher( aProxyMesh->GetFaces(aShape)); myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS, aProxyMesh->GetFaces(aShape));
else else
myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
const SMESHDS_SubMesh * aSubMeshDSFace; const SMESHDS_SubMesh * aSubMeshDSFace;
Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5); Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5);
@ -879,7 +880,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh,
delete myElemSearcher; delete myElemSearcher;
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.IsQuadraticSubMesh(aMesh.GetShapeToMesh());
helper.SetElementsOnShape( true ); helper.SetElementsOnShape( true );
if ( !myElemSearcher )
myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher();
SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
SMESH_ProxyMesh::SubMesh* prxSubMesh = getProxySubMesh(); SMESH_ProxyMesh::SubMesh* prxSubMesh = getProxySubMesh();
if ( !myElemSearcher )
myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
SMDS_FaceIteratorPtr fIt = meshDS->facesIterator(/*idInceasingOrder=*/true); SMDS_FaceIteratorPtr fIt = meshDS->facesIterator(/*idInceasingOrder=*/true);
while( fIt->more()) 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 the face belong to the group of skinFaces, do not build a pyramid outside
if (groupDS && groupDS->Contains(face)) if (groupDS && groupDS->Contains(face))
{
intersected[0] = false; 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 // 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(); int i, j, k, myShapeID = myPyramids[0]->GetNode(4)->getshapeId();
if ( myElemSearcher ) delete myElemSearcher; if ( myElemSearcher ) delete myElemSearcher;
myElemSearcher = SMESH_MeshEditor(&aMesh).GetElementSearcher(); myElemSearcher = SMESH_MeshAlgos::GetElementSearcher( *meshDS );
SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher); SMESH_ElementSearcher* searcher = const_cast<SMESH_ElementSearcher*>(myElemSearcher);
set<const SMDS_MeshNode*> nodesToMove; set<const SMDS_MeshNode*> nodesToMove;
@ -1181,7 +1196,7 @@ bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh&
while ( vIt->more() ) while ( vIt->more() )
{ {
const SMDS_MeshElement* PrmJ = vIt->next(); 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 ); checkedPyrams.insert( PrmJ );
} }
} }

View File

@ -36,6 +36,7 @@
#include "SMESH_Gen.hxx" #include "SMESH_Gen.hxx"
#include "SMESH_Group.hxx" #include "SMESH_Group.hxx"
#include "SMESH_Mesh.hxx" #include "SMESH_Mesh.hxx"
#include "SMESH_MeshAlgos.hxx"
#include "SMESH_MesherHelper.hxx" #include "SMESH_MesherHelper.hxx"
#include "SMESH_ProxyMesh.hxx" #include "SMESH_ProxyMesh.hxx"
#include "SMESH_subMesh.hxx" #include "SMESH_subMesh.hxx"
@ -2067,9 +2068,9 @@ bool _ViscousBuilder::inflate(_SolidData& data)
// Limit inflation step size by geometry size found by itersecting // Limit inflation step size by geometry size found by itersecting
// normals of _LayerEdge's with mesh faces // normals of _LayerEdge's with mesh faces
double geomSize = Precision::Infinite(), intersecDist; double geomSize = Precision::Infinite(), intersecDist;
SMESH_MeshEditor editor( _mesh );
auto_ptr<SMESH_ElementSearcher> searcher auto_ptr<SMESH_ElementSearcher> 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 ) for ( unsigned i = 0; i < data._edges.size(); ++i )
{ {
if ( data._edges[i]->IsOnEdge() ) continue; 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; // Check if the last segments of _LayerEdge intersects 2D elements;
// checked elements are either temporary faces or faces on surfaces w/o the layers // checked elements are either temporary faces or faces on surfaces w/o the layers
SMESH_MeshEditor editor( _mesh );
auto_ptr<SMESH_ElementSearcher> searcher auto_ptr<SMESH_ElementSearcher> searcher
( editor.GetElementSearcher( data._proxyMesh->GetFaces( data._solid )) ); ( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(),
data._proxyMesh->GetFaces( data._solid )) );
distToIntersection = Precision::Infinite(); distToIntersection = Precision::Infinite();
double dist; double dist;
@ -2627,10 +2628,10 @@ bool _ViscousBuilder::updateNormals( _SolidData& data,
// 1) to find and fix intersection // 1) to find and fix intersection
// 2) to check that no new intersection appears as result of 1) // 2) to check that no new intersection appears as result of 1)
SMESH_MeshEditor editor( _mesh );
SMDS_ElemIteratorPtr fIt( new SMDS_ElementVectorIterator( tmpFaces.begin(), SMDS_ElemIteratorPtr fIt( new SMDS_ElementVectorIterator( tmpFaces.begin(),
tmpFaces.end())); tmpFaces.end()));
auto_ptr<SMESH_ElementSearcher> searcher ( editor.GetElementSearcher( fIt )); auto_ptr<SMESH_ElementSearcher> searcher
( SMESH_MeshAlgos::GetElementSearcher( *getMeshDS(), fIt ));
// 1) Find intersections // 1) Find intersections
double dist; 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* n1 = badTrias[iTia]->GetNode( iSide );
const SMDS_MeshNode* n2 = badTrias[iTia]->GetNode(( iSide+1 ) % 3 ); const SMDS_MeshNode* n2 = badTrias[iTia]->GetNode(( iSide+1 ) % 3 );
trias [iSide].first = badTrias[iTia]; trias [iSide].first = badTrias[iTia];
trias [iSide].second = SMESH_MeshEditor::FindFaceInSet( n1, n2, emptySet, involvedFaces, trias [iSide].second = SMESH_MeshAlgos::FindFaceInSet( n1, n2, emptySet, involvedFaces,
& i1, & i2 ); & i1, & i2 );
if ( ! trias[iSide].second || trias[iSide].second->NbCornerNodes() != 3 ) if ( ! trias[iSide].second || trias[iSide].second->NbCornerNodes() != 3 )
continue; continue;