Re: [Pythoncad-developer] Proposal geometry objects
CAD Application entire developed in Python
Status: Beta
Brought to you by:
matteoboscolo
From: Gertwin G. <ger...@gm...> - 2010-02-05 20:07:59
|
Yagnesh, This is a way to store the geometry in memory and file/database. It is independent off the drawing methods, there are no Cairo datatypes in it not does it depend on the Cairo library. We can use it for Cairo, OpenGL or whatever. Regards, Gertwin 2010/2/5 Yagnesh Desai <yn...@gm...>: > Friends; > > Is this method only suited to Cairo or it will > be possible to use this method in other renderer? > > > > > On Fri, Feb 5, 2010 at 1:07 PM, Matteo Boscolo > <mat...@bo...> wrote: >> >> >> Hi Gertwing, >> >> >> >> I like your structure because we can store in a row of db a tuple that >> indicate the points and the kind of object that we are going to store. >> >> >> >> The db entity could be in case of point >> >> Id ++ coordinate ++ type >> >> 01 ++ (10,10)++ point >> >> 02 ++ (10,10,20,20)++Segment >> >> And so on for all the entity >> >> We can go on with this step: >> >> 1) Get a full list of the entity that we need do describe >> >> 2) Create a sort of classes that try to describe all this entity >> >> 3) Create the simple and efficient way to store in on db >> >> 4) Start to convert pythoncad entity to the new entity >> >> >> >> I would like to go on with this step before of all. >> >> So start listing all the entity that we will need in pythoncad >> >> >> >> 1) Point >> >> 2) Segment >> >> 3) Circle >> >> 4) Arc >> >> 5) Ellipse >> >> 6) Nurbs >> >> 7) Polyline >> >> 8) Hatch >> >> 9) Text >> >> 10) Image >> >> 11) Polygon (triangle/rectangle….) >> >> 12) Dimension >> >> 13) Arrow >> >> 14) Marker >> >> 15) Section symbol >> >> 16) Welding symbol >> >> 17) Groups >> >> 18) Layer >> >> 19) Label >> >> 20) Ballon >> >> 21) … >> >> >> >> Regards >> >> Matteo >> >> >> >> From: ger...@gm... [mailto:ger...@gm...] >> Sent: 04 February 2010 22:39 >> To: pythoncad-developer >> Subject: [Pythoncad-developer] Proposal geometry objects >> >> >> >> Hi all, >> >> I did some thinking about the entity geometry. >> >> The current version maintains one point list where all entities make use of. >> I want to preserve this method because it has some advantages. >> >> But I want to change the way the entities use these points. >> The current version defines different geometries for each entity (segment, >> polyline, arc, etc.). >> >> I want to define only two different geometry objects that all entities can >> share. >> It consist of only points, no start-, end angles, center points or radius. >> Because there are only points in the geometry transformations can be done >> really quick, all points are multiplied by the same matrix. >> >> If needed the program must calculate the center point, radius and angles of >> circles and arcs. >> This is done far less often than entity drawing so this is more efficient. >> >> The main advantage is creating point lists for cairo drawing is more easy. >> All entities share the same geometry class, a single function is used to >> draw them all. >> It is more easy to optimize a single draw function for speed than all >> different functions for all entities. >> This excludes hatches of course which will have it own draw function. >> >> >> Some preliminary code: >> >> class Point(object): >> """ >> Indicates a single point with x and y ordinates (2D point) >> The interpretation indicates how the connection is drawn to the next point. >> With this construction linear and circular lines are constructed. >> >> These point objects are stored in a single table in the database. >> """ >> def __init__(self): >> # id of point >> self.__id = 0 >> # X ordinate >> self.__x = 0.0 >> # Y ordinate >> self.__y = 0.0 >> # interpretation connection to next point >> # L = linear >> # C = circular >> # None = not used (single point geometry) >> # more interpretation values needed for dimensions? >> self.__interpretation = 'L' >> >> >> class SGeometry(object): >> """ >> Indicates a single geometry. >> This is used in segment, polyline, arc, circle. >> >> examples: >> 1) A segment geometry consists of a list of two points. >> The point interpretation from the first to the second point is 'L' (linear) >> >> 2) An arc geometry consists of a list of three points. >> The first point is the start point of the arc, the second point is on the >> arc and the third point is the end point. >> The point interpretation from the first to the second point is 'C' >> (circular) >> The point interpretation from the second to the third point is 'C' >> (circular) >> >> 3) An polyline consists of a list of three or more points. >> The point interpretation can be 'L' (linear) or 'C' (circular) >> This gives the opportunity to create polylines with linear and arc segments. >> >> 4) An circle geometry consists of a list of five points. >> A circle is represented as two arcs where the first and fifth point are the >> same. >> The point interpretation from the first to the second point is 'C' >> (circular) >> The point interpretation from the second to the third point is 'C' >> (circular) >> >> For a single geometry the geometry interpretation is None. >> Interpretation is used for complex geometries. >> """ >> def __init__(self): >> # list of points ids >> self.__point_ids = [] >> # interpretation used in complex geometry >> # O = outer ring >> # I = inner ring >> # None = not used. >> self.__interpretation = None >> >> >> class CGeometry(object): >> """ >> Indicates a complex geometry. >> This is used in hatches. >> >> A hatch can contain islands. >> The list contains a outer ring and a inner ring (island). >> The rings are closed polylines (SGeometry objects). >> >> ??? Can inner rings contain other inner rings (nested islands) ??? >> """ >> def __init__(self): >> # list of single geometries. >> # order in the list is important, first a outer ring, than the inner rings >> self.__sgeometries = [] >> >> >> Even a text can have the same geometry as a segment (two points). >> The first point is the text location, the second point is the rotation. >> The distance between the first and second point is the text height. >> >> >> Regards, >> Gertwin >> >> ------------------------------------------------------------------------------ >> The Planet: dedicated and managed hosting, cloud storage, colocation >> Stay online with enterprise data centers and the best network in the >> business >> Choose flexible plans and management services without long-term contracts >> Personal 24x7 support from experience hosting pros just a phone call away. >> http://p.sf.net/sfu/theplanet-com >> _______________________________________________ >> Pythoncad-developer mailing list >> Pyt...@li... >> https://lists.sourceforge.net/lists/listinfo/pythoncad-developer >> >> > > > > -- > Best regards > > Yagnesh Desai > > Save a tree...please don't print this e-mail. > > ------------------------------------------------------------------------------ > The Planet: dedicated and managed hosting, cloud storage, colocation > Stay online with enterprise data centers and the best network in the business > Choose flexible plans and management services without long-term contracts > Personal 24x7 support from experience hosting pros just a phone call away. > http://p.sf.net/sfu/theplanet-com > _______________________________________________ > Pythoncad-developer mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncad-developer > |