<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
PS.<br>
if your data does have a regular cartesian geometry then the process
could be as folows:<br>
note if you have irregular geometry, or no uniform Cartesian geometry,
then you won't want to use vtkImageData, and the procedure below will
need to be modified.<br>
<br>
1)<br>
create a vtkImageData<br>
If your data set has regular cartesian geometry this is especially
simple, you have to set the origin, dimensions and grid spacing.<br>
<br>
2)<br>
for each scalar you wish to visualize<br>
2a)<br>
create a vtkDataArray of the appropriate type(integer,
float,double,char etc...)<br>
you will have to set the number of components(one for scalar data,
three for vector) and the length of the array (number of tuples).<br>
2b)<br>
give the array a name.<br>
2c) <br>
copy the data from your data set into the vtkDataArray <br>
you can give vtk a pointer(set void pointer) or you can set individual
elements(tuples)<br>
2d)<br>
insert(add) these to the vtkDataSet from step 1<br>
to do this you have to access the point data, something like
vtkImageData-&gt;GetPointData()-&gt;AddArray()<br>
<br>
<br>
<br>
for example if your data is a double format:<br>
<br>
// for 2d<br>
int nz = 1;<br>
int nTup=nx*ny*nz;<br>
<br>
// this is the array for your data, note that VTK <br>
// will use a collumn major order<br>
double *data = new double [nTup];<br>
<br>
// copy your data into this data here<br>
<br>
// vtkDataSet defines topology<br>
vtkImageData *id = vtkImageData::New();<br>
id-&gt;SetDimensions(nx,ny,nz);<br>
id-&gt;SetSpacing(dx[0],dx[1],dx[2]);<br>
id-&gt;SetOrigin(x0[0],x0[1],x0[2]);<br>
<br>
// vtk double arrays hold data<br>
vtkDoubleArray *rho = vtkDoubleArray::New();<br>
rho-&gt;SetNumberOfComponents(1);<br>
rho-&gt;SetNumberOfTuples(nTup);<br>
rho-&gt;SetName("rho");<br>
rho-&gt;SetVoidArray( data, (vtkIdType)nTup, 0 );<br>
<br>
// put the array into the vtk data set<br>
id-&gt;GetPointData()-&gt;AddArray( rho&nbsp;&nbsp;&nbsp; );<br>
<br>
id-&gt;Update();<br>
<br>
// do what you want<br>
<br>
id-&gt;Delete();<br>
<br>
<br>
burlen wrote:
<blockquote cite="mid:479602D0.4080109@apollo.sr.unh.edu" type="cite">
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
Hi, Oliver, writing an image loader is fairly strait forward but the
details depend on the specifics of your data. Does your data have a
regular Cartesian geometry? You first need to figure out which
vtkDataSet best matches the geometry of your data. For instance using
an vtkUnstructuredGrid where you could use vtkImageData would overly
complicate things and adversely impact performance. A good deal of
information can be found in the vtk users guide. In ver 4.2 of the user
guide chap 5 has relevant info. If you plan to use VTK you would be
well advised to obtain a copy.<br>
Burlen<br>
  <br>
  <br>
  <br>
Oliver Kania wrote:
  <blockquote
 cite="mid:e22fb1100801220635r55ced7bepaf9f5791e00786cd@mail.gmail.com"
 type="cite">
    <div id="mb_0">Hello !<br>
Can someone provide a step by step guide on<br>
writing a custom image loader.<br>
We basically have 2D-point data with values attached to each point. <br>
    <div><br>
    <br>
Best regards, Oliver<br>
    </div>
    </div>
    <pre wrap=""><hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: <a
 moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
 href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
  </pre>
  </blockquote>
  <br>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: <a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a>
Follow this link to subscribe/unsubscribe:
<a class="moz-txt-link-freetext" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a>
  </pre>
</blockquote>
<br>
</body>
</html>