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

Goodwin Lawlor goodwin.lawlor at ucd.ie
Wed Jul 14 08:58:03 EDT 2004


You might need to update the bcc32.cfg config file to let the compiler know
where its headers and libraries are. With cl you need to set the LIB and
INCLUDE environment variables.

Dont know what's happening with the python code... Do you need to call both
iren.Initialize() and iren.Start() ?? Try

renWin.Render()
iren.Start()

or...

iren.Initialize(0
renWin.Render()
iren.Start()

hth

Goodwin
----- Original Message ----- 
From: "Andrea Gavana" <andrea.gavana at polymtl.ca>
To: "Goodwin Lawlor" <goodwin.lawlor at ucd.ie>
Cc: <vtkusers at public.kitware.com>
Sent: Wednesday, July 14, 2004 9:44 AM
Subject: Re: [vtkusers] Re: 3D Axes For User Orientation...


> 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, so I send
you as
> attachment what I see when I rotate the main Actor.
> 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
>
> Selon Goodwin Lawlor <goodwin.lawlor at ucd.ie>:
>
> > Hi Andrea,
> >
> > This class would have appeared in cvs about the 20th May onwards.
vtk4.4.2
> > was created at the end of March so it wont be in the python wrappers of
vtk
> > 4.2. Maybe someone who builds the nightly dist with python could send
you
> > their binaries.
> >
> > Alternatively, I have a pure tcl implementation which you could
translate to
> > python and use. Its here:
> > http://www.bioengineering-research.com/vtk/axes_example2.tcl
> >
> >
> > Here's how I use the new c++ classes in tcl anyway. It should be pretty
> > similar to python.
> >
> > vtkAnnotatedCubeActor acube
> >     [acube GetCubeProperty] SetRepresentationToWireframe
> >     [acube GetCubeProperty] SetAmbient 1
> >     [acube GetCubeProperty] SetDiffuse 0
> >     acube TextEdgesOff
> > vtkAxesActor aaxes
> > vtkPropAssembly marker
> >     marker AddPart aaxes
> >     marker AddPart aactor
> > vtkOrientationMarkerWidget orientWidget
> >     orientWidget SetOrientationMarker marker
> >     orientWidget SetInteractor iren
> >     orientWidget On
> >
> > hth,
> >
> > Goodwin
> >
>




More information about the vtkusers mailing list