Examples of Using ShapeTools from within Matlab


Create a Matlab shape using the matlabTriangulation method.

% Create a shape, in Matlab, from % a set of triangulated faces

% import Shape tools java classes import edu.ucla.loni.ccb.shape.Shape;
import edu.ucla.loni.ccb.shape.util.ShapeFactory;
import edu.ucla.loni.ccb.shape.Shape;

% create random value ten points ( x, y and z coordinates in separate arrays)
x = rand(1,10);
y = rand(1,10);
z = rand(1,10);

% create a simple triangulation (ignores Z coordinate)
TRI = delaunay(x,y);


% create ShapeTools shape from the matlab triangulation TRI


shape = ShapeFactory.matlabTriangulation(x,y,z,TRI);


Use the ShapeTools library and viewer to read and display a file's vertices

Read a file using the ShapeTools library, extract it's vertices and display using the ShapeViewer

# start matlab code sample

import edu.ucla.loni.ccb.shape.Shape;

import edu.ucla.loni.ccb.shape.geometry.IPointSet;

import edu.ucla.loni.ccb.shapeio.util.ShapeToolsReader;


reader = ShapeToolsReader;


shape = reader.readShape('short.ucf');


points = shape.getVertices;

coords = points.getPoints;

# view coordinates


coords


coords =
1 59 59 59 60
1 133 134 135 135
1 48 48 48 48

# read Minc Binary OBJ
# (Not otherwise possible w/o much suffering)
shape = reader.readShape('tri_binary.obj');


coords = shape.getVertices.getPoints; coords coords =
0 1 1
0 0 1
0 0 0

# end matlab code sample ....