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 Jan 30, 2024
2 parents d4a6246 + 8efb1d1 commit c93b165
Show file tree
Hide file tree
Showing 30 changed files with 50 additions and 42 deletions.
4 changes: 2 additions & 2 deletions include/gproshan/geodesics/geodesics_ptp.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ struct toplesets_t
const index_t * index;
};

double parallel_toplesets_propagation_gpu(const ptp_out_t & ptp_out, const che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool & coalescence = true, const bool & set_inf = true);
double parallel_toplesets_propagation_gpu(const ptp_out_t & ptp_out, const che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool coalescence = true, const bool set_inf = true);

void parallel_toplesets_propagation_cpu(const ptp_out_t & ptp_out, che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool & coalescence = false, const bool & set_inf = true);
void parallel_toplesets_propagation_cpu(const ptp_out_t & ptp_out, che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool coalescence = false, const bool set_inf = true);

real_t farthest_point_sampling_ptp_gpu(che * mesh, std::vector<index_t> & samples, double & time_fps, size_t n, real_t radio = 0);

Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mdict/basis.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class basis
basis(const real_t r, const size_t d);
virtual ~basis() = default;
virtual void discrete(a_mat & phi, const a_vec & x, const a_vec & y) = 0;
virtual void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool & b) = 0;
virtual void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool b) = 0;
virtual real_t freq(const index_t idx) = 0;
real_t & radio();
size_t dim() const;
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mdict/basis_dct.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class basis_dct: public basis
public:
basis_dct(const size_t n, const real_t r = 1);
void discrete(a_mat & phi, const a_vec & x, const a_vec & y);
void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool & b);
void d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool b);
real_t freq(const index_t idx);

private:
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mdict/msparse_coding.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class msparse_coding
void sparse_coding();
void init_sampling();
void load_features(std::vector<index_t> & v_feat, size_t & featsize);
void init_patches( const bool & reset = 1,
void init_patches( const bool reset = 1,
const fmask_t & mask = nullptr
);

Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mesh/che.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace gproshan {


void cuda_create_CHE(CHE * h_che, CHE *& dd_che, CHE *& d_che, const bool & normal = false, const bool & color = false);
void cuda_create_CHE(CHE * h_che, CHE *& dd_che, CHE *& d_che, const bool normal = false, const bool color = false);

void cuda_free_CHE(CHE *& dd_che, CHE *& d_che);

Expand Down
8 changes: 4 additions & 4 deletions include/gproshan/mesh/che_fill_hole.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct border_t

border_t() = default;

border_t(const std::vector<a_vec> & V, const index_t _v, const std::array<index_t, 2> & neighbors, const bool & o):
border_t(const std::vector<a_vec> & V, const index_t _v, const std::array<index_t, 2> & neighbors, const bool o):
v(_v)
{
index_t p_v = neighbors[!o];
Expand All @@ -38,7 +38,7 @@ struct border_t
if(theta < 0) theta += 2 * M_PI;
}

a_vec new_vertex(const std::vector<a_vec> & V, real_t div, const real_t length, const std::array<index_t, 2> & neighbors, const bool & o)
a_vec new_vertex(const std::vector<a_vec> & V, real_t div, const real_t length, const std::array<index_t, 2> & neighbors, const bool o)
{
index_t p_v = neighbors[!o];
index_t n_v = neighbors[o];
Expand All @@ -56,7 +56,7 @@ struct border_t
return r;
}

border_t(const std::vector<a_vec> & V, const index_t _v, const std::array<index_t, 2> & neighbors, const bool & o, const a_vec & normal):
border_t(const std::vector<a_vec> & V, const index_t _v, const std::array<index_t, 2> & neighbors, const bool o, const a_vec & normal):
v(_v)
{
index_t p_v = neighbors[!o];
Expand All @@ -81,7 +81,7 @@ struct border_t
if(theta < 0) theta += 2 * M_PI;
}

a_vec new_vertex(const std::vector<a_vec> & V, real_t div, const real_t length, const std::array<index_t, 2> & neighbors, const bool & o, const a_vec & normal)
a_vec new_vertex(const std::vector<a_vec> & V, real_t div, const real_t length, const std::array<index_t, 2> & neighbors, const bool o, const a_vec & normal)
{
index_t p_v = neighbors[!o];
index_t n_v = neighbors[o];
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mesh/che_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class che_obj : public che
public:
che_obj(const std::string & file);

static void write_file(const che * mesh, const std::string & file, const bool & color = false, const bool & pointcloud = false);
static void write_file(const che * mesh, const std::string & file, const bool color = false, const bool pointcloud = false);

private:
void read_file(const std::string & file);
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mesh/che_off.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class che_off : public che
che_off(const std::string & file);

enum type { OFF, NOFF, COFF, NCOFF };
static void write_file(const che * mesh, const std::string & file, const che_off::type & off = OFF, const bool & pointcloud = false);
static void write_file(const che * mesh, const std::string & file, const che_off::type & off = OFF, const bool pointcloud = false);

private:
void read_file(const std::string & file);
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mesh/che_ply.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class che_ply : public che
public:
che_ply(const std::string & file);

static void write_file(const che * mesh, const std::string & file, const bool & color = false);
static void write_file(const che * mesh, const std::string & file, const bool color = false);

private:
void read_file(const std::string & file);
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/mesh/che_xyz.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class che_xyz : public che
public:
che_xyz(const std::string & file);

static void write_file(const che * mesh, const std::string & file, const bool & color = false);
static void write_file(const che * mesh, const std::string & file, const bool color = false);

private:
void read_file(const std::string & file);
Expand Down
5 changes: 3 additions & 2 deletions include/gproshan/raytracing/embree.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class embree : public raytracing
virtual ~embree();

virtual index_t closest_vertex(const vertex & org, const vertex & dir) const;
virtual eval_hit intersect(const vertex & org, const vertex & dir, const bool & flat = true) const;
virtual eval_hit intersect(const vertex & org, const vertex & dir, const bool flat = true) const;


protected:
Expand All @@ -76,9 +76,10 @@ class embree : public raytracing
vertex & attenuation,
vertex & position,
vertex & ray_dir,
real_t & dist,
random<real_t> & rnd,
const render_params & params,
const bool & flat
const bool flat
) const;

float intersect_depth(const vertex & org, const vertex & dir) const;
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/raytracing/optix.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class optix : public raytracing
optix(const std::vector<che *> & meshes, const std::vector<mat4> & model_mats);
~optix();

void render(vec4 * img, const render_params & params, const bool & flat);
void render(vec4 * img, const render_params & params, const bool flat);

protected:
void create_raygen_programs();
Expand Down
7 changes: 4 additions & 3 deletions include/gproshan/raytracing/raytracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class raytracing
raytracing() = default;
virtual ~raytracing() = default;

virtual void render(vec4 * img, const render_params & params, const bool & flat);
virtual void render(vec4 * img, const render_params & params, const bool flat);

virtual std::vector<float> raycaster( const uvec2 & windows_size,
const mat4 & inv_proj_view,
Expand All @@ -28,7 +28,7 @@ class raytracing

virtual eval_hit intersect( const vertex &, // org
const vertex &, //dir
[[maybe_unused]] const bool & flat = true
[[maybe_unused]] const bool flat = true
) const { return {}; }

virtual index_t closest_vertex( const vertex &, // org,
Expand All @@ -40,9 +40,10 @@ class raytracing
vertex &, // attenuation,
vertex &, // position,
vertex &, // ray_dir,
real_t &, // dist
random<real_t> &, // rnd,
const render_params &, // params,
const bool & // flat
const bool // flat
) const { return false; };

virtual float intersect_depth( const vertex &, // org,
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/viewer/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class camera
mat4 perspective();
mat4 look_at(const quaternion & r);
quaternion current_rotation() const;
void mouse(const bool & press, const double x, const double y, const int w, const int h);
void mouse(const bool press, const double x, const double y, const int w, const int h);
void motion(const double x, const double y, const int w, const int h);
void zoom_in();
void zoom_out();
Expand Down
2 changes: 1 addition & 1 deletion include/gproshan/viewer/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class viewer
che_viewer & selected_mesh();
void add_menu(const std::string & str, const std::vector<int> & vprocesses);
int add_process(const char * name, const function_t & f, const int key = -1);
bool add_mesh(che * p_mesh, const bool & reset_normals = true);
bool add_mesh(che * p_mesh, const bool reset_normals = true);
bool remove_mesh(const index_t idx);
bool pop_mesh();
void update_viewport_meshes();
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/geodesics/geodesics_ptp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace gproshan {
ptp_out_t::ptp_out_t(real_t * d, index_t * c): dist(d), clusters(c) {}


void parallel_toplesets_propagation_cpu(const ptp_out_t & ptp_out, che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool & coalescence, const bool & set_inf)
void parallel_toplesets_propagation_cpu(const ptp_out_t & ptp_out, che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool coalescence, const bool set_inf)
{
CHE h_mesh(mesh);
const size_t n_vertices = h_mesh.n_vertices;
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/geodesics/geodesics_ptp.cu
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace gproshan {


double parallel_toplesets_propagation_gpu(const ptp_out_t & ptp_out, const che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool & coalescence, const bool & set_inf)
double parallel_toplesets_propagation_gpu(const ptp_out_t & ptp_out, const che * mesh, const std::vector<index_t> & sources, const toplesets_t & toplesets, const bool coalescence, const bool set_inf)
{
CHE h_mesh(mesh);
const size_t n_vertices = h_mesh.n_vertices;
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mdict/basis_dct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void basis_dct::discrete(a_mat & phi, const a_vec & x, const a_vec & y)
phi.col(k) = dct(x, y, nx, ny);
}

void basis_dct::d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool & b)
void basis_dct::d_discrete(a_mat & phi, const a_vec & x, const a_vec & y, const bool b)
{
assert(phi.n_cols == _dim);

Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mdict/msparse_coding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ void msparse_coding::load_features(std::vector<index_t> & v_feat, size_t & feats
inp.close();
}

void msparse_coding::init_patches(const bool & reset, const fmask_t & mask)
void msparse_coding::init_patches(const bool reset, const fmask_t & mask)
{
gproshan_log(MDICT);

Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mesh/che.cu
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace gproshan {


void cuda_create_CHE(CHE * h_che, CHE *& dd_che, CHE *& d_che, const bool & normal, const bool & color)
void cuda_create_CHE(CHE * h_che, CHE *& dd_che, CHE *& d_che, const bool normal, const bool color)
{
dd_che = new CHE;
dd_che->n_vertices = h_che->n_vertices;
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mesh/che_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void che_obj::read_file(const std::string & file)
VT[i] = p.trigs[i].x();
}

void che_obj::write_file(const che * mesh, const std::string & file, const bool & color, const bool & pointcloud)
void che_obj::write_file(const che * mesh, const std::string & file, const bool color, const bool pointcloud)
{
FILE * fp = fopen((file + ".obj").c_str(), "w");
assert(fp);
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mesh/che_off.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void che_off::read_file(const std::string & file)
memcpy(VT, trigs.data(), size(trigs) * sizeof(index_t));
}

void che_off::write_file(const che * mesh, const std::string & file, const che_off::type & off, const bool & pointcloud)
void che_off::write_file(const che * mesh, const std::string & file, const che_off::type & off, const bool pointcloud)
{
static const char * str_off[] = {"OFF", "NOFF", "COFF", "NCOFF"};

Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mesh/che_ply.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void che_ply::read_file(const std::string & file)
memcpy(VT, trigs.data(), size(trigs) * sizeof(index_t));
}

void che_ply::write_file(const che * mesh, const std::string & file, const bool & color)
void che_ply::write_file(const che * mesh, const std::string & file, const bool color)
{
FILE * fp = fopen((file + ".ply").c_str(), "wb");
assert(fp);
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/mesh/che_xyz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void che_xyz::read_file(const std::string & file)
update_heatmap(vertices_hm.data());
}

void che_xyz::write_file(const che * mesh, const std::string & file, const bool & color)
void che_xyz::write_file(const che * mesh, const std::string & file, const bool color)
{
FILE * fp = fopen((file + ".xyz").c_str(), "w");
assert(fp);
Expand Down
5 changes: 3 additions & 2 deletions src/gproshan/raytracing/embree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ index_t embree::closest_vertex(const vertex & org, const vertex & dir) const
return closest_hit_vertex(*g_meshes[r.hit.geomID], r.hit);
}

eval_hit embree::intersect(const vertex & org, const vertex & dir, const bool & flat) const
eval_hit embree::intersect(const vertex & org, const vertex & dir, const bool flat) const
{
ray_hit r(org, dir);
if(!intersect(r)) return {};
Expand Down Expand Up @@ -250,9 +250,10 @@ bool embree::closesthit_radiance( vertex & color,
vertex & attenuation,
vertex & position,
vertex & ray_dir,
float &,
random<real_t> & rnd,
const render_params & params,
const bool & flat
const bool flat
) const
{
ray_hit r(position, ray_dir);
Expand Down
6 changes: 3 additions & 3 deletions src/gproshan/raytracing/optix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ optix::optix(const std::string & ptx)
optix_pipeline_compile_opt = {};
optix_pipeline_compile_opt.traversableGraphFlags = OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_SINGLE_GAS;
optix_pipeline_compile_opt.usesMotionBlur = false;
optix_pipeline_compile_opt.numPayloadValues = 3;
optix_pipeline_compile_opt.numAttributeValues = 3;
optix_pipeline_compile_opt.numPayloadValues = 4;
optix_pipeline_compile_opt.numAttributeValues = 4;
optix_pipeline_compile_opt.exceptionFlags = OPTIX_EXCEPTION_FLAG_NONE;
optix_pipeline_compile_opt.pipelineLaunchParamsVariableName = "optix_params";

Expand Down Expand Up @@ -123,7 +123,7 @@ optix::~optix()
cudaFree(data);
}

void optix::render(vec4 * img, const render_params & params, const bool & flat)
void optix::render(vec4 * img, const render_params & params, const bool flat)
{
optix_params.depth = params.depth;
optix_params.n_frames = params.n_frames;
Expand Down
5 changes: 4 additions & 1 deletion src/gproshan/raytracing/optix.cu
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extern "C" __global__ void __raygen__render_frame()
vec3 & ray_dir = trace[3];

uint32_t u0, u1;
unsigned int dist;

do
{
Expand All @@ -144,6 +145,8 @@ extern "C" __global__ void __raygen__render_frame()
position = optix_params.cam_pos;
ray_dir = ray_view_dir(pos, optix_params.window_size, optix_params.inv_proj_view, optix_params.cam_pos, rnd);

dist = 0;

depth = optix_params.depth;
do
{
Expand All @@ -159,7 +162,7 @@ extern "C" __global__ void __raygen__render_frame()
0, // SBT offset
2, // SBT stride
0, // missSBTIndex
u0, u1, (unsigned int &) rnd);
u0, u1, (unsigned int &) rnd, dist);

if(!u0) break; // miss
color_acc += color;
Expand Down
8 changes: 5 additions & 3 deletions src/gproshan/raytracing/raytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace gproshan::rt {


void raytracing::render(vec4 * img, const render_params & params, const bool & flat)
void raytracing::render(vec4 * img, const render_params & params, const bool flat)
{
uvec2 window_size = params.window_size;
if(params.viewport_is_window)
Expand All @@ -17,8 +17,9 @@ void raytracing::render(vec4 * img, const render_params & params, const bool & f
unsigned int samples = params.n_samples;

vec3 color_acc, color, attenuation, position, ray_dir;
float dist;

#pragma omp parallel for private(depth, samples, color_acc, color, attenuation, position, ray_dir)
#pragma omp parallel for private(depth, samples, color_acc, color, attenuation, position, ray_dir, dist)
for(unsigned int i = 0; i < params.viewport_size.x(); ++i)
for(unsigned int j = 0; j < params.viewport_size.y(); ++j)
{
Expand All @@ -35,11 +36,12 @@ void raytracing::render(vec4 * img, const render_params & params, const bool & f
attenuation = 1;
position = params.cam_pos;
ray_dir = ray_view_dir(pos, window_size, params.inv_proj_view, params.cam_pos, rnd);
dist = 0;

depth = params.depth;
do
{
if(!closesthit_radiance(color, attenuation, position, ray_dir, rnd, params, flat))
if(!closesthit_radiance(color, attenuation, position, ray_dir, dist, rnd, params, flat))
break;

color_acc += color;
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/viewer/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ quaternion camera::current_rotation() const
return p_drag * p_click.conj() * r_last;
}

void camera::mouse(const bool & press, const double x, const double y, const int w, const int h)
void camera::mouse(const bool press, const double x, const double y, const int w, const int h)
{
if(press)
{
Expand Down
2 changes: 1 addition & 1 deletion src/gproshan/viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ int viewer::add_process(const char * name, const function_t & f, const int key)
return fkey;
}

bool viewer::add_mesh(che * p_mesh, const bool & reset_normals)
bool viewer::add_mesh(che * p_mesh, const bool reset_normals)
{
if(size(meshes) == max_meshes)
return false;
Expand Down

0 comments on commit c93b165

Please sign in to comment.