[vtkusers] VTk and STL-Containers from C++
ClaudeG
claude.gangolf at gmail.com
Fri Jul 3 04:37:54 EDT 2009
Sorry , but now i have a new problem, i have created a demo-code, which you
asked to me, and in these demo-code evreything works fine, but it is written
in only one file.
In my prject i have a .h file and .cpp file and the main function is written
in a second .cpp file, could that be a problem for the compiler to read all
function, because my project is also compile but doesn't work fine.
But here is the demo-code:
// STL classes
#ifndef WIN32
#include "map.h"
#else
#include <map>
#endif
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkWindows.h"
/// map containing mappers
std::map<unsigned long, vtkPolyDataMapper *, std::less<unsigned long> >
mapper;
/// iterator for mapper
std::map<unsigned long, vtkPolyDataMapper *, std::less<unsigned long>
>::iterator mapper_pos;
/// map containing actors
std::map<unsigned long, vtkActor *, std::less<unsigned long> > actors;
/// iterator for actors
std::map<unsigned long, vtkActor *, std::less<unsigned long> >::iterator
actors_pos;
///map containing Barrel source
std::map<unsigned long, vtkCylinderSource *, std::less<unsigned long> >
cylinder;
/// iterator for mapper
std::map<unsigned long, vtkCylinderSource *, std::less<unsigned long>
>::iterator cylinder_pos;
void setup(vtkRenderer *renderer)
{
int particle_counter = 0;
for(int particle=0; particle<2; particle++)
{
cylinder[particle_counter]=vtkCylinderSource::New();
cylinder[particle_counter]->SetRadius(0.25);
cylinder[particle_counter]->SetHeight(1.);
double shift=particle+1.;
cylinder[particle_counter]->SetCenter(shift, shift, shift);
// mapper responsible for pushing the geometry into the graphics library
mapper[particle_counter] = vtkPolyDataMapper::New();
mapper[particle_counter]->SetInputConnection(cylinder[particle_counter]->GetOutputPort());
// The actor is a grouping mechanism: besides the geometry (mapper), it
// also has a property, transformation matrix, and/or texture map.
actors[particle_counter] = vtkActor::New();
actors[particle_counter]->SetMapper(mapper[particle_counter]);
renderer->AddActor(actors[particle_counter]);
particle_counter++;
}
}
void manipulate(vtkRenderer *renderer)
{
int particle_counter = 0;
for(int particle=0; particle<2; particle++)
{
actors[particle_counter]->SetPosition(0.2, 0.2, 0.3);
particle_counter++;
}
}
int main()
{
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren1);
ren1->SetBackground(1.,1.,1.);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
setup(ren1);
renWin->Render();
Sleep(2000);
manipulate(ren1);
renWin->Render();
Sleep(2000);
}
--
View this message in context: http://www.nabble.com/VTk-and-STL-Containers-from-C%2B%2B-tp24305314p24319614.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list