Fri, 05/31/2002 - 14:59
Hi
I'm using OCC 4.0 and I want to use shape healing to fix bad shapes.
I used samples provided in Shape healing user's guide to fix edges, wires, etc...
This is a part of the code that fixes Curves3D and edges order in wires (to illustrate my questions).
while (ShapeExplorer.More())
{
CurrentFaceShape = ShapeExplorer.Current();
Face = TopoDS::Face(CurrentFaceShape);
FaceExplorer.Init(CurrentFaceShape, TopAbs_EDGE);
while(FaceExplorer.More())
{
ShapeFix_Edge FixEdge;
Edge = TopoDS::Edge(FaceExplorer.Current());
if(!EdgeAnalysis.HasCurve3d(Edge))
FixEdge.FixAddCurve3d(Edge);
FaceExplorer.Next();
}
WireExplorer.Init(CurrentFaceShape, TopAbs_WIRE);
while(WireExplorer.More())
{
Wire = TopoDS::Wire(WireExplorer.Current());
ShapeFix_Wire WireFix(Wire, Face, Precision);
ShapeAnalysis_Wire WireAnalysis(Wire, Face, Precision);
if(WireAnalysis.CheckOrder())
WireFix.FixReorder();
Wire = WireFix.Wire();
WireExplorer.Next();
}
ShapeExplorer.Next();
}
At the end "Edge" contains my fixed edge, and "Wire" my fixed wires.
My questions :
1 - Is it possible to replace the bad edges and wires in the original shape with the fixed ones using a simple function (didn't find such functions in help :-( )? or do I have to reconstruct a shape using BRepBuilder in a Compound, face by face ?
2 - If I have to rebuild a Fixed shape using BRepBuilder face by face, how can I Make a clean and fixed face from :
- My Old Face (from TopExplorer)
- My new edges
- My new wires
to add if to my fixed shape ?
Thanks in advance,
Eric
Fri, 05/31/2002 - 15:21
Hi,
I'm using the following:
void Fix3DElem(TopoDS_Shape &ShapeToFix)
{
ShapeFix_Shape FixShape;
FixShape.Init(ShapeToFix);
FixShape.Perform();
ShapeToFix = FixShape.Shape();
}
Works good for me - just insert the whole shape - it just uses ShapeFixWire ...
Best regards,
Patrik Müller
Fri, 05/31/2002 - 15:26
Thanks for your quick answer !
Is ShapeFix_Shape::Perform() equivalent to WireFix and EdgeFix functions called one after the others ?
Does it include Chack and fix for FreeBounds ?
thanks again,
Eric
Fri, 05/31/2002 - 15:46
Just tried your piece of code . Almost all the time, Using ShapeFix_Shape, I got bad ordered wires after fix (not present before) ! (check done with ShapeAnalysis_Wire::CheckOrder())
Problems detected by ShapeAnalysis_Edge::HasCurves3d() seem to stay uncorrected (Is it really a problem to have missing Curves3d ? )
same for FreeBounds...
Should I use ShapeFix_Shape::Perform() on each face independantly, instead on the global shape ?
Regards,
Eric
Fri, 05/31/2002 - 16:40
Hi,
Have a look at ShapeBuild_ReShape class and ShapeFix_XXX::SetContext() method:
TopoDS_Shape aShape = AnyBadShape ...;
Handle(ShapeBuild_ReShape) theReShape = new ShapeBuild_ReShape();
ShapeUpgrade_ShapeDivideAngle aShapeUpgrade(90*PI/180.,aShape);
//set parameters ....
aShapeUpgrade.SetPrecision (0.001);
aShapeUpgrade.SetMaxTolerance(1.);
aShapeUpgrade.SetContext(theReShape);
if (aShapeUpgrade.Perform (Standard_False))
aShape = theReShape->Apply(aShape);
Math