38 #include <vtkArrowSource.h> 39 #include <vtkPolyData.h> 40 #include <vtkSmartPointer.h> 41 #include <vtkPolyDataMapper.h> 43 #include <vtkRenderWindow.h> 44 #include <vtkRenderer.h> 45 #include <vtkRenderWindowInteractor.h> 47 #include <vtkSphereSource.h> 48 #include <vtkCubeSource.h> 49 #include <vtkProperty.h> 50 #include <vtkTransform.h> 51 #include <vtkTransformPolyDataFilter.h> 57 m_start(start), m_end(end)
60 vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New();
63 Vec diff = end - start;
65 double length = diff.
length();
69 vtkMath::RandomSeed(8775070);
70 arbitrary[0] = vtkMath::Random(-10,10);
71 arbitrary[1] = vtkMath::Random(-10,10);
72 arbitrary[2] = vtkMath::Random(-10,10);
73 Vec dummy(arbitrary[0], arbitrary[1], arbitrary[2]);
79 vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New();
81 for (
unsigned int i = 0; i < 3; i++)
83 matrix->SetElement(i, 0, x_axis[i]);
84 matrix->SetElement(i, 1, y_axis[i]);
85 matrix->SetElement(i, 2, z_axis[i]);
89 vtkSmartPointer<vtkTransform>
transform = vtkSmartPointer<vtkTransform>::New();
90 transform->Translate(start[0], start[1], start[2]);
91 transform->Concatenate(matrix);
92 transform->Scale(length, length, length);
95 vtkSmartPointer<vtkTransformPolyDataFilter> transformPD = vtkSmartPointer<vtkTransformPolyDataFilter>::New();
96 transformPD->SetTransform(transform);
97 transformPD->SetInputConnection(arrowSource->GetOutputPort());
100 vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
102 mapper->SetInputConnection(arrowSource->GetOutputPort());
111 vtkSmartPointer<vtkCubeSource> cubeStartSource = vtkSmartPointer<vtkCubeSource>::New();
112 cubeStartSource->SetBounds(start[0], start[0] + 1, start[1], start[1] + 1,start[2], start[2] + 1);
113 vtkSmartPointer<vtkPolyDataMapper> cubeStartMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
114 cubeStartMapper->SetInputConnection(cubeStartSource->GetOutputPort());
120 vtkSmartPointer<vtkSphereSource> sphereStartSource = vtkSmartPointer<vtkSphereSource>::New();
121 sphereStartSource->SetCenter(start[0], start[1], start[2]);
122 vtkSmartPointer<vtkPolyDataMapper> sphereStartMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
123 sphereStartMapper->SetInputConnection(sphereStartSource->GetOutputPort());
131 vtkSmartPointer<vtkSphereSource> sphereEndSource = vtkSmartPointer<vtkSphereSource>::New();
132 sphereEndSource->SetCenter(end[0], end[1], end[2]);
133 vtkSmartPointer<vtkPolyDataMapper> sphereEndMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
134 sphereEndMapper->SetInputConnection(sphereEndSource->GetOutputPort());
135 m_endActor = vtkSmartPointer<vtkActor>::New();
137 m_endActor->GetProperty()->SetColor(1.0, .3, .3);
CoordT length() const
Returns the length of this vector.
vtkSmartPointer< vtkActor > m_startActor
vtkSmartPointer< vtkActor > getArrowActor()
BaseVector< CoordT > cross(const BaseVector &other) const
Calculates the cross product between this and the given vector. Returns a new BaseVector instance...
vtkSmartPointer< vtkActor > getStartActor()
void setTmpColor(double r, double g, double b)
vtkSmartPointer< vtkActor > m_arrowActor
vtkSmartPointer< vtkActor > getEndActor()
LVRVtkArrow(Vec start, Vec end)
vtkSmartPointer< vtkActor > m_endActor