Ah! Great idea!<br>I'll give that a go<br><br>Thanks for your help<br><br><div><span class="gmail_quote">On 4/20/06, <b class="gmail_sendername">John Biddiscombe</b> <<a href="mailto:biddisco@cscs.ch">biddisco@cscs.ch</a>
> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">If you must use Java, then try subclassing from a PolyDataAlgorithm that<br>
already has zero inputs. (eg. vtkSphereSource, vtkConeSource etc) these<br>objects generate data without having an input. in general Wrapped<br>languages are ok for using vtk etc, but subclassing a native class with<br>a java extension is probably going to be dodgy
<br><br>JB<br><br><br>Alexander MacLennan wrote:<br>> Thanks John,<br>><br>> This option doesn't seem to be available using Java wrappers, or is it<br>> specified as a parameter to the constructor?<br>><br>
> cheers<br>><br>> alex<br>><br>> On 4/20/06, * John Biddiscombe* <<a href="mailto:biddisco@cscs.ch">biddisco@cscs.ch</a><br>> <mailto:<a href="mailto:biddisco@cscs.ch">biddisco@cscs.ch</a>>> wrote:
<br>><br>> You need to ensure in your class that you SetNumberOfInputPorts(0) in<br>> your constructor, what the error message is telling you is that it is<br>> expecting an input, but none has been provided. If your code is a source
<br>> object (ie not a filter), then you can tell it no inputs are needed<br>><br>> JB<br>><br>><br>> Alexander MacLennan wrote:<br>> > Hi,<br>> ><br>> > I am getting the following error message when I use my own class that
<br>> > converts from OOGL to a format viewable using VTK<br>> ><br>> ><br>> ><br>> > ERROR: In<br>> ><br>> /usr/student/tango/maclenna/cvs/VTK/Filtering/vtkDemandDrivenPipeline.cxx,
<br>> > line 692<br>> > vtkStreamingDemandDrivenPipeline (0x8073228): Input port 0 of<br>> algorithm<br>> > vtkPolyDataAlgorithm(0x8074588) has 0 connections but is not<br>> optional.
<br>> ><br>> > Its vtk compiled from CVS as of a few days ago.<br>> ><br>> > Does anyone have some hints?<br>> ><br>> > cheers<br>> ><br>> > alex
<br>> ><br>> > Here is my class:<br>> ><br>> ><br>> ><br>> > import java.awt.color.ColorSpace;<br>> ><br>> > public class vtkOOGLtoVtk extends
vtk.vtkPolyDataAlgorithm {<br>> > private OOGLObject o;<br>> ><br>> > public void setOOGL(OOGLObject o) {<br>> > this.o = o;<br>> > }<br>> >
<br>> ><br>> ><br>> > /**<br>> > * Get oogl object in vtk format<br>> > * Follows the pattern set by vtkPLYReader.cxx<br>> > *<br>> > * @param request
<br>> > * @param inputVector<br>> > * @param outputVector<br>> > * @return<br>> > */<br>> > public int RequestData(vtkInformation request,<br>
> > vtkInformationVector inputVector, vtkInformationVector<br>> > outputVector) {<br>> ><br>> > // Ape the stuff from vtkPLYReader until I know whats<br>> going on
<br>> > vtkInformation outInfo =<br>> outputVector.GetInformationObject(0);<br>> ><br>> > // Casting done with C++ example, not the best for java???<br>> > vtkPolyData output = (vtkPolyData)outInfo.Get(new
<br>> > vtkInformationDataObjectKey());<br>> > output.Initialize();<br>> ><br>> > // Return value<br>> > int result = 1;<br>> ><br>
> > // Temp vertex holder<br>> > Point3d v = null;<br>> ><br>> > // Temp face holder<br>> > Point3i f = null;<br>> ><br>> > // Temp variable for testing number of colours defined
<br>> for OOGL<br>> > Object<br>> > int count = 0;<br>> ><br>> > // Boolean variable for checking to see if RGB data<br>> available (<br>> > well HSV )
<br>> > boolean colourDataAvailable = false;<br>> ><br>> > // RGB values for points<br>> > vtkUnsignedCharArray rgbPoints = null;<br>> ><br>> > // Temp variable for putting colour into table as rgb
<br>> > float[] colourComponents = null;<br>> ><br>> > // Test number of colours defined for vertices<br>> > if ( o.getVertexColours() != null)<br>> > count =
o.getVertexColours ().size();<br>> ><br>> > if ( count > 0)<br>> > colourDataAvailable = true;<br>> ><br>> > // If there are vertex colours then use RGB Points
<br>> > if (colourDataAvailable){<br>> > rgbPoints = new vtkUnsignedCharArray();<br>> > rgbPoints.SetName("RGB");<br>> > output.GetPointData
().SetScalars(rgbPoints);<br>> > rgbPoints.Initialize();<br>> > rgbPoints.SetNumberOfComponents(3);<br>> > rgbPoints.SetNumberOfTuples<br>> (this.o.getVertices
().size());<br>> ><br>> > }<br>> > // Don't worry about colours by face for the moment.. its<br>> not<br>> > important<br>> > // to implement this right now
<br>> ><br>> > // Now load vertices into structure<br>> > vtkPoints points = new vtkPoints();<br>> > points.SetDataTypeToFloat();<br>> >
points.SetNumberOfPoints(this.o.getVertices().size());<br>> ><br>> > for ( int i = 0 ; i < o.getVertices().size(); i++){<br>> > // Get the vertex values and set them in the point
<br>> data object<br>> > v = o.getVertices().get(i);<br>> > points.SetPoint(i, v.x, v.y, v.z);<br>> ><br>> > // If colours available insert them, converting from
<br>> hsb to rgb<br>> ><br>> > if (colourDataAvailable){<br>> > colourComponents =<br>> ><br>> o.getVertexColours().get(i).get().getComponents(
ColorSpace.getInstance(ColorSpace.TYPE_RGB),<br>> > new float[3]);<br>> > rgbPoints.SetTuple3 (i, colourComponents[0],<br>> > colourComponents[1], colourComponents[2]);<br>
> > }<br>> > }<br>> ><br>> > // Now set the up the faces<br>> > vtkCellArray polys = new vtkCellArray();<br>> ><br>> > // Allocate space for faces
<br>> > for (int i = 0; i < this.o.getFaceCount(); i++) {<br>> > // Get face to insert<br>> > f = this.o.getFaces().get(i);<br>> ><br>> > // Tell ca that next cell is a triangle
<br>> > polys.InsertNextCell(3);<br>> ><br>> > // Insert point reference values that<br>> > // make up the face<br>> >
polys.InsertCellPoint(f.x);<br>> > polys.InsertCellPoint (f.y);<br>> > polys.InsertCellPoint (f.z);<br>> > }<br>> ><br>> ><br>> >
output.SetPolys(polys);<br>> > output.SetPoints(points);<br>> ><br>> ><br>> > return result;<br>> > }<br>> ><br>> > }<br>> >
<br>> ><br>> ><br>> ------------------------------------------------------------------------<br>> ><br>> > _______________________________________________<br>> > This is the private VTK discussion list.
<br>> > Please keep messages on-topic. Check the FAQ at:<br>> <a href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br>> > Follow this link to subscribe/unsubscribe:<br>
> > <a href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>><br>><br>> --<br>> John Biddiscombe, email:biddisco @
cscs.ch<br>> <a href="http://www.cscs.ch/about/BJohn.php">http://www.cscs.ch/about/BJohn.php</a><br>> CSCS, Swiss National Supercomputing Centre | Tel: +41 (91) 610.82.07<br>> Via Cantonale, 6928 Manno, Switzerland | Fax: +41 (91)
610.82.82<br>><br>><br><br><br>--<br>John Biddiscombe, email:biddisco @ cscs.ch<br><a href="http://www.cscs.ch/about/BJohn.php">http://www.cscs.ch/about/BJohn.php</a><br>CSCS, Swiss National Supercomputing Centre | Tel: +41 (91)
610.82.07<br>Via Cantonale, 6928 Manno, Switzerland | Fax: +41 (91) 610.82.82<br><br></blockquote></div><br>