[vtkusers] Basic question about different coordinates

posii posii at o2.pl
Tue Oct 26 09:40:27 EDT 2010


Hello!

I have simple problem with coordinates system in VTK. I have two files: the first is .vtk file with polyData and the second is binary .raw file (for example with size 200x200x200). In booth files I have the same object (.vtk file is prepared from .raw data by using marching cubes algorithm). Now I would like to visualize polyData for instance I have used code like this: 

        {
                // object
                vtkPolyDataReader *p_reader = vtkPolyDataReader::New();
                p_reader->SetFileName("object.vtk");
                p_reader->Update();
                vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
                mapper->SetInputConnection(p_reader->GetOutputPort());
                vtkActor* actor = vtkActor::New();
                actor->SetMapper(mapper);
                actor->GetProperty()->SetColor(0.0,0.0,1.0);
                actor->GetProperty()->SetOpacity(0.1);
                ren[0]->AddActor(actor);
                p_reader->Delete();
        }

Next I would like to do some processing on my raw (voxel) data for example search for voxel with value 200 (I have loaded RAW data to simple 3D array of unsigned char). The program has selected voxel at coordinates x=123, y=160, z=20 (myArray[123][160][20]). 
Finally I would like to draw on the same render as before (ren[0]) circle(plane) with radius=10, normal vector perpendicular to axis Z (in my array), and centred on voxel from previously step (123,160,20). For instance code can look like this:

             {   
                vtkPolyDataMapper* mapper1 = vtkPolyDataMapper::New();
                vtkRegularPolygonSource *plane = vtkRegularPolygonSource::New();
                
              
                plane->SetCenter(123,160,20);
                plane->SetNormal(0,0,1);
                plane->SetRadius(10);
                plane->SetNumberOfSides(30);

                mapper1->SetInputConnection(plane->GetOutputPort());
                vtkActor* actor1 = vtkActor::New();
                actor1->SetMapper(mapper1);
                actor1->GetProperty()->SetColor(0.0,1.0,0.0);
                actor1->GetProperty()->SetOpacity(1);
                ren[0]->AddActor(actor1);
                plane->Delete();
             }

Obviously, methods "plane->SetCenter(123,160,20);" and "plane->SetNormal(0,0,1);" have wrong coordinates. My question is how I can define this correctly? 

Thanks for all help,
Best Regards,
Michal



More information about the vtkusers mailing list