Changeset 680

Show
Ignore:
Timestamp:
09/03/03 10:49:42 (5 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBRapier/RBRapier/Formats/SVG/RapierRenderItems.py

    r679 r680  
    213213    fromSVGPath = classmethod(fromSVGPath) 
    214214 
     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 
    215223    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] 
    217226 
    218227    def move_rel(self, x, y):  
     
    790799 
    791800class Polyline(RenderItem): 
    792     tesselator = SVGTesselator(
     801    tesselator = SVGTesselator(normal=(0,0,1)
    793802 
    794803    def Compile(self, style, transform, target): 
     
    804813            if points[0] != points[-1]: 
    805814                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() 
    807819            for glmode, fillpoints in glmodedatalist: 
    808820                fillpoints = transform.TransformPoints(fillpoints) 
     
    826838 
    827839class Polygon(Polyline): 
    828     tesselator = SVGTesselator(
     840    tesselator = SVGTesselator(normal=(0,0,1)
    829841 
    830842    def Compile(self, style, transform, target): 
     
    837849        fillcolor = style.GetFillColor() 
    838850        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() 
    843854            for glmode, fillpoints in glmodedatalist: 
    844855                fillpoints = transform.TransformPoints(fillpoints) 
     
    849860        strokecolor = style.GetStrokeColor() 
    850861        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() 
    855865            for glmode, strokepoints in glmodedatalist: 
    856866                strokepoints = transform.TransformPoints(strokepoints) 
     
    869879 
    870880class Path(RenderItem): 
    871     tesselator = SVGTesselator(
     881    tesselator = SVGTesselator(normal=(0,0,1)
    872882 
    873883    def Compile(self, style, transform, target): 
     
    886896                if windingrule is None: windingrule = FillRuleLookup[None] 
    887897 
    888                 glmodedatalist = self.tesselator.tessellate(contours, windingrule=windingrule) 
     898                self.tesselator.open(windingrule=windingrule) 
     899                glmodedatalist = self.tesselator.tessellate(contourlist) 
     900                self.tesselator.close() 
    889901                for glmode, fillpoints in glmodedatalist: 
    890902                    fillpoints = transform.TransformPoints(fillpoints) 
  • trunk/RBRapier/RBRapier/Tools/Geometry/gluPolygonTesselation.py

    r668 r680  
    9191        for n, v in settings.iteritems(): setattr(self, n, v) 
    9292 
     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) 
    9397        GLU.gluTessBeginPolygon(tessobj, None) 
    9498        for contour in contours: 
    9599            GLU.gluTessBeginContour(tessobj) 
    96             for each in contour: 
    97                 GLU.gluTessVertex(tessobj, each, each) 
     100            map(vertexcall, contour) 
    98101            GLU.gluTessEndContour(tessobj) 
    99102        GLU.gluTessEndPolygon(tessobj)