[vtkusers] Basic question about different coordinates

posii posii at o2.pl
Tue Oct 26 16:45:18 EDT 2010


Hello All,

I have worked a little bit on my problem and I have produced such solution:

          void translateCoordinateArrayToView(double* xyz, double *sizes)
          {
              xyz[0] = xyz[0] - sizes[0]/2;
              double tmp = xyz[1];
              xyz[1] = xyz[2] - sizes[2]/2;
              xyz[2] = sizes[1]/2 - tmp;
          }

          ...
          
          {
                ... //see previous message

                double dataSize[3] = {200,200,200}; //dimension of myArray x,y,z respectively
                double coordinates[3] = {123,160,20}; //x, y, z of my voxel in myArray
                translateCoordinateArrayToView(coordinates, dataSize); // my translate function

                plane->SetCenter(coordinates[0],coordinates[1],coordinates[2]); 
                
                ... //see previous message
           }

When I run the program my circle (plane) is at good position (I think it is). 
What do you think about this strategy? Is it correct and reliable?  

If it is ok then maybe my code will help someone else.

Best regards,
Michal


Dnia 26 października 2010 15:40 posii <posii at o2.pl> napisał(a):

> 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
> _______________________________________________
> 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
> 



More information about the vtkusers mailing list