No subject


Tue Apr 8 17:34:44 EDT 2008


vtk.vtkPoints() to create the point data, which was then added to the
vtk.vtkPolyData() object.  Should I replace the use of vtk.vtkPoints() with
vtk.vtkPointData()?  Perhaps these objects are complementary, so I should
use both?

### BEGIN SNIP
           # put data into vtk data structure
            points = vtk.vtkPoints()
            points.SetNumberOfPoints(nVert)
            for i in range(nVert):
                v = self.vert['xyz'][i]
                points.SetPoint(i, v[0], v[1], v[2])

            faces = vtk.vtkCellArray()
            faces.Allocate(nFace, 1)
            for i in range(nFace):
                fv = self.face['vertex'][i]
                faces.InsertNextCell(3)
                # double check the order of vertices for vtk outward normals
                faces.InsertCellPoint(fv[0])
                faces.InsertCellPoint(fv[1])
                faces.InsertCellPoint(fv[2])

            vtkSurf = vtk.vtkPolyData()
            vtkSurf.SetPoints(points)
            vtkSurf.SetPolys(faces)
### END SNIP


Thanks in advance, Darren (Noob)

------=_Part_13214_28620436.1209916839050
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<br><br><div class="gmail_quote">On Sat, May 3, 2008 at 9:16 PM, T.R.Shashwath &lt;<a href="mailto:trshash84 at gmail.com">trshash84 at gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div></div><div class="Wj3C7c">On Saturday 03 May 2008 20:58:51 Darren Weber wrote:<br>
&gt; I have a closed surface where the faces contain triangles of the points,<br>
&gt; eg:<br>
&gt;<br>
&gt; vtkSurf = vtk.vtkPolyData()<br>
&gt; vtkSurf.SetPoints(points)<br>
&gt; vtkSurf.SetPolys(faces)<br>
&gt;<br>
&gt; I also have a time-series of scalar values for every point. &nbsp;How do I<br>
&gt; display one time-point with a reasonable colormap? &nbsp;How do I create a loop<br>
&gt; that changes the point values that map into the colormap?<br>
&gt;<br>
&gt; Thanks in advance, Darren<br>
<br>
</div></div>Hi,<br>
<br>
You&#39;ll have to create a vtkPointData instance to add to your surface. You can<br>
assign the scalar values of each point to that point data, and turn on scalar<br>
color mode in the poly data mapper. That will display one time-point. If you<br>
want to do an animation of the time-series, just replace all the point values<br>
again.<br>
<br>
-- Shash<br>
</blockquote><div><br><br>From the longer snip of my code below, you can see that I used vtk.vtkPoints() to create the point data, which was then added to the vtk.vtkPolyData() object.&nbsp; Should I replace the use of vtk.vtkPoints() with vtk.vtkPointData()?&nbsp; Perhaps these objects are complementary, so I should use both?<br>
<br>### BEGIN SNIP<br><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # put data into vtk data structure</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points = vtk.vtkPoints()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points.SetNumberOfPoints(nVert)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i in range(nVert):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v = self.vert[&#39;xyz&#39;][i]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points.SetPoint(i, v[0], v[1], v[2])</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; faces = vtk.vtkCellArray()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; faces.Allocate(nFace, 1)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i in range(nFace):</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fv = self.face[&#39;vertex&#39;][i]</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; faces.InsertNextCell(3)</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # double check the order of vertices for vtk outward normals</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; faces.InsertCellPoint(fv[0])</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; faces.InsertCellPoint(fv[1])</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; faces.InsertCellPoint(fv[2])</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSurf = vtk.vtkPolyData()</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSurf.SetPoints(points)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vtkSurf.SetPolys(faces)</span><br style="font-family: courier new,monospace;">
### END SNIP<br>
<span style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;"><br>Thanks in advance, Darren (Noob)<br><br></div></div>

------=_Part_13214_28620436.1209916839050--


More information about the vtkusers mailing list