Skip to content

Commit

Permalink
Merge branch 'dev' into alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
larc committed Nov 1, 2023
2 parents 25d1267 + 1767039 commit 859831f
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 75 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.24)
cmake_minimum_required(VERSION 3.27)

project(gproshan VERSION 3.14)

Expand Down
29 changes: 12 additions & 17 deletions gproshanConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@

include(CMakeFindDependencyMacro)

find_dependency(CUDAToolkit 12)
if(CUDAToolkit_FOUND)
add_definitions(-DGPROSHAN_CUDA)
endif(CUDAToolkit_FOUND)
find_package(CUDAToolkit 12)

find_dependency(embree 4 REQUIRED)
find_dependency(Threads REQUIRED)
find_dependency(OpenMP REQUIRED)
find_dependency(OpenGL REQUIRED)
find_dependency(GLEW REQUIRED)
find_dependency(glfw3 REQUIRED)
find_dependency(X11 REQUIRED)
find_dependency(Armadillo REQUIRED)
find_dependency(Eigen3 REQUIRED)
find_dependency(CGAL REQUIRED)
find_dependency(SuiteSparse REQUIRED)
find_dependency(flann REQUIRED)
find_dependency(Boost COMPONENTS thread system)
find_dependency(embree 4)
find_dependency(OpenMP)
find_dependency(OpenGL)
find_dependency(GLEW)
find_dependency(glfw3)
find_dependency(X11)
find_dependency(Armadillo)
find_dependency(Eigen3)
find_dependency(CGAL)
find_dependency(SuiteSparse)
find_dependency(flann)


include(${CMAKE_CURRENT_LIST_DIR}/gproshanTargets.cmake)
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/app_viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#include <gproshan/include.h>
#include <gproshan/viewer/viewer.h>

#include <gproshan/mesh/che_off.h>
#include <gproshan/mesh/che_obj.h>
#include <gproshan/mesh/che_off.h>
#include <gproshan/mesh/che_ply.h>
#include <gproshan/mesh/che_ptx.h>
#include <gproshan/mesh/che_xyz.h>
Expand Down
6 changes: 0 additions & 6 deletions include/gproshan/geometry/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
#include <cmath>
#include <iostream>

#ifdef __CUDACC__
#define __host_device__ __host__ __device__
#else
#define __host_device__
#endif // __CUDACC__


// geometry processing and shape analysis framework
namespace gproshan {
Expand Down
6 changes: 6 additions & 0 deletions include/gproshan/include.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@

#define NIL (0u - 1)

#ifdef __CUDACC__
#define __host_device__ __host__ __device__
#else
#define __host_device__
#endif // __CUDACC__


// geometry processing and shape analysis framework
namespace gproshan {
Expand Down
1 change: 1 addition & 0 deletions include/gproshan/mesh/che.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class che

public:
static std::vector<index_t> trig_convex_polygon(const index_t * P, const size_t & n);
static che * load_mesh(const std::string & file_path);

friend struct CHE;
};
Expand Down
61 changes: 61 additions & 0 deletions include/gproshan/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,72 @@

#include <gproshan/include.h>

#include <cassert>
#include <vector>


// geometry processing and shape analysis framework
namespace gproshan {


class partitions
{
struct part;

std::vector<index_t> splits;
index_t * sorted = nullptr;

public:
part operator () (const index_t & i) const;
};

struct partitions::part
{
struct iterator
{
index_t i = 0;
const index_t * sorted = nullptr;

__host_device__
iterator & operator ++ ()
{
++i;
return *this;
}

__host_device__
bool operator != (const iterator & it) const
{
return i != it.i;
}

__host_device__
const index_t & operator * ()
{
return sorted ? sorted[i] : i;
}
};


index_t _begin = 0;
index_t _end = 0;
const index_t * sorted = nullptr;


__host_device__
iterator begin() const
{
return {_begin, sorted};
}

__host_device__
iterator end() const
{
return {_end, sorted};
}
};


void copy_real_t_array(float * destination, const float * source, const size_t & n_elem);

void copy_real_t_array(float * destination, const double * source, const size_t & n_elem);
Expand Down
33 changes: 3 additions & 30 deletions src/gproshan/app_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,6 @@ app_viewer::~app_viewer()
delete *m;
}

che * app_viewer::load_mesh(const std::string & file_path)
{
size_t pos = file_path.rfind('.');
assert(pos != std::string::npos);

std::string extension = file_path.substr(pos + 1);

if(extension == "obj")
{
scene * sc = new scene(file_path);
if(!sc->is_scene())
{
delete sc;
return new che_obj(file_path);
}
return sc;
}
if(extension == "off") return new che_off(file_path);
if(extension == "ply") return new che_ply(file_path);
if(extension == "ptx") return new che_ptx(file_path);
if(extension == "xyz") return new che_xyz(file_path);
if(extension == "pts") return new che_pts(file_path);
if(extension == "pcd") return new che_pcd(file_path);

return new che_img(file_path);
}

int app_viewer::main(int nargs, const char ** args)
{
if(nargs < 2)
Expand All @@ -57,7 +30,7 @@ int app_viewer::main(int nargs, const char ** args)

TIC(time)
for(int i = 1; i < nargs; ++i)
add_mesh(load_mesh(args[i]));
add_mesh(che::load_mesh(args[i]));
TOC(time)
update_status_message("meshes loaded in %.3fs", time);

Expand Down Expand Up @@ -693,11 +666,11 @@ bool app_viewer::process_mdict_patch(viewer * p_view)
}

avg_nvp /= mesh.selected.size();
gproshan_debug_var(avg_nvp);
gproshan_log_var(avg_nvp);

delete [] toplevel;
TOC(view->time)
gproshan_debug_var(view->time);
gproshan_log_var(view->time);

return false;
}
Expand Down
6 changes: 5 additions & 1 deletion src/gproshan/mdict/image_denoising.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include <gproshan/mdict/image_denoising.h>

#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#include <CImg.h>
#include <CImg.h>
#pragma GCC diagnostic pop
#else
#include <CImg.h>
#endif // __clang__

using namespace cimg_library;

Expand Down
4 changes: 2 additions & 2 deletions src/gproshan/mdict/msparse_coding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ void msparse_coding::load_sampling()
S.save(tmp_file_path(key_name + ".rsampl"));

gproshan_debug_var(m_params.sum_thres);
gproshan_debug_var(count);
gproshan_debug_var(count_cov);
gproshan_log_var(count);
gproshan_log_var(count_cov);
gproshan_debug_var(seeds.size());
gproshan_debug_var(m_params.n_patches);

Expand Down
38 changes: 38 additions & 0 deletions src/gproshan/mesh/che.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#include <gproshan/mesh/che.h>

#include <gproshan/mesh/che_obj.h>
#include <gproshan/mesh/che_off.h>
#include <gproshan/mesh/che_ply.h>
#include <gproshan/mesh/che_ptx.h>
#include <gproshan/mesh/che_xyz.h>
#include <gproshan/mesh/che_pts.h>
#include <gproshan/mesh/che_pcd.h>
#include <gproshan/mesh/che_img.h>

#include <gproshan/scenes/scene.h>

#include <cassert>
#include <cstring>
#include <cmath>
Expand Down Expand Up @@ -1117,6 +1128,33 @@ std::vector<index_t> che::trig_convex_polygon(const index_t * P, const size_t &
return trigs;
}

che * che::load_mesh(const std::string & file_path)
{
size_t pos = file_path.rfind('.');
assert(pos != std::string::npos);

std::string extension = file_path.substr(pos + 1);

if(extension == "obj")
{
scene * sc = new scene(file_path);
if(!sc->is_scene())
{
delete sc;
return new che_obj(file_path);
}
return sc;
}
if(extension == "off") return new che_off(file_path);
if(extension == "ply") return new che_ply(file_path);
if(extension == "ptx") return new che_ptx(file_path);
if(extension == "xyz") return new che_xyz(file_path);
if(extension == "pts") return new che_pts(file_path);
if(extension == "pcd") return new che_pcd(file_path);

return new che_img(file_path);
}


// iterator classes methods

Expand Down
6 changes: 5 additions & 1 deletion src/gproshan/scenes/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
#include <cmath>
#include <thread>

#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#include <CImg.h>
#include <CImg.h>
#pragma GCC diagnostic pop
#else
#include <CImg.h>
#endif // __clang__

using namespace cimg_library;

Expand Down
7 changes: 7 additions & 0 deletions src/gproshan/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
namespace gproshan {


partitions::part partitions::operator () (const index_t & i) const
{
assert(i > 0 && i < splits.size());
return {splits[i - 1], splits[i], sorted};
}


void copy_real_t_array(float * destination, const float * source, const size_t & n_elem)
{
memcpy(destination, source, n_elem * sizeof(float));
Expand Down
30 changes: 15 additions & 15 deletions src/gproshan/viewer/frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,33 @@ frame::operator const GLuint & () const

vec4 * frame::map_pbo(bool cuda)
{
#ifdef GPROSHAN_CUDA
if(cuda)
if(!cuda)
{
vec4 * img = nullptr;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
return (vec4 *) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
}

vec4 * img = nullptr;
#ifdef GPROSHAN_CUDA
size_t num_bytes = 0;
cudaGraphicsMapResources(1, &pbo_cuda, 0);
cudaGraphicsResourceGetMappedPointer((void **) &img, &num_bytes, pbo_cuda);
return img;
}
#endif // GPROSHAN_CUDA

glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
return (vec4 *) glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
#endif // GPROSHAN_CUDA
return img;
}

void frame::unmap_pbo(bool cuda)
{
#ifdef GPROSHAN_CUDA
if(cuda)
if(!cuda)
{
cudaGraphicsUnmapResources(1, &pbo_cuda, 0);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
return;
}
#endif // GPROSHAN_CUDA

glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
#ifdef GPROSHAN_CUDA
cudaGraphicsUnmapResources(1, &pbo_cuda, 0);
#endif // GPROSHAN_CUDA
}

bool frame::resize(const size_t & w, const size_t & h)
Expand Down
6 changes: 5 additions & 1 deletion src/gproshan/viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
#endif // GPROSHAN_OPTIX


#ifndef __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
#include <CImg.h>
#include <CImg.h>
#pragma GCC diagnostic pop
#else
#include <CImg.h>
#endif // __clang__

using namespace cimg_library;

Expand Down

0 comments on commit 859831f

Please sign in to comment.