|
| 1 | +class Pointset: |
| 2 | + @property |
| 3 | + def n_coords(self): |
| 4 | + """Number of coordinates |
| 5 | +
|
| 6 | + Subclasses should override with more efficient implementations. |
| 7 | + """ |
| 8 | + return len(self.get_coords()) |
| 9 | + |
| 10 | + def get_coords(self, name=None): |
| 11 | + """Nx3 array of coordinates in RAS+ space""" |
| 12 | + raise NotImplementedError |
| 13 | + |
| 14 | + |
| 15 | +class TriangularMesh(Pointset): |
| 16 | + @property |
| 17 | + def n_triangles(self): |
| 18 | + """Number of faces |
| 19 | +
|
| 20 | + Subclasses should override with more efficient implementations. |
| 21 | + """ |
| 22 | + return len(self.get_triangles()) |
| 23 | + |
| 24 | + def get_triangles(self, name=None): |
| 25 | + """Mx3 array of indices into coordinate table""" |
| 26 | + raise NotImplementedError |
| 27 | + |
| 28 | + def get_mesh(self, name=None): |
| 29 | + return self.get_coords(name=name), self.get_triangles(name=name) |
| 30 | + |
| 31 | + def get_names(self): |
| 32 | + """List of surface names that can be passed to |
| 33 | + ``get_{coords,triangles,mesh}`` |
| 34 | + """ |
| 35 | + raise NotImplementedError |
| 36 | + |
| 37 | + ## This method is called for by the BIAP, but it now seems simpler to wait to |
| 38 | + ## provide it until there are any proposed implementations |
| 39 | + # def decimate(self, *, n_coords=None, ratio=None): |
| 40 | + # """ Return a TriangularMesh with a smaller number of vertices that |
| 41 | + # preserves the geometry of the original """ |
| 42 | + # # To be overridden when a format provides optimization opportunities |
| 43 | + # raise NotImplementedError |
| 44 | + |
| 45 | + |
| 46 | +class NdGrid(Pointset): |
| 47 | + """ |
| 48 | + Attributes |
| 49 | + ---------- |
| 50 | + shape : 3-tuple |
| 51 | + number of coordinates in each dimension of grid |
| 52 | + """ |
| 53 | + |
| 54 | + def get_affine(self, name=None): |
| 55 | + """4x4 array""" |
| 56 | + raise NotImplementedError |
0 commit comments