0021231: EDF 1838 SMESH: Pattern mapping on a quadratic element

fix loading pattern from a quadratic mesh
This commit is contained in:
eap 2011-04-22 11:54:06 +00:00
parent 6bd826a5f5
commit 8aec90a5df
2 changed files with 51 additions and 19 deletions

View File

@ -515,6 +515,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
SMESHDS_Mesh * aMeshDS = theMesh->GetMeshDS(); SMESHDS_Mesh * aMeshDS = theMesh->GetMeshDS();
SMESHDS_SubMesh * fSubMesh = aMeshDS->MeshElements( theFace ); SMESHDS_SubMesh * fSubMesh = aMeshDS->MeshElements( theFace );
const bool isQuadMesh = aMeshDS->GetMeshInfo().NbFaces( ORDER_QUADRATIC );
SMESH_MesherHelper helper( *theMesh ); SMESH_MesherHelper helper( *theMesh );
helper.SetSubShape( theFace ); helper.SetSubShape( theFace );
@ -583,15 +584,15 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
{ {
myElemPointIDs.push_back( TElemDef() ); myElemPointIDs.push_back( TElemDef() );
TElemDef& elemPoints = myElemPointIDs.back(); TElemDef& elemPoints = myElemPointIDs.back();
SMDS_ElemIteratorPtr nIt = (*fIt)->nodesIterator(); int nbNodes = (*fIt)->NbCornerNodes();
while ( nIt->more() ) for ( int i = 0;i < nbNodes; ++i )
{ {
const SMDS_MeshElement* node = nIt->next(); const SMDS_MeshElement* node = (*fIt)->GetNode( i );
TNodePointIDMap::iterator nIdIt = nodePointIDMap.find( node ); TNodePointIDMap::iterator nIdIt = nodePointIDMap.insert( make_pair( node, -1 )).first;
if ( nIdIt == nodePointIDMap.end() ) if ( nIdIt->second == -1 )
{ {
elemPoints.push_back( iPoint ); elemPoints.push_back( iPoint );
nodePointIDMap.insert( make_pair( node, iPoint++ )); nIdIt->second = iPoint++;
} }
else else
elemPoints.push_back( (*nIdIt).second ); elemPoints.push_back( (*nIdIt).second );
@ -735,10 +736,15 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
// loop on nodes of an edge: sort them by param on edge // loop on nodes of an edge: sort them by param on edge
typedef map < double, const SMDS_MeshNode* > TParamNodeMap; typedef map < double, const SMDS_MeshNode* > TParamNodeMap;
TParamNodeMap paramNodeMap; TParamNodeMap paramNodeMap;
int nbMeduimNodes = 0;
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes(); SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
while ( nIt->more() ) while ( nIt->more() )
{ {
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = nIt->next();
if ( isQuadMesh && helper.IsMedium( node, SMDSAbs_Face )) {
++nbMeduimNodes;
continue;
}
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition()); static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = epos->GetUParameter(); double u = epos->GetUParameter();
@ -752,7 +758,9 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
paramNodeMap.clear(); paramNodeMap.clear();
nIt = eSubMesh->GetNodes(); nIt = eSubMesh->GetNodes();
for ( int iNode = 0; nIt->more(); ++iNode ) { for ( int iNode = 0; nIt->more(); ++iNode ) {
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = nIt->next();
if ( isQuadMesh && helper.IsMedium( node, SMDSAbs_Face ))
continue;
proj.Perform( gp_Pnt( node->X(), node->Y(), node->Z())); proj.Perform( gp_Pnt( node->X(), node->Y(), node->Z()));
double u = 0; double u = 0;
if ( proj.IsDone() ) { if ( proj.IsDone() ) {
@ -768,9 +776,9 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
} }
//rnv : To fix the bug IPAL21999 Pattern Mapping - New - collapse of pattern mesh //rnv : To fix the bug IPAL21999 Pattern Mapping - New - collapse of pattern mesh
if ( paramNodeMap.size() != eSubMesh->NbNodes() ) if ( paramNodeMap.size() != eSubMesh->NbNodes() - nbMeduimNodes )
return setErrorCode(ERR_UNEXPECTED); return setErrorCode(ERR_UNEXPECTED);
} }
// put U in [0,1] so that the first key-point has U==0 // put U in [0,1] so that the first key-point has U==0
bool isSeam = helper.IsRealSeam( edge ); bool isSeam = helper.IsRealSeam( edge );
@ -854,7 +862,9 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes(); SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes();
while ( nIt->more() ) while ( nIt->more() )
{ {
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = nIt->next();
if ( isQuadMesh && helper.IsMedium( node, SMDSAbs_Face ))
continue;
nodePointIDMap.insert( make_pair( node, iPoint )); nodePointIDMap.insert( make_pair( node, iPoint ));
TPoint* p = &myPoints[ iPoint++ ]; TPoint* p = &myPoints[ iPoint++ ];
fPoints.push_back( p ); fPoints.push_back( p );
@ -880,7 +890,10 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
while ( nIt->more() ) while ( nIt->more() )
{ {
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = smdsNode( nIt->next() );
iPoint = nodePointIDMap[ node ]; // point index of interest n_id = nodePointIDMap.find( node );
if ( n_id == nodePointIDMap.end() )
continue; // medium node
iPoint = n_id->second; // point index of interest
// for a node on a seam edge there are two points // for a node on a seam edge there are two points
if ( helper.IsRealSeam( node->getshapeId() ) && if ( helper.IsRealSeam( node->getshapeId() ) &&
( n_id = closeNodePointIDMap.find( node )) != not_found ) ( n_id = closeNodePointIDMap.find( node )) != not_found )
@ -906,6 +919,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
} }
} }
} }
myPoints.resize( nodePointIDMap.size() + closeNodePointIDMap.size() );
myIsBoundaryPointsFound = true; myIsBoundaryPointsFound = true;
} }
@ -3152,6 +3166,8 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
myIs2D = false; myIs2D = false;
SMESHDS_SubMesh * aSubMesh; SMESHDS_SubMesh * aSubMesh;
const bool isQuadMesh = theMesh->NbVolumes( ORDER_QUADRATIC );
// load shapes in myShapeIDMap // load shapes in myShapeIDMap
SMESH_Block block; SMESH_Block block;
TopoDS_Vertex v1, v2; TopoDS_Vertex v1, v2;
@ -3184,6 +3200,8 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
// store a node and a point // store a node and a point
while ( nIt->more() ) { while ( nIt->more() ) {
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = smdsNode( nIt->next() );
if ( isQuadMesh && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Volume ))
continue;
nodePointIDMap.insert( make_pair( node, iPoint )); nodePointIDMap.insert( make_pair( node, iPoint ));
if ( block.IsVertexID( shapeID )) if ( block.IsVertexID( shapeID ))
myKeyPointIDs.push_back( iPoint ); myKeyPointIDs.push_back( iPoint );
@ -3218,7 +3236,9 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
nIt = aSubMesh->GetNodes(); nIt = aSubMesh->GetNodes();
for ( ; nIt->more(); pIt++ ) for ( ; nIt->more(); pIt++ )
{ {
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = nIt->next();
if ( isQuadMesh && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge ))
continue;
const SMDS_EdgePosition* epos = const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition()); static_cast<const SMDS_EdgePosition*>(node->GetPosition());
double u = ( epos->GetUParameter() - f ) / ( l - f ); double u = ( epos->GetUParameter() - f ) / ( l - f );
@ -3244,11 +3264,12 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
{ {
SMDS_ElemIteratorPtr elemIt = aSubMesh->GetElements(); SMDS_ElemIteratorPtr elemIt = aSubMesh->GetElements();
while ( elemIt->more() ) { while ( elemIt->more() ) {
SMDS_ElemIteratorPtr nIt = elemIt->next()->nodesIterator(); const SMDS_MeshElement* elem = elemIt->next();
myElemPointIDs.push_back( TElemDef() ); myElemPointIDs.push_back( TElemDef() );
TElemDef& elemPoints = myElemPointIDs.back(); TElemDef& elemPoints = myElemPointIDs.back();
while ( nIt->more() ) int nbNodes = elem->NbCornerNodes();
elemPoints.push_back( nodePointIDMap[ nIt->next() ]); for ( int i = 0;i < nbNodes; ++i )
elemPoints.push_back( nodePointIDMap[ elem->GetNode( i )]);
} }
} }
@ -4567,6 +4588,18 @@ void SMESH_Pattern::Clear()
myReverseConnectivity.clear(); myReverseConnectivity.clear();
} }
//================================================================================
/*!
* \brief set ErrorCode and return true if it is Ok
*/
//================================================================================
bool SMESH_Pattern::setErrorCode( const ErrorCode theErrorCode )
{
myErrorCode = theErrorCode;
return myErrorCode == ERR_OK;
}
//======================================================================= //=======================================================================
//function : setShapeToMesh //function : setShapeToMesh
//purpose : set a shape to be meshed. Return True if meshing is possible //purpose : set a shape to be meshed. Return True if meshing is possible

View File

@ -244,8 +244,7 @@ private:
}; };
friend std::ostream & operator <<(std::ostream & OS, const TPoint& p); friend std::ostream & operator <<(std::ostream & OS, const TPoint& p);
bool setErrorCode( const ErrorCode theErrorCode ) bool setErrorCode( const ErrorCode theErrorCode );
{ myErrorCode = theErrorCode; return myErrorCode == ERR_OK; }
// set ErrorCode and return true if it is Ok // set ErrorCode and return true if it is Ok
bool setShapeToMesh(const TopoDS_Shape& theShape); bool setShapeToMesh(const TopoDS_Shape& theShape);