Skip to content
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
4 changes: 2 additions & 2 deletions example/cam2mat.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include <pcprep/pointcloud.h>
#include <pcprep/point_cloud.h>
#include <glm/gtc/matrix_transform.hpp>
#include <cJSON.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pcprep/core.h>
#include <pcprep/utils.h>


int parse_aspect_ratio(const char* aspect_str, int *width, int *height)
Expand Down
20 changes: 13 additions & 7 deletions include/pcprep/aabb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ extern "C"
{

#endif
#include "pcprep/defs.h"
#include "pcprep/mesh.h"
#include "pcprep/pcprep_export.h"
#include "pcprep/vec3f.h"

/**
Expand All @@ -16,11 +16,18 @@ extern "C"
* Defined by its min and max corners.
* @see aabb.h
*/
typedef struct aabb_t
struct pcp_aabb_t
{
vec3f_t min; ///< Minimum (x, y, z)
vec3f_t max; ///< Maximum (x, y, z)
} aabb_t;
pcp_vec3f_t min; ///< Minimum (x, y, z)
pcp_vec3f_t max; ///< Maximum (x, y, z)
pcp_ret_t (*to_mesh)(pcp_aabb_t *self, pcp_mesh_t *mesh);
};

PCPREP_EXPORT
pcp_ret_t pcp_aabb_init(pcp_aabb_t *self);

PCPREP_EXPORT
pcp_ret_t pcp_aabb_free(pcp_aabb_t *self);

/**
* @brief Constructs a triangle mesh from an axis-aligned bounding
Expand All @@ -32,8 +39,7 @@ extern "C"
* @param mesh Output pointer to the resulting mesh.
* @return 0 on success, non-zero on failure.
*/
PCPREP_EXPORT
int aabb_to_mesh(aabb_t aabb, mesh_t *mesh);
pcp_ret_t pcp_aabb_to_mesh(pcp_aabb_t *self, pcp_mesh_t *mesh);

#ifdef __cplusplus
}
Expand Down
55 changes: 25 additions & 30 deletions include/pcprep/canvas.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
#ifndef CANVAS_H
#define CANVAS_H

#include "pcprep/core.h"
#include "pcprep/pcprep_export.h"
#include "pcprep/defs.h"
#include "pcprep/utils.h"
#include "pcprep/vec3uc.h"

typedef struct canvas_t canvas_t;

/**
* @brief holds the data of a virtual screen to be drawn.
*
*
*/
struct canvas_t
struct pcp_canvas_t
{
size_t width;
size_t height;
vec3uc_t bg_col;
pcp_vec3uc_t bg_col;
unsigned char *pixels;
float **min_z_value;

Expand All @@ -31,40 +29,37 @@ struct canvas_t
unsigned int matrix_id;
#endif

void (*draw_points)(
canvas_t *, float *, float *, unsigned char *, size_t);
void (*clear)(canvas_t *);
pcp_ret_t (*draw_points)(
pcp_canvas_t *, float *, float *, unsigned char *, size_t);
pcp_ret_t (*clear)(pcp_canvas_t *);
};

PCPREP_EXPORT
int canvas_init(canvas_t *cv,
size_t width,
size_t height,
pcp_ret_t pcp_canvas_init(pcp_canvas_t *cv,
size_t width,
size_t height,
#ifdef HAVE_GPU
char *vert_shader,
char *frag_shader,
char *vert_shader,
char *frag_shader,
#endif
vec3uc_t bg_col);
pcp_vec3uc_t bg_col);

PCPREP_EXPORT
int canvas_free(canvas_t *cv);
pcp_ret_t pcp_canvas_free(pcp_canvas_t *cv);

#ifdef HAVE_GPU
PCPREP_EXPORT
void canvas_draw_points_gpu(canvas_t *cv,
float *mvp,
float *pos,
unsigned char *rgb,
size_t count);
pcp_ret_t pcp_canvas_draw_points_gpu(pcp_canvas_t *cv,
float *mvp,
float *pos,
unsigned char *rgb,
size_t count);
#endif
PCPREP_EXPORT
void canvas_draw_points_cpu(canvas_t *cv,
float *mvp,
float *pos,
unsigned char *rgb,
size_t count);
pcp_ret_t pcp_canvas_draw_points_cpu(pcp_canvas_t *cv,
float *mvp,
float *pos,
unsigned char *rgb,
size_t count);

PCPREP_EXPORT
void canvas_clear(canvas_t *cv);
pcp_ret_t pcp_canvas_clear(pcp_canvas_t *cv);

#endif
29 changes: 29 additions & 0 deletions include/pcprep/defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef PCPREP_DEFS_H
#define PCPREP_DEFS_H

#include "pcprep/pcprep_export.h"
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

typedef uint32_t pcp_ret_t;

#define PCPREP_RET_FAIL 0x00
#define PCPREP_RET_SUCCESS 0x01

#ifdef __cplusplus
#define PCPREP_NULL nullptr
#else
#define PCPREP_NULL ((void *)0)
#endif

typedef struct pcp_aabb_t pcp_aabb_t;
typedef struct pcp_canvas_t pcp_canvas_t;
typedef struct pcp_mesh_t pcp_mesh_t;
typedef struct pcp_point_cloud_t pcp_point_cloud_t;
typedef struct pcp_vec3f_t pcp_vec3f_t;
typedef struct pcp_vec3u_t pcp_vec3u_t;
typedef struct pcp_vec3uc_t pcp_vec3uc_t;

#endif
40 changes: 27 additions & 13 deletions include/pcprep/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,44 @@ extern "C"

#endif

#include "pcprep/pcprep_export.h"
#include "pcprep/defs.h"
#include <stdint.h>
#include <stdlib.h>

typedef struct mesh_t
struct pcp_mesh_t
{
float *pos;
uint32_t num_verts;
uint32_t *indices;
uint32_t num_indices;
} mesh_t;
pcp_ret_t (*alloc)(pcp_mesh_t *self,
uint32_t num_verts,
uint32_t num_indices);
pcp_ret_t (*load)(pcp_mesh_t *self, const char *filename);
pcp_ret_t (*write)(pcp_mesh_t *self,
const char *filename,
int binary);
pcp_ret_t (*get_screen_ratio)(pcp_mesh_t *self,
float *mvp,
float *screen_ratio);
};

PCPREP_EXPORT
int mesh_init(mesh_t *mesh,
uint32_t num_verts,
uint32_t num_indices);
pcp_ret_t pcp_mesh_init(pcp_mesh_t *self);
PCPREP_EXPORT
int mesh_free(mesh_t *mesh);
PCPREP_EXPORT
int mesh_load(mesh_t *mesh, const char *filename);
PCPREP_EXPORT
int mesh_write(mesh_t mesh, const char *filename, int binary);
PCPREP_EXPORT
int mesh_screen_ratio(mesh_t mesh, float *mvp, float *screen_ratio);
pcp_ret_t pcp_mesh_free(pcp_mesh_t *self);

pcp_ret_t pcp_mesh_alloc(pcp_mesh_t *self,
uint32_t num_verts,
uint32_t num_indices);
pcp_ret_t pcp_mesh_load(pcp_mesh_t *self, const char *filename);

pcp_ret_t
pcp_mesh_write(pcp_mesh_t *self, const char *filename, int binary);

pcp_ret_t pcp_mesh_get_screen_ratio(pcp_mesh_t *self,
float *mvp,
float *screen_ratio);

#ifdef __cplusplus
}
Expand Down
95 changes: 95 additions & 0 deletions include/pcprep/point_cloud.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#ifndef POINT_CLOUD_H
#define POINT_CLOUD_H

#ifdef __cplusplus
extern "C"
{
#endif

#include <pcprep/defs.h>
#include <pcprep/vec3f.h>
#include <stdint.h>
#include <stdlib.h>

struct pcp_point_cloud_t
{
float *pos;
uint8_t *rgb;
size_t size; // number of points, *pos have size*3 elements
pcp_ret_t (*alloc)(pcp_point_cloud_t *self, size_t size);
pcp_ret_t (*load)(pcp_point_cloud_t *self, const char *filename);
pcp_ret_t (*write)(pcp_point_cloud_t *self,
const char *filename,
int binary);
pcp_ret_t (*get_min)(pcp_point_cloud_t *self, pcp_vec3f_t *min);
pcp_ret_t (*get_max)(pcp_point_cloud_t *self, pcp_vec3f_t *max);
pcp_ret_t (*tile)(pcp_point_cloud_t *self,
int n_x,
int n_y,
int n_z,
pcp_point_cloud_t **tiles);
pcp_ret_t (*sample)(pcp_point_cloud_t *self,
float ratio,
unsigned char strategy,
pcp_point_cloud_t *out);
pcp_ret_t (*remove_dupplicates)(pcp_point_cloud_t *self,
pcp_point_cloud_t *out);
pcp_ret_t (*voxelize)(pcp_point_cloud_t *self,
float voxel_size,
pcp_point_cloud_t *out);
pcp_ret_t (*get_pixel_per_tile)(pcp_point_cloud_t *self,
int nx,
int ny,
int nz,
int width,
int height,
float *mvp,
int *pixel_count);
};

PCPREP_EXPORT
pcp_ret_t pcp_point_cloud_init(pcp_point_cloud_t *self);
PCPREP_EXPORT
pcp_ret_t pcp_point_cloud_free(pcp_point_cloud_t *pc);

pcp_ret_t pcp_point_cloud_alloc(pcp_point_cloud_t *pc, size_t size);

pcp_ret_t pcp_point_cloud_load(pcp_point_cloud_t *pc,
const char *filename);
pcp_ret_t pcp_point_cloud_write(pcp_point_cloud_t *pc,
const char *filename,
int binary);
pcp_ret_t pcp_point_cloud_get_min(pcp_point_cloud_t *pc,
pcp_vec3f_t *min);
pcp_ret_t pcp_point_cloud_get_max(pcp_point_cloud_t *pc,
pcp_vec3f_t *max);

pcp_ret_t pcp_point_cloud_tile(pcp_point_cloud_t *pc,
int n_x,
int n_y,
int n_z,
pcp_point_cloud_t **tiles);

pcp_ret_t pcp_point_cloud_sample(pcp_point_cloud_t *pc,
float ratio,
unsigned char strategy,
pcp_point_cloud_t *out);

pcp_ret_t
pcp_point_cloud_remove_dupplicates(pcp_point_cloud_t *pc,
pcp_point_cloud_t *out);
pcp_ret_t pcp_point_cloud_voxelize(pcp_point_cloud_t *pc,
float voxel_size,
pcp_point_cloud_t *out);
pcp_ret_t pcp_point_cloud_get_pixel_per_tile(pcp_point_cloud_t *pc,
int nx,
int ny,
int nz,
int width,
int height,
float *mvp,
int *pixel_count);
#ifdef __cplusplus
}
#endif
#endif
Loading