Changeset 7780:2a1ae37eaaae


Ignore:
Timestamp:
12/14/07 17:11:47 (5 years ago)
Author:
Robert Bradshaw <robertwb@…>
Branch:
default
Children:
7781:81debe531ffd, 7855:0fed8c25284d
Message:

Support for n-polygons in Jmol

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/plot/plot3d/index_face_set.pyx

    r7779 r7780  
    128128                                                     face.vertices[0]) 
    129129    else: 
    130         raise NotImplementedError, "pmesh doesn't support larger than quadrilaterals" # return join([str(face.vertices[i] + off) for i from 0 <= i < face.n] + []) 
     130        # Naive triangulation 
     131        all = [] 
     132        for i from 1 <= i < face.n-1: 
     133            r = sprintf_4i(ss, "4\n%d\n%d\n%d\n%d", face.vertices[0],  
     134                                                    face.vertices[i],  
     135                                                    face.vertices[i+1],  
     136                                                    face.vertices[0]) 
     137            PyList_Append(all, PyString_FromStringAndSize(ss, r)) 
     138        return "\n".join(all) 
    131139    # PyString_FromFormat is almost twice as slow 
    132140    return PyString_FromStringAndSize(ss, r) 
     
    504512         
    505513        faces = [format_pmesh_face(self._faces[i]) for i from 0 <= i < self.fcount] 
     514         
     515        # If a face has more than 4 vertices, it gets chopped up in format_pmesh_face 
     516        cdef Py_ssize_t extra_faces = 0 
     517        for i from 0 <= i < self.fcount: 
     518            if self._faces[i].n >= 5: 
     519                extra_faces += self._faces[i].n-3 
     520         
    506521        _sig_off 
    507522         
    508523        all = [str(self.vcount), 
    509524               points, 
    510                str(self.fcount), 
     525               str(self.fcount + extra_faces), 
    511526               faces] 
    512527         
Note: See TracChangeset for help on using the changeset viewer.