myTLinkNodeMap.insert( make_pair(link,n12));
}
+//================================================================================
+/*!
+ * \brief Return true if position of nodes on the shape hasn't yet been checked or
+ * the positions proved to be invalid
+ */
+//================================================================================
+
+bool SMESH_MesherHelper::toCheckPosOnShape(int shapeID ) const
+{
+ map< int,bool >::const_iterator id_ok = myNodePosShapesValidity.find( shapeID );
+ return ( id_ok == myNodePosShapesValidity.end() || !id_ok->second );
+}
+
+//================================================================================
+/*!
+ * \brief Set validity of positions of nodes on the shape.
+ * Once set, validity is not changed
+ */
+//================================================================================
+
+void SMESH_MesherHelper::setPosOnShapeValidity(int shapeID, bool ok ) const
+{
+ ((SMESH_MesherHelper*)this)->myNodePosShapesValidity.insert( make_pair( shapeID, ok));
+}
+
//=======================================================================
//function : GetUVOnSeam
//purpose : Select UV on either of 2 pcurves of a seam edge, closest to the given UV
const double tol,
const bool force) const
{
- if ( force || !myOkNodePosShapes.count( n->GetPosition()->GetShapeId() ))
+ int shapeID = n->GetPosition()->GetShapeId();
+ if ( force || toCheckPosOnShape( shapeID ))
{
// check that uv is correct
TopLoc_Location loc;
Precision::IsInfinite( uv.Y() ) ||
nodePnt.Distance( surface->Value( uv.X(), uv.Y() )) > tol )
{
+ setPosOnShapeValidity( shapeID, false );
// uv incorrect, project the node to surface
GeomAPI_ProjectPointOnSurf& projector = GetProjector( F, loc, tol );
projector.Perform( nodePnt );
MESSAGE( "SMESH_MesherHelper::CheckNodeUV(), invalid projection" );
return false;
}
+ // store the fixed UV on the face
+ if ( myShape.IsSame(F) && shapeID == myShapeID )
+ const_cast<SMDS_MeshNode*>(n)->SetPosition
+ ( SMDS_PositionPtr( new SMDS_FacePosition( shapeID, U, V )));
}
else if ( uv.Modulus() > numeric_limits<double>::min() )
{
- ((SMESH_MesherHelper*) this)->myOkNodePosShapes.insert( n->GetPosition()->GetShapeId() );
+ setPosOnShapeValidity( shapeID, true );
}
}
return true;
const bool force,
double* distance) const
{
- if ( force || !myOkNodePosShapes.count( n->GetPosition()->GetShapeId() ))
+ int shapeID = n->GetPosition()->GetShapeId();
+ if ( force || toCheckPosOnShape( shapeID ))
{
// check that u is correct
TopLoc_Location loc; double f,l;
if ( distance ) *distance = dist;
if ( dist > tol )
{
+ setPosOnShapeValidity( shapeID, false );
// u incorrect, project the node to the curve
int edgeID = GetMeshDS()->ShapeToIndex( E );
TID2ProjectorOnCurve& i2proj = const_cast< TID2ProjectorOnCurve&>( myEdge2Projector );
MESSAGE( "SMESH_MesherHelper::CheckNodeU(), invalid projection" );
return false;
}
- //u = double( U );
+ // store the fixed U on the edge
+ if ( myShape.IsSame(E) && shapeID == myShapeID )
+ const_cast<SMDS_MeshNode*>(n)->SetPosition
+ ( SMDS_PositionPtr( new SMDS_EdgePosition( shapeID, U )));
}
else if ( fabs( u ) > numeric_limits<double>::min() )
{
- ((SMESH_MesherHelper*) this)->myOkNodePosShapes.insert( n->GetPosition()->GetShapeId() );
+ setPosOnShapeValidity( shapeID, true );
}
if (( u < f-tol || u > l+tol ) && force )
{
SMDS_MeshNode* n12;
SMESHDS_Mesh* meshDS = GetMeshDS();
+ if ( IsSeamShape( n1->GetPosition()->GetShapeId() ))
+ // to get a correct UV of a node on seam, the second node must have checked UV
+ std::swap( n1, n2 );
+
// get type of shape for the new medium node
int faceID = -1, edgeID = -1;
const SMDS_PositionPtr Pos1 = n1->GetPosition();