From 03cc439b08b78075c77c6738c3aa0f25c629b787 Mon Sep 17 00:00:00 2001 From: ozantonkal Date: Thu, 4 Jul 2013 17:59:11 +0300 Subject: [PATCH] cube widget implementation --- modules/viz/include/opencv2/viz/widgets.hpp | 6 ++++++ modules/viz/src/simple_widgets.cpp | 17 +++++++++++++++++ modules/viz/test/test_viz3d.cpp | 3 +++ 3 files changed, 26 insertions(+) diff --git a/modules/viz/include/opencv2/viz/widgets.hpp b/modules/viz/include/opencv2/viz/widgets.hpp index a731dcf..9f83d3c 100644 --- a/modules/viz/include/opencv2/viz/widgets.hpp +++ b/modules/viz/include/opencv2/viz/widgets.hpp @@ -73,5 +73,11 @@ namespace temp_viz public: CylinderWidget(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white()); }; + + class CV_EXPORTS CubeWidget : public Widget + { + public: + CubeWidget(const Point3f& pt_min, const Point3f& pt_max, const Color &color = Color::white()); + }; } diff --git a/modules/viz/src/simple_widgets.cpp b/modules/viz/src/simple_widgets.cpp index 36b22d9..7f7db1b 100644 --- a/modules/viz/src/simple_widgets.cpp +++ b/modules/viz/src/simple_widgets.cpp @@ -208,3 +208,20 @@ temp_viz::CylinderWidget::CylinderWidget(const Point3f& pt_on_axis, const Point3 setColor(color); } + +/////////////////////////////////////////////////////////////////////////////////////////////// +/// cylinder widget implementation + +temp_viz::CubeWidget::CubeWidget(const Point3f& pt_min, const Point3f& pt_max, const Color &color) +{ + vtkSmartPointer cube = vtkSmartPointer::New (); + cube->SetBounds (pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z); + + vtkSmartPointer mapper = vtkSmartPointer::New (); + mapper->SetInput(cube->GetOutput ()); + + vtkSmartPointer actor = WidgetAccessor::getActor(*this); + actor->SetMapper(mapper); + + setColor(color); +} diff --git a/modules/viz/test/test_viz3d.cpp b/modules/viz/test/test_viz3d.cpp index 66a78b1..720145a 100644 --- a/modules/viz/test/test_viz3d.cpp +++ b/modules/viz/test/test_viz3d.cpp @@ -98,6 +98,7 @@ TEST(Viz_viz3d, accuracy) temp_viz::ArrowWidget aw(cv::Point3f(0,0,0), cv::Point3f(1,1,1), temp_viz::Color(255,0,0)); temp_viz::CircleWidget cw(cv::Point3f(0,0,0), 1.0, temp_viz::Color(0,255,0)); temp_viz::CylinderWidget cyw(cv::Point3f(0,0,0), cv::Point3f(-1,-1,-1), 0.5, 30, temp_viz::Color(0,255,0)); + temp_viz::CubeWidget cuw(cv::Point3f(-2,-2,-2), cv::Point3f(-1,-1,-1), temp_viz::Color(0,0,255)); v.showWidget("line", lw); v.showWidget("plane", pw); @@ -105,6 +106,7 @@ TEST(Viz_viz3d, accuracy) v.showWidget("arrow", aw); v.showWidget("circle", cw); v.showWidget("cylinder", cyw); + v.showWidget("cube", cuw); temp_viz::LineWidget lw2 = lw; @@ -132,6 +134,7 @@ TEST(Viz_viz3d, accuracy) cw.setPose(cloudPosition); cyw.setPose(cloudPosition); lw.setPose(cloudPosition); + cuw.setPose(cloudPosition); angle_x += 0.1f; angle_y -= 0.1f; -- 2.7.4