[vtkusers] problem of correct use of SetFocalPoint for vtkCursor3D

Thomas Lambertz thomas at hexerei-software.de
Thu Dec 14 10:21:00 EST 2006


Hi,

i have encountered a problem inserting vtkCursor3D to my scene.

As i understand SetFocalPoint() sets the point of interest where the 
axis cross each other. SetModelBounds() sets a surrounding box which 
limits the axis. Please correct me if i am wrong.

So - by
Cursor3D->AllOn();
Cursor3D->SetFocalPoint(x,y,z);
Cursor3D->SetModelBounds(x-d,x+d,
                                               y-d,y+d,
                                               z-d,z+d);

i expect a cube with centered haircrossing.


SetFocalPoint(0.0,0.0,0.0);  and  all is fine

Using                
Renderer->GetActiveCamera()->ParallelProjectionOn();
Renderer->GetActiveCamera()->SetParallelScale(128.0);
Renderer->GetActiveCamera()->SetPosition  (0,0,100);
Renderer->GetActiveCamera()->SetFocalPoint(0.0,0.0,0.0);

should not change that - except that i have now a 2D-View to my box. 
(without it even looks strange)


Ok - thats theory - as code often say more than thausend words - please 
have a deeper look into the code (this one has been stripped down from 
my project as a testbed)

#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkCursor3D.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"


int main()
{

    vtkRenderWindow* RenderWindow = vtkRenderWindow::New();
    vtkRenderer* Renderer = vtkRenderer::New();

    Renderer->SetBackground( 0.0, 0.0, 0.0 );
    Renderer->SetViewport(0.0,0.0,1.0,1.0);

    // only 2D Projection
    Renderer->GetActiveCamera()->ParallelProjectionOn();
    Renderer->GetActiveCamera()->SetParallelScale(128.0);

    // Look along the z-axis
    Renderer->GetActiveCamera()->SetPosition  (0.0,0.0,100.0);
    Renderer->GetActiveCamera()->SetFocalPoint(0.0,0.0,  0.0);

    vtkCursor3D* Cursor1;
    vtkCursor3D* Cursor2;

    Cursor1 = vtkCursor3D::New();
    Cursor2 = vtkCursor3D::New();

    vtkPolyDataMapper* CursorMapper1;
    vtkPolyDataMapper* CursorMapper2;

    CursorMapper1 = vtkPolyDataMapper::New();
    CursorMapper2 = vtkPolyDataMapper::New();


    vtkActor* CursorActor1;
    vtkActor* CursorActor2;

    CursorActor1 = vtkActor::New();   
    CursorActor2 = vtkActor::New();   

   
    double p1[3]={ -40.0 , 10.0 , 0.0 };
    double p2[3]={  0.0  ,  0.0 , 0.0 };
    double d=50.0;
   

    Cursor1->SetFocalPoint(p1);
    
Cursor1->SetModelBounds(p1[0]-d,p1[0]+d,p1[1]-d,p1[1]+d,p1[2]-d,p1[2]+d);
    Cursor1->AllOn();

    CursorMapper1->SetInput(Cursor1->GetOutput());
    CursorActor1->SetMapper(CursorMapper1);
    CursorActor1->GetProperty()->SetColor(0,1,0);


    Cursor2->SetFocalPoint(p2);
    
Cursor2->SetModelBounds(p2[0]-50.0,p2[0]+50.0,p2[1]-50.0,p2[1]+50.0,p2[2]-50.0,p2[2]+50.0);
    Cursor2->AllOn();

    CursorMapper2->SetInput(Cursor2->GetOutput());
    CursorActor2->SetMapper(CursorMapper2);
    CursorActor2->GetProperty()->SetColor(1.0,0.0,0.0);


    Renderer->AddActor(CursorActor1);
    Renderer->AddActor(CursorActor2);

    RenderWindow->AddRenderer(Renderer);
    RenderWindow->SetSize(800,600);
    RenderWindow->Render();

int i;
cin >> i;
}

The red box lookes correct.
For the green one the bounding box lookes good, but i am unsatisfied 
with the Position of the hair cross.

What went wrong ? Have i misinterpreted the SetFocalPoint() method ?

Additional information about the environment:

VTK 5.0.2
Visual Studio 2005 Prof.
WindowXP 64Bit Ed
Build as native (not managed) in release mode for x86 ( 32bit - no 64bit )
ATI x1600 GPU

For a first look a attach a Screenshot - for saving bandwidth its 
additional zipped.


Feature or bug ? As most bugs sits in front of the display i tend to 
believe i simply missed something.

Any suggestion will be welcomed.

Thanks in advance,
Tom


























-------------- next part --------------
A non-text attachment was scrubbed...
Name: cursor.zip
Type: application/octet-stream
Size: 3495 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061214/51dfbadc/attachment.obj>


More information about the vtkusers mailing list