return setErrorCode( ERR_LOAD_EMPTY_SUBMESH );
}
+ TopoDS_Face face = TopoDS::Face( theFace.Oriented( TopAbs_FORWARD ));
+
// check that face is not closed
TopoDS_Vertex bidon;
list<TopoDS_Edge> eList;
- getOrderedEdges( theFace, bidon, eList, myNbKeyPntInBoundary );
+ getOrderedEdges( face, bidon, eList, myNbKeyPntInBoundary );
list<TopoDS_Edge>::iterator elIt = eList.begin();
for ( ; elIt != eList.end() ; elIt++ )
- if ( BRep_Tool::IsClosed( *elIt , theFace ))
+ if ( BRep_Tool::IsClosed( *elIt , face ))
return setErrorCode( ERR_LOADF_CLOSED_FACE );
Extrema_GenExtPS projector;
- GeomAdaptor_Surface aSurface( BRep_Tool::Surface( theFace ));
+ GeomAdaptor_Surface aSurface( BRep_Tool::Surface( face ));
if ( theProject || nbElems == 0 )
projector.Initialize( aSurface, 20,20, 1e-5,1e-5 );
TNodePointIDMap nodePointIDMap;
if ( nbElems == 0 || (theProject &&
- theMesh->IsMainShape( theFace ) &&
+ theMesh->IsMainShape( face ) &&
!isMeshBoundToShape( theMesh )))
{
MESSAGE("Project the whole mesh");
p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 );
}
// find key-points: the points most close to UV of vertices
- TopExp_Explorer vExp( theFace, TopAbs_VERTEX );
+ TopExp_Explorer vExp( face, TopAbs_VERTEX );
set<int> foundIndices;
for ( ; vExp.More(); vExp.Next() ) {
const TopoDS_Vertex v = TopoDS::Vertex( vExp.Current() );
- gp_Pnt2d uv = BRep_Tool::Parameters( v, theFace );
+ gp_Pnt2d uv = BRep_Tool::Parameters( v, face );
double minDist = DBL_MAX;
int index;
vector< TPoint >::const_iterator pVecIt = myPoints.begin();
for ( elIt = eList.begin(); elIt != eList.end(); elIt++ )
myShapeIDMap.Add( *elIt );
// the face
- myShapeIDMap.Add( theFace );
+ myShapeIDMap.Add( face );
myPoints.resize( nbNodes );
double f, l;
Handle(Geom2d_Curve) C2d;
if ( !theProject )
- C2d = BRep_Tool::CurveOnSurface( edge, theFace, f, l );
+ C2d = BRep_Tool::CurveOnSurface( edge, face, f, l );
bool isForward = ( edge.Orientation() == TopAbs_FORWARD );
// the forward key-point
if ( fSubMesh && fSubMesh->NbElements() )
{
- list< TPoint* > & fPoints = getShapePoints( theFace );
+ list< TPoint* > & fPoints = getShapePoints( face );
SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes();
while ( nIt->more() )
{
}
}
// set element on a shape
- if ( elem && onMeshElements )
+ if ( elem && onMeshElements ) // applied to mesh elements
{
int elemIndex = iElem / nbElems;
- if ( shapeIDs[ elemIndex ] > 0 )
- aMeshDS->SetMeshElementOnShape( elem, shapeIDs[ elemIndex ] );
+ int shapeID = shapeIDs[ elemIndex ];
+ if ( shapeID > 0 ) {
+ aMeshDS->SetMeshElementOnShape( elem, shapeID );
+ // set nodes on a shape
+ TopoDS_Shape S = aMeshDS->IndexToShape( shapeID );
+ if ( S.ShapeType() == TopAbs_SOLID ) {
+ TopoDS_Iterator shellIt( S );
+ if ( shellIt.More() )
+ shapeID = aMeshDS->ShapeToIndex( shellIt.Value() );
+ }
+ SMDS_ElemIteratorPtr noIt = elem->nodesIterator();
+ while ( noIt->more() ) {
+ SMDS_MeshNode* node = const_cast<SMDS_MeshNode*>
+ ( static_cast<const SMDS_MeshNode*>( noIt->next() ));
+ if ( !node->GetPosition() || !node->GetPosition()->GetShapeId() ) {
+ if ( S.ShapeType() == TopAbs_FACE )
+ aMeshDS->SetNodeOnFace( node, shapeID );
+ else
+ aMeshDS->SetNodeInVolume( node, shapeID );
+ }
+ }
+ }
// add elem in groups
list< SMESHDS_Group* >::iterator g = groups[ elemIndex ].begin();
for ( ; g != groups[ elemIndex ].end(); ++g )
(*g)->SMDSGroup().Add( elem );
}
- if ( elem && !myShape.IsNull() )
+ if ( elem && !myShape.IsNull() ) // applied to shape
aMeshDS->SetMeshElementOnShape( elem, myShape );
}
}
elemIDs.push_back( myElements[ i ]->GetID() );
}
- // remove refined elements and their nodes
+ // remove refined elements
editor.Remove( elemIDs, false );
}
thePoints.push_back( & (*pVecIt).myXYZ.XYZ() );
}
else { // applied to mesh elements
+ const gp_XYZ * definedXYZ = & myPoints[ myKeyPointIDs.front() ].myXYZ.XYZ();
vector<gp_XYZ>::const_iterator xyz = myXYZ.begin();
for ( ; xyz != myXYZ.end(); ++xyz )
- thePoints.push_back( & (*xyz) );
+ if ( !isDefined( *xyz ))
+ thePoints.push_back( definedXYZ );
+ else
+ thePoints.push_back( & (*xyz) );
}
return !thePoints.empty();
}