mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-13 10:10:33 +05:00
020749: EDF 1291 SMESH : Create 2D Mesh from 3D improvement / note 0011031
- bool IsFreeFace( int faceIndex ); + bool IsFreeFace( int faceIndex, const SMDS_MeshElement** otherVol=0 );
This commit is contained in:
parent
101f6ec1bf
commit
8f1b298533
@ -1355,20 +1355,23 @@ int SMDS_VolumeTool::GetAllExistingEdges(vector<const SMDS_MeshElement*> & edges
|
|||||||
return edges.size();
|
return edges.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//================================================================================
|
||||||
//function : IsFreeFace
|
/*!
|
||||||
//purpose : check that only one volume is build on the face nodes
|
* \brief check that only one volume is build on the face nodes
|
||||||
//=======================================================================
|
*
|
||||||
|
* If a face is shared by one of <ignoreVolumes>, it is considered free
|
||||||
|
*/
|
||||||
|
//================================================================================
|
||||||
|
|
||||||
bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
|
bool SMDS_VolumeTool::IsFreeFace( int faceIndex, const SMDS_MeshElement** otherVol/*=0*/ )
|
||||||
{
|
{
|
||||||
const int free = true;
|
const bool isFree = true;
|
||||||
|
|
||||||
if (!setFace( faceIndex ))
|
if (!setFace( faceIndex ))
|
||||||
return !free;
|
return !isFree;
|
||||||
|
|
||||||
const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex );
|
const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex );
|
||||||
int nbFaceNodes = myFaceNbNodes;
|
const int nbFaceNodes = myFaceNbNodes;
|
||||||
|
|
||||||
// evaluate nb of face nodes shared by other volume
|
// evaluate nb of face nodes shared by other volume
|
||||||
int maxNbShared = -1;
|
int maxNbShared = -1;
|
||||||
@ -1377,25 +1380,19 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
|
|||||||
TElemIntMap::iterator vNbIt;
|
TElemIntMap::iterator vNbIt;
|
||||||
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
|
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
|
||||||
const SMDS_MeshNode* n = nodes[ iNode ];
|
const SMDS_MeshNode* n = nodes[ iNode ];
|
||||||
SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator();
|
SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator( SMDSAbs_Volume );
|
||||||
while ( eIt->more() ) {
|
while ( eIt->more() ) {
|
||||||
const SMDS_MeshElement* elem = eIt->next();
|
const SMDS_MeshElement* elem = eIt->next();
|
||||||
if ( elem != myVolume && elem->GetType() == SMDSAbs_Volume ) {
|
if ( elem != myVolume ) {
|
||||||
int nbShared = 1;
|
vNbIt = volNbShared.insert( make_pair( elem, 0 )).first;
|
||||||
vNbIt = volNbShared.find( elem );
|
(*vNbIt).second++;
|
||||||
if ( vNbIt == volNbShared.end() ) {
|
if ( vNbIt->second > maxNbShared )
|
||||||
volNbShared.insert ( TElemIntMap::value_type( elem, nbShared ));
|
maxNbShared = vNbIt->second;
|
||||||
}
|
|
||||||
else {
|
|
||||||
nbShared = ++(*vNbIt).second;
|
|
||||||
}
|
|
||||||
if ( nbShared > maxNbShared )
|
|
||||||
maxNbShared = nbShared;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( maxNbShared < 3 )
|
if ( maxNbShared < 3 )
|
||||||
return free; // is free
|
return isFree; // is free
|
||||||
|
|
||||||
// find volumes laying on the opposite side of the face
|
// find volumes laying on the opposite side of the face
|
||||||
// and sharing all nodes
|
// and sharing all nodes
|
||||||
@ -1404,55 +1401,81 @@ bool SMDS_VolumeTool::IsFreeFace( int faceIndex )
|
|||||||
if ( IsFaceExternal( faceIndex ))
|
if ( IsFaceExternal( faceIndex ))
|
||||||
intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z );
|
intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z );
|
||||||
XYZ p0 ( nodes[0] ), baryCenter;
|
XYZ p0 ( nodes[0] ), baryCenter;
|
||||||
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
|
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); ) {
|
||||||
int nbShared = (*vNbIt).second;
|
const int& nbShared = (*vNbIt).second;
|
||||||
if ( nbShared >= 3 ) {
|
if ( nbShared >= 3 ) {
|
||||||
SMDS_VolumeTool volume( (*vNbIt).first );
|
SMDS_VolumeTool volume( (*vNbIt).first );
|
||||||
volume.GetBaryCenter( baryCenter.x, baryCenter.y, baryCenter.z );
|
volume.GetBaryCenter( baryCenter.x, baryCenter.y, baryCenter.z );
|
||||||
XYZ intNormal2( baryCenter - p0 );
|
XYZ intNormal2( baryCenter - p0 );
|
||||||
if ( intNormal.Dot( intNormal2 ) < 0 )
|
if ( intNormal.Dot( intNormal2 ) < 0 ) {
|
||||||
continue; // opposite side
|
// opposite side
|
||||||
|
if ( nbShared >= nbFaceNodes )
|
||||||
|
{
|
||||||
|
// a volume shares the whole facet
|
||||||
|
if ( otherVol ) *otherVol = vNbIt->first;
|
||||||
|
return !isFree;
|
||||||
|
}
|
||||||
|
++vNbIt;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// remove a volume from volNbShared map
|
// remove a volume from volNbShared map
|
||||||
volNbShared.erase( vNbIt-- );
|
volNbShared.erase( vNbIt++ );
|
||||||
}
|
}
|
||||||
|
|
||||||
// here volNbShared contains only volumes laying on the
|
// here volNbShared contains only volumes laying on the opposite side of
|
||||||
// opposite side of the face
|
// the face and sharing 3 or more but not all face nodes with myVolume
|
||||||
if ( volNbShared.empty() ) {
|
if ( volNbShared.size() < 2 ) {
|
||||||
return free; // is free
|
return isFree; // is free
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the whole area of a face is shared
|
// check if the whole area of a face is shared
|
||||||
bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle
|
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ )
|
||||||
for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
|
{
|
||||||
SMDS_VolumeTool volume( (*vNbIt).first );
|
const SMDS_MeshNode* n = nodes[ iNode ];
|
||||||
bool prevLinkShared = false;
|
// check if n is shared by one of volumes of volNbShared
|
||||||
int nbSharedLinks = 0;
|
bool isShared = false;
|
||||||
for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
|
SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator( SMDSAbs_Volume );
|
||||||
bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] );
|
while ( eIt->more() && !isShared )
|
||||||
if ( linkShared )
|
isShared = volNbShared.count( eIt->next() );
|
||||||
nbSharedLinks++;
|
if ( !isShared )
|
||||||
if ( linkShared && prevLinkShared &&
|
return isFree;
|
||||||
volume.IsLinked( nodes[ iNode - 1 ], nodes[ iNode + 1] ))
|
|
||||||
isShared[ iNode ] = true;
|
|
||||||
prevLinkShared = linkShared;
|
|
||||||
}
|
}
|
||||||
if ( nbSharedLinks == nbFaceNodes )
|
if ( otherVol ) *otherVol = volNbShared.begin()->first;
|
||||||
return !free; // is not free
|
return !isFree;
|
||||||
if ( nbFaceNodes == 4 ) {
|
|
||||||
// check traingle parts 1 & 3
|
// if ( !myVolume->IsPoly() )
|
||||||
if ( isShared[1] && isShared[3] )
|
// {
|
||||||
return !free; // is not free
|
// bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle
|
||||||
// check triangle parts 0 & 2;
|
// for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) {
|
||||||
// 0 part could not be checked in the loop; check it here
|
// SMDS_VolumeTool volume( (*vNbIt).first );
|
||||||
if ( isShared[2] && prevLinkShared &&
|
// bool prevLinkShared = false;
|
||||||
volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) &&
|
// int nbSharedLinks = 0;
|
||||||
volume.IsLinked( nodes[ 1 ], nodes[ 3 ] ) )
|
// for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) {
|
||||||
return !free; // is not free
|
// bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] );
|
||||||
}
|
// if ( linkShared )
|
||||||
}
|
// nbSharedLinks++;
|
||||||
return free;
|
// if ( linkShared && prevLinkShared &&
|
||||||
|
// volume.IsLinked( nodes[ iNode - 1 ], nodes[ iNode + 1] ))
|
||||||
|
// isShared[ iNode ] = true;
|
||||||
|
// prevLinkShared = linkShared;
|
||||||
|
// }
|
||||||
|
// if ( nbSharedLinks == nbFaceNodes )
|
||||||
|
// return !free; // is not free
|
||||||
|
// if ( nbFaceNodes == 4 ) {
|
||||||
|
// // check traingle parts 1 & 3
|
||||||
|
// if ( isShared[1] && isShared[3] )
|
||||||
|
// return !free; // is not free
|
||||||
|
// // check triangle parts 0 & 2;
|
||||||
|
// // 0 part could not be checked in the loop; check it here
|
||||||
|
// if ( isShared[2] && prevLinkShared &&
|
||||||
|
// volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) &&
|
||||||
|
// volume.IsLinked( nodes[ 1 ], nodes[ 3 ] ) )
|
||||||
|
// return !free; // is not free
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return free;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
@ -160,8 +160,9 @@ class SMDS_EXPORT SMDS_VolumeTool
|
|||||||
// Check normal orientation of a face.
|
// Check normal orientation of a face.
|
||||||
// SetExternalNormal() is taken into account.
|
// SetExternalNormal() is taken into account.
|
||||||
|
|
||||||
bool IsFreeFace( int faceIndex );
|
bool IsFreeFace( int faceIndex, const SMDS_MeshElement** otherVol=0 );
|
||||||
// Check that all volumes built on the face nodes lays on one side
|
// Check that all volumes built on the face nodes lays on one side
|
||||||
|
// otherVol returns another volume sharing the given facet
|
||||||
|
|
||||||
bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
|
bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z);
|
||||||
// Return a normal to a face
|
// Return a normal to a face
|
||||||
|
Loading…
Reference in New Issue
Block a user