
Mon, 10/12/2009 - 18:20
Hello.
After importing some IGES files and connecting included shapes, I get sometimes edgeTriangulation.isNull() on some or all edges.
Does anyone knows why ?
Thank you for help.
Jean-Yves
This an abstract of my code :
I first import IGES file:
-------------------------
IGESControl_Reader reader;
Standard_Integer readStatus = reader.ReadFile(filename);
switch (readStatus)
{
case IFSelect_RetVoid:
throw WException("Load IGES empty.");
case IFSelect_RetError:
throw WException("Load IGES error.");
case IFSelect_RetFail:
throw WException("Load IGES fail.");
case IFSelect_RetStop:
throw WException("Load IGES stop.");
default:
case IFSelect_RetDone:
// Load IGES readStatus=IFSelect_RetDone"
break;
}
// Tranlate IGES -> OCC.
reader.TransferRoots();
TopoDS_Shape initialShape = reader.OneShape();
Then, I sew the shape:
----------------------
if (sewing)
{
BRepOffsetAPI_Sewing sewedObj(sewingDistance);
sewedObj.Add(initialShape);
sewedObj.Perform();
if (!sewedObj.SewedShape().IsNull())
shape = sewedObj.SewedShape();
else
shape = initialShape;
}
else
shape = initialShape;
Then, I triangulate:
--------------------
BRepTools::Clean(shape);
BRepMesh_FastDiscret *TheDiscret = new BRepMesh_FastDiscret(
deflection, //const Standard_Real defle,
shape, //const TopoDS_Shape &shape,
bbox, //const Bnd_Box &B,
angle, //const Standard_Real angle,
Standard_True, //const Standard_Boolean withShare,
Standard_True, //const Standard_Boolean inshape,
Standard_False, //const Standard_Boolean relative,
Standard_False //const Standard_Boolean shapetrigu
);
for (exp02.Init(aShape, TopAbs_FACE); exp02.More(); exp02.Next())
{
TopoDS_Face face = TopoDS::Face(exp02.Current());
if (!faceTriangulation.IsNull())
{
TopExp_Explorer exp03;
for (exp03.Init(face, TopAbs_EDGE); exp03.More(); exp03.Next())
{
TopoDS_Edge edge = TopoDS::Edge(exp03.Current().Composed(face.Orientation()));
// Edge triangulation
Handle_Poly_PolygonOnTriangulation edgeTriangulation = BRep_Tool::PolygonOnTriangulation(edge, faceTriangulation, edge.Location());
if (edgeTriangulation.IsNull())
cout
}
}
}
Tue, 10/13/2009 - 11:02
Hi Jean-Yves,
does the problem also occur without sewing?
Some models are simply either corrupt, misinterpreted (especially IGES) or not translated properly.
You could try ShapeFix after importing.
Pawel
Fri, 10/16/2009 - 13:18
Dear Pawel.
The problem does not occur without sewing.
Yes the problem is cause by corrupted IGES file.
I open also the file in CAD software and try to sew. The software
is warning about topological error on somme edges.
I add ShapeFix which improve the results (but remain some edge error).
May be do I have to change the healing precision or more
fixing processing ?
This the code I had. After it, I try a second sewing:
// ------------------
// Fixing the shell.
// -----------------
// Creates tools for fixing a shell.
Handle(ShapeFix_Shell) SFS = new ShapeFix_Shell;
// Initialize the fixing tool by the shell.
TopoDS_Shell shell = TopoDS::Shell(shape);
SFS->Init(shell);
// Fixing the set shell.
SFS->Perform();
// Getting the result.
TopoDS_Shape aResult = SFS->Shape();
shape = aResult;
// ------------------
// Fixing wireframes.
// ------------------
Handle(ShapeFix_Wireframe) SFWF = new ShapeFix_Wireframe(shape);
// Set mode for removing small edges.
SFWF->FixSmallEdges();
SFWF->FixWireGaps();
aResult = SFWF->Shape();
Sun, 11/01/2009 - 13:27
Hi Jean,
I have also suffered by the stitching problem for a log time. The stitching will introduce face topology error. The stitching algorithm heavily rely on the tolerance on each vertex and edge. And I think it's too later to use ShapeFix_* to fix errors after stitching.
-Ding