|
|
@ -379,309 +379,6 @@ bool temp_viz::Viz3d::VizImpl::addPointCloudNormals (const cv::Mat &cloud, const |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showLine (const String& id, const Point3f& pt1, const Point3f& pt2, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createLine(pt1,pt2)); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create new line
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createLine (pt1, pt2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToWireframe (); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor (actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showPlane (const String& id, const cv::Vec4f &coeffs, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createPlane(coeffs)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createPlane (coeffs); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showPlane (const String& id ,const cv::Vec4f &coeffs, const Point3f& pt, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createPlane(coeffs, pt)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createPlane (coeffs, pt); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showCube (const String& id, const Point3f& pt1, const Point3f& pt2, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createCube(pt1, pt2)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createCube (pt1, pt2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showCylinder (const String& id, const Point3f& pt_on_axis, const Point3f &axis_direction, double radius, int num_sides, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createCylinder(pt_on_axis, axis_direction, radius, num_sides)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createCylinder(pt_on_axis, axis_direction, radius, num_sides); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showCircle (const String& id, const Point3f& pt, double radius, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(create2DCircle(pt, radius)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = create2DCircle(pt, radius); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showSphere (const String& id, const Point3f& pt, double radius, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createSphere(pt, radius)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createSphere(pt, radius); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::showArrow (const String& id, const Point3f& pt1, const Point3f& pt2, const Color& color) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Check if this Id already exists
|
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
bool exists = am_it != shape_actor_map_->end(); |
|
|
|
|
|
|
|
Color c = vtkcolor(color); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// If it exists just update
|
|
|
|
|
|
|
|
if (exists) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
reinterpret_cast<vtkDataSetMapper*>(actor->GetMapper ())->SetInput(createArrow(pt1,pt2)); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Create a plane
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkDataSet> data = createArrow(pt1,pt2); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Create an Actor
|
|
|
|
|
|
|
|
vtkSmartPointer<vtkLODActor> actor; |
|
|
|
|
|
|
|
createActorFromVTKDataSet (data, actor); |
|
|
|
|
|
|
|
// actor->GetProperty ()->SetRepresentationToWireframe ();
|
|
|
|
|
|
|
|
actor->GetProperty ()->SetRepresentationToSurface (); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetLighting (false); |
|
|
|
|
|
|
|
actor->GetProperty ()->SetColor (c.val); |
|
|
|
|
|
|
|
actor->GetMapper ()->ScalarVisibilityOff (); |
|
|
|
|
|
|
|
renderer_->AddActor(actor); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Save the pointer/ID pair to the global actor map
|
|
|
|
|
|
|
|
(*shape_actor_map_)[id] = actor; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cv::Affine3f temp_viz::Viz3d::VizImpl::getShapePose (const String& id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CV_Assert(am_it != shape_actor_map_->end()); |
|
|
|
|
|
|
|
vtkLODActor* actor = vtkLODActor::SafeDownCast(am_it->second); |
|
|
|
|
|
|
|
return Affine3f(convertToMatx(actor->GetUserMatrix())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void temp_viz::Viz3d::VizImpl::setShapePose (const String& id, const Affine3f &pose) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ShapeActorMap::iterator am_it = shape_actor_map_->find (id); |
|
|
|
|
|
|
|
CV_Assert(am_it != shape_actor_map_->end()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vtkLODActor* actor = vtkLODActor::SafeDownCast (am_it->second); |
|
|
|
|
|
|
|
vtkSmartPointer<vtkMatrix4x4> matrix = convertToVtkMatrix(pose.matrix); |
|
|
|
|
|
|
|
actor->SetUserMatrix (matrix); |
|
|
|
|
|
|
|
actor->Modified (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool temp_viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id) |
|
|
|
bool temp_viz::Viz3d::VizImpl::addPolygonMesh (const Mesh3d& mesh, const Mat& mask, const std::string &id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ()); |
|
|
|
CV_Assert(mesh.cloud.type() == CV_32FC3 && mesh.cloud.rows == 1 && !mesh.polygons.empty ()); |
|
|
|