[vtkusers] shapefile reader

Malcolm Drummond malcolm at geovision.co.za
Thu Apr 15 04:44:24 EDT 2004


Hi Christopher

I haven't tested with Java wrappers, currently wraps Python and Tcl OK.
Here's the (unfinished) code, it's ready to go in the Hybrid directory. It
will handle filled polygons once I get the tessellation stuff in - hope to
do that next weekend (taking me a bit longer than I thought ;).

You can optionally get a subset of the shapes (based on record nos, eg.
result of database query) by passing the filter an IdList (NB. record nos
start at 1) - if you don't pass it a list it creates one internally and
populates with _all_ record nos. NB because of this feature, the index file
(.shx) is required. You can optionally generate record nos as cell-scalars
so you can map into attribute-data downstream (also for picking - get record
no through cell id). I've still got to implement tessellation of Polygons
(there is an option for filled or outlined in case you just want to do an
overlay) and also tessellation of MultiPatch (ie. the ring parts 2,3,4,5 -
strips and fans are handled OK). Also still to come is inclusion of M values
as point scalars.

I found a couple more types - currently tested with Point, PolyLine,
Polygon, PolygonZ and Multipatch. Any other  types for testing would be much
appreciated.

Anyway, try a build/Java-wrap and let me know how it goes. I'm still working
with VTK 4.2 but I think this should be OK with 4.4 as well.

Regards
Malcolm

----- Original Message -----
From: "Christopher M. Navarro" <cnavarro at ncsa.uiuc.edu>
To: "Malcolm Drummond" <malcolm at geovision.co.za>
Sent: Thursday, April 15, 2004 12:28 AM
Subject: Re: [vtkusers] shapefile reader



Hi Malcolm,

I am very interested in a vtk shapefile reader and have a couple of
questions for you.  First, will the c++ class create java wrappers if
included in the vtk build?  If it will, have you been able to fill in the
polygons to create a 2d filled polygon map of a polygonal shapefiles?
I've got a java class that can read the shapefile stuff, written by
someone here, that I use to read in the polygon data and then pass it off
to vtk to draw, but when I read in a polygon shapefile and use vtkPolygon
instead of vtkPolyLine, the polygons have black spots and flicker when the
world is rotated.  Have you experienced this, and if you have, have you
found a workaround?  I'm very interested to hear your progress.

regards,

chris

On Wed, 7 Apr 2004, Malcolm Drummond wrote:

> Hi
>
> I've implemented a shapefile reader in Python as a vtkProgrammableSource
which I'm planning to redo in C++ as a vtkPolyDataSource sometime over the
Easter break. Problem is I only have files of type 1,3 and 5 (point,
polyline and polygon) so currently I only have methods to reliably read
these types. If anyone has multipatch shapefiles or shapefiles containing Z
and/or optional M (measurement) data that I can use for development and
testing PLEASE, PLEASE send me some (ie. anything other than vanilla point,
polyline and polygon).
>
> I'm going to make the reader freely available - I'll put in the vtk
copyright etc. so if it's up to scratch (or can be made so) and the folk at
VTK want to include it, I'll be more than happy.
>
> For any potential-users / interested-parties here's my thinking so far ...
> uses separate method to read each main type (point, polyline, polygon,
multipart - chosen after parsing the header) -hopefully if the format is
extended (or as I get new types for the first time) it lessens impact on
existing code. If present, Z data will be included in the points (otherwise
Z = 0.0), M data as scalars in point-data. The id (record number) will be
included as scalars in cell-data (facilitating look-ups into attribute-data
on picking etc.). Polygons will require tessellation - I'm currently
favouring the GLU built-in tessellator as it can handle the multipart
polygons as is. For flexibility I think importing of attribute-data should
be a separate issue - merging with attribute-data can take part down-stream
if required. I was thinking a dBase reader could be provided later as a
vtkDataObjectSource for those who don't want to connect to a database. Same
goes for the shx indexing files - can provide reader later if need arises
(provides position in shapefile !
 of shape record based on id).
>
> Any suggestions or disagreements most welcome.
> Also, if there already is a reader and I've missed it, I'd rather feel
stupid now than later.
>
> Regards
> Malcolm Drummond
> GeoVision cc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkShapefileReader.h
Type: application/octet-stream
Size: 3711 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040415/dfcceb6f/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkShapefileReader.cxx
Type: application/octet-stream
Size: 16620 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20040415/dfcceb6f/attachment-0001.obj>


More information about the vtkusers mailing list