37 #include "vtkSuperquadricSource.h"
39 #include <vtkPolyDataMapper.h>
40 #include <vtkProperty.h>
41 #include <vtkRenderer.h>
42 #include <vtkRenderWindow.h>
45 #include "vtkMatrix4x4.h"
47 #include <vtkProperty.h>
57 source = vtkSuperquadricSourcePtr::New();
58 source->SetToroidal(
true);
60 source->SetThickness(0.5);
61 source->SetThetaResolution(source->GetThetaResolution()*2);
63 mapper = vtkPolyDataMapperPtr::New();
64 mapper->SetInputConnection(source->GetOutputPort());
66 actor = vtkActorPtr::New();
67 actor->SetMapper(mapper);
80 mRenderer->RemoveActor(actor);
83 mRenderer->AddActor(actor);
88 source->SetSize(value);
93 source->SetThickness(value);
104 this->updateOrientation();
109 mDirection = direction;
111 this->updateOrientation();
114 void GraphicalTorus3D::updateOrientation()
118 bool directionAlongYAxis =
similar(
dot(Vector3D::UnitY(), mDirection.normal()), 1.0);
120 if (directionAlongYAxis)
122 M = Transform3D::Identity();
126 Vector3D ivec =
cross(Vector3D::UnitY(), mDirection).normal();
127 Vector3D jvec = mDirection.normal();
137 actor->SetUserMatrix(M.getVtkMatrix());
147 return source->GetOutput();
vtkSmartPointer< class vtkActor > vtkActorPtr
Transform3D Transform3D
Transform3D is a representation of an affine 3D transform.
void setThickness(double radius)
vtkPolyDataPtr getPolyData()
void setDirection(Vector3D direction)
bool similar(const DoubleBoundingBox3D &a, const DoubleBoundingBox3D &b, double tol)
Vector3D cross(const Vector3D &a, const Vector3D &b)
compute cross product of a and b.
void setRenderer(vtkRendererPtr renderer=vtkRendererPtr())
vtkSmartPointer< class vtkPolyData > vtkPolyDataPtr
Transform3D createTransformIJC(const Vector3D &ivec, const Vector3D &jvec, const Vector3D ¢er)
vtkSmartPointer< class vtkRenderer > vtkRendererPtr
GraphicalTorus3D(vtkRendererPtr renderer=vtkRendererPtr())
Transform3D createTransformTranslate(const Vector3D &translation)
double dot(const Vector3D &a, const Vector3D &b)
compute inner product (or dot product) of a and b.
Eigen::Vector3d Vector3D
Vector3D is a representation of a point or vector in 3D.
void setRadius(double value)
void setColor(QColor color)
void setPosition(Vector3D point)
void setColorAndOpacity(vtkPropertyPtr property, QColor color)