[vtkusers] Creating an Isosurface

Daniel Thorpe dt.mailinglists at mac.com
Tue Aug 14 08:49:08 EDT 2007


Hi, I'm pretty new to VTK, and my book hasn't arrived yet, however  
I'm under a bit of pressure to get this task finished, so any help is  
really appreciated....

I have some weather data such as air temperature for a number of  
points across a country (so it's an unstructured grid), this data is  
retrieved from a database by my application (which is an OS X Cocoa  
app, using Obj-C/++). For each point I have a northing, easting and  
elevation, so x,y,z. I'm trying to plot some sort of isosurface, I've  
written some code which I think puts my data into a  
vtkUnstructuredGrid, which is pasted below.

- (vtkDataSet *)samplesAsVTKDataSet {
	
	vtkPoints		*newPts		= vtkPoints::New();
	vtkDoubleArray	*newScalars = vtkDoubleArray::New();
	PointValue		*point; // this is a class representing a value  
associated with a coordinate
	double xyz[2];
	int i, length = [samples count];

	for(i=0; i<length; i++) {
		point = [samples objectAtIndex:i];
		xyz[0] = [[point north] doubleValue];
		xyz[1] = [[point east] doubleValue];
		xyz[2] = [[point elev] doubleValue];
		newPts->InsertPoint(i,xyz);
		newScalars->InsertValue(i, [[point value] doubleValue]);
	}
	
	vtkUnstructuredGrid	*dataSet = vtkUnstructuredGrid::New();	
	dataSet->SetPoints(newPts);
	dataSet->GetPointData()->SetScalars(newScalars);

	newPts->Delete();
	newScalars->Delete();	
	
	return dataSet;
}

Now, I'm a little stuck, I think I need to create a vtkDataSetMapper,  
or maybe some sort of Filter - as I'm guessing somewhere in the  
pipeline I've got to define how vtk should interpolate between the  
points?

Anyway, if someone can point in the right direction that would be great.

Cheers
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070814/c368e34c/attachment.htm>


More information about the vtkusers mailing list