ShapeFix package

Dear all,

I set up an application which imports IGES files. When I check the shapes imported (faces) from a sample file, most of them are invalid. The only valid ones are those representing planar or spherical faces. This IGES file seems to be of poor quality, so some healing could probably help. I tried to figure out how the ShapeFix package works but couldn't find any documentation on it. Also browsing the source didn't help me much as I don't know in which sequence the methods have to be invoked and what parameters should be chosen. Could anybody help me, please?

Thomas Haller

Douglas McCarthy's picture

Dear Thomas,

Do you mean ShapeFixStd?

If so, I can help you ... especially if you give me some more details on your problem.

Best regards,

Douglas

Thomas Haller's picture

Dear Douglas,

Thank you for the quick response. Yes, I mean ShapeFixStd. When reading an IGES file the BRepCheck_Analyzer finds invalid shapes. As I found no way to do some healing during the transfer process, I tried to do it afterwards. Here is a part of the code wrote for reading the IGES file:

... Handle(TColStd_HSequenceOfTransient) list = reader.GiveList("iges-faces"); Standard_Integer nbtrans = reader.TransferList(list);

if (reader.IsDone()) {

Standard_Integer nbr = reader.NbShapes();

for (int i=1;i<=nbr;i++) {

aShape = reader.Shape(i);

BRepCheck_Analyzer aChecker(aShape);

if (aChecker.IsValid(aShape)) {

aSequence->Append(aShape);

} else {

ShapeFixStd_Shape sfs(aShape);

sfs.Init(aShape); // ???

sfs.SetPrecision(prec); // ???

sfs.SetMinTolerance(mintol); // ???

sfs.SetMaxTolerance(maxtol); // ???

if (sfs.Perform()) { // ???

BRepCheck_Analyzer anotherChecker(sfs.Shape());

if (anotherChecker.IsValid(sfs.Shape()))

aSequence->Append(sfs.Shape());

}

}

} }

The second check says that the shape is still invalid, so I obviously did something wrong. I have no idea which values are recommended for prec, mintol, and maxtol in the methods:

sfs.SetPrecision(prec);

sfs.SetMinTolerance(mintol);

sfs.SetMaxTolerance(maxtol);

As I know that all of the shapes are faces, is it better to directly use ShapeFixStd_Face?

Thank you very much in advance for your help. Best regards,

Thomas

Andrey Betenev's picture

Dear Thomas,

Generally, to use fixing capabilities ShapeFixStd package, you can simply use class ShapeFixStd_Shape in the following manner:

TopoDS_Shape origShape = ....;

ShapeFixStd_Shape sfs ( origShape);

sfs.SetPrecision ( ...); sfs.SetMaxTolerance(...);

... // set parameters for particular fixes

sfs.Perform();

TopoDS_Shape resShape = sfs.Shape();

The Perform() method does all the fixes in such an order which should give the best result. It uses other classes ShapeFixStd_Soldi, _Shell, _Face, _Wire etc. Each of these classes providess a set of fixes on corresponding type of shape. By defaults, most of these fixes are invoked when you call ShapeFixStd_Shape::Perform(). However, you can force or deny call to each of these methods by setting corresponding mode, for example:

sfs.FixWireTool()->FixDegeneratedMode() = Standard_False; // to deny fixing degenerated edges

Actually, ShapeFixStd is automatically applied to the shape at the end of IGES translation. But surely you can call ShapeFixStd after translation with different parameters, to get better result.

Please note that not all possible errors can be fixed by ShapeFixStd in OpenCASCADE. So, if you give more info on the kind of errors you have, I can tell you whether these errors can be fixed by ShapeFixStd or not.

Best Regards, Andrey

Martine Langlois's picture

Only direct mapping of entities is available with interfaces in Open CASCADE. Shape healing is not part of open CASCADE. It is included into the advanced data exchange which is still a commercial product. Please consult the www.opencascade.com web site to find all the information about Advanced Data Exchange.

Martine