///////////////////////////////////////////////////////////////////////////////////////////////
/// line widget implementation
temp_viz::LineWidget::LineWidget(const Point3f &pt1, const Point3f &pt2, const Color &color)
-{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
+{
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New();
line->SetPoint1 (pt1.x, pt1.y, pt1.z);
line->SetPoint2 (pt2.x, pt2.y, pt2.z);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(line->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
void temp_viz::LineWidget::setLineWidth(float line_width)
{
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
+ CV_Assert(actor);
actor->GetProperty()->SetLineWidth(line_width);
}
float temp_viz::LineWidget::getLineWidth()
{
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getProp(*this));
+ CV_Assert(actor);
return actor->GetProperty()->GetLineWidth();
}
/// plane widget implementation
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, double size, const Color &color)
-{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
+{
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
plane->SetNormal (coefs[0], coefs[1], coefs[2]);
double norm = cv::norm(cv::Vec3f(coefs.val));
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(plane->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
actor->SetScale(size);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
temp_viz::PlaneWidget::PlaneWidget(const Vec4f& coefs, const Point3f& pt, double size, const Color &color)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<vtkPlaneSource>::New ();
cv::Point3f coefs3(coefs[0], coefs[1], coefs[2]);
double norm_sqr = 1.0 / coefs3.dot (coefs3);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(plane->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
actor->SetScale(size);
-
+
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
temp_viz::SphereWidget::SphereWidget(const cv::Point3f ¢er, float radius, int sphere_resolution, const Color &color)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
vtkSmartPointer<vtkSphereSource> sphere = vtkSmartPointer<vtkSphereSource>::New ();
sphere->SetRadius (radius);
sphere->SetCenter (center.x, center.y, center.z);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(sphere->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
temp_viz::ArrowWidget::ArrowWidget(const Point3f& pt1, const Point3f& pt2, const Color &color)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
vtkSmartPointer<vtkArrowSource> arrowSource = vtkSmartPointer<vtkArrowSource>::New ();
float startPoint[3], endPoint[3];
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(transformPD->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
temp_viz::CircleWidget::CircleWidget(const temp_viz::Point3f& pt, double radius, double thickness, const temp_viz::Color& color)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
vtkSmartPointer<vtkDiskSource> disk = vtkSmartPointer<vtkDiskSource>::New ();
// Maybe the resolution should be lower e.g. 50 or 25
disk->SetCircumferentialResolution (50);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(tf->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
/// cylinder widget implementation
temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides, const Color &color)
-{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
+{
const cv::Point3f pt2 = pt_on_axis + axis_direction;
vtkSmartPointer<vtkLineSource> line = vtkSmartPointer<vtkLineSource>::New ();
line->SetPoint1 (pt_on_axis.x, pt_on_axis.y, pt_on_axis.z);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(tuber->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New ();
actor->SetMapper(mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, bool wire_frame, const Color &color)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
vtkSmartPointer<vtkCubeSource> cube = vtkSmartPointer<vtkCubeSource>::New ();
cube->SetBounds (pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z);
vtkSmartPointer<vtkDataSetMapper> mapper = vtkSmartPointer<vtkDataSetMapper>::New ();
mapper->SetInput(cube->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
if (wire_frame)
actor->GetProperty ()->SetRepresentationToWireframe ();
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
temp_viz::CoordinateSystemWidget::CoordinateSystemWidget(double scale, const Affine3f& affine)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
vtkSmartPointer<vtkAxes> axes = vtkSmartPointer<vtkAxes>::New ();
axes->SetOrigin (0, 0, 0);
axes->SetScaleFactor (scale);
mapper->SetScalarModeToUsePointData ();
mapper->SetInput(axes_tubes->GetOutput ());
- vtkLODActor *actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
cv::Vec3d t = affine.translation();
actor->SetOrientation(0,0,0);
actor->RotateWXYZ(r_angle*180/CV_PI,rvec[0], rvec[1], rvec[2]);
+
+ WidgetAccessor::setProp(*this, actor);
}
temp_viz::CoordinateSystemWidget& temp_viz::CoordinateSystemWidget::operator=(const Widget &other)
temp_viz::TextWidget::TextWidget(const String &text, const Point2i &pos, int font_size, const Color &color)
{
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkTextActor>::New());
-
- vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New();
actor->SetPosition (pos.x, pos.y);
actor->SetInput (text.c_str ());
Color c = vtkcolor(color);
tprop->SetColor (c.val);
+
+ WidgetAccessor::setProp(*this, actor);
}
temp_viz::TextWidget& temp_viz::TextWidget::operator=(const Widget &other)
return *this;
}
+void temp_viz::TextWidget::setText(const String &text)
+{
+ vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
+ CV_Assert(actor);
+ actor->SetInput(text.c_str());
+}
+
+temp_viz::String temp_viz::TextWidget::getText() const
+{
+ vtkTextActor *actor = vtkTextActor::SafeDownCast(WidgetAccessor::getProp(*this));
+ CV_Assert(actor);
+ return actor->GetInput();
+}
+
///////////////////////////////////////////////////////////////////////////////////////////////
/// point cloud widget implementation
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
CV_Assert(colors.type() == CV_8UC3 && cloud.size() == colors.size());
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
- vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
vtkIdType nr_points;
vtkSmartPointer<vtkPolyData> polydata = CreateCloudWidget::create(cloud, nr_points);
actor->GetProperty ()->SetInterpolationToFlat ();
actor->GetProperty ()->BackfaceCullingOn ();
actor->SetMapper (mapper);
+
+ WidgetAccessor::setProp(*this, actor);
}
temp_viz::CloudWidget::CloudWidget(InputArray _cloud, const Color &color)
Mat cloud = _cloud.getMat();
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
- vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
vtkIdType nr_points;
vtkSmartPointer<vtkPolyData> polydata = CreateCloudWidget::create(cloud, nr_points);
actor->GetProperty ()->BackfaceCullingOn ();
actor->SetMapper (mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
Mat normals = _normals.getMat();
CV_Assert(cloud.type() == CV_32FC3 || cloud.type() == CV_64FC3 || cloud.type() == CV_32FC4 || cloud.type() == CV_64FC4);
CV_Assert(cloud.size() == normals.size() && cloud.type() == normals.type());
-
- WidgetAccessor::setVtkProp(*this, vtkSmartPointer<vtkLODActor>::New());
-
+
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkCellArray> lines = vtkSmartPointer<vtkCellArray>::New();
vtkIdType nr_normals = 0;
mapper->SetColorModeToMapScalars();
mapper->SetScalarModeToUsePointData();
- vtkLODActor * actor = vtkLODActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkSmartPointer<vtkLODActor> actor = vtkSmartPointer<vtkLODActor>::New();
actor->SetMapper(mapper);
+ WidgetAccessor::setProp(*this, actor);
setColor(color);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/// widget accessor implementaion
-vtkSmartPointer<vtkProp> temp_viz::WidgetAccessor::getActor(const Widget& widget)
+vtkSmartPointer<vtkProp> temp_viz::WidgetAccessor::getProp(const Widget& widget)
{
return widget.impl_->actor;
}
-void temp_viz::WidgetAccessor::setVtkProp(Widget& widget, vtkSmartPointer<vtkProp> actor)
+void temp_viz::WidgetAccessor::setProp(Widget& widget, vtkSmartPointer<vtkProp> actor)
{
widget.impl_->actor = actor;
}
temp_viz::Widget3D::Widget3D(const Widget& other) : Widget(other)
{
// Check if other's actor is castable to vtkProp3D
- vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(other));
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(other));
CV_Assert(actor);
}
temp_viz::Widget3D& temp_viz::Widget3D::operator =(const Widget &other)
{
// Check if other's actor is castable to vtkProp3D
- vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(other));
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(other));
CV_Assert(actor);
Widget::operator=(other);
void temp_viz::Widget3D::setPose(const Affine3f &pose)
{
- vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert(actor);
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix);
void temp_viz::Widget3D::updatePose(const Affine3f &pose)
{
- vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert(actor);
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
temp_viz::Affine3f temp_viz::Widget3D::getPose() const
{
- vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkProp3D *actor = vtkProp3D::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert(actor);
vtkSmartPointer<vtkMatrix4x4> matrix = actor->GetUserMatrix();
void temp_viz::Widget3D::setColor(const Color &color)
{
// Cast to actor instead of prop3d since prop3d doesn't provide getproperty
- vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkActor *actor = vtkActor::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert(actor);
Color c = vtkcolor(color);
temp_viz::Widget2D::Widget2D(const Widget &other) : Widget(other)
{
// Check if other's actor is castable to vtkActor2D
- vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getActor(other));
+ vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(other));
CV_Assert(actor);
}
temp_viz::Widget2D& temp_viz::Widget2D::operator=(const Widget &other)
{
// Check if other's actor is castable to vtkActor2D
- vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getActor(other));
+ vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(other));
CV_Assert(actor);
Widget::operator=(other);
return *this;
void temp_viz::Widget2D::setColor(const Color &color)
{
- vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getActor(*this));
+ vtkActor2D *actor = vtkActor2D::SafeDownCast(WidgetAccessor::getProp(*this));
CV_Assert(actor);
Color c = vtkcolor(color);
actor->GetProperty ()->SetColor (c.val);