ReconstructMe SDK  2.6.43-0
Real-time 3D reconstruction engine
CSG

Constructive Solid Geometry operations. More...

Typedefs

typedef int reme_csg_t
 Handle referencing a CSG object. More...
 
typedef enum _reme_set_operation_t reme_set_operation_t
 Enumeration of available CSG set operations. More...
 

Enumerations

enum  _reme_set_operation_t {
  REME_SET_UNION,
  REME_SET_SUBTRACTION,
  REME_SET_INTERSECTION
}
 Enumeration of available CSG set operations. More...
 
reme_error_t reme_csg_create (reme_context_t c, reme_volume_t v, reme_csg_t *csg)
 Create a new CSG module for performing boolean set operations. More...
 
reme_error_t reme_csg_destroy (reme_context_t c, reme_csg_t *csg)
 Destroy a previously created CSG object. More...
 
reme_error_t reme_csg_update_with_spheres (reme_context_t c, reme_csg_t csg, reme_set_operation_t op, const float *spheres, int numspheres)
 Perform boolean set operation on the volume and one or more spheres. More...
 
reme_error_t reme_csg_update_with_boxes (reme_context_t c, reme_csg_t csg, reme_set_operation_t op, const float *boxes, int numboxes)
 Perform boolean set operation on the volume and one or more boxes. More...
 
reme_error_t reme_csg_update_with_planes (reme_context_t c, reme_csg_t csg, reme_set_operation_t op, const float *planes, int numplanes)
 Perform boolean set operation on the volume and one or more planes. More...
 
reme_error_t reme_csg_update_with_surface (reme_context_t c, reme_csg_t csg, reme_set_operation_t op, reme_surface_t s)
 Perform boolean set operation on the volume and a freeform solid mesh. More...
 
reme_error_t reme_csg_close_volume_borders (reme_context_t c, reme_csg_t csg)
 Make sure that volume borders are closed. More...
 

Detailed Description

Constructive Solid Geometry operations.

The CSG module is able to create complex watertight surfaces by combining solid objects using the following Boolean set operations: union, intersection and subtraction. The CSG module works directly on the reconstruction volume and can thus be used to post-process the reconstruction in many ways (e.g. cut the model, add a stand).

Boolean Operations on Sets

The following images show the supported Boolean set operations by the reme_csg_t module applied to box and a sphere primitive.

csg_set_union.png
Union - Joins two or more solids into creating one based on the total geometry of all.
csg_set_subtraction.png
Subtraction - Subtracts one or more solids from another creating a solid based on the remaining geometry.
csg_set_intersection.png
Intersection - Creates a single solid from one more solids based on the intersected geometry.

Supported Objects

Currently, the CSG module supports two types of solid objects to work with. First, you can work with primitive objects such as spheres, boxes and planes. Besides that, you can also use closed free-form surfaces.

Using the CSG Module

To use the CSG module, you would first create a new one.

// Create CSG module
reme_csg_create(c, v, &csg);

Since the CSG module works on concrete reconstruction volume, you need to pass one when you construct it.

Next, you would start to model using primitives or free-form closed surfaces. For example the images from the section above were created using the following two primitives

float sphere[4] = {0, 0, 0, 50};
float box[6] = { -100, -100, -20, 100, 100, 20};

To merge (union) both primitives the CSG module is used in the following way

// Union operation

Subtraction is done by

// Subtraction operation

And finally, intersection can be accomplished by

// Intersection operation

Once you are done with the CSG module you can extract the surface from the volume as always using reme_surface_t.

The entire example can be found in example_reconstructmesdk_csg.cpp For a more complex example involving the reconstruction itself see example_reconstructmesdk_bust.cpp

Typedef Documentation

◆ reme_csg_t

typedef int reme_csg_t

Handle referencing a CSG object.

The CSG object allows you to modify the reconstruction content by applying set operations on solids.

◆ reme_set_operation_t

Enumeration of available CSG set operations.

The CSG module updates the content of the reconstruction volume by performing a binary set operation on it. The left hand side of the operation is the content of the volume. The right hand side is one of the available solids. The reme_set_operation_t defines the operation to apply. The result of the operation is an updated volume content.

Enumeration Type Documentation

◆ _reme_set_operation_t

Enumeration of available CSG set operations.

The CSG module updates the content of the reconstruction volume by performing a binary set operation on it. The left hand side of the operation is the content of the volume. The right hand side is one of the available solids. The reme_set_operation_t defines the operation to apply. The result of the operation is an updated volume content.

Enumerator
REME_SET_UNION 

Joins two or more solids into creating one based on the total geometry of all.

REME_SET_SUBTRACTION 

Subtracts one or more solids from another creating a solid based on the remaining geometry.

REME_SET_INTERSECTION 

Creates a single solid from one more solids based on the intersected geometry.

Function Documentation

◆ reme_csg_create()

reme_error_t reme_csg_create ( reme_context_t  c,
reme_volume_t  v,
reme_csg_t csg 
)

Create a new CSG module for performing boolean set operations.

Parameters
cA valid context object
vA valid volume object to work on
csgA pointer to receive the created CSG object handle.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, example_reconstructmesdk_csg.cpp, and example_reconstructmesdk_marker.cpp.

◆ reme_csg_destroy()

reme_error_t reme_csg_destroy ( reme_context_t  c,
reme_csg_t csg 
)

Destroy a previously created CSG object.

Parameters
cA pointer to a valid context object
csgA mutable pointer to a valid CSG handle to destroy
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure

◆ reme_csg_update_with_spheres()

reme_error_t reme_csg_update_with_spheres ( reme_context_t  c,
reme_csg_t  csg,
reme_set_operation_t  op,
const float *  spheres,
int  numspheres 
)

Perform boolean set operation on the volume and one or more spheres.

Update the content of the volume by applying a boolean set operation with one ore more spheres. Each sphere is represented by four coordinates: its center (cx, cy, cz) and its radius (r). The spheres are are assumed to be stored in a single consecutive array in the following format cx cy cz r cx cy cz r ... .

Parameters
cA valid context object.
csgA valid CSG object.
opSet operation to apply.
spheresSphere data array.
numspheresNumber of spheres in array.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_csg.cpp.

◆ reme_csg_update_with_boxes()

reme_error_t reme_csg_update_with_boxes ( reme_context_t  c,
reme_csg_t  csg,
reme_set_operation_t  op,
const float *  boxes,
int  numboxes 
)

Perform boolean set operation on the volume and one or more boxes.

Update the content of the volume by applying a boolean set operation with one ore more axis aligned boxes. Each box is represented by six coordinates: its minimum corner (minx, miny, minz) and maximum corner (maxx, maxy, maxz). The boxes are are assumed to be stored in a single consecutive array in the following format minx miny minz maxx maxy maxz minx miny minz maxx maxy maxz ... .

Parameters
cA valid context object.
csgA valid CSG object.
opSet operation to apply.
boxesBox data array.
numboxesNumber of boxes in array.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_csg.cpp.

◆ reme_csg_update_with_planes()

reme_error_t reme_csg_update_with_planes ( reme_context_t  c,
reme_csg_t  csg,
reme_set_operation_t  op,
const float *  planes,
int  numplanes 
)

Perform boolean set operation on the volume and one or more planes.

Update the content of the volume by applying a boolean set operation with one ore more planes. Each plane is represented in Hessian normal form using four coordinates: its unit-length normal vector (nx, ny, nz) and its signed distance from the origin (d). The planes are are assumed to be stored in a single consecutive array in the following format nx ny nz d nx ny nz d ... .

Parameters
cA valid context object.
csgA valid CSG object.
opSet operation to apply.
planesPlane data array.
numplanesNumber of planes in array.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, and example_reconstructmesdk_marker.cpp.

◆ reme_csg_update_with_surface()

reme_error_t reme_csg_update_with_surface ( reme_context_t  c,
reme_csg_t  csg,
reme_set_operation_t  op,
reme_surface_t  s 
)

Perform boolean set operation on the volume and a freeform solid mesh.

Update the content of the volume by applying a boolean set operation with a freeform solid mesh. The surface needs to be a closed manifold triangular mesh.

Parameters
cA valid context object.
csgA valid CSG object.
opSet operation to apply.
sA valid surface handle.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, and example_reconstructmesdk_marker.cpp.

◆ reme_csg_close_volume_borders()

reme_error_t reme_csg_close_volume_borders ( reme_context_t  c,
reme_csg_t  csg 
)

Make sure that volume borders are closed.

Due to the way the surface is extracted from the reconstruction volume, objects sticking out of the volume might not be closed. This method will ensure that all unclosed objects are filled watertight on volume borders through a planar solid.

Parameters
cA valid context object.
csgA valid CSG object.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_bust.cpp, and example_reconstructmesdk_marker.cpp.