Bug 0019943: Pb with projection 2d. Fix for a seam edge on not really closed face.

This commit is contained in:
jfa 2008-07-25 10:32:18 +00:00
parent 08ba46c116
commit 4b33363430
2 changed files with 101 additions and 32 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,11 +170,29 @@ 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() );
if ( BRep_Tool::IsClosed( edge, face )) { bool isClosed = BRep_Tool::IsClosed( edge, face );
// BEGIN: jfa for bug 0019943
if (isClosed) {
MESSAGE("$$$ CLOSED 1 $$$")
isClosed = false;
for (TopExp_Explorer expw (face, TopAbs_WIRE); expw.More() && !isClosed; expw.Next()) {
const TopoDS_Wire& wire = TopoDS::Wire(expw.Current());
int nbe = 0;
for (BRepTools_WireExplorer we (wire, face); we.More() && !isClosed; we.Next()) {
if (we.Current().IsSame(edge)) {
nbe++;
if (nbe == 2) isClosed = true;
}
}
}
}
// END: jfa for bug 0019943
if (isClosed) {
MESSAGE("$$$ CLOSED 2 $$$")
// initialize myPar1, myPar2 and myParIndex // initialize myPar1, myPar2 and myParIndex
if ( mySeamShapeIds.empty() ) { if ( mySeamShapeIds.empty() ) {
gp_Pnt2d uv1, uv2; gp_Pnt2d uv1, uv2;

View File

@ -634,7 +634,23 @@ 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 ) ) bool isClosed1 = BRep_Tool::IsClosed( *elIt, theFace );
// 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 )); myShapeIDMap.Add( TopExp::LastVertex( *elIt, true ));
SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( *elIt ); SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( *elIt );
if ( eSubMesh ) if ( eSubMesh )
@ -2060,7 +2076,6 @@ bool SMESH_Pattern::
} }
} }
return true; return true;
} }
@ -2354,7 +2369,23 @@ 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 );
// 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 )); myShapeIDMap.Add( TopExp::LastVertex( *elIt, true ));
} }
int nbVertices = myShapeIDMap.Extent(); int nbVertices = myShapeIDMap.Extent();
@ -4549,10 +4580,29 @@ bool SMESH_Pattern::setShapeToMesh(const TopoDS_Shape& theShape)
if ( myIs2D ) { if ( myIs2D ) {
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());
bool isClosed1 = BRep_Tool::IsClosed(ee, face);
// BEGIN: jfa for bug 0019943
if (isClosed1) {
isClosed1 = false;
for (TopExp_Explorer expw (face, TopAbs_WIRE); expw.More() && !isClosed1; expw.Next()) {
const TopoDS_Wire& wire = TopoDS::Wire(expw.Current());
int nbe = 0;
for (BRepTools_WireExplorer we (wire, face); we.More() && !isClosed1; we.Next()) {
if (we.Current().IsSame(ee)) {
nbe++;
if (nbe == 2) isClosed1 = true;
}
}
}
}
// END: jfa for bug 0019943
if (isClosed1) {
nbNodeOnSeamEdge = 2; nbNodeOnSeamEdge = 2;
} }
}
}
// check nb of vertices // check nb of vertices
TopTools_IndexedMapOfShape vMap; TopTools_IndexedMapOfShape vMap;