added cone implementation
This commit is contained in:
@@ -349,7 +349,7 @@ viz::WCircle
|
|||||||
|
|
||||||
This 3D Widget defines a circle. ::
|
This 3D Widget defines a circle. ::
|
||||||
|
|
||||||
class CV_EXPORTS WCircle : public Widget3D
|
class CV_EXPORTS WCircle : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//! creates default planar circle centred at origin with plane normal along z-axis
|
//! creates default planar circle centred at origin with plane normal along z-axis
|
||||||
@@ -381,6 +381,46 @@ Constructs repositioned planar circle.
|
|||||||
:param thickness: Thickness of the circle.
|
:param thickness: Thickness of the circle.
|
||||||
:param color: :ocv:class:`Color` of the circle.
|
:param color: :ocv:class:`Color` of the circle.
|
||||||
|
|
||||||
|
|
||||||
|
viz::WCone
|
||||||
|
-----------------
|
||||||
|
.. ocv:class:: WCone
|
||||||
|
|
||||||
|
This 3D Widget defines a cone. ::
|
||||||
|
|
||||||
|
class CV_EXPORTS WCone : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! create default cone, oriented along x-axis with center of its base located at origin
|
||||||
|
WCone(double lenght, double radius, int resolution = 6.0, const Color &color = Color::white());
|
||||||
|
|
||||||
|
//! creates repositioned cone
|
||||||
|
WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
|
viz::WCone::WCone
|
||||||
|
-------------------------------
|
||||||
|
Constructs default cone oriented along x-axis with center of its base located at origin
|
||||||
|
|
||||||
|
.. ocv:function:: WCone(double length, double radius, int resolution = 6.0, const Color &color = Color::white());
|
||||||
|
|
||||||
|
:param length: Length of the cone.
|
||||||
|
:param radius: Radius of the cone.
|
||||||
|
:param resolution: Resolution of the cone.
|
||||||
|
:param color: :ocv:class:`Color` of the cone.
|
||||||
|
|
||||||
|
viz::WCone::WCone
|
||||||
|
-------------------------------
|
||||||
|
Constructs repositioned planar cone.
|
||||||
|
|
||||||
|
.. ocv:function:: WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
|
||||||
|
|
||||||
|
:param radius: Radius of the cone.
|
||||||
|
:param center: Center of the cone base.
|
||||||
|
:param tip: Tip of the cone.
|
||||||
|
:param resolution: Resolution of the cone.
|
||||||
|
:param color: :ocv:class:`Color` of the cone.
|
||||||
|
|
||||||
viz::WCylinder
|
viz::WCylinder
|
||||||
--------------
|
--------------
|
||||||
.. ocv:class:: WCylinder
|
.. ocv:class:: WCylinder
|
||||||
|
@@ -171,6 +171,16 @@ namespace cv
|
|||||||
WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
|
WCircle(double radius, const Point3d& center, const Vec3d& normal, double thickness = 0.01, const Color &color = Color::white());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CV_EXPORTS WCone : public Widget3D
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! create default cone, oriented along x-axis with center of its base located at origin
|
||||||
|
WCone(double length, double radius, int resolution = 6.0, const Color &color = Color::white());
|
||||||
|
|
||||||
|
//! creates repositioned cone
|
||||||
|
WCone(double radius, const Point3d& center, const Point3d& tip, int resolution = 6.0, const Color &color = Color::white());
|
||||||
|
};
|
||||||
|
|
||||||
class CV_EXPORTS WCylinder : public Widget3D
|
class CV_EXPORTS WCylinder : public Widget3D
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -341,6 +351,7 @@ namespace cv
|
|||||||
template<> CV_EXPORTS WCylinder Widget::cast<WCylinder>();
|
template<> CV_EXPORTS WCylinder Widget::cast<WCylinder>();
|
||||||
template<> CV_EXPORTS WArrow Widget::cast<WArrow>();
|
template<> CV_EXPORTS WArrow Widget::cast<WArrow>();
|
||||||
template<> CV_EXPORTS WCircle Widget::cast<WCircle>();
|
template<> CV_EXPORTS WCircle Widget::cast<WCircle>();
|
||||||
|
template<> CV_EXPORTS WCone Widget::cast<WCone>();
|
||||||
template<> CV_EXPORTS WCube Widget::cast<WCube>();
|
template<> CV_EXPORTS WCube Widget::cast<WCube>();
|
||||||
template<> CV_EXPORTS WCoordinateSystem Widget::cast<WCoordinateSystem>();
|
template<> CV_EXPORTS WCoordinateSystem Widget::cast<WCoordinateSystem>();
|
||||||
template<> CV_EXPORTS WPolyLine Widget::cast<WPolyLine>();
|
template<> CV_EXPORTS WPolyLine Widget::cast<WPolyLine>();
|
||||||
|
@@ -127,6 +127,7 @@
|
|||||||
#include <vtkTensorGlyph.h>
|
#include <vtkTensorGlyph.h>
|
||||||
#include <vtkImageAlgorithm.h>
|
#include <vtkImageAlgorithm.h>
|
||||||
#include <vtkTransformFilter.h>
|
#include <vtkTransformFilter.h>
|
||||||
|
#include <vtkConeSource.h>
|
||||||
#include <vtkStreamingDemandDrivenPipeline.h>
|
#include <vtkStreamingDemandDrivenPipeline.h>
|
||||||
|
|
||||||
#if !defined(_WIN32) || defined(__CYGWIN__)
|
#if !defined(_WIN32) || defined(__CYGWIN__)
|
||||||
|
@@ -253,6 +253,46 @@ template<> cv::viz::WCircle cv::viz::Widget::cast<cv::viz::WCircle>()
|
|||||||
return static_cast<WCircle&>(widget);
|
return static_cast<WCircle&>(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// WCone widget implementation
|
||||||
|
|
||||||
|
cv::viz::WCone::WCone(double length, double radius, int resolution, const Color &color)
|
||||||
|
{
|
||||||
|
vtkSmartPointer<vtkConeSource> cone_source = vtkSmartPointer<vtkConeSource>::New();
|
||||||
|
cone_source->SetCenter(length*0.5, 0.0, 0.0);
|
||||||
|
cone_source->SetHeight(length);
|
||||||
|
cone_source->SetRadius(radius);
|
||||||
|
cone_source->SetResolution(resolution);
|
||||||
|
cone_source->Update();
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||||
|
VtkUtils::SetInputData(mapper, cone_source->GetOutput());
|
||||||
|
|
||||||
|
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||||
|
actor->SetMapper(mapper);
|
||||||
|
|
||||||
|
WidgetAccessor::setProp(*this, actor);
|
||||||
|
setColor(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
cv::viz::WCone::WCone(double radius, const Point3d& center, const Point3d& tip, int resolution, const Color &color)
|
||||||
|
{
|
||||||
|
Vec3d arbitrary = get_random_vec();
|
||||||
|
Vec3d xvec = normalized(Vec3d(tip - center));
|
||||||
|
Vec3d zvec = normalized(xvec.cross(arbitrary));
|
||||||
|
Vec3d yvec = zvec.cross(xvec);
|
||||||
|
|
||||||
|
WCone circle(norm(tip - center), radius, resolution, color);
|
||||||
|
circle.applyTransform(makeTransformToGlobal(xvec, yvec, zvec, center));
|
||||||
|
*this = circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<> cv::viz::WCone cv::viz::Widget::cast<cv::viz::WCone>()
|
||||||
|
{
|
||||||
|
Widget3D widget = this->cast<Widget3D>();
|
||||||
|
return static_cast<WCone&>(widget);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// cylinder widget implementation
|
/// cylinder widget implementation
|
||||||
|
|
||||||
|
@@ -299,6 +299,8 @@ TEST(Viz, show_simple_widgets)
|
|||||||
viz.showWidget("cir2", WCircle(0.5, Point3d(0.5, 0.0, 0.0), Vec3d(1.0, 0.0, 0.0), 0.01, Color::apricot()));
|
viz.showWidget("cir2", WCircle(0.5, Point3d(0.5, 0.0, 0.0), Vec3d(1.0, 0.0, 0.0), 0.01, Color::apricot()));
|
||||||
|
|
||||||
viz.showWidget("cyl0", WCylinder(Vec3d(-0.5, 0.5, -0.5), Vec3d(0.5, 0.5, -0.5), 0.125, 30, Color::brown()));
|
viz.showWidget("cyl0", WCylinder(Vec3d(-0.5, 0.5, -0.5), Vec3d(0.5, 0.5, -0.5), 0.125, 30, Color::brown()));
|
||||||
|
viz.showWidget("con0", WCone(0.25, 0.125, 6, Color::azure()));
|
||||||
|
viz.showWidget("con1", WCone(0.125, Point3d(0.5, -0.5, 0.5), Point3d(0.5, -1.0, 0.5), 6, Color::turquoise()));
|
||||||
viz.spin();
|
viz.spin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user