ouanabil | 1 Jun 10:10 2009

Fullscreen mode problem


Hi,

I'm having some trouble with the vtkRenderWindow full screen mode under 
X11. When I activate full screen mode, the window renders to full screen 
correctly, however all keyboard/mouse interaction with the window appears 
to cease, ie no further clicks/keypresses are received by the application.

hier is the code:
   typedef int PipeHandle;
   XtAppContext app_context; 
void handle_timer(vtkObject* caller, unsigned long, void* clientdata, void*)
{
    vtkRenderWindowInteractor* iren=
static_cast<vtkInteractorStyle*>(caller)->GetInteractor();
    vtkCamera* cam = reinterpret_cast<vtkCamera*>(clientdata);
    iren->CreateTimer(VTKI_TIMER_UPDATE);
    iren->Render();
    }

void handle_console_event(PipeHandle handle)
{
    static char buf[1024];
    int num_read=0;
    num_read = read(handle, buf, 1024);

    if(num_read == 5 && (strncmp("exit", buf, 4) == 0 || strncmp("quit",
buf, 4) == 0))
    {
        XtAppSetExitFlag(app_context);
(Continue reading)

Nabil El Ouazzani | 1 Jun 10:16 2009

Fullscreen mode problem


subject:Fullscreen mode problem
Hi,

I'm having some trouble with the vtkRenderWindow full screen mode under
X11. When I activate full screen mode, the window renders to full screen
correctly, however all keyboard/mouse interaction with the window appears
to cease, ie no further clicks/keypresses are received by the application.

hier is the code:
   typedef int PipeHandle;
   XtAppContext app_context;
void handle_timer(vtkObject* caller, unsigned long, void* clientdata, void*)
{
    vtkRenderWindowInteractor* iren= static_cast<vtkInteractorStyle*>(caller)->GetInteractor();
    vtkCamera* cam = reinterpret_cast<vtkCamera*>(clientdata);
    iren->CreateTimer(VTKI_TIMER_UPDATE);
    iren->Render();
    }

void handle_console_event(PipeHandle handle)
{
    static char buf[1024];
    int num_read=0;
    num_read = read(handle, buf, 1024);

    if(num_read == 5 && (strncmp("exit", buf, 4) == 0 || strncmp("quit", buf, 4) == 0))
    {
        XtAppSetExitFlag(app_context);
    }
}

static void x11_handle_console_event(XtPointer, int* pipe, XtInputId*)
{
    handle_console_event(*pipe);
}

class vtkMyCallback : public vtkCommand
{
    public:
     static vtkMyCallback *New()
     {
         return new vtkMyCallback;
     }
    
     virtual void Execute(vtkObject *caller1, unsigned long, void*)
     {
         vtkXRenderWindowInteractor *interact = reinterpret_cast<vtkXRenderWindowInteractor*>(caller1);
        
         char* key = interact->GetKeySym();
          if (*key=='g')
         {
             this->Actor->GetProperty()->SetColor(0,1,0);

         }
        
         if (*key=='b')
         {
             this->Actor->GetProperty()->SetColor(0,0,1);            
         }
        
         if (*key=='r')
         {
              this->Actor->GetProperty()->SetColor(1,0,0);             
         }

     }

    void SetActor(vtkActor *actor)
    {
        this->Actor = actor;
    }

    protected:
        vtkActor *Actor;
        vtkRenderWindow* renWin;
};

int main()
{
    XtToolkitInitialize();
    app_context = XtCreateApplicationContext();
    XtAppAddInput(app_context, fileno(stdin), (XtPointer)XtInputReadMask,x11_handle_console_event, NULL);
  
vtkRenderer* ren1 = vtkRenderer::New();
vtkRenderWindow* renWin = vtkRenderWindow::New();
   renWin->AddRenderer (ren1);

vtkXRenderWindowInteractor* iren1 = vtkXRenderWindowInteractor::New();
    iren1->SetRenderWindow(renWin);
    iren1->Initialize(app_context);
   
vtkInteractorStyleTrackballCamera *style = vtkInteractorStyleTrackballCamera::New();
    iren1->SetInteractorStyle(style);

vtkCylinderSource *cylinder1 = vtkCylinderSource::New();
     cylinder1->SetCenter(0,0,0);
     cylinder1->SetRadius(1);
     cylinder1->SetHeight(2);
     cylinder1->SetResolution(100);

    
 vtkPolyDataMapper *cylinderMapper1 = vtkPolyDataMapper::New();
    cylinderMapper1->SetInputConnection (cylinder1 ->GetOutputPort());

vtkActor *cylinderActor1 = vtkActor::New();
    cylinderActor1->SetMapper(cylinderMapper1);
    cylinderActor1->GetProperty()->SetColor(1,0,0);
    cylinderActor1->SetPosition(1,1,1);
 
    ren1->AddActor(cylinderActor1);
    ren1->SetBackground(1, 1, 1 );
    renWin->FullScreenOn();
      
vtkCamera *cam1 = vtkCamera::New();
    ren1->ResetCamera();
    cam1 = ren1->GetActiveCamera();
   
vtkCallbackCommand* callback = vtkCallbackCommand::New();
    callback->SetClientData(cam1);
    callback->SetCallback(handle_timer);
    style->AddObserver(vtkCommand::TimerEvent, callback);

vtkMyCallback *cb = vtkMyCallback::New();
    cb->SetActor(cylinderActor1);
    style->AddObserver(vtkCommand::KeyReleaseEvent ,cb);
    iren1->CreateTimer(VTKI_TIMER_FIRST);

    printf("type 'exit' to quit\n"); 
           
  while(!XtAppGetExitFlag(app_context))
  {
        float x=0,y=0,z=0;
        for( double i = 0; i<9;i++)
        {
            {x=fmod(i,6);
            y=fmod(i,3);
            z=fmod(i,9);
        }
           cylinderActor1 ->SetPosition(x,y,z);
         XtAppProcessEvent(app_context, XtIMAll);
 
        }   
  }
    return 0;
}

I am using Debian with VTK5.0, on a system with NVIDIA drivers.
Can anyone offer any suggestions as to why this is happening?

--
Cheers,
ouanabil

_______________________________________________
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
Giancarlo Amati | 1 Jun 12:24 2009
Picon

Intersection RAY and MR-polygonal surface

Hello everybody,

I have this problem: I have 2 threedimensional points defining a ray in the space. and a Surface obtained with standard marching cube from an MRI set.
Now I need to compute the intesection points between the ray and the surface!?

Is there any VTK class I can exploit?!

Very kind Regards.
GC.

Cerchi i tuoi spazi? Hotmail va oltre i 5GB. Scopri perché!
_______________________________________________
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
Francois Bertel | 1 Jun 14:23 2009

Re: Fullscreen mode problem

Hello,

I have been able to reproduce the issue with a minimal piece of code
on VTK CVS. I added a bug report:

http://www.vtk.org/Bug/view.php?id=9087

On Mon, Jun 1, 2009 at 4:16 AM, Nabil El Ouazzani
<ouanabil <at> googlemail.com> wrote:
>
> subject:Fullscreen mode problem
> Hi,
>
> I'm having some trouble with the vtkRenderWindow full screen mode under
> X11. When I activate full screen mode, the window renders to full screen
> correctly, however all keyboard/mouse interaction with the window appears
> to cease, ie no further clicks/keypresses are received by the application.
>
> hier is the code:
>    typedef int PipeHandle;
>    XtAppContext app_context;
> void handle_timer(vtkObject* caller, unsigned long, void* clientdata, void*)
> {
>     vtkRenderWindowInteractor* iren=
> static_cast<vtkInteractorStyle*>(caller)->GetInteractor();
>     vtkCamera* cam = reinterpret_cast<vtkCamera*>(clientdata);
>     iren->CreateTimer(VTKI_TIMER_UPDATE);
>     iren->Render();
>     }
>
> void handle_console_event(PipeHandle handle)
> {
>     static char buf[1024];
>     int num_read=0;
>     num_read = read(handle, buf, 1024);
>
>     if(num_read == 5 && (strncmp("exit", buf, 4) == 0 || strncmp("quit",
> buf, 4) == 0))
>     {
>         XtAppSetExitFlag(app_context);
>     }
> }
>
> static void x11_handle_console_event(XtPointer, int* pipe, XtInputId*)
> {
>     handle_console_event(*pipe);
> }
>
> class vtkMyCallback : public vtkCommand
> {
>     public:
>      static vtkMyCallback *New()
>      {
>          return new vtkMyCallback;
>      }
>
>      virtual void Execute(vtkObject *caller1, unsigned long, void*)
>      {
>          vtkXRenderWindowInteractor *interact =
> reinterpret_cast<vtkXRenderWindowInteractor*>(caller1);
>
>          char* key = interact->GetKeySym();
>           if (*key=='g')
>          {
>              this->Actor->GetProperty()->SetColor(0,1,0);
>
>          }
>
>          if (*key=='b')
>          {
>              this->Actor->GetProperty()->SetColor(0,0,1);
>          }
>
>          if (*key=='r')
>          {
>               this->Actor->GetProperty()->SetColor(1,0,0);
>          }
>
>      }
>
>     void SetActor(vtkActor *actor)
>     {
>         this->Actor = actor;
>     }
>
>     protected:
>         vtkActor *Actor;
>         vtkRenderWindow* renWin;
> };
>
> int main()
> {
>     XtToolkitInitialize();
>     app_context = XtCreateApplicationContext();
>     XtAppAddInput(app_context, fileno(stdin),
> (XtPointer)XtInputReadMask,x11_handle_console_event, NULL);
>
> vtkRenderer* ren1 = vtkRenderer::New();
> vtkRenderWindow* renWin = vtkRenderWindow::New();
>    renWin->AddRenderer (ren1);
>
> vtkXRenderWindowInteractor* iren1 = vtkXRenderWindowInteractor::New();
>     iren1->SetRenderWindow(renWin);
>     iren1->Initialize(app_context);
>
> vtkInteractorStyleTrackballCamera *style =
> vtkInteractorStyleTrackballCamera::New();
>     iren1->SetInteractorStyle(style);
>
> vtkCylinderSource *cylinder1 = vtkCylinderSource::New();
>      cylinder1->SetCenter(0,0,0);
>      cylinder1->SetRadius(1);
>      cylinder1->SetHeight(2);
>      cylinder1->SetResolution(100);
>
>
>  vtkPolyDataMapper *cylinderMapper1 = vtkPolyDataMapper::New();
>     cylinderMapper1->SetInputConnection (cylinder1 ->GetOutputPort());
>
> vtkActor *cylinderActor1 = vtkActor::New();
>     cylinderActor1->SetMapper(cylinderMapper1);
>     cylinderActor1->GetProperty()->SetColor(1,0,0);
>     cylinderActor1->SetPosition(1,1,1);
>
>     ren1->AddActor(cylinderActor1);
>     ren1->SetBackground(1, 1, 1 );
>     renWin->FullScreenOn();
>
> vtkCamera *cam1 = vtkCamera::New();
>     ren1->ResetCamera();
>     cam1 = ren1->GetActiveCamera();
>
> vtkCallbackCommand* callback = vtkCallbackCommand::New();
>     callback->SetClientData(cam1);
>     callback->SetCallback(handle_timer);
>     style->AddObserver(vtkCommand::TimerEvent, callback);
>
> vtkMyCallback *cb = vtkMyCallback::New();
>     cb->SetActor(cylinderActor1);
>     style->AddObserver(vtkCommand::KeyReleaseEvent ,cb);
>     iren1->CreateTimer(VTKI_TIMER_FIRST);
>
>     printf("type 'exit' to quit\n");
>
>   while(!XtAppGetExitFlag(app_context))
>   {
>         float x=0,y=0,z=0;
>         for( double i = 0; i<9;i++)
>         {
>             {x=fmod(i,6);
>             y=fmod(i,3);
>             z=fmod(i,9);
>         }
>            cylinderActor1 ->SetPosition(x,y,z);
>          XtAppProcessEvent(app_context, XtIMAll);
>
>         }
>   }
>     return 0;
> }
>
> I am using Debian with VTK5.0, on a system with NVIDIA drivers.
> Can anyone offer any suggestions as to why this is happening?
>
> --
> Cheers,
> ouanabil
>
> _______________________________________________
> 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
>
>

--

-- 
François Bertel, PhD  | Kitware Inc. Suite 204
1 (518) 371 3971 x113 | 28 Corporate Drive
                      | Clifton Park NY 12065, USA
_______________________________________________
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

x0_y0_0 | 1 Jun 14:16 2009

convert RAW format to DICOM

hi,everyone,
    I have a dataset of 3D RAW ,and its Parameters:  256*256*256; 16bits, effective bits are 12 bits. I want to convert it to 256 pieces DICOM image. Can VTK deal with it? Could anyone help me ?thanks
 
 
regards,
 
 
                                                                                            mexiao  



网易全新推出企业邮箱
_______________________________________________
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
Yusuf OEZBEK | 1 Jun 16:18 2009
Picon

Re: VolumeRendering Problem

Hello!
My CMakeList.cxx :
project (MIRCIT)

#
#FIND ITK
#
FIND_PACKAGE(ITK)
IF (USE_ITK_FILE)
  INCLUDE (${USE_ITK_FILE})
ELSE (USE_ITK_FILE)
  MESSAGE( FATAL_ERROR "This application requires ITK. One of these components is missing. Please verify configuration")
ENDIF (USE_ITK_FILE)


#
#FIND VTK
#
FIND_PACKAGE(VTK)
IF(USE_VTK_FILE)
 INCLUDE(${USE_VTK_FILE})
ELSE (USE_VTK_FILE)
 MESSAGE( FATAL_ERROR "This app. req. VTK. One of these comp. is. missing. Please verify conf.")
ENDIF (USE_VTK_FILE)


#
#FIND FLTK
#
FIND_PACKAGE(FLTK)
  IF (FLTK_FOUND)
  INCLUDE_DIRECTORIES (${FLTK_INCLUDE_DIR})
  LINK_LIBRARIES( ${FLTK_LIBRARIES} ${OPENGL_LIBRARIES} )
  ELSE (FLTK_FOUND)
  MESSAGE( FATAL_ERROR "This application requires FLTK. One of these components is missing. Please verify configuration")
ENDIF (FLTK_FOUND)

add_executable (MIRCIT main.cpp MIRCIT.cpp MIRCIT.h MIRCITGui.cpp MIRCITGui.h info.cpp vtkFlRenderWindowInteractor.cpp)


TARGET_LINK_LIBRARIES(MIRCIT vtkCommon vtkexpat vtkFiltering vtkfreetype vtkftgl vtkGraphics vtkHybrid vtkImaging vtkIO vtkjpeg vtkpng vtkVolumeRendering vtkRendering vtktiff vtkzlib ITKBasicFilters ITKCommon ITKIO ${ITK_LIBRARIES})

Thanks!

Von: zhouyu <iconme <at> 163.com>
An: Yusuf OEZBEK <nasil122002 <at> yahoo.de>
Gesendet: Montag, den 1. Juni 2009, 10:08:33 Uhr
Betreff: Re: [vtkusers] VolumeRendering Problem

DIV { MARGIN:0px;} _filtered { font-family:宋体; } _filtered { font-family:Verdana; } _filtered { } _filtered {margin:72.0pt 90.0pt 72.0pt 90.0pt;} P.MsoNormal { TEXT-JUSTIFY:inter-ideograph;FONT-SIZE:10.5pt;MARGIN:0cm 0cm 0pt;FONT-FAMILY:"Times New Roman";TEXT-ALIGN:justify;} LI.MsoNormal { TEXT-JUSTIFY:inter-ideograph;FONT-SIZE:10.5pt;MARGIN:0cm 0cm 0pt;FONT-FAMILY:"Times New Roman";TEXT-ALIGN:justify;} DIV.MsoNormal { TEXT-JUSTIFY:inter-ideograph;FONT-SIZE:10.5pt;MARGIN:0cm 0cm 0pt;FONT-FAMILY:"Times New Roman";TEXT-ALIGN:justify;} A:link { COLOR:blue;TEXT-DECORATION:underline;} SPAN.MsoHyperlink { COLOR:blue;TEXT-DECORATION:underline;} A:visited { COLOR:purple;TEXT-DECORATION:underline;} SPAN.MsoHyperlinkFollowed { COLOR:purple;TEXT-DECORATION:underline;} SPAN.EmailStyle17 { FONT-WEIGHT:normal;COLOR:windowtext;FONT-STYLE:normal;FONT-FAMILY:Verdana;TEXT-DECORATION:none;} DIV.Section1 { } UNKNOWN { FONT-SIZE:10pt;} BLOCKQUOTE { MARGIN-TOP:0px;MARGIN-BOTTOM:0px;MARGIN-LEFT:2em;} OL { MARGIN-TOP:0px;MARGIN-BOTTOM:0px;} UL { MARGIN-TOP:0px;MARGIN-BOTTOM:0px;}
You may miss linking some libraries, I'm not quite sure though. If so, you can add them in the CMakeList.txt.
 
Yu
 
 
2009-06-01
发件人: Yusuf OEZBEK
发送时间: 2009-06-01  04:25:14
收件人: VTK Mailinglist
抄送:
主题: [vtkusers] VolumeRendering Problem
Hello! 

I wanted my watershed-segmentation result (from ITK) through vtkVolumeProMapper 3D So make a volume. I have used vtkVolumeProMapper and vtkVolume. But I always get the error "undefined reference to vtkVolumeProMapper". Where is my mistake? I would be glad if you can help. 

Thank you! 

My code:

void MIRCIT::imageDisplayingWatershed(){

 this->displayImage3D->show();
 this->displayImage3D->redraw();

  typedef unsigned char PixelType;
  const unsigned int Dimension = 3;

  typedef itk::OrientedImage< PixelType, Dimension > ImageType;
  typedef itk::ImageSeriesReader< ImageType > ReaderType;
  ReaderType::Pointer reader = ReaderType::New();

  typedef itk::GDCMImageIO ImageIOType;
  ImageIOType::Pointer dicomIO = ImageIOType::New();
  
  reader->SetImageIO( dicomIO );

  typedef itk::GDCMSeriesFileNames NamesGeneratorType;
  NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

  nameGenerator->SetUseSeriesDetails( true );
  nameGenerator->AddSeriesRestriction("0008|0021" );
  nameGenerator->SetDirectory( selectedDirectory);

  typedef std::vector< std::string > SeriesIdContainer;
   
  const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
  SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
  SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();

  while( seriesItr != seriesEnd )
  {
  seriesItr++;
  }

  std::string seriesIdentifier;
  seriesIdentifier = seriesUID.begin()->c_str();

  typedef std::vector< std::string > FileNamesContainer;
  FileNamesContainer fileNames;

  fileNames = nameGenerator->GetFileNames( seriesIdentifier );
  reader->SetFileNames( fileNames );
  reader->Update();

  typedef float InternalPixelType;
  typedef itk::RGBPixel<unsigned char> RGBPixelType;
  typedef itk::Image< RGBPixelType, Dimension > RGBImageType;
  typedef itk::ImageFileWriter< RGBImageType > WriterType;
  typedef itk::WatershedImageFilter< ImageType > WatershedFilterType;
  typedef itk::Functor::ScalarToRGBPixelFunctor< unsigned long> ColorMapFunctorType;
  typedef WatershedFilterType::OutputImageType LabeledImageType;
  typedef itk::UnaryFunctorImageFilter<LabeledImageType,RGBImageType,ColorMapFunctorType > ColorMapFilterType;
  typedef itk::ImageToVTKImageFilter <LabeledImageType> ConnectorType;
  typedef itk::GradientMagnitudeImageFilter<ImageType, ImageType> GradientMagnitudeFilterType;
 
  GradientMagnitudeFilterType::Pointer magnitudeFilter = GradientMagnitudeFilterType::New();
  magnitudeFilter->SetInput(reader->GetOutput());

  WatershedFilterType::Pointer watershedFilter = WatershedFilterType::New();
  watershedFilter->SetInput( magnitudeFilter->GetOutput() );
  watershedFilter->SetLevel(this->sliderLevelWatershed->value());
  watershedFilter->SetThreshold(this->sliderLevelWatershed->value());

  ColorMapFilterType::Pointer colorMapFilter = ColorMapFilterType::New();
  colorMapFilter->SetInput( watershedFilter->GetOutput() );

  ConnectorType::Pointer connector = ConnectorType::New();
  connector->SetInput(watershedFilter->GetOutput());

  vtkImageShiftScale *shift = vtkImageShiftScale::New();
  shift->SetInput(connector->GetOutput());
  shift->SetOutputScalarTypeToUnsignedChar();

  vtkVolumeProMapper *mapperb = vtkVolumeProMapper::New();
  mapperb->SetInputConnection(shift->GetOutputPort());

  vtkVolume *volumeb = vtkVolume::New();
  volumeb->SetMapper(mapperb);

  camera3D = vtkCamera::New();
  camera3D->SetViewUp(0, 0, -1);
  camera3D->SetPosition(0, 1, 0);
  camera3D->SetFocalPoint(0, 0, 0);
  camera3D->ComputeViewPlaneNormal();
  camera3D->Azimuth(20);

  renderer3DWaterShed = vtkRenderer::New();
  renderWindow3DWaterShed = vtkRenderWindow::New();
  renderWindow3DWaterShed->AddRenderer(renderer3DWaterShed);

  displayImage3D->SetRenderWindow(renderWindow3DWaterShed);
  displayImage3D->SetInteractorStyle(mode3DWaterShed);
  displayImage3D->Initialize();

  renderer3DWaterShed->AddViewProp(volumeb);
  renderer3DWaterShed->SetActiveCamera(camera3D);
  renderer3DWaterShed->ResetCamera();
  camera3D->Dolly(1.3);
  renderer3DWaterShed->ResetCameraClippingRange();
  renderer3DWaterShed->Render();

  this->displayImage3D->show();
  this->displayImage3D->redraw();

  WriterType::Pointer writer = WriterType::New();
  writer->SetInput( colorMapFilter->GetOutput() );
  writer->SetFileName("fds.tiff" );
  writer->Update();
}




_______________________________________________
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
Floarea Serban | 1 Jun 18:26 2009
Picon

Re ad 16-bit TIFF stack


Hi everybody,

I upgraded my VTK from version 5.1 to version 5.4 and I have problems in
reading 16-bit TIFF files. This was possible in the previous version I had
but now I get this error message:
Invalid memory access of location 00000008 eip=4229a779

I am using VTK 5.4 on a Mac OS with the Java wrapper. For reading TIFF
images I use vtkTIFFReader.
Does anybody know how can I make it work?

Thanks a lot!
                   Flory

--

-- 
View this message in context: http://www.nabble.com/Read-16-bit-TIFF-stack-tp23817779p23817779.html
Sent from the VTK - Users mailing list archive at Nabble.com.

_______________________________________________
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

David Doria | 1 Jun 18:57 2009
Picon

Line/triangle intersection

I am trying to intersect a ray with a triangulated mesh. I see that vtkOBBTree is derived from vtkCellLocator, but they both have a IntersectWithLine function. When should I use a vtkOBBTree vs a vtkCellLocator?

I tried to use a CellLocator to find the intersection with a triangle (vertices [0,0,0], [1,0,0], [0,1,0]) and a line segment (end points [.5, .5, 1], [.5, .5, -1]).

It doesn't seem to give the result of (.5, .5, 0) as I would expect - instead all the values seem to be uninitialized.

Here is the function declaration:
virtual int IntersectWithLine (float a0[3], float a1[3], float tol, float &t, float x[3], float pcoords[3], int &subId)

I'm assuming a0 and a1 are the endpoints of the line? tol is the tolerance for the intersection calculation, x is the point of intersection.  Then what is pcoords and subId??

Here is my example code:

#include <vtkCellArray.h>
#include <vtkPoints.h>
#include <vtkTriangle.h>
#include <vtkPolyData.h>
#include <vtkPointData.h>
#include <vtkLine.h>
#include <vtkCellLocator.h>
#include <vtkSmartPointer.h>

#include <iostream>


int main(int argc, char *argv[])
{
    //create the points
    vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
    points->InsertNextPoint(1.0, 0.0, 0.0);
    points->InsertNextPoint(0.0, 0.0, 0.0);
    points->InsertNextPoint(0.0, 1.0, 0.0);
       
    //create the triangles
    vtkSmartPointer<vtkCellArray> triangles = vtkSmartPointer<vtkCellArray>::New();

    vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
    triangle->GetPointIds()->SetId(0,0);
    triangle->GetPointIds()->SetId(1,1);
    triangle->GetPointIds()->SetId(2,2);
    triangles->InsertNextCell(triangle);
   
    vtkSmartPointer<vtkPolyData> polydata = vtkPolyData::New();

    polydata->SetPoints(points);
    polydata->SetPolys(triangles);
   
    //create the locator
    vtkCellLocator* Locator = vtkCellLocator::New();
    Locator->SetDataSet(polydata);

    //intersect the locator with the line
    double LineP0[3] = {0.5, 0.5, 1.0};
    double LineP1[3] = {0.5, 0.5, -1.0};
    double t;
    double x[3];
    double pcoords[3];
    int subId;
    Locator->IntersectWithLine(LineP0, LineP1, 1e-6, t, x, pcoords, subId);

    std::cout << "t: " << t << std::endl;
    std::cout << "subId: " << subId << std::endl;
    std::cout << "x: " << x[0] << " " << x[1] << " " << x[2] << std::endl;
    std::cout << "pcoords: " << pcoords[0] << " " << pcoords[1] << " " << pcoords[2] << std::endl;
   
   
    return 0;
}


Anyone see what is wrong with that? I assume it is with my missing understanding of pcoords because it is not passed by reference and therefore I am passing in uninitialized values - thoughts?

Thanks,

David

_______________________________________________
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
Sean McBride | 1 Jun 19:06 2009

Re: Re ad 16-bit TIFF stack

On 6/1/09 9:26 AM, Floarea Serban said:

>I upgraded my VTK from version 5.1 to version 5.4 and I have problems in
>reading 16-bit TIFF files. This was possible in the previous version I had
>but now I get this error message:
>Invalid memory access of location 00000008 eip=4229a779
>
>I am using VTK 5.4 on a Mac OS with the Java wrapper. For reading TIFF
>images I use vtkTIFFReader.
>Does anybody know how can I make it work?

There's really not a lot of info here for others to help you.  Do you
have a backtrace of the crash?  Can you create a minimal example that
reproduces the crash?  Did you try in C++ only (to rule out wrapping
problems)?

--

-- 
____________________________________________________________
Sean McBride, B. Eng                 sean <at> rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada

_______________________________________________
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

Robert Golebiowski | 1 Jun 20:42 2009

ITK VTK and MFC

Hi,

I’ve been trying to connect VTK ITK and MFC for three days now. I use ITK to generate 3D imageData object and then I convert this object to VTK volume by using itkImageToVTKImageFilter. It worked fine as long as I was using vtkRenderWindowInteractor, vtkRenderWindow and vtkRenderer, now as I moved to MFC I’m using vtkWin32OpenGLRenderWindow, vtkRenderer, and vtkWin32RenderWindowInteractor. I had tried to use vtkMFCWindow, but when it hadn’t worked I implemented the code from SDI_Instructions.chm from the VTK Examples (MFC). Both times I got the same error from itkImageToVTKImageFilter, from function VTKImageExportBase::UpdateInformationCallbackFunction. I found this post about this error :

http://public.kitware.com/pipermail/insight-users/2003-April/003226.html
http://markmail.org/message/lzzuxmxrlk2zifa3#query:MFC%20UpdateInformationCallbackFunction+page:1+mid:wsjr4dvccvsscvhq+state:results

It seems that this problem hasn’t yet been solved. I hope I’m wrong…
I would appreciate any help you can give me, any workaround ? 

Thanks,
Robert


_______________________________________________
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

Gmane