<!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">
Daniel you can pass the unstructured grid through the contour filter
however it wont work if your unstructured grid doesn't have cells
defined. Cells tell vtk how points are connected, the contouring
algorithms need the information. for instance marching cubes uses
interpolations along cell edges to construct contours.<br>
<br>
Daniel Thorpe wrote:
<blockquote cite="mid213CF628-71FD-4D25-BA14-4396F9B51F63@mac.com"
type="cite">
<div>Burlen, thanks for the quick response!</div>
<div><br class="khtml-block-placeholder">
</div>
I've just been looking at the vtkContourFilter - can't I just pass in a
vtkUnstructuredGrid? Because its SetInput function expects a
vtkDataSet, which is the superclass of a vtkUnstructuredGrid?
<div><br class="khtml-block-placeholder">
</div>
<div>Anyway, I'll look into a probe filter and see what happens -
thanks....</div>
<div><br class="khtml-block-placeholder">
</div>
<div><br>
<div>
<div>On 14 Aug 2007, at 14:27, burlen wrote:</div>
<br class="Apple-interchange-newline">
<blockquote type="cite"> You do need to create some geometry for your
dataset if you want use the vtkContourFilter to create iso surfaces.
which means you have to add cells to your dataset not just points. the
cells tell vtk how the points connect to one another. Two option that
you have are to do this manually by adding cells, or you could use a
probe filter. If your points all have a different elevation then they
all lie between two clipped spherical shells the inner shell with the
radius of the lowest elevation and the outer a shell with the radius of
the highest elevation. You could create a dataset with
vtkStructuredGrid(topologically regular but geometrically irregular)
and probe your unstructured data with it. The result is that vtk will
interpolate to nodes of the new structured grid, which has cells
defined implicitly. Then you can use all of vtks filters on the result.
hope it helps<br>
<pre class="moz-signature" cols="72">--
Burlen Loring
Information Technologist III
Space Science Center
Institute for the Study of Earth, Oceans, and Space
University of New Hampshire
39 College Road, Durham, NH 03824
Phone: 603-862-1140</pre>
<br>
<br>
Daniel Thorpe wrote:
<blockquote cite="midED2AA52F-3E9A-4A0C-B300-7C7E9EF0B74C@mac.com"
type="cite">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....
<div><br class="khtml-block-placeholder">
</div>
<div>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.</div>
<div><br class="khtml-block-placeholder">
</div>
<div style="margin: 0px;"><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">- (vtkDataSet *)samplesAsVTKDataSet {</span></font></div>
<div style="margin: 0px; min-height: 14px;"><span
class="Apple-tab-span" style="white-space: pre;"> </span><br
class="khtml-block-placeholder">
</div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">vtkPoints</span></font><span
class="Apple-tab-span" style="white-space: pre;"> </span><span
class="Apple-tab-span" style="white-space: pre;"> </span><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">*newPts</span></font><span
class="Apple-tab-span" style="white-space: pre;"> </span><span
class="Apple-tab-span" style="white-space: pre;"> </span><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">= vtkPoints::New();</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">vtkDoubleArray</span></font><span
class="Apple-tab-span" style="white-space: pre;"> </span><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">*newScalars =
vtkDoubleArray::New();</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">PointValue</span></font><span
class="Apple-tab-span" style="white-space: pre;"> </span><span
class="Apple-tab-span" style="white-space: pre;"> </span><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">*point; // this is a
class representing a value associated with a coordinate</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
color="#760f50" face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">double</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;"> xyz[</span></font><font
class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">2</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">];</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
color="#760f50" face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">int</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;"> i, length =
[samples count]; </span></font></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"><br>
</div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
color="#760f50" face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">for</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">(i=</span></font><font
class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">0</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">; i<length; i++) {</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">point = [samples objectAtIndex:i];</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">xyz[</span></font><font
class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">0</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">] = [[point north]
doubleValue];</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">xyz[</span></font><font
class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">1</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">] = [[point east]
doubleValue];</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">xyz[</span></font><font
class="Apple-style-span" color="#0000ff" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">2</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">] = [[point elev]
doubleValue];</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">newPts->InsertPoint(i,xyz);</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">newScalars->InsertValue(i, [[point value]
doubleValue]);</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">}</span></font></div>
<div style="margin: 0px; min-height: 14px;"><span
class="Apple-tab-span" style="white-space: pre;"> </span><br
class="khtml-block-placeholder">
</div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">vtkUnstructuredGrid</span></font><span
class="Apple-tab-span" style="white-space: pre;"> </span><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;">*dataSet =
vtkUnstructuredGrid::New();</span></font><span class="Apple-tab-span"
style="white-space: pre;"> </span></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">dataSet->SetPoints(newPts);</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">dataSet->GetPointData()->SetScalars(newScalars);</span></font></div>
<div
style="margin: 0px; font-family: Monaco; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10px; line-height: normal; font-size-adjust: none; font-stretch: normal; min-height: 14px;"><br>
</div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">newPts->Delete();</span></font></div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">newScalars->Delete();</span></font><span
class="Apple-tab-span" style="white-space: pre;"> </span></div>
<div style="margin: 0px; min-height: 14px;"><span
class="Apple-tab-span" style="white-space: pre;"> </span><br
class="khtml-block-placeholder">
</div>
<div style="margin: 0px;"><span class="Apple-tab-span"
style="white-space: pre;"> </span><font class="Apple-style-span"
color="#760f50" face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">return</span></font><font
class="Apple-style-span" face="Monaco" size="2"><span
class="Apple-style-span" style="font-size: 10px;"> dataSet;</span></font></div>
<div style="margin: 0px;"><font class="Apple-style-span"
face="Monaco" size="2"><span class="Apple-style-span"
style="font-size: 10px;">}</span></font></div>
<div style="margin: 0px;"><br class="khtml-block-placeholder">
</div>
<div style="margin: 0px;">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?</div>
<div style="margin: 0px;"><br class="khtml-block-placeholder">
</div>
<div style="margin: 0px;">Anyway, if someone can point in the
right direction that would be great.</div>
<div style="margin: 0px;"><br class="khtml-block-placeholder">
</div>
<div style="margin: 0px;">Cheers</div>
<div style="margin: 0px;">Dan</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
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>
</blockquote>
</div>
<br>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Burlen Loring
Information Technologist III
Space Science Center
Institute for the Study of Earth, Oceans, and Space
University of New Hampshire
39 College Road, Durham, NH 03824
Phone: 603-862-1140</pre>
</body>
</html>