Dear David Doria:<br><br><div class="gmail_quote">2012/4/18 David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div class="im">2012/4/18 Rong Xu <span dir="ltr"><<a href="mailto:xurong1981@gmail.com" target="_blank">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><div>You'll need to do something like this:</div><div><br>
</div>
<a href="http://codepad.org/2ySABKkh" target="_blank">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.<span class="HOEnZb"><font color="#888888"><br>
</font></span></div></blockquote><div><br>Thank you very much for your codes !<br><br>I have successfully realize to set the parameters of vtkCubeSource by 8 vertices based on your codes. But I encounter another problem, it seems the order of 8 vertices should be arranged correctly, otherwise, the visualized cube is not correct. About the order of vertices, do you have an easy idea to set ? Otherwise, I need to check the coordinates of 8 vertices every time and re-order them.<br>
<br>Greatly appreciate your help!<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><span class="HOEnZb"><font color="#888888">
<br>David<br></font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><br> ---------------------<br>Best Regards!<br><br>===============================================<br>Rong Xu, Ph.D Student<br>Ohya Lab<br>Graduate School of Global Information
and Telecommunication<br>Studies (GITS), Waseda University<br>1-6-1 Nishi Waseda, Shinjuku-ku,
Tokyo, Japan (¨“169-8050)<br><br>Tel: +81-80-4208-1207<br>E-mail: <a href="mailto:xurong1981@gmail.com" target="_blank">xurong1981@gmail.com</a><br> <a href="mailto:xurong@fuji.waseda.jp" target="_blank">xurong@fuji.waseda.jp</a><br>
===============================================<br><br>