[vtkusers] vtkOrientationMarkerWidget scalar bug

madz madaramh at gmail.com
Tue Dec 17 23:02:44 EST 2013


I'm trying to add vtkAxesActor as a widget in my 3D plot application and I
noticed that if I turn on scalar point data, the back of the  plot turns
black. The front remains unaffected. If I turn
mapper->ScalarVisibilityOff();, the plot displays without colours as normal
and if I turn widget->SetEnabled( 0 );, the plot displays with colours as
normal (but without the widget). Is there anything I can do to prevent the
plot from turning black? I have included the code for the application.
Thank you.

#include <vtkSmartPointer.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkDoubleArray.h>
#include <vtkPolyDataMapper.h>
#include <vtkActor.h>
#include <vtkProperty.h>
#include <vtkDelaunay2D.h>
#include <vtkMath.h>
#include <vtkPointData.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <vtkCamera.h>
#include <vtkButterflySubdivisionFilter.h>

#include <vtkOrientationMarkerWidget.h>
#include <vtkAxesActor.h>

int main(int, char *[])
{
        bool setScaler = false; //set true to test with elevation
        std::vector<double> zVal;
        // Create a grid of points (height/terrian map)
        vtkSmartPointer<vtkPoints> points = 
vtkSmartPointer<vtkPoints>::New();

        std::vector<std::vector&lt;double>> p;
        for(int i=0; i<4; i++){
                for(int ii=0;ii<3;ii++){
                        double z = vtkMath::Random(0, 3);
                        points->InsertNextPoint(i, ii, z);
                        zVal.push_back(z);
                }
        }

        vtkSmartPointer<vtkPolyData> inputPolyData =
vtkSmartPointer<vtkPolyData>::New();
        inputPolyData->SetPoints(points);

        vtkSmartPointer<vtkDelaunay2D> delaunay =
vtkSmartPointer<vtkDelaunay2D>::New();
#if VTK_MAJOR_VERSION <= 5
        delaunay->SetInput(inputPolyData);
#else
        delaunay->SetInputData(inputPolyData);
#endif
        delaunay->Update();

        vtkSmartPointer<vtkPolyData> outputPolyData =
vtkSmartPointer<vtkPolyData>::New();


		outputPolyData = delaunay->GetOutput();
		vtkSmartPointer<vtkDoubleArray> tempArray =
vtkSmartPointer<vtkDoubleArray>::New();
		tempArray->SetName("colordata");
		for(int i=0;i<zVal.size();i++)
		{
			tempArray->InsertNextValue(zVal[i]);
		}
		outputPolyData->GetPointData()->SetScalars(tempArray);
        

        vtkSmartPointer<vtkButterflySubdivisionFilter> subdivide =
vtkSmartPointer<vtkButterflySubdivisionFilter>::New();
        subdivide->SetNumberOfSubdivisions(4);
#if VTK_MAJOR_VERSION <= 5
        subdivide->SetInputConnection(outputPolyData->GetProducerPort());
#else
        //subdivide->SetInputData(outputPolyData);
#endif
        subdivide->Update();

        // Create a mapper and actor
        vtkSmartPointer<vtkPolyDataMapper> mapper
=vtkSmartPointer<vtkPolyDataMapper>::New();
        mapper->SetInputConnection(subdivide->GetOutputPort());

        vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
        actor->SetMapper(mapper);

        vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
        vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
        renderWindow->AddRenderer(renderer);
        vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
        renderWindowInteractor->SetRenderWindow(renderWindow);

        //prevents the pointer option from going haywire
        vtkSmartPointer<vtkInteractorStyleTrackballCamera> style =
vtkSmartPointer<vtkInteractorStyleTrackballCamera>::New();
        renderWindowInteractor->SetInteractorStyle(style);

        // Add the actor to the scene
        renderer->AddActor(actor);
        renderWindow->Render();
        
		vtkSmartPointer<vtkAxesActor> axes2 =
vtkSmartPointer<vtkAxesActor>::New();
		vtkSmartPointer<vtkOrientationMarkerWidget> widget =
vtkSmartPointer<vtkOrientationMarkerWidget>::New();
		widget->SetOrientationMarker( axes2 );
		widget->SetInteractor( renderWindowInteractor );
		widget->SetEnabled( 1 );

        renderWindow->Render();

        renderWindowInteractor->Start();

        return EXIT_SUCCESS;
} 



--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkOrientationMarkerWidget-scalar-bug-tp5725058.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list