merge from V4_1_0_maintainance branch (from tag mergeto_BR_QT4_Dev_29Jul08)

This commit is contained in:
vsr 2008-07-29 14:08:56 +00:00
parent ddd20dd943
commit 8ce2153da0
5 changed files with 108 additions and 67 deletions

View File

@ -32,6 +32,7 @@
#include <BRepAdaptor_Surface.hxx> #include <BRepAdaptor_Surface.hxx>
#include <BRepTools.hxx> #include <BRepTools.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <Geom2d_Curve.hxx> #include <Geom2d_Curve.hxx>
#include <Geom_Curve.hxx> #include <Geom_Curve.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
@ -169,7 +170,7 @@ void SMESH_MesherHelper::SetSubShape(const TopoDS_Shape& aSh)
BRepAdaptor_Surface surface( face ); BRepAdaptor_Surface surface( face );
if ( surface.IsUPeriodic() || surface.IsVPeriodic() ) if ( surface.IsUPeriodic() || surface.IsVPeriodic() )
{ {
for ( TopExp_Explorer exp( face, TopAbs_EDGE ); exp.More(); exp.Next()) for (TopExp_Explorer exp( face, TopAbs_EDGE ); exp.More(); exp.Next())
{ {
// look for a seam edge // look for a seam edge
const TopoDS_Edge& edge = TopoDS::Edge( exp.Current() ); const TopoDS_Edge& edge = TopoDS::Edge( exp.Current() );
@ -190,10 +191,13 @@ void SMESH_MesherHelper::SetSubShape(const TopoDS_Shape& aSh)
myPar2 = surface.LastVParameter(); myPar2 = surface.LastVParameter();
} }
} }
// store shapes indices // store seam shape indices, negative if shape encounters twice
mySeamShapeIds.insert( meshDS->ShapeToIndex( edge )); int edgeID = meshDS->ShapeToIndex( edge );
for ( TopExp_Explorer v( edge, TopAbs_VERTEX ); v.More(); v.Next() ) mySeamShapeIds.insert( IsSeamShape( edgeID ) ? -edgeID : edgeID );
mySeamShapeIds.insert( meshDS->ShapeToIndex( v.Current() )); for ( TopExp_Explorer v( edge, TopAbs_VERTEX ); v.More(); v.Next() ) {
int vertexID = meshDS->ShapeToIndex( v.Current() );
mySeamShapeIds.insert( IsSeamShape( vertexID ) ? -vertexID : vertexID );
}
} }
// look for a degenerated edge // look for a degenerated edge
@ -318,7 +322,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F,
Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l);
uv = C2d->Value( epos->GetUParameter() ); uv = C2d->Value( epos->GetUParameter() );
// for a node on a seam edge select one of UVs on 2 pcurves // for a node on a seam edge select one of UVs on 2 pcurves
if ( n2 && mySeamShapeIds.find( edgeID ) != mySeamShapeIds.end() ) if ( n2 && IsSeamShape( edgeID ) )
uv = GetUVOnSeam( uv, GetNodeUV( F, n2, 0 )); uv = GetUVOnSeam( uv, GetNodeUV( F, n2, 0 ));
} }
else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX) else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX)
@ -370,7 +374,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F,
} }
} }
} }
if ( n2 && mySeamShapeIds.find( vertexID ) != mySeamShapeIds.end() ) if ( n2 && IsSeamShape( vertexID ) )
uv = GetUVOnSeam( uv, GetNodeUV( F, n2, 0 )); uv = GetUVOnSeam( uv, GetNodeUV( F, n2, 0 ));
} }
} }

View File

@ -258,7 +258,8 @@ public:
* \param subShape - edge or vertex index in SMESHDS * \param subShape - edge or vertex index in SMESHDS
* \retval bool - true if subShape is a seam shape * \retval bool - true if subShape is a seam shape
* *
* It works only if IsQuadraticSubMesh() or SetSubShape() has been called * It works only if IsQuadraticSubMesh() or SetSubShape() has been called.
* Seam shape has two 2D alternative represenations on the face
*/ */
bool IsSeamShape(const int subShape) const bool IsSeamShape(const int subShape) const
{ return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); } { return mySeamShapeIds.find( subShape ) != mySeamShapeIds.end(); }
@ -267,10 +268,23 @@ public:
* \param subShape - edge or vertex * \param subShape - edge or vertex
* \retval bool - true if subShape is a seam shape * \retval bool - true if subShape is a seam shape
* *
* It works only if IsQuadraticSubMesh() or SetSubShape() has been called * It works only if IsQuadraticSubMesh() or SetSubShape() has been called.
* Seam shape has two 2D alternative represenations on the face
*/ */
bool IsSeamShape(const TopoDS_Shape& subShape) const bool IsSeamShape(const TopoDS_Shape& subShape) const
{ return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); } { return IsSeamShape( GetMeshDS()->ShapeToIndex( subShape )); }
/*!
* \brief Return true if an edge or a vertex encounters twice in face wire
* \param subShape - Id of edge or vertex
*/
bool IsRealSeam(const int subShape) const
{ return mySeamShapeIds.find( -subShape ) != mySeamShapeIds.end(); }
/*!
* \brief Return true if an edge or a vertex encounters twice in face wire
* \param subShape - edge or vertex
*/
bool IsRealSeam(const TopoDS_Shape& subShape) const
{ return IsRealSeam( GetMeshDS()->ShapeToIndex( subShape)); }
/*! /*!
* \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape() * \brief Check if the shape set through IsQuadraticSubMesh() or SetSubShape()
* has a seam edge * has a seam edge

View File

@ -521,7 +521,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
TopoDS_Face face = TopoDS::Face( theFace.Oriented( TopAbs_FORWARD )); TopoDS_Face face = TopoDS::Face( theFace.Oriented( TopAbs_FORWARD ));
// check that face is not closed // check if face is closed
bool isClosed = helper.HasSeam(); bool isClosed = helper.HasSeam();
TopoDS_Vertex bidon; TopoDS_Vertex bidon;
list<TopoDS_Edge> eList; list<TopoDS_Edge> eList;
@ -634,10 +634,13 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
// vertices // vertices
for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) { for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) {
myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true )); myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true ));
if ( BRep_Tool::IsClosed( *elIt, theFace ) ) if ( helper.IsSeamShape( *elIt ) ) {
myShapeIDMap.Add( TopExp::LastVertex( *elIt, true )); // vertices present twice in the wire have two corresponding key points
SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( *elIt ); const TopoDS_Vertex& lastV = TopExp::LastVertex( *elIt, true );
if ( eSubMesh ) if ( helper.IsRealSeam( lastV ))
myShapeIDMap.Add( lastV );// vertex orienation is REVERSED
}
if ( SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( *elIt ))
nbNodes += eSubMesh->NbNodes() + 1; nbNodes += eSubMesh->NbNodes() + 1;
} }
// edges // edges
@ -665,15 +668,15 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
v2.Reverse(); v2.Reverse();
// on closed face we must have REVERSED some of seam vertices // on closed face we must have REVERSED some of seam vertices
bool isSeam = helper.IsSeamShape( edge );
if ( isClosed ) { if ( isClosed ) {
if ( isSeam ) { // reverse on reversed SEAM edge if ( helper.IsSeamShape( edge ) ) {
if ( !isForward ) { if ( helper.IsRealSeam( edge ) && !isForward ) {
// reverse on reversed SEAM edge
v1.Reverse(); v1.Reverse();
v2.Reverse(); v2.Reverse();
} }
} }
else { // on CLOSED edge else { // on CLOSED edge (i.e. having one vertex with different orienations)
for ( int is2 = 0; is2 < 2; ++is2 ) { for ( int is2 = 0; is2 < 2; ++is2 ) {
TopoDS_Shape & v = is2 ? v2 : v1; TopoDS_Shape & v = is2 ? v2 : v1;
if ( helper.IsSeamShape( v ) ) { if ( helper.IsSeamShape( v ) ) {
@ -757,6 +760,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
} }
} }
// 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 );
double du = l - f; double du = l - f;
TParamNodeMap::iterator unIt = paramNodeMap.begin(); TParamNodeMap::iterator unIt = paramNodeMap.begin();
TParamNodeMap::reverse_iterator unRIt = paramNodeMap.rbegin(); TParamNodeMap::reverse_iterator unRIt = paramNodeMap.rbegin();
@ -851,6 +855,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 ); p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 );
} }
// load elements // load elements
TNodePointIDMap::iterator n_id, not_found = closeNodePointIDMap.end();
SMDS_ElemIteratorPtr elemIt = fSubMesh->GetElements(); SMDS_ElemIteratorPtr elemIt = fSubMesh->GetElements();
while ( elemIt->more() ) while ( elemIt->more() )
{ {
@ -864,10 +869,8 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh,
const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_MeshNode* node = smdsNode( nIt->next() );
iPoint = nodePointIDMap[ node ]; // point index of interest iPoint = nodePointIDMap[ node ]; // 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
TNodePointIDMap::iterator n_id = closeNodePointIDMap.end(); if ( helper.IsRealSeam( node->GetPosition()->GetShapeId() ) &&
if ( helper.IsSeamShape( node->GetPosition()->GetShapeId() )) ( n_id = closeNodePointIDMap.find( node )) != not_found )
n_id = closeNodePointIDMap.find( node );
if ( n_id != closeNodePointIDMap.end() )
{ {
TPoint & p1 = myPoints[ iPoint ]; TPoint & p1 = myPoints[ iPoint ];
TPoint & p2 = myPoints[ n_id->second ]; TPoint & p2 = myPoints[ n_id->second ];
@ -2060,7 +2063,6 @@ bool SMESH_Pattern::
} }
} }
return true; return true;
} }
@ -2354,8 +2356,24 @@ bool SMESH_Pattern::Apply (const TopoDS_Face& theFace,
list<TopoDS_Edge>::iterator elIt = eList.begin(); list<TopoDS_Edge>::iterator elIt = eList.begin();
for ( ; elIt != eList.end(); elIt++ ) { for ( ; elIt != eList.end(); elIt++ ) {
myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true )); myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true ));
if ( BRep_Tool::IsClosed( *elIt, theFace ) ) bool isClosed1 = BRep_Tool::IsClosed( *elIt, theFace );
myShapeIDMap.Add( TopExp::LastVertex( *elIt, true )); // BEGIN: jfa for bug 0019943
if (isClosed1) {
isClosed1 = false;
for (TopExp_Explorer expw (theFace, TopAbs_WIRE); expw.More() && !isClosed1; expw.Next()) {
const TopoDS_Wire& wire = TopoDS::Wire(expw.Current());
int nbe = 0;
for (BRepTools_WireExplorer we (wire, theFace); we.More() && !isClosed1; we.Next()) {
if (we.Current().IsSame(*elIt)) {
nbe++;
if (nbe == 2) isClosed1 = true;
}
}
}
}
// END: jfa for bug 0019943
if (isClosed1)
myShapeIDMap.Add( TopExp::LastVertex( *elIt, true ));// vertex orienation is REVERSED
} }
int nbVertices = myShapeIDMap.Extent(); int nbVertices = myShapeIDMap.Extent();
@ -2364,7 +2382,7 @@ bool SMESH_Pattern::Apply (const TopoDS_Face& theFace,
myShapeIDMap.Add( face ); myShapeIDMap.Add( face );
if ( myShapeIDToPointsMap.size() != myShapeIDMap.Extent()/* + nbSeamShapes*/ ) { if ( myShapeIDToPointsMap.size() != myShapeIDMap.Extent() ) {
MESSAGE( myShapeIDToPointsMap.size() <<" != " << myShapeIDMap.Extent()); MESSAGE( myShapeIDToPointsMap.size() <<" != " << myShapeIDMap.Extent());
return setErrorCode( ERR_APPLF_INTERNAL_EEROR ); return setErrorCode( ERR_APPLF_INTERNAL_EEROR );
} }
@ -4547,11 +4565,17 @@ bool SMESH_Pattern::setShapeToMesh(const TopoDS_Shape& theShape)
// check if a face is closed // check if a face is closed
int nbNodeOnSeamEdge = 0; int nbNodeOnSeamEdge = 0;
if ( myIs2D ) { if ( myIs2D ) {
TopTools_MapOfShape seamVertices;
TopoDS_Face face = TopoDS::Face( theShape ); TopoDS_Face face = TopoDS::Face( theShape );
TopExp_Explorer eExp( theShape, TopAbs_EDGE ); TopExp_Explorer eExp( theShape, TopAbs_EDGE );
for ( ; eExp.More() && nbNodeOnSeamEdge == 0; eExp.Next() ) for ( ; eExp.More() && nbNodeOnSeamEdge == 0; eExp.Next() ) {
if ( BRep_Tool::IsClosed( TopoDS::Edge( eExp.Current() ), face )) const TopoDS_Edge& ee = TopoDS::Edge(eExp.Current());
nbNodeOnSeamEdge = 2; if ( BRep_Tool::IsClosed(ee, face) ) {
// seam edge and vertices encounter twice in theFace
if ( !seamVertices.Add( TopExp::FirstVertex( ee ))) nbNodeOnSeamEdge++;
if ( !seamVertices.Add( TopExp::LastVertex( ee ))) nbNodeOnSeamEdge++;
}
}
} }
// check nb of vertices // check nb of vertices

View File

@ -1358,7 +1358,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
} }
if ( nodesOfFaces ) if ( nodesOfFaces )
{ {
if ( BRep_Tool::IsClosed( e2, face2 )) { if ( helper2.IsRealSeam( e2 )) {
seam1 = e1; seam2 = e2; seam1 = e1; seam2 = e2;
} }
else { else {
@ -1430,7 +1430,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
const TopoDS_Face & face = is2 ? face2 : face1; const TopoDS_Face & face = is2 ? face2 : face1;
SMDS_ElemIteratorPtr eIt = sm->GetElements(); SMDS_ElemIteratorPtr eIt = sm->GetElements();
if ( !helper->IsSeamShape( is2 ? edge2 : edge1 )) if ( !helper->IsRealSeam( is2 ? edge2 : edge1 ))
{ {
while ( eIt->more() ) elems.insert( eIt->next() ); while ( eIt->more() ) elems.insert( eIt->next() );
} }
@ -1515,7 +1515,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1,
// On a sphere, add matching nodes on the edge // On a sphere, add matching nodes on the edge
if ( helper1.IsSeamShape( edge1 )) if ( helper1.IsRealSeam( edge1 ))
{ {
// sort nodes on edges by param on edge // sort nodes on edges by param on edge
map< double, const SMDS_MeshNode* > u2nodesMaps[2]; map< double, const SMDS_MeshNode* > u2nodesMaps[2];

View File

@ -295,16 +295,14 @@ namespace {
// Find a new node connected to nV1 and belonging to edge submesh; // Find a new node connected to nV1 and belonging to edge submesh;
const SMDS_MeshNode* nE = 0; const SMDS_MeshNode* nE = 0;
SMESHDS_SubMesh* smDS = sm->GetSubMeshDS(); SMESHDS_SubMesh* smDS = sm->GetSubMeshDS();
SMDS_ElemIteratorPtr vElems = nV1->GetInverseElementIterator(); SMDS_ElemIteratorPtr vElems = nV1->GetInverseElementIterator(SMDSAbs_Face);
while ( vElems->more() && !nE ) { while ( vElems->more() && !nE ) {
const SMDS_MeshElement* elem = vElems->next(); const SMDS_MeshElement* elem = vElems->next();
if ( elem->GetType() != SMDSAbs_Face )
continue; // new nodes are shared by faces
int nbNodes = elem->NbNodes(); int nbNodes = elem->NbNodes();
if ( elem->IsQuadratic() ) if ( elem->IsQuadratic() )
nbNodes /= 2; nbNodes /= 2;
int iV1 = elem->GetNodeIndex( nV1 ); int iV1 = elem->GetNodeIndex( nV1 );
// try next aftre nV1 // try next after nV1
int iE = SMESH_MesherHelper::WrapIndex( iV1 + 1, nbNodes ); int iE = SMESH_MesherHelper::WrapIndex( iV1 + 1, nbNodes );
if ( smDS->Contains( elem->GetNode( iE ) )) if ( smDS->Contains( elem->GetNode( iE ) ))
nE = elem->GetNode( iE ); nE = elem->GetNode( iE );
@ -515,7 +513,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
// Sort new and old nodes of a submesh separately // Sort new and old nodes of a submesh separately
bool isSeam = helper.IsSeamShape( sm->GetId() ); bool isSeam = helper.IsRealSeam( sm->GetId() );
enum { NEW_NODES = 0, OLD_NODES }; enum { NEW_NODES = 0, OLD_NODES };
map< double, const SMDS_MeshNode* > u2nodesMaps[2], u2nodesOnSeam; map< double, const SMDS_MeshNode* > u2nodesMaps[2], u2nodesOnSeam;
@ -537,7 +535,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
continue; // node is already in the map continue; // node is already in the map
} }
// sort nodes on edges by its position // sort nodes on edges by their position
map< double, const SMDS_MeshNode* > & pos2nodes = u2nodesMaps[isOld ? OLD_NODES : NEW_NODES]; map< double, const SMDS_MeshNode* > & pos2nodes = u2nodesMaps[isOld ? OLD_NODES : NEW_NODES];
switch ( node->GetPosition()->GetTypeOfPosition() ) switch ( node->GetPosition()->GetTypeOfPosition() )
{ {
@ -560,10 +558,11 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape&
{ {
if ( u2nodesMaps[ NEW_NODES ].size() == 0 && if ( u2nodesMaps[ NEW_NODES ].size() == 0 &&
sm->GetSubShape().ShapeType() == TopAbs_EDGE && sm->GetSubShape().ShapeType() == TopAbs_EDGE &&
BRep_Tool::Degenerated( TopoDS::Edge( sm->GetSubShape() ))) helper.IsDegenShape( sm->GetId() ) )
// NPAL15894 (tt88bis.py) - project mesh built by NETGEN_1d_2D that // NPAL15894 (tt88bis.py) - project mesh built by NETGEN_1d_2D that
// does not make segments/nodes on degenerated edges // does not make segments/nodes on degenerated edges
continue; continue;
RETURN_BAD_RESULT("Different nb of old and new nodes on shape #"<< sm->GetId() <<" "<< RETURN_BAD_RESULT("Different nb of old and new nodes on shape #"<< sm->GetId() <<" "<<
u2nodesMaps[ OLD_NODES ].size() << " != " << u2nodesMaps[ OLD_NODES ].size() << " != " <<
u2nodesMaps[ NEW_NODES ].size()); u2nodesMaps[ NEW_NODES ].size());