From 1830059969d6aa20b51d668c2e77b1971b504116 Mon Sep 17 00:00:00 2001 From: ozantonkal Date: Thu, 27 Jun 2013 13:05:52 +0300 Subject: [PATCH] removed redundant addShape methods --- modules/viz/src/q/shapes.h | 113 ------------------------- modules/viz/src/q/viz3d_impl.hpp | 78 ------------------ modules/viz/src/shapes.cpp | 172 --------------------------------------- modules/viz/src/viz3d.cpp | 5 -- modules/viz/src/viz3d_impl.cpp | 66 --------------- modules/viz/src/viz_main.cpp | 130 ----------------------------- 6 files changed, 564 deletions(-) diff --git a/modules/viz/src/q/shapes.h b/modules/viz/src/q/shapes.h index 1ebc6ae..be83cd5 100644 --- a/modules/viz/src/q/shapes.h +++ b/modules/viz/src/q/shapes.h @@ -15,119 +15,6 @@ namespace temp_viz CV_EXPORTS vtkSmartPointer createCube(const Point3f& pt_min, const Point3f& pt_max); CV_EXPORTS vtkSmartPointer createSphere (const Point3f& pt, double radius); CV_EXPORTS vtkSmartPointer createArrow (const Point3f& pt1, const Point3f& pt2); -// CV_EXPORTS vtkSmartPointer createCube (const Point3f& pt, const Quaternionf& qt, ); -// CV_EXPORTS vtkSmartPointer createCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth); -// CV_EXPORTS vtkSmartPointer createCube (double x_min, double x_max, double y_min, double y_max, double z_min, double z_max); -// -// - /** \brief Create a cylinder shape from a set of model coefficients. - * \param[in] coefficients the model coefficients (point_on_axis, axis_direction, radius) - * \param[in] numsides (optional) the number of sides used for rendering the cylinder - * - * \code - * // The following are given (or computed using sample consensus techniques -- see SampleConsensusModelCylinder) - * // Eigen::Vector3f pt_on_axis, axis_direction; - * // float radius; - * - * temp_viz::ModelCoefficients cylinder_coeff; - * cylinder_coeff.values.resize (7); // We need 7 values - * cylinder_coeff.values[0] = pt_on_axis.x (); - * cylinder_coeff.values[1] = pt_on_axis.y (); - * cylinder_coeff.values[2] = pt_on_axis.z (); - * - * cylinder_coeff.values[3] = axis_direction.x (); - * cylinder_coeff.values[4] = axis_direction.y (); - * cylinder_coeff.values[5] = axis_direction.z (); - * - * cylinder_coeff.values[6] = radius; - * - * vtkSmartPointer data = temp_viz::createCylinder (cylinder_coeff, numsides); - * \endcode - * - * \ingroup visualization - */ - CV_EXPORTS vtkSmartPointer createCylinder (const temp_viz::ModelCoefficients &coefficients, int numsides = 30); - - - /** \brief Create a planar shape from a set of model coefficients. - * \param[in] coefficients the model coefficients (a, b, c, d with ax+by+cz+d=0) - * - * \code - * // The following are given (or computed using sample consensus techniques -- see SampleConsensusModelPlane) - * // Eigen::Vector4f plane_parameters; - * - * temp_viz::ModelCoefficients plane_coeff; - * plane_coeff.values.resize (4); // We need 4 values - * plane_coeff.values[0] = plane_parameters.x (); - * plane_coeff.values[1] = plane_parameters.y (); - * plane_coeff.values[2] = plane_parameters.z (); - * plane_coeff.values[3] = plane_parameters.w (); - * - * vtkSmartPointer data = temp_viz::createPlane (plane_coeff); - * \endcode - * - * \ingroup visualization - */ - CV_EXPORTS vtkSmartPointer createPlane (const temp_viz::ModelCoefficients &coefficients); - - /** \brief Create a planar shape from a set of model coefficients. - * \param[in] coefficients the model coefficients (a, b, c, d with ax+by+cz+d=0) - * \param[in] x,y,z projection of this point on the plane is used to get the center of the plane. - * \ingroup visualization - */ - CV_EXPORTS vtkSmartPointer createPlane (const temp_viz::ModelCoefficients &coefficients, double x, double y, double z); - - /** \brief Create a 2d circle shape from a set of model coefficients. - * \param[in] coefficients the model coefficients (x, y, radius) - * \param[in] z (optional) specify a z value (default: 0) - * - * \code - * // The following are given (or computed using sample consensus techniques -- see SampleConsensusModelCircle2D) - * // float x, y, radius; - * - * temp_viz::ModelCoefficients circle_coeff; - * circle_coeff.values.resize (3); // We need 3 values - * circle_coeff.values[0] = x; - * circle_coeff.values[1] = y; - * circle_coeff.values[2] = radius; - * - * vtkSmartPointer data = temp_viz::create2DCircle (circle_coeff, z); - * \endcode - * - * \ingroup visualization - */ - CV_EXPORTS vtkSmartPointer create2DCircle (const temp_viz::ModelCoefficients &coefficients, double z = 0.0); - - - /** \brief Creaet a cube shape from a set of model coefficients. - * \param[in] coefficients the cube coefficients (Tx, Ty, Tz, Qx, Qy, Qz, Qw, width, height, depth) - * \ingroup visualization - */ - CV_EXPORTS vtkSmartPointer createCube (const temp_viz::ModelCoefficients &coefficients); - - /** \brief Creaet a cube shape from a set of model coefficients. - * - * \param[in] translation a translation to apply to the cube from 0,0,0 - * \param[in] rotation a quaternion-based rotation to apply to the cube - * \param[in] width the cube's width - * \param[in] height the cube's height - * \param[in] depth the cube's depth - * \ingroup visualization - */ - CV_EXPORTS vtkSmartPointer createCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth); - - /** \brief Create a cube from a set of bounding points - * \param[in] x_min is the minimum x value of the box - * \param[in] x_max is the maximum x value of the box - * \param[in] y_min is the minimum y value of the box - * \param[in] y_max is the maximum y value of the box - * \param[in] z_min is the minimum z value of the box - * \param[in] z_max is the maximum z value of the box - * \param[in] id the cube id/name (default: "cube") - * \param[in] viewport (optional) the id of the new viewport (default: 0) - */ - CV_EXPORTS vtkSmartPointer createCube (double x_min, double x_max, double y_min, double y_max, double z_min, double z_max); - /** \brief Allocate a new unstructured grid smartpointer. For internal use only. * \param[out] polydata the resultant unstructured grid. */ diff --git a/modules/viz/src/q/viz3d_impl.hpp b/modules/viz/src/q/viz3d_impl.hpp index 50d50bb..cf6d7db 100644 --- a/modules/viz/src/q/viz3d_impl.hpp +++ b/modules/viz/src/q/viz3d_impl.hpp @@ -153,8 +153,6 @@ public: bool addPolygon(const cv::Mat& cloud, const Color& color, const std::string &id = "polygon"); bool addArrow (const cv::Point3f &pt1, const cv::Point3f &pt2, const Color& color, bool display_length, const std::string &id = "arrow"); bool addArrow (const cv::Point3f &pt1, const cv::Point3f &pt2, const Color& color_line, const Color& color_text, const std::string &id = "arrow"); - bool addSphere (const cv::Point3f ¢er, float radius, const Color& color, const std::string &id = "sphere"); - bool updateSphere (const cv::Point3f ¢er, float radius, const Color& color, const std::string &id = "sphere"); // Add a vtkPolydata as a mesh bool addModelFromPolyData (vtkSmartPointer polydata, const std::string & id = "PolyData"); @@ -162,82 +160,6 @@ public: bool addModelFromPLYFile (const std::string &filename, const std::string &id = "PLYModel"); bool addModelFromPLYFile (const std::string &filename, vtkSmartPointer transform, const std::string &id = "PLYModel"); - /** \brief Add a cylinder from a set of given model coefficients - * \param[in] coefficients the model coefficients (point_on_axis, axis_direction, radius) - * \param[in] id the cylinder id/name (default: "cylinder") - * - * \code - * // The following are given (or computed using sample consensus techniques) - * // See SampleConsensusModelCylinder for more information. - * // float radius; - * - * temp_viz::ModelCoefficients cylinder_coeff; - * cylinder_coeff.values.resize (7); // We need 7 values - * cylinder_coeff.values[0] = pt_on_axis.x (); - * cylinder_coeff.values[1] = pt_on_axis.y (); - * cylinder_coeff.values[2] = pt_on_axis.z (); - * - * cylinder_coeff.values[3] = axis_direction.x (); - * cylinder_coeff.values[4] = axis_direction.y (); - * cylinder_coeff.values[5] = axis_direction.z (); - * - * cylinder_coeff.values[6] = radius; - * - * addCylinder (cylinder_coeff); - * \endcode - */ - bool addCylinder (const temp_viz::ModelCoefficients &coefficients, const std::string &id = "cylinder"); - - /** \brief Add a circle from a set of given model coefficients - * \param[in] coefficients the model coefficients (x, y, radius) - * \param[in] id the circle id/name (default: "circle") - * - * \code - * // The following are given (or computed using sample consensus techniques) - * // See SampleConsensusModelCircle2D for more information - * // float x, y, radius; - * - * temp_viz::ModelCoefficients circle_coeff; - * circle_coeff.values.resize (3); // We need 3 values - * circle_coeff.values[0] = x; - * circle_coeff.values[1] = y; - * circle_coeff.values[2] = radius; - * - * vtkSmartPointer data = temp_viz::create2DCircle (circle_coeff, z); - * \endcode - */ - bool addCircle (const temp_viz::ModelCoefficients &coefficients, const std::string &id = "circle"); - - /** \brief Add a cube from a set of given model coefficients - * \param[in] coefficients the model coefficients (Tx, Ty, Tz, Qx, Qy, Qz, Qw, width, height, depth) - * \param[in] id the cube id/name (default: "cube") - */ - bool addCube (const temp_viz::ModelCoefficients &coefficients, const std::string &id = "cube"); - - /** \brief Add a cube from a set of given model coefficients - * \param[in] translation a translation to apply to the cube from 0,0,0 - * \param[in] rotation a quaternion-based rotation to apply to the cube - * \param[in] width the cube's width - * \param[in] height the cube's height - * \param[in] depth the cube's depth - * \param[in] id the cube id/name (default: "cube") - */ - bool addCube (const cv::Vec3f& translation, const cv::Vec3f quaternion, double width, double height, double depth, const std::string &id = "cube"); - - /** \brief Add a cube - * \param[in] x_min the min X coordinate - * \param[in] x_max the max X coordinate - * \param[in] y_min the min Y coordinate - * \param[in] y_max the max Y coordinate - * \param[in] z_min the min Z coordinate - * \param[in] z_max the max Z coordinate - * \param[in] r how much red (0.0 -> 1.0) - * \param[in] g how much green (0.0 -> 1.0) - * \param[in] b how much blue (0.0 -> 1.0) - * \param[in] id the cube id/name (default: "cube") - */ - bool addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max, const Color& color, const std::string &id = "cube"); - /** \brief Changes the visual representation for all actors to surface representation. */ void setRepresentationToSurfaceForAllActors (); diff --git a/modules/viz/src/shapes.cpp b/modules/viz/src/shapes.cpp index 3f9fcd2..362b615 100644 --- a/modules/viz/src/shapes.cpp +++ b/modules/viz/src/shapes.cpp @@ -140,178 +140,6 @@ vtkSmartPointer temp_viz::createArrow (const Point3f& pt1, const Poi } //////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createCylinder (const temp_viz::ModelCoefficients &coefficients, int numsides) -{ - vtkSmartPointer line = vtkSmartPointer::New (); - line->SetPoint1 (coefficients.values[0], coefficients.values[1], coefficients.values[2]); - line->SetPoint2 (coefficients.values[3]+coefficients.values[0], coefficients.values[4]+coefficients.values[1], coefficients.values[5]+coefficients.values[2]); - - vtkSmartPointer tuber = vtkSmartPointer::New (); - tuber->SetInputConnection (line->GetOutputPort ()); - tuber->SetRadius (coefficients.values[6]); - tuber->SetNumberOfSides (numsides); - - return (tuber->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createCube (const temp_viz::ModelCoefficients &coefficients) -{ - // coefficients = [Tx, Ty, Tz, Qx, Qy, Qz, Qw, width, height, depth] - vtkSmartPointer t = vtkSmartPointer::New (); - t->Identity (); - t->Translate (coefficients.values[0], coefficients.values[1], coefficients.values[2]); - - Eigen::AngleAxisf a (Eigen::Quaternionf (coefficients.values[6], coefficients.values[3], - coefficients.values[4], coefficients.values[5])); - t->RotateWXYZ (rad2deg (a.angle ()), a.axis ()[0], a.axis ()[1], a.axis ()[2]); - - vtkSmartPointer cube = vtkSmartPointer::New (); - cube->SetXLength (coefficients.values[7]); - cube->SetYLength (coefficients.values[8]); - cube->SetZLength (coefficients.values[9]); - - vtkSmartPointer tf = vtkSmartPointer::New (); - tf->SetTransform (t); - tf->SetInputConnection (cube->GetOutputPort ()); - - return (tf->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createCube (const Eigen::Vector3f &translation, const Eigen::Quaternionf &rotation, double width, double height, double depth) -{ - // coefficients = [Tx, Ty, Tz, Qx, Qy, Qz, Qw, width, height, depth] - vtkSmartPointer t = vtkSmartPointer::New (); - t->Identity (); - t->Translate (translation.x (), translation.y (), translation.z ()); - - Eigen::AngleAxisf a (rotation); - t->RotateWXYZ (rad2deg (a.angle ()), a.axis ()[0], a.axis ()[1], a.axis ()[2]); - - vtkSmartPointer cube = vtkSmartPointer::New (); - cube->SetXLength (width); - cube->SetYLength (height); - cube->SetZLength (depth); - - vtkSmartPointer tf = vtkSmartPointer::New (); - tf->SetTransform (t); - tf->SetInputConnection (cube->GetOutputPort ()); - - return (tf->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createCube (double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) -{ - vtkSmartPointer t = vtkSmartPointer::New (); - vtkSmartPointer cube = vtkSmartPointer::New (); - cube->SetBounds (x_min, x_max, y_min, y_max, z_min, z_max); - return (cube->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createPlane (const temp_viz::ModelCoefficients &coefficients) -{ - vtkSmartPointer plane = vtkSmartPointer::New (); - plane->SetNormal (coefficients.values[0], coefficients.values[1], coefficients.values[2]); - - double norm_sqr = coefficients.values[0] * coefficients.values[0] - + coefficients.values[1] * coefficients.values[1] - + coefficients.values[2] * coefficients.values[2]; - - plane->Push (-coefficients.values[3] / sqrt(norm_sqr)); - return (plane->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createPlane (const temp_viz::ModelCoefficients &coefficients, double x, double y, double z) -{ - vtkSmartPointer plane = vtkSmartPointer::New (); - - - double norm_sqr = 1.0 / (coefficients.values[0] * coefficients.values[0] + - coefficients.values[1] * coefficients.values[1] + - coefficients.values[2] * coefficients.values[2] ); - -// double nx = coefficients.values [0] * norm; -// double ny = coefficients.values [1] * norm; -// double nz = coefficients.values [2] * norm; -// double d = coefficients.values [3] * norm; - -// plane->SetNormal (nx, ny, nz); - plane->SetNormal (coefficients.values[0], coefficients.values[1], coefficients.values[2]); - - double t = x * coefficients.values[0] + y * coefficients.values[1] + z * coefficients.values[2] + coefficients.values[3]; - x -= coefficients.values[0] * t * norm_sqr; - y -= coefficients.values[1] * t * norm_sqr; - z -= coefficients.values[2] * t * norm_sqr; - plane->SetCenter (x, y, z); - - return (plane->GetOutput ()); -} - - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::create2DCircle (const temp_viz::ModelCoefficients &coefficients, double z) -{ - vtkSmartPointer disk = vtkSmartPointer::New (); - // Maybe the resolution should be lower e.g. 50 or 25 - disk->SetCircumferentialResolution (100); - disk->SetInnerRadius (coefficients.values[2] - 0.001); - disk->SetOuterRadius (coefficients.values[2] + 0.001); - disk->SetCircumferentialResolution (20); - - // An alternative to could be with - /* - vtkSmartPointer circle = vtkSmartPointer::New(); - circle->SetRadius (coefficients.values[2]); - circle->SetNumberOfSides (100); - - vtkSmartPointer tube = vtkSmartPointer::New(); - tube->SetInput (circle->GetOutput()); - tube->SetNumberOfSides (25); - tube->SetRadius (0.001); - */ - - // Set the circle origin - vtkSmartPointer t = vtkSmartPointer::New (); - t->Identity (); - t->Translate (coefficients.values[0], coefficients.values[1], z); - - vtkSmartPointer tf = vtkSmartPointer::New (); - tf->SetTransform (t); - tf->SetInputConnection (disk->GetOutputPort ()); - /* - tf->SetInputConnection (tube->GetOutputPort ()); - */ - - return (tf->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -vtkSmartPointer temp_viz::createSphere (const cv::Point3f& center, float radius, int sphere_resolution) -{ - // Set the sphere origin - vtkSmartPointer t = vtkSmartPointer::New (); - t->Identity (); - t->Translate (center.x, center.y, center.z); - - vtkSmartPointer s_sphere = vtkSmartPointer::New (); - s_sphere->SetRadius (radius); - s_sphere->SetPhiResolution (sphere_resolution); - s_sphere->SetThetaResolution (sphere_resolution); - s_sphere->LatLongTessellationOff (); - - vtkSmartPointer tf = vtkSmartPointer::New (); - tf->SetTransform (t); - tf->SetInputConnection (s_sphere->GetOutputPort ()); - tf->Update (); - - return (tf->GetOutput ()); -} - -//////////////////////////////////////////////////////////////////////////////////////////// vtkSmartPointer temp_viz::createLine (const cv::Point3f& pt1, const cv::Point3f& pt2) { vtkSmartPointer line = vtkSmartPointer::New (); diff --git a/modules/viz/src/viz3d.cpp b/modules/viz/src/viz3d.cpp index 65d036d..bb2974c 100644 --- a/modules/viz/src/viz3d.cpp +++ b/modules/viz/src/viz3d.cpp @@ -63,11 +63,6 @@ bool temp_viz::Viz3d::addPolygon(const Mat& cloud, const Color& color, const Str return impl_->addPolygon(cloud, color, id); } -bool temp_viz::Viz3d::addSphere (const cv::Point3f ¢er, double radius, const Color& color, const std::string &id) -{ - return impl_->addSphere(center, radius, color, id); -} - void temp_viz::Viz3d::spin() { impl_->spin(); diff --git a/modules/viz/src/viz3d_impl.cpp b/modules/viz/src/viz3d_impl.cpp index af564b3..a8aedc1 100644 --- a/modules/viz/src/viz3d_impl.cpp +++ b/modules/viz/src/viz3d_impl.cpp @@ -958,72 +958,6 @@ bool temp_viz::Viz3d::VizImpl::addArrow (const cv::Point3f &p1, const cv::Point3 return (true); } -#include -//////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::addSphere (const cv::Point3f& center, float radius, const Color& color, const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it != shape_actor_map_->end ()) - return std::cout << "[addSphere] A shape with id <"< already exists! Please choose a different id and retry." << std::endl, false; - - //vtkSmartPointer data = createSphere (center.getVector4fMap (), radius); - vtkSmartPointer data = vtkSmartPointer::New (); - data->SetRadius (radius); - data->SetCenter (center.x, center.y, center.z); - data->SetPhiResolution (10); - data->SetThetaResolution (10); - data->LatLongTessellationOff (); - data->Update (); - - // Setup actor and mapper - vtkSmartPointer mapper = vtkSmartPointer::New (); - mapper->SetInputConnection (data->GetOutputPort ()); - - // Create an Actor - vtkSmartPointer actor = vtkSmartPointer::New (); - actor->SetMapper (mapper); - //createActorFromVTKDataSet (data, actor); - actor->GetProperty ()->SetRepresentationToSurface (); - actor->GetProperty ()->SetInterpolationToFlat (); - - Color c = vtkcolor(color); - actor->GetProperty ()->SetColor (c.val); - actor->GetMapper ()->ImmediateModeRenderingOn (); - actor->GetMapper ()->StaticOn (); - actor->GetMapper ()->ScalarVisibilityOff (); - actor->GetMapper ()->Update (); - renderer_->AddActor (actor); - - // Save the pointer/ID pair to the global actor map - (*shape_actor_map_)[id] = actor; - return (true); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::updateSphere (const cv::Point3f ¢er, float radius, const Color& color, const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it == shape_actor_map_->end ()) - return (false); - - ////////////////////////////////////////////////////////////////////////// - // Get the actor pointer - vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second); - vtkAlgorithm *algo = actor->GetMapper ()->GetInput ()->GetProducerPort ()->GetProducer (); - vtkSphereSource *src = vtkSphereSource::SafeDownCast (algo); - - src->SetCenter(center.x, center.y, center.z); - src->SetRadius(radius); - src->Update (); - Color c = vtkcolor(color); - actor->GetProperty ()->SetColor (c.val); - actor->Modified (); - - return (true); -} - ////////////////////////////////////////////////// bool temp_viz::Viz3d::VizImpl::addText3D (const std::string &text, const cv::Point3f& position, const Color& color, double textScale, const std::string &id) { diff --git a/modules/viz/src/viz_main.cpp b/modules/viz/src/viz_main.cpp index a55247b..e03ace6 100644 --- a/modules/viz/src/viz_main.cpp +++ b/modules/viz/src/viz_main.cpp @@ -894,111 +894,6 @@ void temp_viz::Viz3d::VizImpl::resetCameraViewpoint (const std::string &id) renderer_->Render (); } - -//////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::addCylinder (const temp_viz::ModelCoefficients &coefficients, const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it != shape_actor_map_->end ()) - { - std::cout << "[addCylinder] A shape with id <"< already exists! Please choose a different id and retry." << std::endl; - return (false); - } - - vtkSmartPointer data = createCylinder (coefficients); - - // Create an Actor - vtkSmartPointer actor; - createActorFromVTKDataSet (data, actor); - actor->GetProperty ()->SetRepresentationToWireframe (); - actor->GetProperty ()->SetLighting (false); - renderer_->AddActor (actor); - - // Save the pointer/ID pair to the global actor map - (*shape_actor_map_)[id] = actor; - return (true); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::addCube (const temp_viz::ModelCoefficients &coefficients, const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it != shape_actor_map_->end ()) - { - std::cout << "[addCube] A shape with id <" << id << "> already exists! Please choose a different id and retry." << std::endl; - return (false); - } - - vtkSmartPointer data = createCube (coefficients); - - // Create an Actor - vtkSmartPointer actor; - createActorFromVTKDataSet (data, actor); - actor->GetProperty ()->SetRepresentationToWireframe (); - actor->GetProperty ()->SetLighting (false); - renderer_->AddActor (actor); - - // Save the pointer/ID pair to the global actor map - (*shape_actor_map_)[id] = actor; - return (true); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::addCube (const cv::Vec3f& translation, const cv::Vec3f quaternion, double width, double height, double depth, const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it != shape_actor_map_->end ()) - { - std::cout << "[addCube] A shape with id <" << id << "> already exists! Please choose a different id and retry." << std::endl; - return (false); - } - - Eigen::Vector3f t(translation[0], translation[1], translation[2]); - Eigen::Quaternionf q(quaternion[0], quaternion[1], quaternion[2], quaternion[3]); - - vtkSmartPointer data = createCube (t, q, width, height, depth); - - // Create an Actor - vtkSmartPointer actor; - createActorFromVTKDataSet (data, actor); - actor->GetProperty ()->SetRepresentationToWireframe (); - actor->GetProperty ()->SetLighting (false); - renderer_->AddActor (actor); - - // Save the pointer/ID pair to the global actor map - (*shape_actor_map_)[id] = actor; - return (true); -} - -//////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::addCube (float x_min, float x_max, float y_min, float y_max, float z_min, float z_max, - const Color& color , const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it != shape_actor_map_->end ()) - return std::cout << "[addCube] A shape with id <" << id << "> already exists! Please choose a different id and retry." << std::endl, false; - - vtkSmartPointer data = createCube (x_min, x_max, y_min, y_max, z_min, z_max); - - // Create an Actor - vtkSmartPointer actor; - createActorFromVTKDataSet (data, actor); - actor->GetProperty ()->SetRepresentationToWireframe (); - actor->GetProperty ()->SetLighting (false); - - Color c = vtkcolor(color); - actor->GetProperty ()->SetColor (c.val); - renderer_->AddActor (actor); - - // Save the pointer/ID pair to the global actor map - (*shape_actor_map_)[id] = actor; - return (true); -} - //////////////////////////////////////////////////////////////////////////////////////////// bool temp_viz::Viz3d::VizImpl::addModelFromPolyData (vtkSmartPointer polydata, const std::string & id) { @@ -1089,31 +984,6 @@ bool temp_viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename, } ///////////////////////////////////////////////////////////////////////////////////////////// -bool temp_viz::Viz3d::VizImpl::addCircle (const temp_viz::ModelCoefficients &coefficients, const std::string &id) -{ - // Check to see if this ID entry already exists (has it been already added to the visualizer?) - ShapeActorMap::iterator am_it = shape_actor_map_->find (id); - if (am_it != shape_actor_map_->end ()) - { - std::cout << "[addCircle] A shape with id <"< already exists! Please choose a different id and retry.\n" << std::endl; - return (false); - } - - vtkSmartPointer data = create2DCircle (coefficients); - - // Create an Actor - vtkSmartPointer actor; - createActorFromVTKDataSet (data, actor); - actor->GetProperty ()->SetRepresentationToWireframe (); - actor->GetProperty ()->SetLighting (false); - - - // Save the pointer/ID pair to the global actor map - (*shape_actor_map_)[id] = actor; - return (true); -} - -///////////////////////////////////////////////////////////////////////////////////////////// bool temp_viz::Viz3d::VizImpl::addText (const std::string &text, int xpos, int ypos, const Color& color, int fontsize, const std::string &id) { std::string tid = id.empty() ? text : id; -- 2.7.4