[vtkusers] Re: 3D Axes For User Orientation...

Andrea Gavana andrea.gavana at polymtl.ca
Wed Jul 14 04:54:48 EDT 2004


Hello NG,

    thank to you all for your kind suggestions. I still have some problems:

1) Regarding the use of vtkOrientationMarkerWidget and vtkAnnotatedCubeActor, 
I'm having big troubles in compiling VTK-4.4 with Cmake (on Windows 2000 
machine). Cmake keeps telling me that the NMake compiler (cl.exe) and the 
Borland compiler (bcc32) are not able to compile a simple application (!!!!). 
The error message is:

"Determining if the C compiler works failed with the following output:

Building object file testCCompiler.obj...

cl @C:\DOCUME~1\ag12905\IMPOST~1\Temp\nma02312.
testCCompiler.c
Building executable C:\ciao\CMakeTmp\cmTryCompileExec.exe...
cl /nologo @C:\DOCUME~1\ag12905\IMPOST~1\Temp\nmb02312.
testCCompiler.obj : error LNK2001: unresolved external symbol __RTC_Shutdown
testCCompiler.obj : error LNK2001: unresolved external symbol __RTC_InitBase

C:\ciao\CMakeTmp\cmTryCompileExec.exe : fatal error LNK1120: 2 unresolved 
externals

NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop. "

I don't know why, but all my C/C++ compilers fail. I would also use g++ from 
GNU/Cygwin, but I have no idea on how to do it...

So I can not use the very useful VTK new classes that most of you suggested.

2) By translating (I hope correctly) the code from Goodwin Lawlor found at this 
url:

http://www.bioengineering-research.com/vtk/axes_example2.tcl

I was able to create the orientation axes at the bottom left of the VTK window, 
but I'm facing some strange behaviors. When I rotate the main Actor (a Cone, in 
my example), I get a sequence of superimposing images that represent all the 
rotation I have done on my cone. I can not explain it clearly, I've tried to 
attach an image but the vtkuser server told me that it was too big, so I posted 
an image explining what I said at this url:

http://xoomer.virgilio.it/infinity77/vtkproblem.jpg

It's a strange behavior, I don't know why it happens...

I post here my python code, if someone has comments on this, please let me 
know... probably I have done something wrong in traslating it from tcl...

Thank you for every suggestion.

Andrea.

# BEGIN PYTHON CODE

import vtkpython
import Numeric

cone = vtkpython.vtkConeSource()
coneMapper = vtkpython.vtkPolyDataMapper()
coneMapper.SetInput(cone.GetOutput())
coneActor = vtkpython.vtkActor()
coneActor.SetMapper(coneMapper)

camAxes = vtkpython.vtkCamera()
camAxes.ParallelProjectionOn()

renAxes = vtkpython.vtkRenderer()
renAxes.InteractiveOff()
renAxes.SetActiveCamera(camAxes)
renAxes.SetViewport(0, 0, 0.25, 0.25)
renAxes.SetLayer(1)
    
def SyncCameras(renderer, event_string):
    
    cam = ren.GetActiveCamera()
    camAxes.SetViewUp(cam.GetViewUp())
    proj = cam.GetDirectionOfProjection()
    x, y, z = cam.GetDirectionOfProjection()

    # figure out the distance away from 0 0 0
    # if the renderer resets the camera to optimally inlcude all props
    # composing the orientation marker
    
    bnds = renAxes.ComputeVisiblePropBounds()
    x0, x1, y0, y1, z0, z1 = renAxes.ComputeVisiblePropBounds()
    renAxes.ResetCamera(x0, x1, y0, y1, z0, z1)
    pos = camAxes.GetPosition()
    px, py, pz = camAxes.GetPosition()
    d = Numeric.sqrt(px*px + py*py + pz*pz)
    dproj = Numeric.sqrt(x*x + y*y + z*z)

    # reset the camera back along the unit vector of the
    # direction of projection using our optimal distance
    camAxes.SetFocalPoint(0,0,0)
    camAxes.SetPosition(-d*x/dproj, -d*y/dproj, -d*z/dproj)
    renAxes.ResetCameraClippingRange()

    
ren = vtkpython.vtkRenderer()
ren.AddActor(coneActor)

ren.AddObserver("StartEvent", SyncCameras)

renWin = vtkpython.vtkRenderWindow()
renWin.SetNumberOfLayers(2)
renWin.AddRenderer(renAxes)
renWin.SetSize(600,600)
renWin.AddRenderer(ren)
iren = vtkpython.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)

## The corner axes
xAxis = vtkpython.vtkArrowSource()
xAxisMapper = vtkpython.vtkPolyDataMapper()
xAxisMapper.SetInput(xAxis.GetOutput())
xAxisActor = vtkpython.vtkActor()
xAxisActor.SetMapper(xAxisMapper)
xAxisActor.GetProperty().SetColor(1,0,0)
    
yAxis = vtkpython.vtkArrowSource()
yAxisMapper = vtkpython.vtkPolyDataMapper()
yAxisMapper.SetInput(yAxis.GetOutput())
yAxisActor = vtkpython.vtkActor()
yAxisActor.SetMapper(yAxisMapper)
yAxisActor.GetProperty().SetColor(1,1,0)
yAxisActor.RotateZ(90)

zAxis = vtkpython.vtkArrowSource()
zAxisMapper = vtkpython.vtkPolyDataMapper()
zAxisMapper.SetInput(zAxis.GetOutput())
zAxisActor = vtkpython.vtkActor()
zAxisActor.SetMapper(zAxisMapper)
zAxisActor.GetProperty().SetColor(0,1,0)
zAxisActor.RotateY(-90)

xLabel = vtkpython.vtkCaptionActor2D()
xLabel.SetCaption("X")
xLabel.SetAttachmentPoint(1,0,0)
xLabel.LeaderOff()
xLabel.BorderOff()
xLabel.SetPosition(0,0)

yLabel = vtkpython.vtkCaptionActor2D()
yLabel.SetCaption("Y")
yLabel.SetAttachmentPoint(0,1,0)
yLabel.LeaderOff()
yLabel.BorderOff()
yLabel.SetPosition(0,0)

zLabel = vtkpython.vtkCaptionActor2D()
zLabel.SetCaption("Z")
zLabel.SetAttachmentPoint(0,0,1)
zLabel.LeaderOff()
zLabel.BorderOff()
zLabel.SetPosition(0,0)

Axes3D = vtkpython.vtkPropAssembly()
Axes3D.AddPart(xAxisActor)
Axes3D.AddPart(yAxisActor)
Axes3D.AddPart(zAxisActor)
Axes3D.AddPart(xLabel)
Axes3D.AddPart(yLabel)
Axes3D.AddPart(zLabel)

renAxes.AddActor(Axes3D)

iren.Initialize()
iren.Start()

# END PYTHON CODE




More information about the vtkusers mailing list