[vtkusers] problem with xyPlot

edoardo.belletti at alice.it edoardo.belletti at alice.it
Fri Mar 26 06:24:14 EDT 2010


Hi
I have a problem with this exaple:

/*=========================================================================

  Program:   Visualization Toolkit
  Module:    $RCSfile: Cylinder.cxx,v $

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/
//This example demonstrates the use of vtkXYPlotActor to display three
//probe lines using three different techniques.  In this example, we are
//loading data using the vtkPLOT3DReader.  We are using the vtkProbeFilter
//to extract the underlying point data along three probe lines.

//
//First we include the VTK Tcl packages which will make available
//all of the vtk commands to Tcl.
//
#include "vtkPLOT3DReader.h"
#include "vtkLineSource.h"
#include "vtkTransform.h"
#include "vtkTransformPolyDataFilter.h"
#include "vtkProbeFilter.h"
#include "vtkProperty2D.h"

#include "vtkAppendPolyData.h"
#include "vtkTubeFilter.h"

#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkXYPlotActor.h"
#include "vtkTextProperty.h"
#include "vtkStructuredGridOutlineFilter.h"

#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"

int main()
{
  //Create a PLOT3D reader and load the data.
//
vtkPLOT3DReader *pl3d=vtkPLOT3DReader::New();
    pl3d->SetXYZFileName("combxyz.bin");
    pl3d->SetQFileName("combq.bin");
    pl3d->SetScalarFunctionNumber(100);
    pl3d->SetVectorFunctionNumber(202);
    pl3d->Update();

//Create three the line source to use for the probe lines.
vtkLineSource *line=vtkLineSource::New();
    line->SetResolution(30);


//Move the line into place and create the probe filter.  For vtkProbeFilter,
//the probe line is the input, and the underlying data set is the source.
vtkTransform *transL1=vtkTransform::New();
    transL1->Translate(3.7,0.0,28.37);
    transL1->Scale(5,5,5);
    transL1->RotateY(90);
vtkTransformPolyDataFilter *tf=vtkTransformPolyDataFilter::New();
    tf->SetInputConnection(line->GetOutputPort());
    tf->SetTransform(transL1);
vtkProbeFilter *probe=vtkProbeFilter::New();
    probe->SetInputConnection(tf->GetOutputPort());
    probe->SetSource(pl3d->GetOutput());

//Move the line again and create another probe filter.
vtkTransform *transL2=vtkTransform::New();
    transL2->Translate(9.2,0.0,31.20);
    transL2->Scale (5, 5, 5);
    transL2-> RotateY (90);
vtkTransformPolyDataFilter *tf2=vtkTransformPolyDataFilter::New();
    tf2-> SetInputConnection (line-> GetOutputPort());
    tf2 ->SetTransform (transL2);
vtkProbeFilter *probe2=vtkProbeFilter::New();
    probe2-> SetInputConnection (tf2 ->GetOutputPort());
    probe2-> SetSource (pl3d-> GetOutput());

//Move the line again and create a third probe filter.
vtkTransform *transL3=vtkTransform::New();
    transL3-> Translate( 13.27, 0.0, 33.40);
    transL3->Scale( 4.5, 4.5, 4.5);
    transL3-> RotateY( 90);
vtkTransformPolyDataFilter *tf3=vtkTransformPolyDataFilter::New();
    tf3-> SetInputConnection(line->GetOutputPort());
    tf3-> SetTransform (transL3);
vtkProbeFilter *probe3=vtkProbeFilter::New();
    probe3-> SetInputConnection (tf3 ->GetOutputPort());
    probe3-> SetSource(pl3d-> GetOutput());

//Create a vtkAppendPolyData to merge the output of the three probe filters
//into one data set.
vtkAppendPolyData *appendF=vtkAppendPolyData::New();
    appendF-> AddInput (probe-> GetPolyDataOutput());
    appendF-> AddInput (probe2-> GetPolyDataOutput());
    appendF-> AddInput (probe3-> GetPolyDataOutput());

//Create a tube filter to represent the lines as tubes.  Set up the associated
//mapper and actor.
vtkTubeFilter *tuber=vtkTubeFilter::New();
    tuber-> SetInputConnection (appendF->GetOutputPort());
    tuber-> SetRadius (0.1);
vtkPolyDataMapper *lineMapper=vtkPolyDataMapper::New();
    lineMapper-> SetInputConnection (tuber-> GetOutputPort());
vtkActor *lineActor=vtkActor::New();
    lineActor-> SetMapper( lineMapper);

// Create an xy-plot using the output of the 3 probe filters as input.
//The x-values we are plotting are arc length.
vtkXYPlotActor *xyplot=vtkXYPlotActor::New();
    xyplot-> AddInput (probe-> GetOutput());
    xyplot-> AddInput (probe2-> GetOutput());
    xyplot->AddInput (probe3-> GetOutput());
    xyplot->GetPositionCoordinate()-> SetValue (0.0, 0.67, 0);
    xyplot-> GetPosition2Coordinate()-> SetValue (1.0, 0.33, 0);    //relative to
Position
    xyplot-> SetXValuesToArcLength();
    xyplot-> SetNumberOfXLabels( 6);
    xyplot ->SetTitle ("Pressure vs. Arc Length (Zoomed View)");
    xyplot-> SetXTitle( "");
    xyplot-> SetYTitle ("P");
    xyplot-> SetXRange( .1 ,.35);
    xyplot-> SetYRange( .2, .4);
    xyplot-> GetProperty()-> SetColor (0, 0, 0);
    xyplot-> GetProperty()-> SetLineWidth( 2);
    //Set text prop color (same color for backward compat with test)
    //Assign same object to all text props
vtkTextProperty *tprop;
    tprop =xyplot-> GetTitleTextProperty();
    tprop ->SetColor(xyplot-> GetProperty()-> GetColor());
    xyplot ->SetAxisTitleTextProperty (tprop);
    xyplot-> SetAxisLabelTextProperty (tprop);

//Create an xy-plot using the output of the 3 probe filters as input.
//The x-values we are plotting are normalized arc length.
vtkXYPlotActor *xyplot2=vtkXYPlotActor::New();
    xyplot2-> AddInput (probe-> GetOutput());
    xyplot2 ->AddInput (probe2 ->GetOutput());
    xyplot2-> AddInput (probe3 ->GetOutput());
    xyplot2-> GetPositionCoordinate()-> SetValue (0.00 ,0.33, 0);
    xyplot2-> GetPosition2Coordinate()-> SetValue( 1.0, 0.33, 0);        //
relative to Position
    xyplot2-> SetXValuesToNormalizedArcLength();
    xyplot2-> SetNumberOfXLabels (6);
    xyplot2-> SetTitle ("Pressure vs. Normalized Arc Length");
    xyplot2-> SetXTitle ("");
    xyplot2 ->SetYTitle ("P");
    xyplot2-> PlotPointsOn();
    xyplot2 ->PlotLinesOff();
    xyplot2-> GetProperty()-> SetColor (1 ,0, 0);
    xyplot2-> GetProperty()-> SetPointSize (2);
    //Set text prop color (same color for backward compat with test)
    //Assign same object to all text props
//vtkTextProperty *tprop;
    tprop =xyplot2-> GetTitleTextProperty();
    tprop ->SetColor(xyplot-> GetProperty()-> GetColor());
    xyplot2 ->SetAxisTitleTextProperty (tprop);
    xyplot2-> SetAxisLabelTextProperty (tprop);

//Create an xy-plot using the output of the 3 probe filters as input.
//The x-values we are plotting are the underlying point data values.
vtkXYPlotActor *xyplot3=vtkXYPlotActor::New();
    xyplot3-> AddInput (probe-> GetOutput());
    xyplot3-> AddInput (probe2-> GetOutput());
    xyplot3 ->AddInput (probe3 ->GetOutput());
    xyplot3-> GetPositionCoordinate()-> SetValue (0.0, 0.0 ,0);
    xyplot3-> GetPosition2Coordinate()-> SetValue (1.0, 0.33, 0);            
//relative to Position
    xyplot3 ->SetXValuesToIndex();
    xyplot3-> SetNumberOfXLabels (6);
    xyplot3 ->SetTitle ("Pressure vs. Point Id");
    xyplot3-> SetXTitle ("Probe Length");
    xyplot3 ->SetYTitle ("P");
    xyplot3 ->PlotPointsOn();
    xyplot3->GetProperty()-> SetColor (0 ,0, 1);
    xyplot3-> GetProperty()-> SetPointSize (3);
   // Set text prop color (same color for backward compat with test)
    //sign same object to all text props
//vtkTextProperty *tprop;
    tprop =xyplot3-> GetTitleTextProperty();
    tprop ->SetColor(xyplot-> GetProperty()-> GetColor());
    xyplot3 ->SetAxisTitleTextProperty (tprop);
    xyplot3-> SetAxisLabelTextProperty (tprop);

//aw an outline of the PLOT3D data set.
vtkStructuredGridOutlineFilter *outline=vtkStructuredGridOutlineFilter::New();
    outline ->SetInputConnection (pl3d-> GetOutputPort());
vtkPolyDataMapper *outlineMapper=vtkPolyDataMapper::New();
    outlineMapper-> SetInputConnection (outline ->GetOutputPort());
vtkActor *outlineActor=vtkActor::New();
    outlineActor-> SetMapper (outlineMapper);
    outlineActor-> GetProperty()-> SetColor( 0, 0, 0);

//Create the Renderers, RenderWindow, and RenderWindowInteractor.
  vtkRenderer *ren1 = vtkRenderer::New();
  vtkRenderer *ren2 = vtkRenderer::New();

  vtkRenderWindow *renWin = vtkRenderWindow::New();
  renWin->AddRenderer(ren1);
  renWin->AddRenderer(ren2);

  vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
  iren->SetRenderWindow(renWin);

//Set the background, viewport (necessary because we want to have the
//renderers draw to different parts of the render window) of the first
// renderer.  Add the outline and line actors to the renderer.  
ren1-> SetBackground (0.6784 ,0.8471, 0.9020);
ren1 ->SetViewport (0, 0, .5, 1);
ren1-> AddActor (outlineActor);
ren1 ->AddActor (lineActor);
// Set the background and viewport of the second renderer.  Add the xy-plot
//actors to the renderer.  Set the size of the render window.
ren2 ->SetBackground (1, 1, 1);
ren2 ->SetViewport (0.5 ,0.0 ,1.0, 1.0);
ren2 ->AddActor2D (xyplot);
ren2->AddActor2D (xyplot2);
ren2-> AddActor2D (xyplot3);
renWin-> SetSize (500, 250);
  // We'll zoom in a little by accessing the camera and invoking a "Zoom"
  // method on it.
  ren1->ResetCamera();
  ren1->GetActiveCamera()->Zoom(1.5);
  renWin->Render();
 
  
// Set up the camera parameters.
  vtkCamera *cam1;
     cam1= ren1 ->GetActiveCamera();
     cam1-> SetClippingRange (3.95297, 100);
     cam1-> SetFocalPoint (8.88908, 0.595038 ,29.3342);
     cam1-> SetPosition (-12.3332, 31.7479, 41.2387);
     cam1-> SetViewUp (0.060772, -0.319905, 0.945498);
iren ->Initialize();



  // 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.
  pl3d->Delete();
  line->Delete();
  transL1->Delete();
	tf->Delete();
	probe->Delete();
	transL2->Delete();
	tf2->Delete();
	probe2->Delete();
	transL3->Delete();
	tf3->Delete();
	probe3->Delete();
	appendF->Delete();
	tuber->Delete();
	lineMapper->Delete();
	lineActor->Delete();
	xyplot->Delete();
	xyplot2->Delete();
	xyplot3->Delete();
	outline->Delete();
	outlineMapper->Delete();
	outlineActor->Delete();
  ren1->Delete();
  ren2->Delete();
  renWin->Delete();
  iren->Delete();

  return 0;
}


why my output is that?:

~$ make
[100%] Building CXX object CMakeFiles/xyPlot.dir/xyPlot.o
/home/edoardo/VTK/plot/src/xyPlot.cxx: In function ‘int main()’:
/home/edoardo/VTK/plot/src/xyPlot.cxx:73: error: no matching function for call to ‘vtkProbeFilter::SetSource(vtkStructuredGrid*)’
/usr/local/include/vtk-5.4/vtkProbeFilter.h:55: note: candidates are: void vtkProbeFilter::SetSource(vtkDataObject*)
/home/edoardo/VTK/plot/src/xyPlot.cxx:85: error: no matching function for call to ‘vtkProbeFilter::SetSource(vtkStructuredGrid*)’
/usr/local/include/vtk-5.4/vtkProbeFilter.h:55: note: candidates are: void vtkProbeFilter::SetSource(vtkDataObject*)
/home/edoardo/VTK/plot/src/xyPlot.cxx:97: error: no matching function for call to ‘vtkProbeFilter::SetSource(vtkStructuredGrid*)’
/usr/local/include/vtk-5.4/vtkProbeFilter.h:55: note: candidates are: void vtkProbeFilter::SetSource(vtkDataObject*)
/home/edoardo/VTK/plot/src/xyPlot.cxx:124: error: ‘Position’ was not declared in this scope
/home/edoardo/VTK/plot/src/xyPlot.cxx:125: error: expected ‘;’ before ‘xyplot’
/home/edoardo/VTK/plot/src/xyPlot.cxx:150: error: ‘relative’ was not declared in this scope
/home/edoardo/VTK/plot/src/xyPlot.cxx:150: error: expected ‘;’ before ‘to’
make[2]: *** [CMakeFiles/xyPlot.dir/xyPlot.o] Errore 1
make[1]: *** [CMakeFiles/xyPlot.dir/all] Errore 2
make: *** [all] Errore 2

Thank you very much for the interest
Best regards
Edoardo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100326/60aa45b5/attachment.htm>


More information about the vtkusers mailing list