2010/4/18 Dave Cowden <[email protected]>
> Hi, all:
>
> I'm struggling with a couple of problems that I presume to be null pointers
> that are crashing OCC. I have a feeling this may be related to memory
> management.
>
> For example, I've tracked down one crash to one line:
> BRepBuilderAPI_MakeOffset.Perform(). I load it with several wires, each of
> which I can display successfully immediately before invoking perform. Yet,
> Perform() crashes. See example below. I do not believe any object scoping
> issues are at play that I can see: all of the objects in question seem to be
> in scope when the crash happens.
>
> I am also fairly certain that its something I'm doing: all of the 'simple'
> test cases I create work fine.
>
> So my question is: are there any tricks/techniques I can use to isolate the
> problem when a crash occurs? Right now i'm using old school print
> statements to get to what method call dies, but I still cannot see what
> exactly is going wrong. Help is appreciated, this is completely kicking my
> butt :(
>
>
> #offset a face, returning the offset shape
> def _offsetFace(self,face,offset ):
> brt = BRepTools.BRepTools();
> ow = brt.OuterWire(face);
> bo = BRepOffsetAPI.BRepOffsetAPI_MakeOffset();
>
> bo.AddWire(ow);
>
> #now get the other wires
> te = TopExp.TopExp_Explorer();
> te.Init(face,TopAbs.TopAbs_WIRE);
> while te.More():
> w = ts.Wire(te.Current());
> TestDisplay.display.showShape(w); # this line succesfully shows the wires
> on screen
> if not w.IsSame(ow):
> bo.AddWire(w);
> te.Next();
> te.ReInit();
> print "about to offset...";
>
> bo.Perform(offset,0.00001); #this line crashes hard, but only sometimes.
> print "done offsetting..";
>
> if not bo.IsDone():
> raise Exception, "Offset Was Not Successful.";
> else:
> return bo.Shape();
>
>
Hi Dave,
If you want to traverse topology, I suggest you use the Topo class available
from the High-Level Topology subpackage (the 'Topo' name for this class is
maybe not the best one). This is a wrapper over the TopExp class which fixes
issues related to TopExp (with the use of the __hash__ method):
from OCC.Utils.Topology import Topo
#offset a face, returning the offset shape
def _offsetFace(self,face,offset ):
brt = BRepTools.BRepTools();
ow = brt.OuterWire(face);
bo = BRepOffsetAPI.BRepOffsetAPI_MakeOffset();
bo.AddWire(ow);
#now get the other wires
for w in Topo(face).wires():
bo.AddWire(w);
print "about to offset...";
bo.Perform(offset,0.00001);
print "done offsetting..";
if not bo.IsDone():
raise Exception, "Offset Was Not Successful.";
else:
return bo.Shape();
Hope this helps,
Regards,
Thomas
_______________________________________________
Pythonocc-users mailing list
[email protected]
https://mail.gna.org/listinfo/pythonocc-users