Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform classic loops to range-based for loops in module outofcore #2848

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,19 +164,19 @@ class OutofcoreCloud : public Object
}

int
getDisplayDepth ()
getDisplayDepth () const
{
return display_depth_;
}

uint64_t
getPointsLoaded ()
getPointsLoaded () const
{
return points_loaded_;
}

uint64_t
getDataLoaded ()
getDataLoaded () const
{
return data_loaded_;
}
Expand Down
8 changes: 4 additions & 4 deletions outofcore/src/visualization/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ Camera::Camera (std::string name) :
camera_actor_->GetProperty ()->SetLighting (false);
camera_actor_->GetProperty ()->SetLineStipplePattern (1010101010);

for (int i = 0; i < 24; i++)
frustum_[i] = 0;
for (double &f : frustum_)
f = 0;

hull_actor_ = vtkSmartPointer<vtkActor>::New ();
vtkSmartPointer<vtkPolyDataMapper> hull_mapper = vtkSmartPointer<vtkPolyDataMapper>::New ();
Expand All @@ -55,8 +55,8 @@ Camera::Camera (std::string name, vtkSmartPointer<vtkCamera> camera) :
camera_actor_->SetCamera (camera_);
camera_actor_->GetProperty ()->SetLighting (false);

for (int i = 0; i < 24; i++)
frustum_[i] = 0;
for (double &f : frustum_)
f = 0;

hull_actor_ = vtkSmartPointer<vtkActor>::New ();
vtkSmartPointer<vtkPolyDataMapper> hull_mapper = vtkSmartPointer<vtkPolyDataMapper>::New ();
Expand Down
8 changes: 4 additions & 4 deletions outofcore/src/visualization/outofcore_cloud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ OutofcoreCloud::updateVoxelData ()
double voxel_side_length = octree_->getVoxelSideLength (display_depth_);

double s = voxel_side_length / 2;
for (size_t i = 0; i < voxel_centers.size (); i++)
for (const auto &voxel_center : voxel_centers)
{
double x = voxel_centers[i].x;
double y = voxel_centers[i].y;
double z = voxel_centers[i].z;
double x = voxel_center.x;
double y = voxel_center.y;
double z = voxel_center.z;

voxel_data->AddInputData (getVtkCube (x - s, x + s, y - s, y + s, z - s, z + s));
}
Expand Down
18 changes: 9 additions & 9 deletions outofcore/src/visualization/scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ Scene::getCameras ()
Camera*
Scene::getCamera (vtkCamera *camera)
{
for (size_t i = 0; i < cameras_.size (); i++)
for (const auto &c : cameras_)
{
if (cameras_[i]->getCamera ().GetPointer () == camera)
if (c->getCamera ().GetPointer () == camera)
{
return cameras_[i];
return c;
}
}

Expand All @@ -42,9 +42,9 @@ Scene::getCamera (vtkCamera *camera)
Camera*
Scene::getCamera (std::string name)
{
for (size_t i = 0; i < cameras_.size (); i++)
if (cameras_[i]->getName () == name)
return cameras_[i];
for (const auto &camera : cameras_)
if (camera->getName () == name)
return camera;

return NULL;
}
Expand All @@ -60,9 +60,9 @@ Scene::addObject (Object *object)
Object*
Scene::getObjectByName (std::string name)
{
for (size_t i = 0; i < objects_.size (); i++)
if (objects_[i]->getName () == name)
return objects_[i];
for (const auto &object : objects_)
if (object->getName () == name)
return object;

return NULL;
}
Expand Down
33 changes: 6 additions & 27 deletions outofcore/src/visualization/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>

//void CallbackFunction (vtkObject* caller, long unsigned int vtkNotUsed (eventId), void* clientData, void* vtkNotUsed (callData) )
//{
// vtkRenderer* renderer = static_cast<vtkRenderer*> (caller);
//
// double timeInSeconds = renderer->GetLastRenderTimeInSeconds ();
// double fps = 1.0/timeInSeconds;
// std::cout << "FPS: " << fps << std::endl;
//
// std::cout << "Callback" << std::endl;
//}

// Operators
// -----------------------------------------------------------------------------
Viewport::Viewport (vtkSmartPointer<vtkRenderWindow> window, double xmin/*=0.0*/, double ymin/*=0.0*/,
Expand Down Expand Up @@ -144,24 +133,15 @@ Viewport::viewportActorUpdate ()

std::vector<Camera*> cameras = scene->getCameras ();

for (size_t i = 0; i < cameras.size (); i++)
for (auto &camera : cameras)
{
cameras[i]->render (renderer_);
// if (cameras[i]->getCamera () != renderer_->GetActiveCamera ())
// {
// renderer_->AddActor (cameras[i]->getCameraActor ());
// if (cameras[i]->getName () == "octree")
// {
// renderer_->AddActor (cameras[i]->getHullActor ());
// }
// }
camera->render (renderer_);
}

std::vector<Object*> objects = scene->getObjects ();
for (size_t i = 0; i < objects.size (); i++)
for (auto &object : objects)
{
//std::cout << objects[i]->getName () << std::endl;
objects[i]->render (renderer_);
object->render (renderer_);
}
}

Expand Down Expand Up @@ -189,10 +169,9 @@ Viewport::viewportHudUpdate ()

uint64_t points_loaded = 0;
uint64_t data_loaded = 0;
for (size_t i = 0; i < objects.size (); i++)
for (const auto &object : objects)
{
//TYPE& dynamic_cast<TYPE&> (object);
OutofcoreCloud* cloud = dynamic_cast<OutofcoreCloud*> (objects[i]);
const auto cloud = dynamic_cast<const OutofcoreCloud*> (object);
if (cloud != NULL)
{
points_loaded += cloud->getPointsLoaded ();
Expand Down
8 changes: 4 additions & 4 deletions outofcore/tools/outofcore_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@ outofcoreProcess (std::vector<boost::filesystem::path> pcd_paths, boost::filesys
uint64_t total_pts = 0;

// Iterate over all pcd files adding points to the octree
for (size_t i = 0; i < pcd_paths.size (); i++)
for (const auto &pcd_path : pcd_paths)
{

PCLPointCloud2::Ptr cloud = getCloudFromFile (pcd_paths[i]);
PCLPointCloud2::Ptr cloud = getCloudFromFile (pcd_path);

boost::uint64_t pts = 0;

Expand Down Expand Up @@ -303,9 +303,9 @@ main (int argc, char* argv[])
std::vector<int> file_arg_indices = parse_file_extension_argument (argc, argv, ".pcd");

std::vector<boost::filesystem::path> pcd_paths;
for (size_t i = 0; i < file_arg_indices.size (); i++)
for (const int &file_arg_index : file_arg_indices)
{
boost::filesystem::path pcd_path (argv[file_arg_indices[i]]);
boost::filesystem::path pcd_path (argv[file_arg_index]);
if (!boost::filesystem::exists (pcd_path))
{
PCL_WARN ("File %s doesn't exist", pcd_path.string ().c_str ());
Expand Down