diff --git a/modules/viz/src/precomp.hpp b/modules/viz/src/precomp.hpp index f6779d3ce1..ddbef3a49e 100644 --- a/modules/viz/src/precomp.hpp +++ b/modules/viz/src/precomp.hpp @@ -153,6 +153,5 @@ #endif -#include #include "opencv2/viz/widget_accessor.hpp" #include diff --git a/modules/viz/src/q/shapes.h b/modules/viz/src/q/shapes.h deleted file mode 100644 index 4055cd1b2d..0000000000 --- a/modules/viz/src/q/shapes.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include - -namespace temp_viz -{ - vtkSmartPointer createLine (const cv::Point3f& pt1, const cv::Point3f& pt2); - vtkSmartPointer createSphere (const cv::Point3f ¢er, float radius, int sphere_resolution = 10); - vtkSmartPointer createCylinder (const Point3f& pt_on_axis, const Point3f& axis_direction, double radius, int numsides = 30); - vtkSmartPointer createPlane (const Vec4f& coefs); - vtkSmartPointer createPlane (const Vec4f& coefs, const Point3f& pt); - vtkSmartPointer create2DCircle (const Point3f& pt, double radius); - vtkSmartPointer createCube(const Point3f& pt_min, const Point3f& pt_max); - vtkSmartPointer createSphere (const Point3f& pt, double radius); - vtkSmartPointer createArrow (const Point3f& pt1, const Point3f& pt2); - - //brief Allocate a new unstructured grid smartpointer. For internal use only. - void allocVtkUnstructuredGrid (vtkSmartPointer &polydata); -} diff --git a/modules/viz/src/shapes.cpp b/modules/viz/src/shapes.cpp deleted file mode 100644 index 7fa9a2cd82..0000000000 --- a/modules/viz/src/shapes.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "precomp.hpp" - -inline float rad2deg(float alpha) { return (alpha * 57.29578f); } -inline double rad2deg(double alpha) { return (alpha * 57.29578); } - -vtkSmartPointer temp_viz::createCylinder (const cv::Point3f& pt_on_axis, const cv::Point3f& axis_direction, double radius, int numsides) -{ - const cv::Point3f pt2 = pt_on_axis + axis_direction; - vtkSmartPointer line = vtkSmartPointer::New (); - line->SetPoint1 (pt_on_axis.x, pt_on_axis.y, pt_on_axis.z); - line->SetPoint2 (pt2.x, pt2.y, pt2.z); - - vtkSmartPointer tuber = vtkSmartPointer::New (); - tuber->SetInputConnection (line->GetOutputPort ()); - tuber->SetRadius (radius); - tuber->SetNumberOfSides (numsides); - return (tuber->GetOutput ()); -} - -vtkSmartPointer temp_viz::createPlane (const cv::Vec4f& coefs) -{ - vtkSmartPointer plane = vtkSmartPointer::New (); - plane->SetNormal (coefs[0], coefs[1], coefs[2]); - double norm = cv::norm(cv::Vec3f(coefs.val)); - plane->Push (-coefs[3] / norm); - return plane->GetOutput (); -} - -vtkSmartPointer temp_viz::createPlane(const cv::Vec4f& coefs, const cv::Point3f& pt) -{ - vtkSmartPointer plane = vtkSmartPointer::New (); - cv::Point3f coefs3(coefs[0], coefs[1], coefs[2]); - double norm_sqr = 1.0 / coefs3.dot (coefs3); - plane->SetNormal(coefs[0], coefs[1], coefs[2]); - - double t = coefs3.dot(pt) + coefs[3]; - cv::Vec3f p_center = pt - coefs3 * t * norm_sqr; - plane->SetCenter (p_center[0], p_center[1], p_center[2]); - - return (plane->GetOutput ()); -} - -vtkSmartPointer temp_viz::create2DCircle (const cv::Point3f& pt, double radius) -{ - vtkSmartPointer disk = vtkSmartPointer::New (); - // Maybe the resolution should be lower e.g. 50 or 25 - disk->SetCircumferentialResolution (100); - disk->SetInnerRadius (radius - 0.001); - disk->SetOuterRadius (radius + 0.001); - disk->SetCircumferentialResolution (20); - - // Set the circle origin - vtkSmartPointer t = vtkSmartPointer::New (); - t->Identity (); - t->Translate (pt.x, pt.y, pt.z); - - vtkSmartPointer tf = vtkSmartPointer::New (); - tf->SetTransform (t); - tf->SetInputConnection (disk->GetOutputPort ()); - - return tf->GetOutput (); -} - -vtkSmartPointer temp_viz::createCube(const cv::Point3f& pt_min, const cv::Point3f& pt_max) -{ - vtkSmartPointer cube = vtkSmartPointer::New (); - cube->SetBounds (pt_min.x, pt_max.x, pt_min.y, pt_max.y, pt_min.z, pt_max.z); - return cube->GetOutput (); -} - -vtkSmartPointer temp_viz::createSphere (const Point3f& pt, double radius) -{ - vtkSmartPointer sphere = vtkSmartPointer::New (); - sphere->SetRadius (radius); - sphere->SetCenter (pt.x, pt.y, pt.z); - sphere->SetPhiResolution (10); - sphere->SetThetaResolution (10); - sphere->LatLongTessellationOff (); - sphere->Update (); - - return sphere->GetOutput (); -} - -vtkSmartPointer temp_viz::createArrow (const Point3f& pt1, const Point3f& pt2) -{ - vtkSmartPointer arrowSource = vtkSmartPointer::New (); - - float startPoint[3], endPoint[3]; - startPoint[0] = pt1.x; - startPoint[1] = pt1.y; - startPoint[2] = pt1.z; - endPoint[0] = pt2.x; - endPoint[1] = pt2.y; - endPoint[2] = pt2.z; - float normalizedX[3], normalizedY[3], normalizedZ[3]; - - // The X axis is a vector from start to end - vtkMath::Subtract(endPoint, startPoint, normalizedX); - float length = vtkMath::Norm(normalizedX); - vtkMath::Normalize(normalizedX); - - // The Z axis is an arbitrary vecotr cross X - float arbitrary[3]; - arbitrary[0] = vtkMath::Random(-10,10); - arbitrary[1] = vtkMath::Random(-10,10); - arbitrary[2] = vtkMath::Random(-10,10); - vtkMath::Cross(normalizedX, arbitrary, normalizedZ); - vtkMath::Normalize(normalizedZ); - - // The Y axis is Z cross X - vtkMath::Cross(normalizedZ, normalizedX, normalizedY); - vtkSmartPointer matrix = vtkSmartPointer::New(); - - // Create the direction cosine matrix - matrix->Identity(); - for (unsigned int i = 0; i < 3; i++) - { - matrix->SetElement(i, 0, normalizedX[i]); - matrix->SetElement(i, 1, normalizedY[i]); - matrix->SetElement(i, 2, normalizedZ[i]); - } - - // Apply the transforms - vtkSmartPointer transform = - vtkSmartPointer::New(); - transform->Translate(startPoint); - transform->Concatenate(matrix); - transform->Scale(length, length, length); - - // Transform the polydata - vtkSmartPointer transformPD = - vtkSmartPointer::New(); - transformPD->SetTransform(transform); - transformPD->SetInputConnection(arrowSource->GetOutputPort()); - - return transformPD->GetOutput(); -} - -vtkSmartPointer temp_viz::createLine (const cv::Point3f& pt1, const cv::Point3f& pt2) -{ - vtkSmartPointer line = vtkSmartPointer::New (); - line->SetPoint1 (pt1.x, pt1.y, pt1.z); - line->SetPoint2 (pt2.x, pt2.y, pt2.z); - line->Update (); - return line->GetOutput (); -} - -void temp_viz::allocVtkUnstructuredGrid (vtkSmartPointer &polydata) -{ - polydata = vtkSmartPointer::New (); -} - - diff --git a/modules/viz/src/viz3d_impl.cpp b/modules/viz/src/viz3d_impl.cpp index 79d49a30a7..ae2e062284 100644 --- a/modules/viz/src/viz3d_impl.cpp +++ b/modules/viz/src/viz3d_impl.cpp @@ -1,5 +1,4 @@ #include "precomp.hpp" -#include #include namespace temp_viz diff --git a/modules/viz/src/viz_main.cpp b/modules/viz/src/viz_main.cpp index 42fe649e92..0d56fe0a56 100644 --- a/modules/viz/src/viz_main.cpp +++ b/modules/viz/src/viz_main.cpp @@ -1,7 +1,6 @@ #include "precomp.hpp" #include -#include #include #include