0020833: EDF 1361 SMESH : Graphical Selection of the boundary faces in one clic

Change behavior of CoplanarFaces: normals of neighboring faces
   are compared and not that of the selected face and candidate faces
This commit is contained in:
eap 2012-09-03 08:26:53 +00:00
parent 3f3fd308b1
commit 8203a3d57e

View File

@ -2737,30 +2737,37 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh )
return; return;
const double radianTol = myToler * M_PI / 180.; const double radianTol = myToler * M_PI / 180.;
typedef SMDS_StdIterator< const SMDS_MeshElement*, SMDS_ElemIteratorPtr > TFaceIt; std::set< SMESH_TLink > checkedLinks;
std::set<const SMDS_MeshElement*> checkedFaces, checkedNodes;
std::list<const SMDS_MeshElement*> faceQueue( 1, face ); std::list< pair< const SMDS_MeshElement*, gp_Vec > > faceQueue;
faceQueue.push_back( make_pair( face, myNorm ));
while ( !faceQueue.empty() ) while ( !faceQueue.empty() )
{ {
face = faceQueue.front(); face = faceQueue.front().first;
if ( checkedFaces.insert( face ).second ) myNorm = faceQueue.front().second;
faceQueue.pop_front();
for ( int i = 0, nbN = face->NbCornerNodes(); i < nbN; ++i )
{ {
gp_Vec norm = getNormale( static_cast<const SMDS_MeshFace*>(face), &normOK ); const SMDS_MeshNode* n1 = face->GetNode( i );
if (!normOK || myNorm.Angle( norm ) <= radianTol) const SMDS_MeshNode* n2 = face->GetNode(( i+1 )%nbN);
if ( !checkedLinks.insert( SMESH_TLink( n1, n2 )).second )
continue;
SMDS_ElemIteratorPtr fIt = n1->GetInverseElementIterator(SMDSAbs_Face);
while ( fIt->more() )
{ {
myCoplanarIDs.insert( face->GetID() ); const SMDS_MeshElement* f = fIt->next();
std::set<const SMDS_MeshElement*> neighborFaces; if ( f->GetNodeIndex( n2 ) > -1 )
for ( int i = 0; i < face->NbCornerNodes(); ++i )
{ {
const SMDS_MeshNode* n = face->GetNode( i ); gp_Vec norm = getNormale( static_cast<const SMDS_MeshFace*>(f), &normOK );
if ( checkedNodes.insert( n ).second ) if (!normOK || myNorm.Angle( norm ) <= radianTol)
neighborFaces.insert( TFaceIt( n->GetInverseElementIterator(SMDSAbs_Face)), {
TFaceIt()); myCoplanarIDs.insert( f->GetID() );
faceQueue.push_back( make_pair( f, norm ));
}
} }
faceQueue.insert( faceQueue.end(), neighborFaces.begin(), neighborFaces.end() );
} }
} }
faceQueue.pop_front();
} }
} }
} }
@ -2770,7 +2777,7 @@ bool CoplanarFaces::IsSatisfy( long theElementId )
} }
/* /*
*Class : RangeOfIds *Class : RangeOfIds
*Description : Predicate for Range of Ids. *Description : Predicate for Range of Ids.
* Range may be specified with two ways. * Range may be specified with two ways.
* 1. Using AddToRange method * 1. Using AddToRange method