> > Hi,Thomas: > thanks for the review. I didnt even think about subclassing, that's a great idea. From the code below, it appears you may already have the wrapper classes I have written somewhere else. Should I polish mine and contribute, or are there already others defined?
> > Hi Dave, > > Thanks for this contribution! The generator approach is very convincing and > may be a good way to 'wrap the wrapper', that is to say build more pythonic > classes to handle basic topologies or geometries. > > I would however suggest that your Point, Edge or Wire class inherit from > gp_Pnt, TopoDS_Edge or TopoDS_Wire. This way, the Point/Edge/Wire instances > could be passed to and processed by basic OCC classes/methods. > A Great idea, didnt even think about that possibility. That should be fairly easy to change. > > At last, we use the following convention for the high level API: > - class naming use the CamelCase convention, > - methods/function use the lowercase do_something() convention. This > convention allows distinguishing builtin OCC methods/our high level methods. > Okie dokie. > Best Regards, > > Thomas > > ========================== > def testSubClass(self): > ''' > Checks that OCC objects can be subclassed, and passed as > parameters. In this test, we create > a MyPoint and MyVec class, inheriting from gp_Pnt and gp_Vec. > ''' > class MyPoint(gp_Pnt): > def __init__(self,*kargs): > gp_Pnt.__init__(self,*kargs) > self.x = 4 > def get_x(self): > return self.x > class MyVec(gp_Vec): > def __init__(self,*kargs): > gp_Vec.__init__(self,*kargs) > self._an_attribute = "something" > def get_attribute(self): > return self._an_attribute > # Create the first point > point1 = MyPoint(1,2,3) > self.assertEqual(point1.Coord(),(1.,2.,3.)) > self.assertEqual(point1.get_x(),4) > # Create the second point > point2 = MyPoint(2,2,3) > # Then create the vec from these two points > # The magnitude of the vector should equal 1.0 > vec = MyVec(point1,point2) > self.assertEqual(vec.Magnitude(),1.) > self.assertEqual(vec.get_attribute(),"something") > > > _______________________________________________ > 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