multi-objects in VTK; loop-Problem

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

multi-objects in VTK; loop-Problem

Fabian
Hi everyone,

I am quite new in VTK so this might be an easy question:

I want to write a program, that shows me a specified number of polygons (lets say 1000).
For some reasons I need different ojects. So I thought of rendering 500 planes (2 polygons each).

So i would like to create a loop that works like this (of course this is pseudocode):

- loop (for i < 500)
- create a vtk-plane with vtkplanesource with the name plane#i (plane1, plane2, plane3,...plane500)
- i++

Unfortunately I cannot manage this problem.

Any help is appreciated, THANK YOU,
Fabian

[Windows 7, MS Visual Studio 2010]
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Dženan Zukić
Have you considered using an array of planes? So instead of plane1, plane2 etc you have plane[1], plane[500]?

On Mon, Aug 15, 2011 at 12:57, Fabian <[hidden email]> wrote:
Hi everyone,

I am quite new in VTK so this might be an easy question:

I want to write a program, that shows me a specified number of polygons
(lets say 1000).
For some reasons I need different ojects. So I thought of rendering 500
planes (2 polygons each).

So i would like to create a loop that works like this (of course this is
pseudocode):

- loop (for i < 500)
- create a vtk-plane with vtkplanesource with the name plane#i (plane1,
plane2, plane3,...plane500)
- i++

Unfortunately I cannot manage this problem.

Any help is appreciated, THANK YOU,
Fabian

[Windows 7, MS Visual Studio 2010]

--
View this message in context: http://vtk.1045678.n5.nabble.com/multi-objects-in-VTK-loop-Problem-tp4700582p4700582.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Fabian
Hi,

yes I tried. But the line

vtkPlaneSource *plane[i] = vtkPlaneSource::New();

caused trouble.

This is a part of the code:

int main()
{
        int plane[500];

        int i;
         for (i = 0; i < 499; ++i)
        {
          plane[i]=i+1;
          vtkPlaneSource *plane[i] = vtkPlaneSource::New();
        }
  system("PAUSE"); //Just a check for me
return 0;
}
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Jothy
I feel it would be better to use std::vector<vtkPlaneSource>planes.

Then create a plane and add to the vector using push_back.

HTH

Jothy

On Mon, Aug 15, 2011 at 1:47 PM, Fabian <[hidden email]> wrote:
Hi,

yes I tried. But the line

vtkPlaneSource *plane[i] = vtkPlaneSource::New();

caused trouble.

This is a part of the code:

int main()
{
       int plane[500];

       int i;
        for (i = 0; i < 499; ++i)
       {
         plane[i]=i+1;
         vtkPlaneSource *plane[i] = vtkPlaneSource::New();
       }
 system("PAUSE"); //Just a check for me
return 0;
}

--
View this message in context: http://vtk.1045678.n5.nabble.com/multi-objects-in-VTK-loop-Problem-tp4700582p4700838.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Fabian
Thank You for your ideas!

But *ashamed* I dont know how to do implement this or how to use push back :((

I searched for some hints on the web but didnt find fast help.

Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Jothy
It's simple

#include<vector>

std::vector<vtkPlaneSource>planeList;

for(i=0;i<10;i++)
{

vtkPlaneSource *plane=vtkPlaneSource::New();
//Do whatever you want
planeList.push_back(plane);

}

If you want to acess the plane, you could do it by

planeList[i]->GetOrigin();//For instance

Neither I am a c++ expert, just started a copule of months ago!

HTH

Jothy



On Mon, Aug 15, 2011 at 2:21 PM, Fabian <[hidden email]> wrote:
Thank You for your ideas!

But *ashamed* I dont know how to do implement this or how to use push back
:((

I searched for some hints on the web but didnt find fast help.



--
View this message in context: http://vtk.1045678.n5.nabble.com/multi-objects-in-VTK-loop-Problem-tp4700582p4700989.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Fabian
This post has NOT been accepted by the mailing list yet.
Thank You very much.

It still is not working properly....but that might be due to my skills ^^

Tomorrow i will try again :))

Thanks alot!
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Martijn de Greef
In reply to this post by Jothy
Just a small addition (you would probably figure yourself as well):

std::vector<vtkPlaneSource> planeList;

should be:

std::vector<vtkPlaneSource*> planeList;

Martijn

2011/8/15 Jothy <[hidden email]>
It's simple

#include<vector>

std::vector<vtkPlaneSource>planeList;

for(i=0;i<10;i++)
{

vtkPlaneSource *plane=vtkPlaneSource::New();
//Do whatever you want
planeList.push_back(plane);

}

If you want to acess the plane, you could do it by

planeList[i]->GetOrigin();//For instance

Neither I am a c++ expert, just started a copule of months ago!

HTH

Jothy




On Mon, Aug 15, 2011 at 2:21 PM, Fabian <[hidden email]> wrote:
Thank You for your ideas!

But *ashamed* I dont know how to do implement this or how to use push back
:((

I searched for some hints on the web but didnt find fast help.



--
View this message in context: http://vtk.1045678.n5.nabble.com/multi-objects-in-VTK-loop-Problem-tp4700582p4700989.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
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


_______________________________________________
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



_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: multi-objects in VTK; loop-Problem

Fabian
THANKS!!!

This helped me very much! And it would have taken me hours to add the *! This was very useful!