[vtkusers] About drawing a cube

Rong Xu xurong1981 at gmail.com
Wed Apr 18 09:05:27 EDT 2012


I use the following codes.

int v1,v2, v3;  //* are the vertices of the n cubes i want to draw.
v1 = v2 = v3 = 0;
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} };

vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();

for (int i = 0; i < pointCloud.size(); i++)
{
    points->InsertNextPoint(x[i]);
}

vtkSmartPointer<vtkCubeSource> cubeSource =
vtkSmartPointer<vtkCubeSource>::New();
cubeSource->GetOutput()->SetPoints(points);
//cubeSource->GetOutput()->Update();
cubeSource->Update();

ÔÚ 2012Äê4ÔÂ18ÈÕ ÏÂÎç9:50£¬Rong Xu <xurong1981 at gmail.com>дµÀ£º

>
>
> ÔÚ 2012Äê4ÔÂ18ÈÕ ÏÂÎç9:46£¬Jothybasu Selvaraj <jothybasu at gmail.com>дµÀ£º
>
> Did you call cubeSource->Update() ?
>>
>
> Yes, I have called cubeSource->Update().
>
>
>>
>> Jothy
>>
>> 2012/4/18 Rong Xu <xurong1981 at gmail.com>
>>
>>>  Dear David Doria :
>>>
>>> 2012/4/18 David Doria <daviddoria at gmail.com>
>>>
>>>> 2012/4/18 Jothybasu Selvaraj <jothybasu at gmail.com>
>>>>
>>>>> Look at this
>>>>>
>>>>> http://www.vtk.org/Wiki/VTK/Examples/Cxx/GeometricObjects/Cube
>>>>>
>>>>> SetDimesions and SetOrigin should do what you need.
>>>>>
>>>>> Jothy
>>>>>
>>>>
>>>> Additionally, you can use the vtkCubeSource to setup the topology
>>>> (connectivity), then use
>>>>
>>>> vtkPoints* points = vtkPoints::New();
>>>>
>>>> points->InsertNextPoint(x,y,z);
>>>> // ... do this 8 times for your 8 points...
>>>>
>>>> cubeSource->GetOutput()->SetPoints(points);
>>>>
>>>
>>> Thank you for your help!
>>>
>>> But I used "cubeSource->GetOutput()->SetPoints(points);" that you
>>> introduced, the cube created still has default attributes. Do you have any
>>> ideas ?
>>>
>>>
>>>>
>>>> David
>>>>
>>>
>>>
>>>
>>> --
>>>
>>> ---------------------
>>> Best Regards!
>>>
>>> ===============================================
>>> Rong Xu,  Ph.D Student
>>> Ohya Lab
>>> Graduate School of Global Information and Telecommunication
>>> Studies (GITS), Waseda University
>>> 1-6-1 Nishi Waseda, Shinjuku-ku, Tokyo, Japan (¨“169-8050)
>>>
>>> Tel:          +81-80-4208-1207
>>> E-mail:     xurong1981 at gmail.com
>>>                xurong at fuji.waseda.jp
>>> ===============================================
>>>
>>>
>>> _______________________________________________
>>> Powered by www.kitware.com
>>>
>>> Visit other Kitware open-source projects at
>>> http://www.kitware.com/opensource/opensource.html
>>>
>>> Please keep messages on-topic and check the VTK FAQ at:
>>> http://www.vtk.org/Wiki/VTK_FAQ
>>>
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>
>>>
>>
>>
>> --
>> Jothy
>>
>>
>
>
> --
>
> ---------------------
> Best Regards!
>
> ===============================================
> Rong Xu,  Ph.D Student
> Ohya Lab
> Graduate School of Global Information and Telecommunication
> Studies (GITS), Waseda University
> 1-6-1 Nishi Waseda, Shinjuku-ku, Tokyo, Japan (¨“169-8050)
>
> Tel:          +81-80-4208-1207
> E-mail:     xurong1981 at gmail.com
>                xurong at fuji.waseda.jp
> ===============================================
>
>


-- 

---------------------
Best Regards!

===============================================
Rong Xu,  Ph.D Student
Ohya Lab
Graduate School of Global Information and Telecommunication
Studies (GITS), Waseda University
1-6-1 Nishi Waseda, Shinjuku-ku, Tokyo, Japan (¨“169-8050)

Tel:          +81-80-4208-1207
E-mail:     xurong1981 at gmail.com
               xurong at fuji.waseda.jp
===============================================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120418/2a4cd620/attachment.htm>


More information about the vtkusers mailing list