A couple of changes needed to work with vertex attributes fully. This allows an attribute such as depth to be attached to a vertex and on each extra vertex insertion the attribute is interpolated by triangle. Not working at the moment. The example I worked with was 'A'. It (not sure why) ignored the attributes. Didnt realise till I made changes to the 2013 code that there was a git repository. These dont seem to be fixed in that repository.
Other wise this is a great way to access triangle through python.
so that attributes are passed in. We also need to skip the dimension test part later because attributes can be any dimension * no_of_points. Flattened arrays are passed backwards and forwards.
for n0, n1, _, d in fields:
try:
value = np.array(getattr(b, n0))
except ValueError:
continue
print 'output reshape',n1,value.shape
if n1=='vertex_attributes': <<<<<< this skips an upfront definition - could be hard coded as 'variable' in fields.
d=value.shape[0]/len(r['vertices'])
r[n1] = value.reshape((-1,d))
return r
In core.pyx need to modify the definition
property pointattributelist:
def get(self):
return <double[:self.c.numberofpoints*self.c.numberofpointattributes]> self.c.pointattributelist
def set(self, double[:] value):
This latter modification allows multi attributes at each vertex. It deals with total size of the attribute which will be self.c.numberofpoints*self.c.numberofpointattributes.
A couple of changes needed to work with vertex attributes fully. This allows an attribute such as depth to be attached to a vertex and on each extra vertex insertion the attribute is interpolated by triangle. Not working at the moment. The example I worked with was 'A'. It (not sure why) ignored the attributes. Didnt realise till I made changes to the 2013 code that there was a git repository. These dont seem to be fixed in that repository.
Other wise this is a great way to access triangle through python.
need to add to the fields variable in init
so that attributes are passed in. We also need to skip the dimension test part later because attributes can be any dimension * no_of_points. Flattened arrays are passed backwards and forwards.
In core.pyx need to modify the definition property pointattributelist: def get(self): return <double[:self.c.numberofpoints*self.c.numberofpointattributes]> self.c.pointattributelist def set(self, double[:] value):
assert value.size == self.c.numberofpoints
This latter modification allows multi attributes at each vertex. It deals with total size of the attribute which will be self.c.numberofpoints*self.c.numberofpointattributes.