Point Cloud module API
Accessing point clouds
The number of point clouds being passed into the node can be found:
num= pfpy.getNumClouds()
print("node is reading", num, "clouds")
A reference to an existing cloud can be obtained as follows:
c= pfpy.getCloudRef(index)
where index is an integer indicating which cloud to read in the range 0 and N-1 inclusive, where N is the number of clouds returned by pfpy.getNumClouds().
By calling the Point Cloud API functions described below, cloud data can be fetched or modified before being passed down-stream. The internal cloud can be copied and freed as follows:
c= pfpy.getCloudRef(index)
cc= c.copy()
# do stuff
cc.freeCopy()
Copying a point cloud in this way allows original cloud data to be read from the copy, regardless of how the actual cloud is then modified by the script. An example of this copying process in action for trackers (the process is the same for point clouds) is given in the filterTracks.py example script.
Creating new point clouds
To create a new point cloud, use the new function:
c= pfpy.Cloud.new(name)
This will create a new point cloud with the specified name ready to be modified in the script and then passed down-stream.
API functions
Examples of these functions in use are provided by the python scripts available in the exports, macros and nodes installation folders.
getExport()
Parameters:
none
Description:
Returns true if the point cloud has been flagged for export by an Export node. Note that point clouds are flagged for export by default.
Example:
c= pfpy.getCloudRef(0)
print("Export cloud: ", c.getExport())
setExport(state)
Parameters:
boolean state
Description:
Flag the point cloud for export or not. Note that point clouds are flagged for export by default.
Example:
c= pfpy.getCloudRef(0)
c.setExport(False)
saveOBJ(objFilename, mtlFilename)
Parameters:
string objFilename
optional string mtlFilename
Description:
Saved the point cloud as an OBJ file with objFilename. If mtlFilename is provided, the material file will be saved using that filename, otherwise it will be saved by changing the obj extension of objFilename to mtl.
Example:
c= pfpy.getCloudRef(0)
c.save('/path/to/myCloud.obj')
c.save('/path/to/myCloud.obj', '/path/to/myCloudMaterial.mtl')
save3DS(filename)
Parameters:
string filename
Description:
Saves the point cloud as a 3DS file with the given filename
Example:
c= pfpy.getCloudRef(0)
c.save3DS('/path/to/mycloud.3ds')
saveLWO(filename)
Parameters:
string filename
Description:
Saves the point cloud as a LWO file with the given filename
Example:
c= pfpy.getCloudRef(0)
c.saveLWO('/path/to/mycloud.lwo)
getName()
Parameters:
none
Description:
Returns the point cloud name
Example:
c= pfpy.getCloudRef(0)
print("Cloud is named", c.getName())
setName(name)
Parameters:
string name
Description:
Sets the point cloud name to the string
Example:
c= pfpy.getCloudRef(0)
c.setName("myName")
getNumPoints()
Parameters:
none
Description:
Returns the number of points in the cloud
Example:
c= pfpy.getCloudRef(0)
print("Point count= ", m.getNumPoints())
isPointSolved(index)
Parameters:
unsigned integer point index number
Description:
Returns True if the point is solved
Example:
c= pfpy.getCloudRef(0)
if c.isPointSolved(100):
pos= c.getPointPos(100)
print("Point 100 position= ", pos)
getPointPos(index)
Parameters:
unsigned integer point index number
Description:
Returns the position of the specified point
Example:
c= pfpy.getCloudRef(0)
if c.isPointSolved(100):
print("Point 100 position= ", c.getPointPos(100))
print("Point 100 normal= ", c.getPointNormal(100))
print("Point 100 colour= ", c.getPointColour(100))
getPointNormal(index)
Parameters:
unsigned integer point index number
Description:
Returns the normal of the specified point
Example:
c= pfpy.getCloudRef(0)
if c.isPointSolved(100):
print("Point 100 position= ", c.getPointPos(100))
print("Point 100 normal= ", c.getPointNormal(100))
print("Point 100 colour= ", c.getPointColour(100))
getPointColour(index)
Parameters:
unsigned integer point index number
Description:
Returns the colour of the specified point in the range [0..1]
Example:
c= pfpy.getCloudRef(0)
if c.isPointSolved(100):
print("Point 100 position= ", c.getPointPos(100))
print("Point 100 normal= ", c.getPointNormal(100))
print("Point 100 colour= ", c.getPointColour(100))
setNumPoints(number)
Parameters:
unsigned integer point count number
Description:
Sets the number of points in the point cloud
Example:
c= pfpy.getCloudRef(0)
c.setNumPoints(3)
c.setPointPos(0, 0.13, 0.523, 0.615)
c.setPointPos(1, 1.45, 0.178, 0.114)
c.setPointPos(2, 1.12, 1.545, 0.516)
setPointPos(index, x, y, z)
Parameters:
unsigned integer point index number
floating point x, y and z coordinates
Description:
Sets the position of the point in 3D space
Example:
c= pfpy.getCloudRef(0)
c.setNumPoints(3)
c.setPointPos(0, 0.13, 0.523, 0.615)
c.setPointPos(1, 1.45, 0.178, 0.114)
c.setPointPos(2, 1.12, 1.545, 0.516)
setPointNormal(index, x, y, z)
Parameters:
unsigned integer point index number
floating point x, y and z normal values
Description:
Sets the normal of the point in 3D space
Example:
c= pfpy.getCloudRef(0)
c.setNumPoints(1)
c.setPointPos(0, 0.13, 0.523, 0.615)
c.setPointNormal(0, 0.0, 1.0, 0.0)
c.setPointColour(0, 0.9, 0.9, 0.9)
setPointColour(index, r, g, b)
Parameters:
unsigned integer point index number
floating point r, g and b colour values
Description:
Sets the colour of the point in 3D space
Example:
c= pfpy.getCloudRef(0)
c.setNumPoints(1)
c.setPointPos(0, 0.13, 0.523, 0.615)
c.setPointNormal(0, 0.0, 1.0, 0.0)
c.setPointColour(0, 0.9, 0.9, 0.9)
getNumTriangles()
Parameters:
none
Description:
Returns the number of triangles in the point cloud when it is represented with a single triangle-per-point. This will be the same as the number of points in the cloud.
Example:
c= pfpy.getCloudRef(0)
print("Triangle count= ", c.getNumTriangles())
getTrianglePoint(tindex, vindex)
Parameters:
unsigned integer triangle index number
unsigned integer corner index number
Description:
Returns the 3D position of a particular corner of the triangle (in the range [0..2]) as an unsigned integer
Example:
c= pfpy.getCloudRef(0)
print("Triangle 100:")
print("Corner0= ", c.getTrianglePoint(100,0))
print("Corner1= ", c.getTrianglePoint(100,1))
print("Corner2= ", c.getTrianglePoint(100,2))