[vtkusers] extending vtkPolyDataAlgoritm
Alexander MacLennan
alex.maclennan at gmail.com
Thu Apr 20 02:16:43 EDT 2006
Hi,
I am getting the following error message when I use my own class that
converts from OOGL to a format viewable using VTK
ERROR: In
/usr/student/tango/maclenna/cvs/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
line 692
vtkStreamingDemandDrivenPipeline (0x8073228): Input port 0 of algorithm
vtkPolyDataAlgorithm(0x8074588) has 0 connections but is not optional.
Its vtk compiled from CVS as of a few days ago.
Does anyone have some hints?
cheers
alex
Here is my class:
import java.awt.color.ColorSpace;
public class vtkOOGLtoVtk extends vtk.vtkPolyDataAlgorithm {
private OOGLObject o;
public void setOOGL(OOGLObject o) {
this.o = o;
}
/**
* Get oogl object in vtk format
* Follows the pattern set by vtkPLYReader.cxx
*
* @param request
* @param inputVector
* @param outputVector
* @return
*/
public int RequestData(vtkInformation request,
vtkInformationVector inputVector, vtkInformationVector
outputVector) {
// Ape the stuff from vtkPLYReader until I know whats going on
vtkInformation outInfo = outputVector.GetInformationObject(0);
// Casting done with C++ example, not the best for java???
vtkPolyData output = (vtkPolyData)outInfo.Get(new
vtkInformationDataObjectKey());
output.Initialize();
// Return value
int result = 1;
// Temp vertex holder
Point3d v = null;
// Temp face holder
Point3i f = null;
// Temp variable for testing number of colours defined for OOGL
Object
int count = 0;
// Boolean variable for checking to see if RGB data available ( well
HSV )
boolean colourDataAvailable = false;
// RGB values for points
vtkUnsignedCharArray rgbPoints = null;
// Temp variable for putting colour into table as rgb
float[] colourComponents = null;
// Test number of colours defined for vertices
if ( o.getVertexColours() != null)
count = o.getVertexColours().size();
if ( count > 0)
colourDataAvailable = true;
// If there are vertex colours then use RGB Points
if (colourDataAvailable){
rgbPoints = new vtkUnsignedCharArray();
rgbPoints.SetName("RGB");
output.GetPointData().SetScalars(rgbPoints);
rgbPoints.Initialize();
rgbPoints.SetNumberOfComponents(3);
rgbPoints.SetNumberOfTuples(this.o.getVertices().size());
}
// Don't worry about colours by face for the moment.. its not
important
// to implement this right now
// Now load vertices into structure
vtkPoints points = new vtkPoints();
points.SetDataTypeToFloat();
points.SetNumberOfPoints(this.o.getVertices().size());
for ( int i = 0 ; i < o.getVertices().size(); i++){
// Get the vertex values and set them in the point data object
v = o.getVertices().get(i);
points.SetPoint(i, v.x, v.y, v.z);
// If colours available insert them, converting from hsb to rgb
if (colourDataAvailable){
colourComponents = o.getVertexColours
().get(i).get().getComponents(ColorSpace.getInstance(ColorSpace.TYPE_RGB),
new float[3]);
rgbPoints.SetTuple3(i, colourComponents[0],
colourComponents[1], colourComponents[2]);
}
}
// Now set the up the faces
vtkCellArray polys = new vtkCellArray();
// Allocate space for faces
for (int i = 0; i < this.o.getFaceCount(); i++) {
// Get face to insert
f = this.o.getFaces().get(i);
// Tell ca that next cell is a triangle
polys.InsertNextCell(3);
// Insert point reference values that
// make up the face
polys.InsertCellPoint(f.x);
polys.InsertCellPoint(f.y);
polys.InsertCellPoint(f.z);
}
output.SetPolys(polys);
output.SetPoints(points);
return result;
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060420/56dc3019/attachment.htm>
More information about the vtkusers
mailing list