ReconstructMe SDK  1.5.795-79862
Real-time 3D reconstruction engine
 All Classes Files Functions Typedefs Enumerations Enumerator Groups Pages
Typedefs
Surface

Compute a 3D triangle mesh from content of the reconstruction volume. More...

Typedefs

typedef int reme_surface_t
 Handle referencing a surface object.
 
reme_error_t reme_surface_create (reme_context_t c, reme_surface_t *s)
 Create a new surface object.
 
reme_error_t reme_surface_destroy (reme_context_t c, reme_surface_t *s)
 Destroy a previously created surface object.
 
reme_error_t reme_surface_bind_generation_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the surface generation options.
 
reme_error_t reme_surface_bind_poisson_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the poisson reconstruction options.
 
reme_error_t reme_surface_bind_decimation_options (reme_context_t c, reme_surface_t s, reme_options_t o)
 Access the surface decimation options.
 
reme_error_t reme_surface_generate (reme_context_t c, reme_surface_t s, reme_volume_t v)
 Extract the iso-surface from the given volume.
 
reme_error_t reme_surface_poisson (reme_context_t c, reme_surface_t s)
 Perform poisson reconstruction on the extracted surface.
 
reme_error_t reme_surface_decimate (reme_context_t c, reme_surface_t s)
 Decimate the extracted surface.
 
reme_error_t reme_surface_transform (reme_context_t c, reme_surface_t s, const float *coordinates)
 Transform the surface.
 
reme_error_t reme_surface_get_points (reme_context_t c, reme_surface_t s, const float **coordinates, int *length)
 Get points of a surface.
 
reme_error_t reme_surface_get_normals (reme_context_t c, reme_surface_t s, const float **coordinates, int *length)
 Get point normals of a surface.
 
reme_error_t reme_surface_get_triangles (reme_context_t c, reme_surface_t s, const unsigned int **indices, int *length)
 Get triangle faces of a surface.
 
reme_error_t reme_surface_save_to_file (reme_context_t c, reme_surface_t s, const char *filename)
 Export the surface to file.
 

Detailed Description

Compute a 3D triangle mesh from content of the reconstruction volume.

This modules provides methods to generate triangle meshes from reconstruction volumes. Besides basic surface extraction, hole closing and decimation functionality is provided.

The example below illustrates the functionality.

// Create a new empty surface
// We use an options object to control various aspects of the generation process
// Bind the options that define how the basic surface is extracted from the volume.
// We disable merging of close vertices at this stage because the data is directly
// passed into poisson reconstruction which deals with duplicate vertices anyway
reme_options_set_bool(c, o, "merge_duplicate_vertices", false);
// Extract surface from volume.
// Close holes through Poisson reconstruction
reme_options_set_int(c, o, "depth", 8);
// Reduce mesh down to 20k triangles
reme_options_set_int(c, o, "maximum_faces", 20000);
// View the result and wait until the user closes the viewer
reme_viewer_t viewer;
reme_viewer_create_surface(c, m, "This is ReconstructMeSDK", &viewer);
reme_viewer_wait(c, viewer);
// Transform the mesh from world space to CAD space, so external viewers
// can cope better with the result.
float mat[16];
// Export mesh
reme_surface_save_to_file(c, m, "test.ply");

Typedef Documentation

typedef int reme_surface_t

Handle referencing a surface object.

A reme_surface_t represents a 3D mesh surface extracted from a volume. Its associated methods allow to influence the generation process, access mesh data and save volumes using our exporters.

Function Documentation

reme_error_t reme_surface_create ( reme_context_t  c,
reme_surface_t s 
)

Create a new surface object.

Parameters
cA valid context object
sA pointer that will receive the handle of the created surface
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_options_type_safe.cpp, example_reconstructmesdk_point_and_shoot.cpp, example_reconstructmesdk_sensor_printing.cpp, and example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_destroy ( reme_context_t  c,
reme_surface_t s 
)

Destroy a previously created surface object.

Parameters
cA pointer to a valid context object
sA mutable pointer to a valid surface handle to destroy
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_point_and_shoot.cpp, and example_reconstructmesdk_sensor_printing.cpp.
reme_error_t reme_surface_bind_generation_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the surface generation options.

Associated Protocol Buffers Specification
// Surface generation from reconstruction volume
message generation_options {
// When enabled duplicate vertices within a certain radius are merged towards a single vertex.
optional bool merge_duplicate_vertices = 1 [default = true];
// Defines merge radius. Larger values will perform a simple decimation
optional float merge_radius = 2 [default = 0.1];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_bind_poisson_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the poisson reconstruction options.

Associated Protocol Buffers Specification
// Poisson surface generation options
message poisson_options {
optional int32 depth = 1 [default = 8];
optional int32 solver_divide = 2 [default = 8];
optional int32 iso_divide = 3 [default = 8];
optional int32 minimum_samples_per_node = 4 [default = 1];
optional float scale = 5 [default = 1.25];
optional bool enable_manifold = 6 [default = true];
optional int32 minimum_depth = 7 [default = 5];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_options_type_safe.cpp, and example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_bind_decimation_options ( reme_context_t  c,
reme_surface_t  s,
reme_options_t  o 
)

Access the surface decimation options.

Associated Protocol Buffers Specification
// Mesh decimation options
message decimation_options {
// Decimate to target complexity.
// Range: 0..inf
optional int32 maximum_faces = 1 [default = 100000];
// Maximum quadric error to accept per collapse. The quadric error is similar
// to the Hausdorff Distance.
// Range: 0..inf
optional float maximum_quadric_error = 2 [default = 100000];
// Minimum triangle roundness. Normalized triangle roundness with respect to
// equiliteral triangle shape.
// Range: 0..1
optional float minimum_triangle_roundness = 3 [default = 0];
// Maximum normal angle error in degrees.
// Range: 0..180
optional float maximum_angle_error = 4 [default = 90];
// Preserve the boundary of the mesh.
optional bool preserve_boundary = 5 [default = false];
}
Parameters
cA valid context object
sA valid surface object
oA valid options binding object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_generate ( reme_context_t  c,
reme_surface_t  s,
reme_volume_t  v 
)

Extract the iso-surface from the given volume.

The surface is generated with respect to the world coordinate system.

In case you are using an unlicensed version of ReconstructMe SDK, this function blocks for at least 15 seconds. Without this limitation the mesh is usually generated in under a second.

Parameters
cA valid context object
sA valid surface object
vA valid volume object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_point_and_shoot.cpp, example_reconstructmesdk_sensor_printing.cpp, and example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_poisson ( reme_context_t  c,
reme_surface_t  s 
)

Perform poisson reconstruction on the extracted surface.

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_decimate ( reme_context_t  c,
reme_surface_t  s 
)

Decimate the extracted surface.

Parameters
cA valid context object
sA valid surface object
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_transform ( reme_context_t  c,
reme_surface_t  s,
const float *  coordinates 
)

Transform the surface.

This will transform the points and normals of the surface.

Parameters
cA valid context object
sA valid surface object
coordinatesA pointer to constant Transform data.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_surface.cpp.
reme_error_t reme_surface_get_points ( reme_context_t  c,
reme_surface_t  s,
const float **  coordinates,
int *  length 
)

Get points of a surface.

The surface points are represented as an array of floats where each point consists of 4 coordinates Px Py Pz Pw Px Py Pz Pw ... . The w component is always zero.

Note the i-th point starts at index i * 4 of coordinate array returned.

Memory Management Rules Exception

The returned coordinates pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
coordinatesA mutable pointer to constant point data.
lengthThe number of coordinates returned. To get the number of points divide this value by 4.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
reme_error_t reme_surface_get_normals ( reme_context_t  c,
reme_surface_t  s,
const float **  coordinates,
int *  length 
)

Get point normals of a surface.

The surface point normals are represented as an array of floats where each point consists of 4 coordinates Px Py Pz Pw Px Py Pz Pw ... . The w component is always zero.

Note the i-th point normal starts at index i * 4 of coordinate array returned.

Memory Management Rules Exception

The returned coordinates pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
coordinatesA mutable pointer to constant point normal data.
lengthThe number of coordinates returned. To get the number of point normals divide this value by 4.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
reme_error_t reme_surface_get_triangles ( reme_context_t  c,
reme_surface_t  s,
const unsigned int **  indices,
int *  length 
)

Get triangle faces of a surface.

The triangle faces are represented as an array of unsigned integers (point indice s) where each triangle consists of 3 indices that represent that points that make up each face P0 P1 P2 P0 P1 P2 ... .

Note the i-th triangle starts at index i * 3 of index array returned.

Memory Management Rules Exception

The returned indices pointer remains valid until the mesh changes.

Parameters
cA valid context object
sA valid surface object
indicesA mutable pointer to constant triangle index data.
lengthThe number of indices returned. To get the number of triangles divide this value by 3.
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
reme_error_t reme_surface_save_to_file ( reme_context_t  c,
reme_surface_t  s,
const char *  filename 
)

Export the surface to file.

The exporter is chosen based on the file extension. Currently supported are

  • .PLY - Polygon File Format
  • .STL - StereoLithography
  • .OBJ - Wavefront
  • .3DS - 3D Studio Max
Parameters
cA valid context object
sA valid surface object
filenameFilename to save mesh as
Return values
REME_ERROR_SUCCESSOn success
REME_ERROR_UNSPECIFIEDOn failure
Examples:
example_reconstructmesdk_one_minute.cpp, example_reconstructmesdk_point_and_shoot.cpp, example_reconstructmesdk_sensor_printing.cpp, and example_reconstructmesdk_surface.cpp.