[vtkusers] Locating a 3D position in 3D scheme from a XYZ coordinates

Dean Inglis dean.inglis at camris.ca
Wed Sep 3 07:26:22 EDT 2008


Hi Wagner,

 

sorry, incomplete message accidentally got sent:

 

dummyCoords (pcoords method parameter) needs to be passed

through the calling window but you don't need to use it.  Another

way to calculate xyz coords (for example, x):

double* spacing = m_ImageData->GetSpacing();

double* origin = m_ImageData->GetOrigin();

x = m_coords[0]*spacing[0] + origin[0];

 

although the method below should work.

 

Dean

 

 

Hi Dean,

My point are defined in int XYZ, which Z are my slice, and XY the simple
pixel coordinate. Are no interpolation here. This points are used to
segment, works fine.
Bu I need to show this points on 3D. The only way that's I know until now
are the celllocation by vtkCell::EvaluateLocation. But are crashing, and I
think are thread problem since this method aren't thread safe. I tried with
the thread safe method too, and are not working. Based on your sugestion, I
tried the second option, which appears to be the correct to my case:

    double dummyCoords[3];
    int mCoords[3] = { m_XPosition, m_YPosition, m_ZPosition };
    int ret = m_ImageData->ComputeStructuredCoordinates(viewCordinates,
mCoords, dummyCoords);
    if(ret >0 )
    {
        std::cout << "Point inside. Coords are: " << viewCordinates[0] << ",
" << viewCordinates[1] << ", " << viewCordinates[2] << endl;
    } else {
        std::cout << "Point outside of volume" << endl;
    }

Well, the point are always outside of the volume. dummyCoords ( pcoords
method parameter ) don't needs to be calculated?

Regards,

Wagner Sales

2008/9/1 Dean Inglis <dean.inglis at sympatico.ca>

Hi Wagner,

 

how are m_XPosition, m_YPosition, m_ZPosition defined?

 

Given a 3D double precision 3D spatial point:

 

vktIdType id = m_CurrentImageData->FindPoint(xyzCoords)

if(id > -1)

{

//do what you need to do with the point: it's valid!

}

 

if you have integer ijk indices:

 

double queryPoint[3];

double dummyPcoords[3];

if(m_CurrentImageData->ComputeStructuredCoordinates(queryPoint,myijkindices,
dummyPcoords) == 1)

{

//the ijk indices refer to a point in the 3D image volume and you have a
valid 3D point

//otherwise, try with different ijk indices

}

 

HTH

Dean

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080903/19e1cc9a/attachment.htm>


More information about the vtkusers mailing list