class CV_EXPORTS WCylinder : public Widget3D
{
public:
- WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
+ WCylinder(const Point3d& axis_point1, const Point3d& axis_point2, double radius, int numsides = 30, const Color &color = Color::white());
};
viz::WCylinder::WCylinder
.. ocv:function:: WCylinder(const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30, const Color &color = Color::white())
- :param pt_on_axis: A point on the axis of the cylinder.
- :param axis_direction: Direction of the axis of the cylinder.
+ :param axis_point1: A point1 on the axis of the cylinder.
+ :param axis_point2: A point2 on the axis of the cylinder.
:param radius: Radius of the cylinder.
:param numsides: Resolution of the cylinder.
:param color: :ocv:class:`Color` of the cylinder.
class CV_EXPORTS WCircle : public Widget3D
{
public:
- //! creates default circle centred at origin with normal along z-axis
+ //! creates default planar circle centred at origin with plane normal along z-axis
WCircle(double radius, double thickness = 0.01, const Color &color = Color::white());
//! creates repositioned circle
class CV_EXPORTS WCylinder : public Widget3D
{
public:
- WCylinder(const Point3d& pt_on_axis, const Point3d& axis_direction, double radius, int numsides = 30, const Color &color = Color::white());
+ WCylinder(const Point3d& axis_point1, const Point3d& axis_point2, double radius, int numsides = 30, const Color &color = Color::white());
};
class CV_EXPORTS WCube : public Widget3D
///////////////////////////////////////////////////////////////////////////////////////////////
/// cylinder widget implementation
-cv::viz::WCylinder::WCylinder(const Point3d& pt_on_axis, const Point3d& axis_direction, double radius, int numsides, const Color &color)
+cv::viz::WCylinder::WCylinder(const Point3d& axis_point1, const Point3d& axis_point2, double radius, int numsides, const Color &color)
{
- const Point3d 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);
- line->SetPoint2(pt2.x, pt2.y, pt2.z);
+ line->SetPoint1(axis_point1.x, axis_point1.y, axis_point1.z);
+ line->SetPoint2(axis_point2.x, axis_point2.y, axis_point2.z);
vtkSmartPointer<vtkTubeFilter> tuber = vtkSmartPointer<vtkTubeFilter>::New();
tuber->SetInputConnection(line->GetOutputPort());
- tuber->SetRadius(radius);
tuber->SetNumberOfSides(numsides);
+ tuber->SetRadius(radius);
tuber->Update();
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
cv::viz::WCube::WCube(const Point3d& min_point, const Point3d& max_point, bool wire_frame, const Color &color)
{
+ double bounds[6];
+ bounds[0] = std::min(min_point.x, max_point.x);
+ bounds[1] = std::max(min_point.x, max_point.x);
+ bounds[2] = std::min(min_point.y, max_point.y);
+ bounds[3] = std::max(min_point.y, max_point.y);
+ bounds[4] = std::min(min_point.z, max_point.z);
+ bounds[5] = std::max(min_point.z, max_point.z);
+
vtkSmartPointer<vtkPolyDataAlgorithm> cube;
if (wire_frame)
{
cube = vtkSmartPointer<vtkOutlineSource>::New();
- vtkOutlineSource::SafeDownCast(cube)->SetBounds(min_point.x, max_point.x, min_point.y, max_point.y, min_point.z, max_point.z);
+ vtkOutlineSource::SafeDownCast(cube)->SetBounds(bounds);
}
else
{
cube = vtkSmartPointer<vtkCubeSource>::New();
- vtkCubeSource::SafeDownCast(cube)->SetBounds(min_point.x, max_point.x, min_point.y, max_point.y, min_point.z, max_point.z);
+ vtkCubeSource::SafeDownCast(cube)->SetBounds(bounds);
}
cube->Update();
Viz3d viz("show_simple_widgets");
viz.showWidget("coos", WCoordinateSystem());
viz.showWidget("cube", WCube());
+ viz.showWidget("cub0", WCube(Vec3d::all(-1.0), Vec3d::all(-0.5), false, Color::indigo()));
viz.showWidget("arro", WArrow(Vec3d::all(-0.5), Vec3d::all(0.5), 0.009, Color::raspberry()));
viz.showWidget("cir1", WCircle(0.5, 0.01, Color::bluberry()));
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.spin();
}