[vtkusers] Slicing 3D graphical model

Wagner Sales wsales at gmail.com
Tue Dec 4 13:22:15 EST 2007


Hi Hala,

I don't know about the conversion to import others formats in VTK.
But slice extraction aren't a difficult task.
Take a look at the class vtkImageReslice.
The following pieces of code are in C++ and can helps you to extract the
slices.

//create the matrices
double transversalElements[16] = {
           1, 0, 0, 0,
           0, 1, 0, 0,
           0, 0, 1, 0,
           0, 0, 0, 1 };

double coronalElements[16] = {
           1, 0, 0, 0,
           0, 0, 1, 0,
           0,-1, 0, 0,
           0, 0, 0, 1 };

double sagittalElements[16] ={
           0, 0,-1, 0,
           1, 0, 0, 0,
           0,-1, 0, 0,
           0, 0, 0, 1 };


// an example of extraction in axial
//'ll assume that's the image are readed and are stored in vtkImageData
*m_CurrentImageData:
    m_CurrentImageData->UpdateInformation();
    double point[4];
    double temp[4];
    int extentT[6];
    double spacingT[3];
    m_CurrentImageData->GetSpacing(spacingT);
    m_CurrentImageData->GetExtent(extentT);
    vtkMatrix4x4 *m_Matrix = vtkMatrix4x4::New();
    m_Matrix->DeepCopy(sagittalElements);
    point[0] = 0.0;
        point[1] = 0.0;
    //sets the point to the slice to be extracted.
    point[2] = - m_CurrentImageData->GetSpacing()[1] *m_SliceNumber;

    point[3] = 1.0;
        m_Matrix->MultiplyPoint(point, temp);
        m_Matrix->SetElement(0, 3, temp[0]);
        m_Matrix->SetElement(1, 3, temp[1]);
        m_Matrix->SetElement(2, 3, temp[2]);
   vtkImageReslice *m_Reslicer =  vtkImageReslice::New();
   m_Reslicer->SetResliceAxes(m_Matrix);
    vtkImageData *m_ExtractedSlice = m_Reslicer->GetOutput();

..................

With this example and more work, I believe you'll can extract all the
slices. That's are just a piece of code, are a good idea take more care
about, for example, the slice interval.

Regards,

Wagner

2007/12/4, Hala ALBakour <haloul02 at yahoo.co.uk>:
>
>
> I am very new to 3D modelling and vtk, Actually just
> looking around to find out if vtk would solve my
> problem, I am wondering if vtk helps to extract 2D
> slice data (2D image x,y coordinates) from a 3D
> computer graphical model, originally the 3D model is
> imported from a standard file format like 3DS, so in
> any case I need a plugin which helps importing such
> file and convert it to vtk data structure,
>
> Most importantly, does vtk data structure encapsulate
> x,y,z coordinates, is it possible to extract x,y
> values at certain cut offs of z for example, what is
> the most appropriate rendering mechanism/data
> structure in vtk that supports this,
>
> Would it be easier in this case to use other low
> levels tools like OpenGL,
>
> Your help is highly appreciated,
> Please advise,
>
> Hala
>
>
>
>       __________________________________________________________
> Sent from Yahoo! - the World's favourite mail http://uk.mail.yahoo.com
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20071204/1c22da68/attachment.htm>


More information about the vtkusers mailing list