Hi Dave,

Good to hear your making progress.
We've noticed that the .Delete method  does absolutely nothing in some cases.
What happens if you call .Destroy  rather than .Delete ?

Currently we're working on overloading __del__ such that this type of
thing can be done in slightly more pythonic syntax.

Cheers,

-jelle

On Wed, May 13, 2009 at 3:52 AM, Dave Cowden <dave.cow...@gmail.com> wrote:
> Hello, everyone!
>
> I have a slicing program up and running!
>
> Unfortunately, when I try to do large numbers of slices or larger objects,
> my memory usage continually rises.
>
> Initially I had visions of keeping a copy of the faces created by the slices
> for better visualization, but re-worked my code to collapse everything (
> optionally ) into simple strings so I can free the OCC objects.
>
> But alas, I cannot figure out how to release the memory.
>
> Here is my code.  My slicing approach is different than the slicer you guys
> implemented-- I am using BRepAlgoAPI_Cut so that my result is a face with
> the edges and wires organized.  BRepAlgo_Section is faster, but then I dont
> have a face, and I was unable to figure out how to use
> ShapeAnalysis:WireOrder to get the wires organized.
>
> _anyway_  here is my slice code. the code in the #free memory section doesnt
> seem to have had any effect.
>
> Does anyone know how I should be freeing memory for the occ objects?
>
> thanks in advance, code follows
>
> dave
>
>
>  def _makeSlice(self,shapeToSlice,zLevel,curveTolerance=0.001):
>   s = Slice();
>
>   #change if layers are variable thickness
>   s.sliceHeight = self.sliceHeight;
>   s.zLevel = zLevel;
>   #make a cutting plane
>   p = gp.gp_Pnt ( 0,0,zLevel );
>
>   origin = gp.gp_Pnt(0,0,zLevel-1);
>   csys = gp.gp_Ax3(p,gp.gp().DZ())
>   cuttingPlane = gp.gp_Pln(csys);
>   bff = BRepBuilderAPI.BRepBuilderAPI_MakeFace(cuttingPlane);
>   face = bff.Face();
>
>   #odd, a halfspace is faster than a box?
>   hs = BRepPrimAPI.BRepPrimAPI_MakeHalfSpace(face,origin);
>   hs.Build();
>   halfspace = hs.Solid();
>
>   #bounds = getBoundingBox(shapeToSlice);
>   #c1 = gp.gp_Pnt( bounds[0], bounds[1],bounds[2]  ); #lower left corner
>   #c2 = gp.gp_Pnt( bounds[3], bounds[4], zLevel ); #upper right corner
>   #bs = BRepPrimAPI.BRepPrimAPI_MakeBox(c1,c2);
>   #bs.Build();
>   #halfspace = bs.Solid();
>
>   #make the cut
>   bc = BRepAlgoAPI.BRepAlgoAPI_Cut(shapeToSlice,halfspace);
>   bc.Build();
>   cutShape = bc.Shape();
>   #search the shape for faces at the specified zlevel
>   texp = TopExp.TopExp_Explorer();
>   texp.Init(cutShape,TopAbs.TopAbs_FACE);
>   foundFace = False;
>   while ( texp.More() ):
>    face = ts.Face(texp.Current());
>    #logging.debug("Checking Face for zLevel " + str(zLevel));
>    if isAtZLevel(zLevel,face):
>     foundFace = True;
>     logging.debug( "Face is at zlevel" + str(zLevel) );
>     s.addFace(face);
>    texp.Next();
>
>   #free memory
>   hs.Delete();
>   halfspace.Nullify();
>   cutShape.Nullify();
>   bc.Delete();
>   texp.Destroy();
>
>   if not foundFace:
>    logging.warn("No faces found after slicing at zLevel " + str(zLevel) + "
> !. Skipping This layer completely");
>    return None;
>   else:
>    return s;
>
> _______________________________________________
> Pythonocc-users mailing list
> Pythonocc-users@gna.org
> https://mail.gna.org/listinfo/pythonocc-users
>
>

_______________________________________________
Pythonocc-users mailing list
Pythonocc-users@gna.org
https://mail.gna.org/listinfo/pythonocc-users

Reply via email to