showPlane with color
This commit is contained in:
parent
f94c2414e6
commit
93fe2f6e4d
@ -33,8 +33,8 @@ namespace temp_viz
|
|||||||
bool addPointCloudNormals (const Mat &cloud, const Mat& normals, int level = 100, float scale = 0.02f, const String &id = "cloud");
|
bool addPointCloudNormals (const Mat &cloud, const Mat& normals, int level = 100, float scale = 0.02f, const String &id = "cloud");
|
||||||
|
|
||||||
void showLine(const String &id, const Point3f &pt1, const Point3f &pt2, const Color &color);
|
void showLine(const String &id, const Point3f &pt1, const Point3f &pt2, const Color &color);
|
||||||
void showPlane(const String &id, const Vec4f &coefs);
|
void showPlane(const String &id, const Vec4f &coefs, const Color &color);
|
||||||
void showPlane(const String &id, const Vec4f &coefs, const Point3f &pt);
|
void showPlane(const String &id, const Vec4f &coefs, const Point3f &pt, const Color &color);
|
||||||
|
|
||||||
bool addPlane (const ModelCoefficients &coefficients, const String &id = "plane");
|
bool addPlane (const ModelCoefficients &coefficients, const String &id = "plane");
|
||||||
bool addPlane (const ModelCoefficients &coefficients, double x, double y, double z, const String &id = "plane");
|
bool addPlane (const ModelCoefficients &coefficients, double x, double y, double z, const String &id = "plane");
|
||||||
|
@ -139,8 +139,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showLine (const String &id, const cv::Point3f &pt1, const cv::Point3f &pt2, const Color &color);
|
void showLine (const String &id, const cv::Point3f &pt1, const cv::Point3f &pt2, const Color &color);
|
||||||
void showPlane (const String &id, const cv::Vec4f &coefs);
|
void showPlane (const String &id, const cv::Vec4f &coefs, const Color &color);
|
||||||
void showPlane (const String &id ,const cv::Vec4f &coefs, const cv::Point3f &pt);
|
void showPlane (const String &id ,const cv::Vec4f &coefs, const cv::Point3f &pt, const Color &color);
|
||||||
|
|
||||||
bool addPolygon(const cv::Mat& cloud, const Color& color, const std::string &id = "polygon");
|
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, bool display_length, const std::string &id = "arrow");
|
||||||
|
@ -83,14 +83,14 @@ void temp_viz::Viz3d::showLine(const String &id, const Point3f &pt1, const Point
|
|||||||
impl_->showLine(id, pt1, pt2, color);
|
impl_->showLine(id, pt1, pt2, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::showPlane(const String &id, const Vec4f &coefs)
|
void temp_viz::Viz3d::showPlane(const String &id, const Vec4f &coefs, const Color &color)
|
||||||
{
|
{
|
||||||
impl_->showPlane(id, coefs);
|
impl_->showPlane(id, coefs, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::showPlane(const String &id, const Vec4f &coefs, const Point3f &pt)
|
void temp_viz::Viz3d::showPlane(const String &id, const Vec4f &coefs, const Point3f &pt, const Color &color)
|
||||||
{
|
{
|
||||||
impl_->showPlane(id, coefs, pt);
|
impl_->showPlane(id, coefs, pt, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool temp_viz::Viz3d::removeCoordinateSystem (const String &id)
|
bool temp_viz::Viz3d::removeCoordinateSystem (const String &id)
|
||||||
|
@ -302,17 +302,19 @@ void temp_viz::Viz3d::VizImpl::showLine (const String &id, const cv::Point3f &pt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::showPlane (const String &id, const cv::Vec4f &coefs)
|
void temp_viz::Viz3d::VizImpl::showPlane (const String &id, const cv::Vec4f &coefs, const Color &color)
|
||||||
{
|
{
|
||||||
// Check if this Id already exists
|
// Check if this Id already exists
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
bool exists = (am_it != shape_actor_map_->end());
|
bool exists = (am_it != shape_actor_map_->end());
|
||||||
|
Color c = vtkcolor(color);
|
||||||
// If it exists just update
|
// If it exists just update
|
||||||
if (exists)
|
if (exists)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second);
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second);
|
||||||
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createPlane(coefs));
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createPlane(coefs));
|
||||||
|
actor->GetProperty ()->SetColor (c.val);
|
||||||
|
actor->GetMapper ()->ScalarVisibilityOff ();
|
||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -326,6 +328,8 @@ void temp_viz::Viz3d::VizImpl::showPlane (const String &id, const cv::Vec4f &coe
|
|||||||
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
||||||
actor->GetProperty ()->SetRepresentationToSurface ();
|
actor->GetProperty ()->SetRepresentationToSurface ();
|
||||||
actor->GetProperty ()->SetLighting (false);
|
actor->GetProperty ()->SetLighting (false);
|
||||||
|
actor->GetProperty ()->SetColor (c.val);
|
||||||
|
actor->GetMapper ()->ScalarVisibilityOff ();
|
||||||
renderer_->AddActor(actor);
|
renderer_->AddActor(actor);
|
||||||
|
|
||||||
// Save the pointer/ID pair to the global actor map
|
// Save the pointer/ID pair to the global actor map
|
||||||
@ -333,17 +337,19 @@ void temp_viz::Viz3d::VizImpl::showPlane (const String &id, const cv::Vec4f &coe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void temp_viz::Viz3d::VizImpl::showPlane (const String &id ,const cv::Vec4f &coefs, const cv::Point3f &pt)
|
void temp_viz::Viz3d::VizImpl::showPlane (const String &id ,const cv::Vec4f &coefs, const cv::Point3f &pt, const Color &color)
|
||||||
{
|
{
|
||||||
// Check if this Id already exists
|
// Check if this Id already exists
|
||||||
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id);
|
||||||
bool exists = (am_it != shape_actor_map_->end());
|
bool exists = (am_it != shape_actor_map_->end());
|
||||||
|
Color c = vtkcolor(color);
|
||||||
// If it exists just update
|
// If it exists just update
|
||||||
if (exists)
|
if (exists)
|
||||||
{
|
{
|
||||||
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second);
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second);
|
||||||
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createPlane(coefs, pt));
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createPlane(coefs, pt));
|
||||||
|
actor->GetProperty ()->SetColor (c.val);
|
||||||
|
actor->GetMapper ()->ScalarVisibilityOff ();
|
||||||
actor->Modified ();
|
actor->Modified ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -357,6 +363,8 @@ void temp_viz::Viz3d::VizImpl::showPlane (const String &id ,const cv::Vec4f &coe
|
|||||||
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
||||||
actor->GetProperty ()->SetRepresentationToSurface ();
|
actor->GetProperty ()->SetRepresentationToSurface ();
|
||||||
actor->GetProperty ()->SetLighting (false);
|
actor->GetProperty ()->SetLighting (false);
|
||||||
|
actor->GetProperty ()->SetColor (c.val);
|
||||||
|
actor->GetMapper ()->ScalarVisibilityOff ();
|
||||||
renderer_->AddActor(actor);
|
renderer_->AddActor(actor);
|
||||||
|
|
||||||
// Save the pointer/ID pair to the global actor map
|
// Save the pointer/ID pair to the global actor map
|
||||||
|
@ -93,8 +93,6 @@ TEST(Viz_viz3d, accuracy)
|
|||||||
int col_green = 0;
|
int col_green = 0;
|
||||||
int col_red = 0;
|
int col_red = 0;
|
||||||
|
|
||||||
v.showPlane("plane1", cv::Vec4f(1.0f,1.0f,1.0f,1.0f));
|
|
||||||
|
|
||||||
while(!v.wasStopped())
|
while(!v.wasStopped())
|
||||||
{
|
{
|
||||||
// Creating new point cloud with id cloud1
|
// Creating new point cloud with id cloud1
|
||||||
@ -104,7 +102,7 @@ TEST(Viz_viz3d, accuracy)
|
|||||||
v.showLine("line2", cv::Point3f(0.0,0.0,0.0), cv::Point3f(1.0f-pos_x, pos_y, pos_z) , temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
v.showLine("line2", cv::Point3f(0.0,0.0,0.0), cv::Point3f(1.0f-pos_x, pos_y, pos_z) , temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
||||||
v.showLine("line3", cv::Point3f(0.0,0.0,0.0), cv::Point3f(pos_x, 1.0f-pos_y, pos_z) , temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
v.showLine("line3", cv::Point3f(0.0,0.0,0.0), cv::Point3f(pos_x, 1.0f-pos_y, pos_z) , temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
||||||
v.showLine("line4", cv::Point3f(0.0,0.0,0.0), cv::Point3f(pos_x, pos_y, 1.0f-pos_z) , temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
v.showLine("line4", cv::Point3f(0.0,0.0,0.0), cv::Point3f(pos_x, pos_y, 1.0f-pos_z) , temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
||||||
v.showPlane("plane1", cv::Vec4f(pos_x*pos_y,pos_y,pos_z,pos_x+pos_y*pos_z));
|
v.showPlane("plane1", cv::Vec4f(pos_x*pos_y,pos_y,pos_z,pos_x+pos_y*pos_z), temp_viz::Color(255-col_blue, 255-col_green, 255-col_red));
|
||||||
|
|
||||||
angle_x += 0.1f;
|
angle_x += 0.1f;
|
||||||
angle_y -= 0.1f;
|
angle_y -= 0.1f;
|
||||||
|
Loading…
Reference in New Issue
Block a user