# [vtk-developers] Fwd: About constructing a 3D geographical surface

Andrew Maclean andrew.amaclean at gmail.com
Thu Oct 11 20:57:23 EDT 2007

```Even simpler, you can just use vtkParticle reader. It will read x,y,z data
along with a scalar.

Here is the code I use. Note it writes out a .vtp file that can be used for
further processing in either vtk or ParaView.

Sorry for the last post, I meant to attach it!

Andrew
On 10/11/07, Soeren Gebbert <soerengebbert at googlemail.com> wrote:
>
> Hi John,
> i dont know java so i can only provide some C++ code snips.
> But i guess you can do something like this:
>
> double x, y, z, value;
> vtkIdList *ids = vtkIdList::New();
> vtkPoints *points = vtkPoints::New();
> vtkDoubleArray *values = vtkDoubleArray::New();
> values->SetNumberOfTuples(NumberOfPointsInDataset);
> values->SetNumberOfComponents(1);
> values->SetName("resistivity");
>
> for(i = 0; i < NumberOfPointsInDataset; i++)
> {
>   points->InsertPoint(i, x, y, z);
>
>   values->InsertValue(i, value);
>
>   //Create point ids for the cells
>   ids->InsertNextId(i);
> }
>
> // Build PolyData
> vtkPolyData *poly = vtkPolyData::New();
> poly->Allocate(NumberOfPointsInDataset);
> poly->SetPoints(points);
> points->Delete();
> poly->GetPointData()->SetScalars(values);
> values->Delete();
>
> //Now build the cells. You can build triangles if you know the order
> //of your points. If you dont know the order than just create a PolyVertex
> cell to render the points in VTK
> //use the delaunay triangulator: to triangluate the data
>
> poly->InsertNextCell(VTK_POLY_VERTEX, ids);
> ids->Delete();
> poly->Sqeeze();
>
> //Now use the delaunay triangulator to triangulate the poly data set
> vtkDelaunay2d ....
>
> //The code is untested and without any warranty :)
>
> //END
>
> References:
> http://www.vtk.org/doc/release/5.0/html/a01872.html
> http://www.vtk.org/doc/release/5.0/html/a01335.html
> http://www.vtk.org/doc/release/5.0/html/a01867.html
> http://www.vtk.org/doc/release/5.0/html/a01322.html
> http://www.vtk.org/doc/release/5.0/html/a01880.html
>
> Best regards
> Soeren
>
> 2007/10/11, John Ownsoul <mongwarrior at yahoo.com>:
> >
> >
> > Hi Soeran;
> >
> > Thanks for your attention and help. I can write my own program to map
> > the
> > geographical data to java. But, what must i do after than getting the
> > values
> > and coordinates? Could you send me a sample code or a reference about
> > this?
> > Thanks again; (I want to use only java and vtk)
> >
> > Best regards;
> >
> > John Ownsoul
> >
> >
> >
> >
> >
> >
> >
> >
> > Soeren Gebbert-2 wrote:
> > >
> > > Hi John,
> > > just an idea. If you have geographical data which you want to
> > visualize
> > > with
> > > vtk
> > > than try the combination of the gis grass and paraview. There are many
> > > options
> > > in grass to get your x,y,z ascii data into it. You can process the
> > data
> > > there and export it with the grass module r.out.vtk into the vtk
> > format to
> > > visualize
> > > the data with paraview, visit or mayavi.
> > >
> > > Or you can build in java a poly dataset with x,y,z point coordinates
> > > connected with triangles to
> > > each other and store the resistivity values in an point data double
> > array.
> > > If you have
> > > an ordered point set the triangulation should be no problem.
> > > AFAIC you have to import the data with your own program. There is no
> > > x,y,z,value import module in vtk. But im not sure.
> > >
> > > Best regards
> > > soeren
> > >
> > > Link to grass:
> > > grass.itc.it
> > >
> > > Link to some grass/vtk modules and related stuff:
> > > www-pool.math.tu-berlin.de/~soeren/grass/modules<http://www-pool.math.tu-berlin.de/%7Esoeren/grass/modules
> > <http://www-pool.math.tu-berlin.de/~soeren/grass/modules>>
> > >
> > > 2007/10/11, John Ownsoul <mongwarrior at yahoo.com>:
> > >>
> > >>
> > >> Dear Fellows;
> > >>
> > >> I have some data about a geographical surface, and i want to show an
> > >> image
> > >> in VTK (with Java).
> > >> But i am a beginner, so i don't know the syntax very well. I practice
> > >> with
> > >> VTK, but i don't know the file operations. Could you help me to
> > construct
> > >> the file and show the image in vtk??
> > >>
> > >> I use these datas at the below:
> > >>
> > >> x(m)   y(m)   z(m)    resistivity value(ohm.m)
> > >> 2        1    -1,406           204,934
> > >> 3        1    -1,406           108,021
> > >> 4        1    -1,406             62,275
> > >> 5        1    -1,406             47,608
> > >>                     ...
> > >>
> > >>
> > >> Thanks for everything...
> > >>
> > >> --
> > >> View this message in context:
> >
> > >> Sent from the VTK - Dev mailing list archive at Nabble.com<http://nabble.com/>
> > .
> > >>
> > >> _______________________________________________
> > >> vtk-developers mailing list
> > >> vtk-developers at vtk.org
> > >> http://www.vtk.org/mailman/listinfo/vtk-developers
> > >>
> > >
> > > _______________________________________________
> > > vtk-developers mailing list
> > > vtk-developers at vtk.org
> > > http://www.vtk.org/mailman/listinfo/vtk-developers
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/About-constructing-a-3D-geographical-surface-tf4605431.html#a13152207
> >
> > Sent from the VTK - Dev mailing list archive at Nabble.com<http://nabble.com/>
> > .
> >
> > _______________________________________________
> > vtk-developers mailing list
> > vtk-developers at vtk.org
> > http://www.vtk.org/mailman/listinfo/vtk-developers
> >
>
>
> _______________________________________________
> vtk-developers mailing list
> vtk-developers at vtk.org
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>

--
___________________________________________
Andrew J. P. Maclean
Centre for Autonomous Systems
The Rose Street Building J04
The University of Sydney  2006  NSW
AUSTRALIA
Ph: +61 2 9351 3283
Fax: +61 2 9351 7474
URL: http://www.acfr.usyd.edu.au/
___________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20071012/31bd475d/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...