0020714: EDF GHS3DPLUGIN: shapeToMesh when creating 3D mesh from 2D mesh

* Fix GetPointState()
This commit is contained in:
eap 2010-03-05 11:13:07 +00:00
parent 8781de04b7
commit 78364113e1

View File

@ -5974,6 +5974,12 @@ struct SMESH_ElementSearcherImpl: public SMESH_ElementSearcher
}; };
}; };
ostream& operator<< (ostream& out, const SMESH_ElementSearcherImpl::TInters& i)
{
return out << "TInters(face=" << ( i._face ? i._face->GetID() : 0)
<< ", _coincides="<<i._coincides << ")";
}
//======================================================================= //=======================================================================
/*! /*!
* \brief define tolerance for search * \brief define tolerance for search
@ -6077,13 +6083,11 @@ void SMESH_ElementSearcherImpl::findOuterBoundary(const SMDS_MeshElement* outerF
{ {
if ( _outerFacesFound ) return; if ( _outerFacesFound ) return;
// Collect all outer faces passing from one outer face to another via their links // Collect all outer faces by passing from one outer face to another via their links
// and BTW find out if there are internal faces at all. // and BTW find out if there are internal faces at all.
bool hasInternal = false; // checked links and links where outer boundary meets internal one
set< SMESH_TLink > visitedLinks, seamLinks;
// checked links
set< SMESH_TLink > visitedLinks;
// links to treat with already visited faces sharing them // links to treat with already visited faces sharing them
list < TFaceLink > startLinks; list < TFaceLink > startLinks;
@ -6112,7 +6116,8 @@ void SMESH_ElementSearcherImpl::findOuterBoundary(const SMDS_MeshElement* outerF
} }
else if ( faces.size() > 2 ) else if ( faces.size() > 2 )
{ {
hasInternal = true; seamLinks.insert( link );
// link direction within the outerFace // link direction within the outerFace
gp_Vec n1n2( SMESH_MeshEditor::TNodeXYZ( link.node1()), gp_Vec n1n2( SMESH_MeshEditor::TNodeXYZ( link.node1()),
SMESH_MeshEditor::TNodeXYZ( link.node2())); SMESH_MeshEditor::TNodeXYZ( link.node2()));
@ -6157,8 +6162,18 @@ void SMESH_ElementSearcherImpl::findOuterBoundary(const SMDS_MeshElement* outerF
startLinks.pop_front(); startLinks.pop_front();
} }
_outerFacesFound = true; _outerFacesFound = true;
if ( !hasInternal )
if ( !seamLinks.empty() )
{
// There are internal boundaries touching the outher one,
// find all faces of internal boundaries in order to find
// faces of boundaries of holes, if any.
}
else
{
_outerFaces.clear(); _outerFaces.clear();
}
} }
//======================================================================= //=======================================================================
@ -6300,6 +6315,8 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
nbInt2Axis.insert( make_pair( min( nbIntBeforePoint, nbIntAfterPoint ), axis )); nbInt2Axis.insert( make_pair( min( nbIntBeforePoint, nbIntAfterPoint ), axis ));
if ( _outerFacesFound ) break; // pass to thorough analysis
} // three attempts - loop on CS axes } // three attempts - loop on CS axes
// Analyse intersections thoroughly. // Analyse intersections thoroughly.
@ -6332,13 +6349,16 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
int nbIntBeforePoint = 0, nbIntAfterPoint = 0; int nbIntBeforePoint = 0, nbIntAfterPoint = 0;
double f = numeric_limits<double>::max(), l = -numeric_limits<double>::max(); double f = numeric_limits<double>::max(), l = -numeric_limits<double>::max();
map< double, TInters >::iterator u_int2 = u2inters.begin(), u_int1 = u_int2++; map< double, TInters >::iterator u_int1 = u2inters.begin(), u_int2 = u_int1;
bool ok = ! u_int1->second._coincides; bool ok = ! u_int1->second._coincides;
while ( ok && u_int1 != u2inters.end() ) while ( ok && u_int1 != u2inters.end() )
{
double u = u_int1->first;
bool touchingInt = false;
if ( ++u_int2 != u2inters.end() )
{ {
// skip intersections at the same point (if the line passes through edge or node) // skip intersections at the same point (if the line passes through edge or node)
int nbSamePnt = 0; int nbSamePnt = 0;
double u = u_int1->first;
while ( u_int2 != u2inters.end() && fabs( u_int2->first - u ) < tolerance ) while ( u_int2 != u2inters.end() && fabs( u_int2->first - u ) < tolerance )
{ {
++nbSamePnt; ++nbSamePnt;
@ -6364,16 +6384,15 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
// skip intersections at the same point after tangent intersections // skip intersections at the same point after tangent intersections
if ( nbTgt > 0 ) if ( nbTgt > 0 )
{ {
double u = u_int2->first; double u2 = u_int2->first;
++u_int2; ++u_int2;
while ( u_int2 != u2inters.end() && fabs( u_int2->first - u ) < tolerance ) while ( u_int2 != u2inters.end() && fabs( u_int2->first - u2 ) < tolerance )
{ {
++nbSamePnt; ++nbSamePnt;
++u_int2; ++u_int2;
} }
} }
// decide if we skipped a touching intersection
bool touchingInt = false;
if ( nbSamePnt + nbTgt > 0 ) if ( nbSamePnt + nbTgt > 0 )
{ {
double minDot = numeric_limits<double>::max(), maxDot = -numeric_limits<double>::max(); double minDot = numeric_limits<double>::max(), maxDot = -numeric_limits<double>::max();
@ -6387,6 +6406,7 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
} }
touchingInt = ( minDot*maxDot < 0 ); touchingInt = ( minDot*maxDot < 0 );
} }
}
if ( !touchingInt ) if ( !touchingInt )
{ {
if ( !hasPositionInfo || isOuterBoundary( u_int1->second._face )) if ( !hasPositionInfo || isOuterBoundary( u_int1->second._face ))
@ -6395,13 +6415,12 @@ TopAbs_State SMESH_ElementSearcherImpl::GetPointState(const gp_Pnt& point)
++nbIntBeforePoint; ++nbIntBeforePoint;
else else
++nbIntAfterPoint; ++nbIntAfterPoint;
} }
if ( u < f ) f = u; if ( u < f ) f = u;
if ( u > l ) l = u; if ( u > l ) l = u;
} }
u_int1 = u_int2++; // to next intersection u_int1 = u_int2; // to next intersection
} // loop on intersections with one line } // loop on intersections with one line