Ah, that makes sense.  I figured that it would be something like that since
the code was not hand-generated.
 
That's _awesome_ that you're working on a visualization layer! 
 
My code is a bit in flux, i'm kind of changing it around as i can to work
towards the classes that are wrapped.  I only get an hour or so a day to
work on this so i keep the code working.  That means that it does not call
any of the classes that are not wrapped.
 
Many of the methods I need next are to:
  (a) be able to replace in the script below STL import vs STEP input and
still get a cross-section ( STL*)
  (b) use BndLib to get the upper and lower bounds so that I can run the
cutting slice in a loop through the whole part
  (c) convert the compound edges I get from the intersection into a wire, so
that I can travers the loops
  (d) offset the section edges to make loops inset from the edges that are
toolpaths
  (d) fill the resulting section with cross-hatching or something like that
 
 
I'm glad to hear you like the feedback!  I was afraid I was bothering you.
Keep up the good work! I'd much rather do my coding in python than in C++.
Last night, I got basically the same code working in C++ so I could link in
the OpenCascade libs directly, but its much more and ugly code-- i would not
like to do the rest of the project that way ...
 
 
Here is the source:

 
from OCC import *
import os
import sys
 


def toInches(val):
 return val / 25.4;
 
def countEdges(shape):
 te = TopExp_Explorer();
 te.Init(shape,TopAbs_EDGE);
 
 edges = {}
 while te.More():
  edge = te.Current();
  edges[edge.HashCode(111333331)] = edge;
  te.Next();
  
 return len(edges);
 
""" 
  Dump an edge as a sequcence of points
"""
def dumpEdge(edge):
 q = GCPnts_QuasiUniformDeflection();
 
"""
 Print the details of an object from the top down
""" 
def dumpTopology(shape,level=0):
 brt = BRep_Tool();
 s = shape.ShapeType();
 ts = TopoDS();
 print
 print "." * level,shapeTypeString(shape),
 if s == TopAbs_VERTEX:
  #print type(shape )
  #if this is a vertext, print coords
  #pnt = shape.TShape().Pnt();
  pnt = brt.Pnt(ts.Vertex(shape))
  print "(",pnt.X()/25.4," ",pnt.Y()/25.4," ",pnt.Z()/25.4,")",
  return;
 
 it = TopoDS_Iterator(shape);
 while it.More():
  it.Next();
  shp = it.Value();
  dumpTopology(it.Value(),level + 1 );  
 

def shapeTypeString(shape):
 
 st = shape.ShapeType();
 s = "?";
 if st == TopAbs_VERTEX:
  s = "Vertex";
 if st == TopAbs_SOLID:
  s = "Solid";
 if st == TopAbs_EDGE:
  s = "Edge";
 if st == TopAbs_FACE:
  s = "Face";
 if st == TopAbs_SHELL:
  s = "Shell";
 if st == TopAbs_WIRE:
  s = "Wire";
 if st == TopAbs_COMPOUND:
  s = "Compound."
 if st == TopAbs_COMPSOLID:
  s = "Compsolid."
 
 return s + ":" + str(shape.HashCode(23232232));
 
#read step file
 
stepReader = STEPControl_Reader();
 
stepReader.ReadFile('Test.STEP')
numItems = stepReader.NbRootsForTransfer();
numTranslated = stepReader.TransferRoots();
print numTranslated," Items Loaded."
 
shape = stepReader.OneShape();
#print shape;
 
print "Shape Topology:"
dumpTopology(shape);
print "Part has ",countEdges(shape), " Edges";
 

#make a cutting plane
p = gp_Pnt ( 1,1,-6 );
 
csys = gp_Ax3(p,gp().DZ())
 
#cuttingPlane = gp_Pln(p,gp().DZ());
cuttingPlane = gp_Pln(csys);
BRepTools().Write(shape,'test.out');
print "Made cutting plane."
b = BRepAlgo_Section(shape,cuttingPlane,True);
#b.Build();
intersection = b.Shape();
print "Made the section"
dumpTopology(intersection);
print "Intersection:",intersection.IsNull(),intersection.ShapeType()
print "Intersection has",countEdges(intersection)," edges."


  _____  

From: Paviot Thomas [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 10, 2008 12:25 AM
To: Dave Cowden; minerva-pythonocc@gna.org
Subject: RE : [Minerva-pythonocc] pythonOCC 0.96 and STEP import bug



Hello,

STLReader surely inherits its Read() method from a parent class that is not
wrapped.

BTW, feel free to send me the scripts you use to check pythonocc. Any
contribution is welcome!

Thomas


-------- Message d'origine--------
De: [EMAIL PROTECTED] de la part de Dave Cowden
Date: jeu. 09/10/2008 03:08
À: minerva-pythonocc@gna.org
Objet : Re: [Minerva-pythonocc] pythonOCC 0.96 and STEP import bug

Several  issues related to dealing with STL:

*  STLReader and StlApi are missing the Read(..) methods

* STLMesh* is missing. ( STLMesh.Merge() would be useful to import multiple
files, StlMesh_Explorer for reading a mesh )

Thanks, Thomas for the continued work!  this will be great, python is an
excellent language binding as it supports so many other libraries!

On Wed, Oct 8, 2008 at 8:10 PM, Dave Cowden <[EMAIL PROTECTED]> wrote:

> Greetings, List:
>
> I continue to work on my mission, which is to use pythonOCC to "slice" a
> solid model into layers for use in RepRap, an open source rapid
prototyper.
>
> Thanks, Thomas for version 0.97, I needed BRepBndLib!
>
> In my last post I was looking for TopAbs_SHAPE-- i found them-- they are
> module variables of OCC that that works fantastically!
>
> I have come across a few other modules that have missing pieces.  There is
> not much method to the list, other than i'm listing them as i come across
> them.
>
> *   BRep_Tool is present, but is missing many methods for some reason--
for
> example it has methods "Pnt" and "Surface", but is missing
> "Curve","CurveOnSurface", etc.
>
> * There are a few classes for tesselation that are present but have
missing
> init methods.
> All of these classes:
>
>    - GCPnts_QuasiUniformAbscissa
>    - GCPnts_QuasiUniformDeflection
>    - GCPnts_TangentialDeflection
>    - GCPnts_UniformAbscissa
>    - GCPnts_UniformDeflection
>
> seem to be missing the constructors and initialize methods that allow them
> to operate.
>
> * BRepOffset_MakeLoops -- similar to above, class definition is there but
> no methods are bound.
>
> * BRepOffset_Tool -- missing most of the methods
>
> * BRepTools -- Read, (very handy opposite Write), UVBounds methods missing
>
> I'm guessing that these were omitted due to some class/signiture that
could
> not be resolved or something....
>
>
>
>



_______________________________________________
Minerva-pythonocc mailing list
Minerva-pythonocc@gna.org
https://mail.gna.org/listinfo/minerva-pythonocc

Reply via email to