Changeset 680
- Timestamp:
- 09/03/03 10:49:42 (5 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBRapier/RBRapier/Formats/SVG/RapierRenderItems.py
r679 r680 213 213 fromSVGPath = classmethod(fromSVGPath) 214 214 215 def _ReduceDuplications(self): 216 def _reduce(path): 217 for idx in range(len(path)-1, 0, -1): 218 if path[idx] == path[idx-1]: 219 del path[idx] 220 return path 221 self.pathlist = filter(None, map(_reduce, self.pathlist)) 222 215 223 def GetContours(self): 216 return [map(tuple, contour) for contour in filter(None, self.pathlist)] 224 self._ReduceDuplications() 225 return [map(tuple, contour) for contour in self.pathlist] 217 226 218 227 def move_rel(self, x, y): … … 790 799 791 800 class Polyline(RenderItem): 792 tesselator = SVGTesselator( )801 tesselator = SVGTesselator(normal=(0,0,1)) 793 802 794 803 def Compile(self, style, transform, target): … … 804 813 if points[0] != points[-1]: 805 814 points.append(points[0]) 806 glmodedatalist = self.tesselator.tessellate([points], windingrule=windingrule) 815 816 self.tesselator.open(windingrule=windingrule) 817 glmodedatalist = self.tesselator.tessellate([points]) 818 self.tesselator.close() 807 819 for glmode, fillpoints in glmodedatalist: 808 820 fillpoints = transform.TransformPoints(fillpoints) … … 826 838 827 839 class Polygon(Polyline): 828 tesselator = SVGTesselator( )840 tesselator = SVGTesselator(normal=(0,0,1)) 829 841 830 842 def Compile(self, style, transform, target): … … 837 849 fillcolor = style.GetFillColor() 838 850 if fillcolor is not None: 839 points = self.points[:] 840 if points[0] != points[-1]: 841 points.append(points[0]) 842 glmodedatalist = self.tesselator.tessellate([points], windingrule=windingrule) 851 self.tesselator.open(windingrule=windingrule) 852 glmodedatalist = self.tesselator.tessellate([points]) 853 self.tesselator.close() 843 854 for glmode, fillpoints in glmodedatalist: 844 855 fillpoints = transform.TransformPoints(fillpoints) … … 849 860 strokecolor = style.GetStrokeColor() 850 861 if strokecolor is not None: 851 points = self.points[:] 852 if points[0] != points[-1]: 853 points.append(points[0]) 854 glmodedatalist = self.tesselator.tessellate([points], windingrule=windingrule) 862 self.tesselator.open(windingrule=windingrule) 863 glmodedatalist = self.tesselator.tessellate([points]) 864 self.tesselator.close() 855 865 for glmode, strokepoints in glmodedatalist: 856 866 strokepoints = transform.TransformPoints(strokepoints) … … 869 879 870 880 class Path(RenderItem): 871 tesselator = SVGTesselator( )881 tesselator = SVGTesselator(normal=(0,0,1)) 872 882 873 883 def Compile(self, style, transform, target): … … 886 896 if windingrule is None: windingrule = FillRuleLookup[None] 887 897 888 glmodedatalist = self.tesselator.tessellate(contours, windingrule=windingrule) 898 self.tesselator.open(windingrule=windingrule) 899 glmodedatalist = self.tesselator.tessellate(contourlist) 900 self.tesselator.close() 889 901 for glmode, fillpoints in glmodedatalist: 890 902 fillpoints = transform.TransformPoints(fillpoints) trunk/RBRapier/RBRapier/Tools/Geometry/gluPolygonTesselation.py
r668 r680 91 91 for n, v in settings.iteritems(): setattr(self, n, v) 92 92 93 if len(contours[0][0]) == 2: 94 vertexcall = lambda (x,y): GLU.gluTessVertex(tessobj, (x,y, 0), (x,y)) 95 else: 96 vertexcall = lambda each: GLU.gluTessVertex(tessobj, each[:3], each) 93 97 GLU.gluTessBeginPolygon(tessobj, None) 94 98 for contour in contours: 95 99 GLU.gluTessBeginContour(tessobj) 96 for each in contour: 97 GLU.gluTessVertex(tessobj, each, each) 100 map(vertexcall, contour) 98 101 GLU.gluTessEndContour(tessobj) 99 102 GLU.gluTessEndPolygon(tessobj)
