[vtkusers] vtkInteractorStyleTerrain not compatible with vtkAxesActor/vtkOrientationMarkerWidget ?
pof
jd379252 at gmail.com
Sun Apr 3 05:01:54 EDT 2011
Dear vtker's,
No answer yet, so does it means that I'm now the only one having this
problem ?
Herebelow is a small example program that illustrate this
incompatibility between vtkInteractorStyleTerrain and
vtkAxesActor/vtkOrientationMarkerWidget.
Any idea/comment ?
////////////////
#include "vtkCylinderSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
#include "vtkAxesActor.h"
#include "vtkOrientationMarkerWidget.h"
#include "vtkInteractorStyleTerrain.h"
int main()
{
// Creates a polygonal cylinder model with eight circumferential
facets.
vtkCylinderSource *cylinder = vtkCylinderSource::New();
cylinder->SetResolution(20);
cylinder->SetCenter(0,0,0.);
cylinder->SetRadius(10.);
cylinder->SetHeight(20.);
vtkPolyDataMapper *cylinderMapper = vtkPolyDataMapper::New();
cylinderMapper->SetInputConnection(cylinder->GetOutputPort());
vtkActor *cylinderActor = vtkActor::New();
cylinderActor->SetMapper(cylinderMapper);
cylinderActor->GetProperty()->SetColor(1.0000, 0.3882, 0.2784);
vtkPolyDataMapper *MeshMapper = vtkPolyDataMapper::New();
vtkActor *MeshActor = vtkActor::New();
MeshMapper->SetInputConnection(cylinder->GetOutputPort());
MeshActor->SetMapper(MeshMapper);
(MeshActor->GetProperty())->SetInterpolationToFlat();
(MeshActor->GetProperty())->BackfaceCullingOff();
(MeshActor->GetProperty())->EdgeVisibilityOn();
(MeshActor->GetProperty())->SetLineWidth(2);
(MeshActor->GetProperty())->SetColor(0.,0.6,0.8);
(MeshActor->GetProperty())->SetRepresentationToWireframe();
// Create the graphics structure.
vtkRenderer *ren = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(ren);
renWin->SetSize(600, 600);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
// Add the actors to the renderer, set the background and size
ren->AddActor(cylinderActor);
ren->AddActor(MeshActor);
ren->SetBackground(0.1, 0.2, 0.4);
// We'll zoom in a little by accessing the camera and invoking a "Zoom"
// method on it.
ren->ResetCamera();
ren->GetActiveCamera()->Zoom(1.0);
renWin->Render();
vtkInteractorStyleTerrain *styleTerrain =
vtkInteractorStyleTerrain::New();
iren->SetInteractorStyle(styleTerrain);
vtkAxesActor *Axes = vtkAxesActor::New();
Axes->SetShaftTypeToCylinder();
Axes->SetXAxisLabelText( "X" );
Axes->SetYAxisLabelText( "Y" );
Axes->SetZAxisLabelText( "Z" );
vtkOrientationMarkerWidget *AxesWidget =
vtkOrientationMarkerWidget::New();
AxesWidget->SetOutlineColor(0,0,0);
AxesWidget->SetOrientationMarker(Axes);
AxesWidget->SetInteractor(iren);
AxesWidget->SetViewport( 0.0, 0.0, 0.2, 0.2 );
AxesWidget->SetEnabled(1);
AxesWidget->InteractiveOn();
// This starts the event loop and as a side effect causes an
initial render.
iren->Start();
// Exiting from here, we have to delete all the instances that
// have been created.
cylinder->Delete();
cylinderMapper->Delete();
cylinderActor->Delete();
MeshMapper->Delete();
MeshActor->Delete();
ren->Delete();
renWin->Delete();
iren->Delete();
return 0;
}
Le 24/03/2011 11:26, Pof a écrit :
> Answering to myself, just to mention that similar problem has already
> been reported in the mailing list, but I could not find any answer.
> So does this means the only solution is not to use
> vtkInteractorStyleTerrain with vtkOrientationMarkerWidget??
> Thanks for any tip/advice
> JD
>
> 2011/3/22 Pof <jd379252 at gmail.com <mailto:jd379252 at gmail.com>>
>
> Hi all,
>
> when the vtkInteractorStyleTerrain is used with
> vtkAxesActor/vtkOrientationMarkerWidget:
> - the following error message is obtained "Resetting view-up since
> view plane normal is parallel"
> - the orientation of the vtkAxesActor gets wrong when viewing
> along the z-axis.
>
> Is there any way to correct this behaviour (apart from not
> displaying the warning message)?
>
> Thanks
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110403/370fbfbf/attachment.htm>
More information about the vtkusers
mailing list