1 #include <cpExtensions/Visualization/LineSource.h>
2 #include <vtkInformation.h>
3 #include <vtkInformationVector.h>
5 // -------------------------------------------------------------------------
6 cpExtensions::Visualization::LineSource::
7 Self* cpExtensions::Visualization::LineSource::
10 return( new Self( ) );
13 // -------------------------------------------------------------------------
14 void cpExtensions::Visualization::LineSource::
15 SetPoint1( float pnt[ 3 ] )
24 // -------------------------------------------------------------------------
25 void cpExtensions::Visualization::LineSource::
26 SetPoint2( float pnt[ 3 ] )
35 // -------------------------------------------------------------------------
36 cpExtensions::Visualization::LineSource::
40 this->SetNumberOfInputPorts( 0 );
41 this->Point1[ 0 ] = -double( 0.5 );
42 this->Point1[ 1 ] = double( 0.0 );
43 this->Point1[ 2 ] = double( 0.0 );
44 this->Point2[ 0 ] = double( 0.5 );
45 this->Point2[ 1 ] = double( 0.0 );
46 this->Point2[ 2 ] = double( 0.0 );
49 // -------------------------------------------------------------------------
50 cpExtensions::Visualization::LineSource::
55 // -------------------------------------------------------------------------
56 int cpExtensions::Visualization::LineSource::
58 vtkInformation* request,
59 vtkInformationVector** inputVector,
60 vtkInformationVector* outputVector
64 vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
66 vtkPolyData::SafeDownCast(
67 outInfo->Get( vtkDataObject::DATA_OBJECT( ) )
71 vtkPoints* points = vtkPoints::New( );
72 points->SetDataType( VTK_FLOAT );
73 points->Allocate( 2 );
76 vtkCellArray* verts = vtkCellArray::New( );
77 vtkCellArray* lines = vtkCellArray::New( );
78 vtkCellArray* faces = vtkCellArray::New( );
79 vtkCellArray* strips = vtkCellArray::New( );
80 lines->Allocate( lines->EstimateSize( 2, 2 ) );
83 points->InsertPoint( 0, this->Point1 );
84 points->InsertPoint( 1, this->Point2 );
87 vtkIdType cell_pts[ 2 ] = { 0, 1 };
88 lines->InsertNextCell( 2, cell_pts );
91 output->SetPoints( points );
92 output->SetVerts( verts );
93 output->SetLines( lines );
94 output->SetPolys( faces );
95 output->SetStrips( strips );
106 // -------------------------------------------------------------------------
107 int cpExtensions::Visualization::LineSource::
109 vtkInformation* request,
110 vtkInformationVector** inputVector,
111 vtkInformationVector* outputVector
114 vtkInformation* outInfo = outputVector->GetInformationObject( 0 );
115 outInfo->Set( CAN_HANDLE_PIECE_REQUEST(), 1 );