//================================================================================
SMESH_MesherHelper::SMESH_MesherHelper(SMESH_Mesh& theMesh)
- : myParIndex(0), myMesh(&theMesh), myShapeID(0), myCreateQuadratic(false)
+ : myParIndex(0), myMesh(&theMesh), myShapeID(0), myCreateQuadratic(false),
+ myFixNodeParameters(false)
{
myPar1[0] = myPar2[0] = myPar1[1] = myPar2[1] = 0;
mySetElemOnShape = ( ! myMesh->HasShapeToMesh() );
((SMESH_MesherHelper*)this)->myNodePosShapesValidity.insert( make_pair( shapeID, ok));
}
+//=======================================================================
+//function : ToFixNodeParameters
+//purpose : Enables fixing node parameters on EDGEs and FACEs in
+// GetNodeU(...,check=true), GetNodeUV(...,check=true), CheckNodeUV() and
+// CheckNodeU() in case if a node lies on a shape set via SetSubShape().
+// Default is False
+//=======================================================================
+
+void SMESH_MesherHelper::ToFixNodeParameters(bool toFix)
+{
+ myFixNodeParameters = toFix;
+}
+
+
//=======================================================================
//function : GetUVOnSeam
//purpose : Select UV on either of 2 pcurves of a seam edge, closest to the given UV
return false;
}
// store the fixed UV on the face
- if ( myShape.IsSame(F) && shapeID == myShapeID )
+ if ( myShape.IsSame(F) && shapeID == myShapeID && myFixNodeParameters )
const_cast<SMDS_MeshNode*>(n)->SetPosition
( SMDS_PositionPtr( new SMDS_FacePosition( U, V )));
}
return false;
}
// store the fixed U on the edge
- if ( myShape.IsSame(E) && shapeID == myShapeID )
+ if ( myShape.IsSame(E) && shapeID == myShapeID && myFixNodeParameters )
const_cast<SMDS_MeshNode*>(n)->SetPosition
( SMDS_PositionPtr( new SMDS_EdgePosition( U )));
}
return elem;
}
+namespace
+{
+ //================================================================================
+ /*!
+ * \brief Check if a node belongs to any face of sub-mesh
+ */
+ //================================================================================
+
+ bool isNodeInSubMesh( const SMDS_MeshNode* n, const SMESHDS_SubMesh* sm )
+ {
+ SMDS_ElemIteratorPtr fIt = n->GetInverseElementIterator( SMDSAbs_Face );
+ while ( fIt->more() )
+ if ( sm->Contains( fIt->next() ))
+ return true;
+ return false;
+ }
+}
+
//=======================================================================
//function : LoadNodeColumns
//purpose : Load nodes bound to face into a map of node columns
SMESH_Algo::GetSortedNodesOnEdge( theMesh, *edge,/*noMedium=*/true, sortedBaseNodes);
if ( sortedBaseNodes.empty() ) continue;
+ map< double, const SMDS_MeshNode*>::iterator u_n = sortedBaseNodes.begin();
+ if ( theProxyMesh ) // from sortedBaseNodes remove nodes not shared by faces of faceSubMesh
+ {
+ const SMDS_MeshNode* n1 = sortedBaseNodes.begin()->second;
+ const SMDS_MeshNode* n2 = sortedBaseNodes.rbegin()->second;
+ bool allNodesAreProxy = ( n1 != theProxyMesh->GetProxyNode( n1 ) &&
+ n2 != theProxyMesh->GetProxyNode( n2 ));
+ if ( allNodesAreProxy )
+ for ( u_n = sortedBaseNodes.begin(); u_n != sortedBaseNodes.end(); u_n++ )
+ u_n->second = theProxyMesh->GetProxyNode( u_n->second );
+
+ if ( u_n = sortedBaseNodes.begin(), !isNodeInSubMesh( u_n->second, faceSubMesh ))
+ {
+ while ( ++u_n != sortedBaseNodes.end() && !isNodeInSubMesh( u_n->second, faceSubMesh ));
+ sortedBaseNodes.erase( sortedBaseNodes.begin(), u_n );
+ }
+ else if ( u_n = --sortedBaseNodes.end(), !isNodeInSubMesh( u_n->second, faceSubMesh ))
+ {
+ while ( u_n != sortedBaseNodes.begin() && !isNodeInSubMesh( (--u_n)->second, faceSubMesh ));
+ sortedBaseNodes.erase( ++u_n, sortedBaseNodes.end() );
+ }
+ if ( sortedBaseNodes.empty() ) continue;
+ }
+
double f, l;
BRep_Tool::Range( *edge, f, l );
if ( edge->Orientation() == TopAbs_REVERSED ) std::swap( f, l );
const double coeff = 1. / ( l - f ) * length[iE] / fullLen;
const double prevPar = theParam2ColumnMap.empty() ? 0 : theParam2ColumnMap.rbegin()->first;
- map< double, const SMDS_MeshNode*>::iterator u_n = sortedBaseNodes.begin();
- for ( ; u_n != sortedBaseNodes.end(); u_n++ )
+ for ( u_n = sortedBaseNodes.begin(); u_n != sortedBaseNodes.end(); u_n++ )
{
double par = prevPar + coeff * ( u_n->first - f );
TParam2ColumnMap::iterator u2nn =
u2nn->second.push_back( u_n->second );
}
}
- TParam2ColumnMap::iterator par_nVec_2, par_nVec_1 = theParam2ColumnMap.begin();
- if ( theProxyMesh )
- {
- for ( ; par_nVec_1 != theParam2ColumnMap.end(); ++par_nVec_1 )
- {
- const SMDS_MeshNode* & n = par_nVec_1->second[0];
- n = theProxyMesh->GetProxyNode( n );
- }
- }
+ if ( theParam2ColumnMap.empty() )
+ return false;
+
int nbRows = 1 + faceSubMesh->NbElements() / ( theParam2ColumnMap.size()-1 );
// fill theParam2ColumnMap column by column by passing from nodes on
// theBaseEdge up via mesh faces on theFace
+ TParam2ColumnMap::iterator par_nVec_1, par_nVec_2;
par_nVec_2 = theParam2ColumnMap.begin();
par_nVec_1 = par_nVec_2++;
TIDSortedElemSet emptySet, avoidSet;
if ( getenv("NO_FixQuadraticElements") )
return;
- // 0. Apply algorithm to solids or geom faces
+ // 0. Apply algorithm to SOLIDs or FACEs
// ----------------------------------------------
if ( myShape.IsNull() ) {
if ( !myMesh->HasShapeToMesh() ) return;
SMESH_MesherHelper h(*myMesh);
h.SetSubShape( fIt.Key() );
h.FixQuadraticElements(true);
+ h.ToFixNodeParameters(true);
}
//perf_print_all_meters(1);
return;