[vtkusers] extending vtkPolyDataAlgoritm
John Biddiscombe
biddisco at cscs.ch
Thu Apr 20 07:33:18 EDT 2006
You need to ensure in your class that you SetNumberOfInputPorts(0) in
your constructor, what the error message is telling you is that it is
expecting an input, but none has been provided. If your code is a source
object (ie not a filter), then you can tell it no inputs are needed
JB
Alexander MacLennan wrote:
> 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;
> }
>
> }
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
--
John Biddiscombe, email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82
More information about the vtkusers
mailing list