DAVID4 SDK
1.8.7
|
Implements interface functions of IShapeFusion using DAVID Low Level Library. More...
#include <ShapeFusionD4Lib.h>
Public Member Functions | |
(De-)Construction | |
ShapeFusionD4Lib () | |
Constructor. | |
virtual | ~ShapeFusionD4Lib () |
Destructor. | |
Interface functions from IShapeFusion | |
virtual void | ExportMesh (int meshID, const std::string &filename) |
Exports the selected mesh. More... | |
virtual int | ImportMesh (const std::string &filename) |
Imports a mesh into the mesh list from a file given by 'filename'. More... | |
virtual int | NewMesh () |
Create a new empty mesh. More... | |
virtual int | DuplicateMesh (int sourceMeshID) |
Duplicate mesh with mesh ID 'sourceMeshID'. More... | |
virtual void | DeleteAllMeshes () |
Deletes all meshes in the mesh list. | |
virtual void | DeleteMesh (int meshID) |
Deletes a specific mesh of the mesh list. More... | |
virtual void | GetVertexPositions (std::vector< float > &positions, int meshID, enum CoordinateSystem coordinateSystem=WorldCoordinates) |
Gets the vertex positions of a specific mesh. More... | |
virtual void | GetVertexQualities (std::vector< float > &qualities, int meshID) |
Gets the vertex qualities [0..1] of a specific mesh. More... | |
virtual void | GetVertexNormals (std::vector< float > &normals, int meshID, enum CoordinateSystem coordinateSystem=WorldCoordinates) |
Gets the vertex normals of a specific mesh. More... | |
virtual void | GetVertexTexCoords (std::vector< float > &texCoords, int meshID) |
Gets the vertex texture coordinates (u,v) of a specific mesh. More... | |
virtual void | GetTriangles (std::vector< int > &triangles, int meshID) |
Gets the triangles of a specific mesh as an indexed face set. More... | |
virtual void | GetTextureImageData (void *data, size_t dataSizeInBytes, int meshID, int submeshIndex=0) |
Get the texture image of a mesh as binary data. More... | |
virtual bool | GetTextureImageFormat (int &width, int &height, enum PixelFormat &pixelFormat, int meshID, int submeshIndex=0) |
Get the format of the texture image. More... | |
virtual void | SetTexture (const void *data, size_t dataSizeInBytes, int width, int height, enum PixelFormat pixelFormat, int meshID, int submeshIndex=0) |
Set texture of a mesh. More... | |
virtual void | GetPose (double world_T_local[16], int meshID) |
Get the position and orientation of a mesh as a homogeneous transformation matrix. More... | |
virtual void | SetPose (const double world_T_local[16], int meshID) |
Set the position and orientation of a mesh as a homogeneous transformation matrix. More... | |
virtual void | Rotate (int meshID, enum TransformType transformType, double degrees) |
Rotate a mesh around specified axis by given degrees. More... | |
virtual void | Translate (int meshID, enum TransformType transformType, double amount) |
Translate a mesh along specified axis by given amount. More... | |
virtual void | ReduceMeshDensity (int meshID, float factor) |
Reduce the density of a mesh. More... | |
virtual void | RemoveVerticesByVirtualCamMask (const std::vector< bool > &mask, int width, int height, double f, const double world_T_cam[16]) |
Remove any vertex i that when projected into a virtual camera view has a mask value of 'mask[i]==true'. More... | |
virtual void | RemoveSelectedVertices (const std::vector< SubmeshVertexIndex > &selectedVertices, int meshID) |
Remove selected vertices. More... | |
virtual void | InvertTriangleOrientation (int meshID) |
Invert orientation of all triangles in given mesh. More... | |
virtual double | AlignPairCoarse (int meshID1, int meshID2, const CoarseAlignParams ¶ms) |
Coarse alignment of mesh '1' to another mesh '2'. More... | |
virtual void | AlignPairFine (int meshID1, int meshID2, const FineAlignParams ¶ms) |
Fine alignment of mesh '1' to another mesh '2'. More... | |
virtual void | AlignGlobalFine (const GlobalFineAlignParams ¶ms) |
Global fine alignment of all meshes. More... | |
virtual int | Fuse (int resolution, float holeSizeThresRel=1.f, int sharpness=1) |
Fuse all visible meshes of the mesh list. More... | |
virtual int | GetFuseResolution (double metricResolution, int maxResolution) |
Converts a metric resolution value into a resolution value required by Fuse. More... | |
virtual int | CombineMeshes (const std::vector< int > &meshIDs) |
Combines several meshes into one group. More... | |
virtual std::vector< int > | UncombineMeshes (int meshIDgroup) |
Uncombines a group of meshes into separate meshes. More... | |
virtual int | GetSubmeshCount (int meshID) |
Get the number of submeshes (combined meshes) in 'mesh'. More... | |
virtual void | SetSubmeshCount (int count, int meshID) |
Set the number of submeshes (combined meshes) in 'mesh'. More... | |
virtual void | GetSubmeshBuffer (void *data, size_t size, enum SubmeshBufferType bufferType, int meshID, int submeshIndex) |
Copy requested buffer ('bufferType') content into 'data'. More... | |
virtual void | SetSubmeshBuffer (const void *data, size_t size, enum SubmeshBufferType bufferType, int meshID, int submeshIndex) |
Copy 'data' into the desired buffer ('bufferType'). More... | |
virtual bool | HasSubmeshBuffer (enum SubmeshBufferType bufferType, int meshID, int submeshIndex) |
Is the buffer 'bufferType' available? See SubmeshBufferType for information about which buffers are optional. More... | |
virtual size_t | GetSubmeshBufferSize (enum SubmeshBufferType bufferType, int meshID, int submeshIndex) |
Get size of buffer 'bufferType' in bytes. More... | |
virtual int | GetSubmeshVertexCount (int meshID, int submeshIndex) |
Get the number of vertices in submesh. More... | |
virtual void | SetSubmeshVertexCount (int vertexCount, int meshID, int submeshIndex) |
Set the number of vertices in submesh. More... | |
virtual int | GetSubmeshTriangleCount (int meshID, int submeshIndex) |
Get the number of triangles in submesh. More... | |
virtual void | SetSubmeshTriangleCount (int triangleCount, int meshID, int submeshIndex) |
Set the number of triangles in submesh. More... | |
Special functions | |
int | AddToList (std::shared_ptr< d4mesh > mesh) |
Add a new mesh to the list of scans. More... | |
void | Translate (int meshID, double dx, double dy, double dz, enum CoordinateSystem coordinateSystem) |
Translate (move) mesh into direction (dx, dy, dz) with respect to choosen coordinate system. More... | |
![]() | |
virtual | ~IShapeFusion () |
Destructor. | |
Protected Types | |
typedef std::recursive_mutex | Mutex |
Used mutex. | |
typedef std::lock_guard < std::recursive_mutex > | Guard |
Guard for automatic unlocking. | |
typedef std::map< int, std::shared_ptr< d4mesh > > | Scanlist |
Scans are stored with an associated ID. | |
Protected Member Functions | |
int | CheckMeshID (int meshID) |
Check mesh ID. More... | |
std::shared_ptr< d4mesh > & | GetMesh (int meshID) |
Get mesh by 'meshID'. More... | |
void | Helper_AlignPairCoarse_ConvertContactVertices (std::vector< int > &contactVertices, int meshID, const std::vector< SubmeshVertexIndex > &svi) |
Helper function which converts vertex indices from "indices per submesh" (SubmeshVertexIndex) to "total indices" over all submeshes. | |
Protected Attributes | |
Scanlist | m_scanlist |
List of scans. | |
std::shared_ptr< d4mesh > | m_fusionResult |
Mesh for fusion result. | |
Mutex | m_mutex |
Used for synchronization. | |
Implements interface functions of IShapeFusion using DAVID Low Level Library.
Definition at line 24 of file ShapeFusionD4Lib.h.
int david::ShapeFusionD4Lib::AddToList | ( | std::shared_ptr< d4mesh > | mesh) |
Add a new mesh to the list of scans.
[in,out] | mesh | Valid handle to mesh. The mesh is stored directly, no copy. |
|
virtual |
Global fine alignment of all meshes.
[in] | params | Alignment parameter set. See GlobalFineAlignParams. |
Implements david::IShapeFusion.
|
virtual |
Coarse alignment of mesh '1' to another mesh '2'.
[in] | meshID1 | ID of the mesh that is to be aligned. |
[in] | meshID2 | ID of the other mesh. |
[in] | params | Alignment parameter set. See CoarseAlignParams. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_AlignFailed | (david::FunctionException) Alignment could not find a solution. |
Implements david::IShapeFusion.
|
virtual |
Fine alignment of mesh '1' to another mesh '2'.
[in] | meshID1 | ID of the mesh that is to be aligned. |
[in] | meshID2 | ID of the other mesh. |
[in] | params | Alignment parameter set. See FineAlignParams. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_AlignFailed | (david::FunctionException) Alignment could not find a solution. |
Implements david::IShapeFusion.
|
protected |
|
virtual |
Combines several meshes into one group.
[in] | meshIDs | List of the IDs of the meshes to be combined. |
Implements david::IShapeFusion.
|
virtual |
Deletes a specific mesh of the mesh list.
[in] | meshID | ID of the mesh to be deleted. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
Implements david::IShapeFusion.
|
virtual |
Duplicate mesh with mesh ID 'sourceMeshID'.
[in] | sourceMeshID | ID of the mesh to be duplicated. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
Implements david::IShapeFusion.
|
virtual |
Exports the selected mesh.
See documentation of DAVID software for supported file formats.
[in] | meshID | ID of the mesh. |
[in] | filename | Filename of the mesh to be exported. |
david::Error_NoAccess | (david::FunctionException) No access to path. |
david::Error_InvalidPath | (david::FunctionException) Specified path is invalid. |
david::Error_MissingFilename | (david::FunctionException) Specified path misses file name. |
david::Error_DirectoryNotFound | (david::FunctionException) Specified directory does not exist. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
Implements david::IShapeFusion.
|
virtual |
Fuse all visible meshes of the mesh list.
[in] | resolution | Limits the maximum resolution and thus the required memory usage. |
holeSizeThresRel | Holes, which have a smaller area than holeSizeThresRel * size of original data surface, will be closed. 0 = open all holes. 1 = close all holes. | |
[in] | sharpness | Fusion sharpness in [-3,+5]. Negative values for smoothing. Default is 1. |
Implements david::IShapeFusion.
|
virtual |
Converts a metric resolution value into a resolution value required by Fuse.
It uses the maximum bounding box length of all meshes to be fused.
[in] | metricResolution | Smallest possible element size in units (e.g. 0.1 [mm]). |
[in] | maxResolution | Returned value is bounded by this value (e.g. 2000). |
Implements david::IShapeFusion.
|
protected |
Get mesh by 'meshID'.
[in] | meshID | Valid ID of the mesh. Use 0 for fusion result. |
|
virtual |
Get the position and orientation of a mesh as a homogeneous transformation matrix.
[out] | world_T_local | Valid pointer to an array of 16 doubles representing a homogeneous transformation matrix that transforms local coordinates into world coordinates: p_world = world_T_local * p_local. Values will be stored in the following order: nx, ny, nz, 0, ox, oy, oz, 0, ax, ay, az, 0, px, py, pz, 1. |
[in] | meshID | ID of the mesh. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
Implements david::IShapeFusion.
|
virtual |
Copy requested buffer ('bufferType') content into 'data'.
You can use GetSubmeshVertexCount, GetSubmeshTriangleCount, and GetSubmeshBufferSize to compute the correct size of 'data'. Coordinates are given with respect to local coordinate system.
[out] | data | Valid pointer to data buffer. |
[in] | size | Size of 'data' buffer in bytes. |
[in] | bufferType | Desired data buffer, see SubmeshBufferType. |
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Get size of buffer 'bufferType' in bytes.
[in] | bufferType | Desired data buffer, see SubmeshBufferType. |
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Get the number of submeshes (combined meshes) in 'mesh'.
A mesh has at least one submesh. This is also the standard case unless CombineMeshes was used.
[in] | meshID | Valid mesh ID. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Get the number of triangles in submesh.
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Get the number of vertices in submesh.
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Get the texture image of a mesh as binary data.
Each pixel is represented according to the pixel format in GetTextureImageFormat. The pixels are ordered row by row, from top to bottom, each row from left to right.
Usage example for pixelFormat == david::RGB24:
[out] | data | Valid pointer to an array that will be filled with the pixel data. |
[in] | dataSizeInBytes | Size of 'data' in bytes. Has to be in compliance with GetTextureImageFormat. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
[in] | meshID | ID of the mesh. |
Implements david::IShapeFusion.
|
virtual |
Get the format of the texture image.
[out] | width | Width of the image in [px] |
[out] | height | Height of the image in [px] |
[out] | pixelFormat | See PixelFormat. Will be david::UnknownPixelFormat, if no texture is set. |
[in] | meshID | ID of the mesh. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
Implements david::IShapeFusion.
|
virtual |
Gets the triangles of a specific mesh as an indexed face set.
Each triangle is defined by a triple of vertex indices (a,b,c).
[out] | triangles | For each triangle int triples are written to this array. (a1,b1,c1,...,an,bn,cn). |
[in] | meshID | ID of the mesh. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InconsistentBuffer | (david::FunctionException) Buffer size differs from expected buffer size. |
Implements david::IShapeFusion.
|
virtual |
Gets the vertex normals of a specific mesh.
[out] | normals | For each vertex float triples are written to this array. (x1,y1,z1,...,xn,yn,zn). |
[in] | meshID | ID of the mesh. |
[in] | coordinateSystem | 'normals' should be relative to which coordinate system? See CoordinateSystem. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InconsistentBuffer | (david::FunctionException) Buffer size differs from expected buffer size. |
Implements david::IShapeFusion.
|
virtual |
Gets the vertex positions of a specific mesh.
[out] | positions | For each vertex float triples are written to this array. (x1,y1,z1,...,xn,yn,zn). |
[in] | meshID | ID of the mesh. |
[in] | coordinateSystem | 'positions' should be relative to which coordinate system? See CoordinateSystem. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InconsistentBuffer | (david::FunctionException) Buffer size differs from expected buffer size. |
Implements david::IShapeFusion.
|
virtual |
Gets the vertex qualities [0..1] of a specific mesh.
Vertex qualities are not always available. At this time, only a Fusion result has vertex qualities.
[out] | qualities | For each vertex, a float value [0..1] is written to this array |
[in] | meshID | ID of the mesh. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_MissingObject | (david::FunctionException) Mesh does not have vertex qualities. |
david::Error_InconsistentBuffer | (david::FunctionException) Buffer size differs from expected buffer size. |
Implements david::IShapeFusion.
|
virtual |
Gets the vertex texture coordinates (u,v) of a specific mesh.
All texture coords are in [0,1].
[out] | texCoords | For each vertex, a pair of floats is written to this array. (u1,v1, u2,v2, ..., un,vn). |
[in] | meshID | ID of the mesh. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InconsistentBuffer | (david::FunctionException) Buffer size differs from expected buffer size. |
Implements david::IShapeFusion.
|
virtual |
Is the buffer 'bufferType' available? See SubmeshBufferType for information about which buffers are optional.
[in] | bufferType | Desired data buffer, see d4mesh_BufferType. |
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Imports a mesh into the mesh list from a file given by 'filename'.
See documentation of DAVID software for supported file formats.
[in] | filename | Filename of the mesh to be imported. |
david::Error_NoAccess | (david::FunctionException) No access to path. |
david::Error_InvalidPath | (david::FunctionException) Specified path is invalid. |
david::Error_MissingFilename | (david::FunctionException) Specified path misses file name. |
david::Error_DirectoryNotFound | (david::FunctionException) Specified directory does not exist. |
david::Error_FileNotFound | (david::FunctionException) Specified file does not exist. |
Implements david::IShapeFusion.
|
virtual |
Invert orientation of all triangles in given mesh.
[in] | meshID | ID of mesh to be transformed. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
Implements david::IShapeFusion.
|
virtual |
|
virtual |
Reduce the density of a mesh.
[in] | meshID | ID of mesh to be transformed. |
[in] | factor | Factor of reduction, between 0 and 1. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InvalidArgument | (david::FunctionException) Invalid factor value. |
Implements david::IShapeFusion.
|
virtual |
Remove selected vertices.
[in] | selectedVertices | Index array of selected vertices. |
[in] | meshID | ID of mesh that 'selectedVertices' references. |
david::Error_InvalidArgument | (david::FunctionException) At least one of the arguments is invalid. |
Implements david::IShapeFusion.
|
virtual |
Remove any vertex i that when projected into a virtual camera view has a mask value of 'mask[i]==true'.
Vertices outside view or with a mask value fo 'mask[i]==false' are not removed. If a vertex is removed, its referenced triangles are also removed. The virtual camera is described by a perspective camera model:
[in] | mask | Valid pointer to an boolean array of size 'width*height'. True: Vertex should be removed. False: Keep vertex. |
[in] | width | Width of the mask image [pixel]. Has to be > 0. |
[in] | height | Height of the mask image [pixel]. Has to be > 0. |
[in] | f | Focal length (distance of image plane to origin camera coordinate system). |
[in] | world_T_cam | Position and orientation (pose) of the camera with respect to world coordinates. The pose is represented as a homogenenous transformation matrix. See d4mesh_getPose for more information. |
david::Error_InvalidArgument | (david::FunctionException) At least one of the arguments is invalid. |
Implements david::IShapeFusion.
|
virtual |
Rotate a mesh around specified axis by given degrees.
[in] | meshID | ID of mesh to be transformed. |
[in] | transformType | Type of transform. See david::TransformType. |
[in] | degrees | Amount of rotation in degrees. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InvalidArgument | (david::FunctionException) Invalid transform type. |
Implements david::IShapeFusion.
|
virtual |
Set the position and orientation of a mesh as a homogeneous transformation matrix.
[out] | world_T_local | Valid pointer to an array of 16 doubles representing a homogeneous transformation matrix that transforms local coordinates into world coordinates: p_world = world_T_local * p_local. Values will be stored in the following order: nx, ny, nz, 0, ox, oy, oz, 0, ax, ay, az, 0, px, py, pz, 1. |
[in] | meshID | ID of the mesh. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
Implements david::IShapeFusion.
|
virtual |
Copy 'data' into the desired buffer ('bufferType').
You can use GetSubmeshVertexCount, GetSubmeshTriangleCount, and GetSubmeshBufferSize to compute the correct size of 'data'. Coordinates have to be given with respect to local coordinate system.
[in] | data | Valid pointer to data buffer. |
[in] | size | Size of 'data' buffer in bytes. |
[in] | bufferType | Desired data buffer, see d4mesh_BufferType. |
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Set the number of submeshes (combined meshes) in 'mesh'.
A mesh has at least one submesh. This is also the standard case unless CombineMeshes was used.
[in] | count | New number of submeshes (>0). |
[in] | meshID | Valid mesh ID. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Set the number of triangles in submesh.
[in] | triangleCount | New number of triangles in submesh. |
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
david::Error_InvalidArgument | (david::FunctionException) |
Implements david::IShapeFusion.
|
virtual |
Set the number of vertices in submesh.
[in] | vertexCount | New number of vertices in submesh. Old data remains in buffers, if 'vertexCount' increases. |
[in] | meshID | Valid mesh ID. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
Implements david::IShapeFusion.
|
virtual |
Set texture of a mesh.
[in] | data | Valid pointer to an array of pixel data. |
[in] | dataSizeInBytes | Size of 'data' in bytes. Has to be in compliance with given texture format. |
[in] | width | Width of the image in [px] |
[in] | height | Height of the image in [px] |
[in] | pixelFormat | See PixelFormat. Will be david::UnknownPixelFormat, if no texture is set. |
[in] | meshID | ID of the mesh. |
[in] | submeshIndex | Zero based index to a submesh of 'mesh'. Also see GetSubmeshCount. |
Implements david::IShapeFusion.
|
virtual |
Translate a mesh along specified axis by given amount.
[in] | meshID | ID of mesh to be transformed. |
[in] | transformType | Type of transform. See david::TransformType. |
[in] | amount | Amount of translation. Typically in mm. |
david::Error_InvalidMeshId | (david::FunctionException) Specified meshID does not exist. |
david::Error_InvalidArgument | (david::FunctionException) Invalid transform type. |
Implements david::IShapeFusion.
void david::ShapeFusionD4Lib::Translate | ( | int | meshID, |
double | dx, | ||
double | dy, | ||
double | dz, | ||
enum CoordinateSystem | coordinateSystem | ||
) |
Translate (move) mesh into direction (dx, dy, dz) with respect to choosen coordinate system.
[in] | meshID | Valid mesh ID. |
[in] | dx | Amount of translation in x direction. |
[in] | dy | Amount of translation in y direction. |
[in] | dz | Amount of translation in z direction. |
[in] | coordinateSystem | See CoordinateSystem. |
|
virtual |
Uncombines a group of meshes into separate meshes.
[in] | meshIDgroup | Mesh ID of the mesh group to be separated. |
Implements david::IShapeFusion.