try to cope with invalid node params on edges

This commit is contained in:
eap 2008-04-17 07:42:14 +00:00
parent 3a53c225bc
commit ce4982ab11

View File

@ -32,13 +32,13 @@ using namespace std;
#include <Bnd_Box.hxx>
#include <Bnd_Box2d.hxx>
#include <ElSLib.hxx>
#include <Extrema_ExtPC.hxx>
#include <Extrema_GenExtPS.hxx>
#include <Extrema_POnSurf.hxx>
#include <Geom2d_Curve.hxx>
#include <GeomAdaptor_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Surface.hxx>
//#include <IntAna2d_AnaIntersection.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
@ -655,9 +655,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
TopoDS_Edge & edge = *elIt;
list< TPoint* > & ePoints = getShapePoints( edge );
double f, l;
Handle(Geom2d_Curve) C2d;
if ( !theProject )
C2d = BRep_Tool::CurveOnSurface( edge, face, f, l );
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface( edge, face, f, l );
bool isForward = ( edge.Orientation() == TopAbs_FORWARD );
TopoDS_Shape v1 = TopExp::FirstVertex( edge, true ); // always FORWARD
@ -733,7 +731,30 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
double u = epos->GetUParameter();
paramNodeMap.insert( TParamNodeMap::value_type( u, node ));
paramNodeMap.insert( make_pair( u, node ));
}
if ( paramNodeMap.size() != eSubMesh->NbNodes() ) {
// wrong U on edge, project
Extrema_ExtPC proj;
BRepAdaptor_Curve aCurve( edge );
proj.Initialize( aCurve, f, l );
paramNodeMap.clear();
nIt = eSubMesh->GetNodes();
for ( int iNode = 0; nIt->more(); ++iNode ) {
const SMDS_MeshNode* node = smdsNode( nIt->next() );
proj.Perform( gp_Pnt( node->X(), node->Y(), node->Z()));
double u = 0;
if ( proj.IsDone() ) {
for ( int i = 1, nb = proj.NbExt(); i <= nb; ++i )
if ( proj.IsMin( i )) {
u = proj.Point( i ).Parameter();
break;
}
} else {
u = isForward ? iNode : eSubMesh->NbNodes() - iNode;
}
paramNodeMap.insert( make_pair( u, node ));
}
}
// put U in [0,1] so that the first key-point has U==0
double du = l - f;