[vtkusers] VTK Contour Widget Problem

Gishara Indeewarie gish.777 at gmail.com
Thu Jul 12 04:43:35 EDT 2012


Hi all,
When I comment the line  " interactor->SetInteractorStyle(style)" the
contour lines is displayed, but not in the right position.
I have to rotate and make it on the right place.
Can you please tell me how could I make it appear on the right position?
Thanks.

On Thu, Jul 12, 2012 at 10:43 AM, Gishara Indeewarie <gish.777 at gmail.com>wrote:

> Hi all,
>
> I am doing a VTK contour widget with control points.
> My problem is that the control points and the contour is visible when I am
> using vtk 5.8 libs.
> But when I move to vtk 5.0 I can't see it.
> I want to use it in vtk 5.0 because the project I am working now uses 5.0.
> Below is my code.
>
> #include <vtkSmartPointer.h>
> #include <vtkProperty.h>
> #include <vtkContourWidget.h>
> #include <vtkOrientedGlyphContourRepresentation.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkCommand.h>
> #include <vtkRegressionTestImage.h>
> #include <vtkDebugLeaks.h>
> #include <vtkTestUtilities.h>
> #include <vtkCamera.h>
> #include <vtkPlane.h>
> #include <vtkPolyData.h>
> #include <vtkCellArray.h>
> #include <vtkPoints.h>
> #include <vtkMath.h>
> #include <vtkWidgetEvent.h>
> #include <vtkWidgetEventTranslator.h>
> #include <vtkInteractorStyleImage.h>
>
> int main( int argc, char *argv[] )
> {
>   // Create the RenderWindow, Renderer and both Actors
>   //
>   vtkSmartPointer<vtkRenderer> renderer =
> vtkSmartPointer<vtkRenderer>::New();
>   vtkSmartPointer<vtkRenderWindow> renderWindow =
> vtkSmartPointer<vtkRenderWindow>::New();
>   renderWindow->AddRenderer(renderer);
>
>   vtkSmartPointer<vtkRenderWindowInteractor> interactor =
>       vtkSmartPointer<vtkRenderWindowInteractor>::New();
>   interactor->SetRenderWindow(renderWindow);
>
>   renderer->SetBackground(0.1, 0.2, 0.4);
>   renderWindow->SetSize(600, 600);
>
>   vtkSmartPointer<vtkOrientedGlyphContourRepresentation> contourRep =
>       vtkSmartPointer<vtkOrientedGlyphContourRepresentation>::New();
>   contourRep->GetLinesProperty()->SetColor(1, 0, 0); //set color to red
>
>   vtkSmartPointer<vtkContourWidget> contourWidget =
>       vtkSmartPointer<vtkContourWidget>::New();
>   contourWidget->SetInteractor(interactor);
>   contourWidget->SetRepresentation(contourRep);
>   contourWidget->On();
>
>   vtkSmartPointer<vtkPolyData> pd = vtkSmartPointer<vtkPolyData>::New();
>
>   vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
>   vtkSmartPointer<vtkCellArray> lines =
> vtkSmartPointer<vtkCellArray>::New();
>   vtkIdType* lineIndices = new vtkIdType[3];
>
>     points->InsertPoint(static_cast<vtkIdType>(0), 100,
>                         315,0.0 );
>     lineIndices[0] = static_cast<vtkIdType>(0);
>
>     points->InsertPoint(static_cast<vtkIdType>(1), 160,
>                         285,0.0 );
>     lineIndices[1] = static_cast<vtkIdType>(1);
>
>     points->InsertPoint(static_cast<vtkIdType>(2), 210,
>                         315,0.0 );
>     lineIndices[2] = static_cast<vtkIdType>(2);
>
>   lines->InsertNextCell(3,lineIndices);
>   delete [] lineIndices;
>   pd->SetPoints(points);
>   pd->SetLines(lines);
>
>   contourWidget->Initialize(pd);
>   contourWidget->Render();
>   renderer->ResetCamera();
>   renderWindow->Render();
>
>   vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
>     vtkSmartPointer<vtkRenderWindowInteractor>::New();
>   vtkSmartPointer<vtkInteractorStyleImage> style =
>     vtkSmartPointer<vtkInteractorStyleImage>::New();
>
>   interactor->SetInteractorStyle(style);
>
>   interactor->Initialize();
>   interactor->Start();
>
>   contourWidget->Off();
>
>   return EXIT_SUCCESS;
> }
>
> Thanks a lot.
>



-- 
Gish
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120712/4debabdc/attachment.htm>


More information about the vtkusers mailing list