Commit eef81955 authored by ozantonkal's avatar ozantonkal

clean unnecessary methods, make text3d face camera

parent 5813a3a9
......@@ -26,16 +26,11 @@ namespace temp_viz
void setBackgroundColor(const Color& color = Color::black());
void showPointCloud(const String& id, InputArray cloud, InputArray colors, const Affine3f& pose = Affine3f::Identity());
void showPointCloud(const String& id, InputArray cloud, const Color& color, const Affine3f& pose = Affine3f::Identity());
bool addPointCloudNormals (const Mat &cloud, const Mat& normals, int level = 100, float scale = 0.02f, const String& id = "cloud");
bool addPolygonMesh (const Mesh3d& mesh, const String& id = "polygon");
bool updatePolygonMesh (const Mesh3d& mesh, const String& id = "polygon");
bool addPolylineFromPolygonMesh (const Mesh3d& mesh, const String& id = "polyline");
bool addText (const String &text, int xpos, int ypos, const Color& color, int fontsize = 10, const String& id = "");
bool addPolygon(const Mat& cloud, const Color& color, const String& id = "polygon");
void spin ();
......
......@@ -52,36 +52,15 @@ public:
void setBackgroundColor (const Color& color);
bool addText (const String &text, int xpos, int ypos, const Color& color, int fontsize = 10, const String& id = "");
bool updateText (const String &text, int xpos, int ypos, const Color& color, int fontsize = 10, const String& id = "");
/** \brief Set the pose of an existing shape. Returns false if the shape doesn't exist, true if the pose was succesfully updated. */
bool updateShapePose (const String& id, const Affine3f& pose);
bool addText3D (const String &text, const Point3f &position, const Color& color, double textScale = 1.0, const String& id = "");
bool addPointCloudNormals (const cv::Mat &cloud, const cv::Mat& normals, int level = 100, float scale = 0.02f, const String& id = "cloud");
/** \brief If the id exists, updates the point cloud; otherwise, adds a new point cloud to the scene
* \param[in] id a variable to identify the point cloud
* \param[in] cloud cloud input in x,y,z coordinates
* \param[in] colors color input in the same order of the points or single uniform color
* \param[in] pose transform to be applied on the point cloud
*/
void showPointCloud(const String& id, InputArray cloud, InputArray colors, const Affine3f& pose = Affine3f::Identity());
void showPointCloud(const String& id, InputArray cloud, const Color& color, const Affine3f& pose = Affine3f::Identity());
bool addPolygonMesh (const Mesh3d& mesh, const cv::Mat& mask, const String& id = "polygon");
bool updatePolygonMesh (const Mesh3d& mesh, const cv::Mat& mask, const String& id = "polygon");
bool addPolylineFromPolygonMesh (const Mesh3d& mesh, const String& id = "polyline");
void setPointCloudColor (const Color& color, const String& id = "cloud");
bool setPointCloudRenderingProperties (int property, double value, const String& id = "cloud");
bool getPointCloudRenderingProperties (int property, double &value, const String& id = "cloud");
bool setShapeRenderingProperties (int property, double value, const String& id);
void setShapeColor (const Color& color, const String& id);
/** \brief Set whether the point cloud is selected or not
* \param[in] selected whether the cloud is selected or not (true = selected)
......
......@@ -17,21 +17,6 @@ void temp_viz::Viz3d::setBackgroundColor(const Color& color)
impl_->setBackgroundColor(color);
}
void temp_viz::Viz3d::showPointCloud(const String& id, InputArray cloud, InputArray colors, const Affine3f& pose)
{
impl_->showPointCloud(id, cloud, colors, pose);
}
void temp_viz::Viz3d::showPointCloud(const String& id, InputArray cloud, const Color& color, const Affine3f& pose)
{
impl_->showPointCloud(id, cloud, color, pose);
}
bool temp_viz::Viz3d::addPointCloudNormals (const Mat &cloud, const Mat& normals, int level, float scale, const String& id)
{
return impl_->addPointCloudNormals(cloud, normals, level, scale, id);
}
bool temp_viz::Viz3d::addPolygonMesh (const Mesh3d& mesh, const String& id)
{
return impl_->addPolygonMesh(mesh, Mat(), id);
......@@ -47,11 +32,6 @@ bool temp_viz::Viz3d::addPolylineFromPolygonMesh (const Mesh3d& mesh, const Stri
return impl_->addPolylineFromPolygonMesh(mesh, id);
}
bool temp_viz::Viz3d::addText (const String &text, int xpos, int ypos, const Color& color, int fontsize, const String& id)
{
return impl_->addText(text, xpos, ypos, color, fontsize, id);
}
bool temp_viz::Viz3d::addPolygon(const Mat& cloud, const Color& color, const String& id)
{
return impl_->addPolygon(cloud, color, id);
......
This diff is collapsed.
......@@ -350,21 +350,6 @@ void temp_viz::Viz3d::VizImpl::setBackgroundColor (const Color& color)
renderer_->SetBackground (c.val);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void temp_viz::Viz3d::VizImpl::setPointCloudColor (const Color& color, const std::string &id)
{
CloudActorMap::iterator am_it = cloud_actor_map_->find (id);
if (am_it != cloud_actor_map_->end ())
{
vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second.actor);
Color c = vtkcolor(color);
actor->GetProperty ()->SetColor (c.val);
actor->GetMapper ()->ScalarVisibilityOff ();
actor->Modified ();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool temp_viz::Viz3d::VizImpl::getPointCloudRenderingProperties (int property, double &value, const std::string &id)
{
......@@ -470,26 +455,6 @@ bool temp_viz::Viz3d::VizImpl::setPointCloudSelected (const bool selected, const
return true;
}
/////////////////////////////////////////////////////////////////////////////////////////////
void temp_viz::Viz3d::VizImpl::setShapeColor (const Color& color, const std::string &id)
{
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
if (am_it != shape_actor_map_->end ())
{
vtkActor* actor = vtkActor::SafeDownCast (am_it->second);
Color c = vtkcolor(color);
actor->GetMapper ()->ScalarVisibilityOff ();
actor->GetProperty ()->SetColor (c.val);
actor->GetProperty ()->SetEdgeColor (c.val);
actor->GetProperty ()->SetAmbient (0.8);
actor->GetProperty ()->SetDiffuse (0.8);
actor->GetProperty ()->SetSpecular (0.8);
actor->GetProperty ()->SetLighting (0);
actor->Modified ();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool temp_viz::Viz3d::VizImpl::setShapeRenderingProperties (int property, double value, const std::string &id)
{
......@@ -618,28 +583,6 @@ void temp_viz::Viz3d::VizImpl::updateCamera ()
renderer_->Render ();
}
/////////////////////////////////////////////////////////////////////////////////////////////
bool temp_viz::Viz3d::VizImpl::updateShapePose (const std::string &id, const cv::Affine3f& pose)
{
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
vtkLODActor* actor;
if (am_it == shape_actor_map_->end ())
return (false);
else
actor = vtkLODActor::SafeDownCast (am_it->second);
vtkSmartPointer<vtkMatrix4x4> matrix = vtkSmartPointer<vtkMatrix4x4>::New ();
convertToVtkMatrix (pose.matrix, matrix);
actor->SetUserMatrix (matrix);
actor->Modified ();
return (true);
}
/////////////////////////////////////////////////////////////////////////////////////////////
void temp_viz::Viz3d::VizImpl::getCameras (temp_viz::Camera& camera)
{
......@@ -916,62 +859,6 @@ bool temp_viz::Viz3d::VizImpl::addModelFromPLYFile (const std::string &filename,
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;
// 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 (tid);
if (am_it != shape_actor_map_->end ())
return std::cout << "[addText] A text with id <"<<id <<"> already exists! Please choose a different id and retry.\n" << std::endl, false;
// Create an Actor
vtkSmartPointer<vtkTextActor> actor = vtkSmartPointer<vtkTextActor>::New ();
actor->SetPosition (xpos, ypos);
actor->SetInput (text.c_str ());
vtkSmartPointer<vtkTextProperty> tprop = actor->GetTextProperty ();
tprop->SetFontSize (fontsize);
tprop->SetFontFamilyToArial ();
tprop->SetJustificationToLeft ();
tprop->BoldOn ();
Color c = vtkcolor(color);
tprop->SetColor (c.val);
renderer_->AddActor(actor);
// Save the pointer/ID pair to the global actor map
(*shape_actor_map_)[tid] = actor;
return (true);
}
//////////////////////////////////////////////////////////////////////////////////////////
bool temp_viz::Viz3d::VizImpl::updateText (const std::string &text, int xpos, int ypos, const Color& color, int fontsize, const std::string &id)
{
std::string tid = id.empty() ? text : id;
ShapeActorMap::iterator am_it = shape_actor_map_->find (tid);
if (am_it == shape_actor_map_->end ())
return false;
// Retrieve the Actor
vtkTextActor *actor = vtkTextActor::SafeDownCast (am_it->second);
actor->SetPosition (xpos, ypos);
actor->SetInput (text.c_str ());
vtkTextProperty* tprop = actor->GetTextProperty ();
tprop->SetFontSize (fontsize);
Color c = vtkcolor(color);
tprop->SetColor (c.val);
actor->Modified ();
return (true);
}
bool temp_viz::Viz3d::VizImpl::addPolylineFromPolygonMesh (const Mesh3d& mesh, const std::string &id)
{
CV_Assert(mesh.cloud.rows == 1 && mesh.cloud.type() == CV_32FC3);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment