<div class="gmail_quote">2012/4/18 Rong Xu <span dir="ltr"><<a href="mailto:xurong1981@gmail.com">xurong1981@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I use the following codes.<br><br>int v1,v2, v3; //* are the vertices of the n cubes i want to draw.<br>v1 = v2 = v3 = 0;<br>float x[8][3] = { {v1,v2,v3}, {v1+1,v2,v3}, {v1+1,v2+1,v3}, {v1,v2+1,v3}, {v1,v2,v3+1}, {v1+1,v2,v3+1}, {v1+1,v2+1,v3+1}, {v1,v2+1,v3+1} };<br>
<br>vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();<br><br>for (int i = 0; i < pointCloud.size(); i++)<br>{<br> points->InsertNextPoint(x[i]);<br>}<br><br>vtkSmartPointer<vtkCubeSource> cubeSource = vtkSmartPointer<vtkCubeSource>::New();<br>
cubeSource->GetOutput()->SetPoints(points);<br>//cubeSource->GetOutput()->Update();<br>cubeSource->Update();<br></blockquote><div><br></div><div>You'll need to do something like this:</div><div><br></div>
<a href="http://codepad.org/2ySABKkh">http://codepad.org/2ySABKkh</a><br clear="all"><br>Note the use of the vtkCleanPolyDataFilter. The reason is that the vtkCubeSource actually creates 24 points (1 for each corner of each face). This is not what you want here (or ever really...), so the clean filter merges these points so it has 8 points as you'd expect. Then you can get a pointer to the points and change one of them and see the result (the demo code I posted). Of course you can change all 8 in the same manner to get the effect you're looking for.<br>
<br>David<br></div>