DAVID4 SDK  1.8.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
IShapeFusion.h
1 //=============================================================================
2 // See License in Related Pages
3 //=============================================================================
4 
5 #pragma once
6 
7 #ifndef DAVID_SDK_I_SHAPE_FUSION_H
8 #define DAVID_SDK_I_SHAPE_FUSION_H
9 
10 #include "davidSDK/Common.h"
11 #include <vector>
12 #include <limits>
13 
14 namespace david {
15 
16 //*****************************************************************************
17 /// @addtogroup InterfaceGroup
18 /// @{
19 /// @defgroup ShapeFusionGroup Shape Fusion
20 /// Provides functions and types related 'Shape Fusion'.
21 /// @{
22 //*****************************************************************************
23 
24 //=============================================================================
25 // TransformType
26 //=============================================================================
27 
28 /// Defines transform types used by ShapeFusion::Translate and ShapeFusion::Rotate.
30 {
31  TransformGlobalX = 0, ///< Transform around or along global (world) x axis.
32  TransformGlobalY, ///< Transform around or along global (world) y axis.
33  TransformGlobalZ, ///< Transform around or along global (world) z axis.
34  TransformMeshX, ///< Transform around or along mesh's x axis.
35  TransformMeshY, ///< Transform around or along mesh's y axis.
36  TransformMeshZ, ///< Transform around or along mesh's z axis.
37 };
38 
39 
40 //=============================================================================
41 // CoordinateSystem
42 //=============================================================================
43 
44 /// Selection of coordinate system.
46 {
47  WorldCoordinates = 0, ///< Coordinates are given with respect to world (global coordinates).
48  LocalCoordinates, ///< Coordinates are given with respect to local object coordinate system.
49 };
50 
51 
52 //=============================================================================
53 // SubmeshBufferType
54 //=============================================================================
55 
56 /// Buffer selection.
58 {
59  /// The vertex position buffer stores the vertex positions as an array of tuples.
60  /// Each vertex position is described by a tuple (x,y,z) of three 32bit floats .
61  /// This buffer is always present.
62  /// @note Coordinates are always with respect to the local coordinate system of the mesh.
64 
65  /// The vertex normal buffer stores the vertex normals as an array of tuples.
66  /// Each vertex normal is described by a tuple (nx,ny,nz) of three 32bit floats.
67  /// This buffer is always present.
68  /// @note Coordinates are always with respect to the local coordinate system of the mesh.
70 
71  /// The texture coordinates buffer stores texture coordinates as an array of tuples.
72  /// Each vertex texture coordinate is described a tuple (u,v) of two 32bit floats.
73  /// This buffer is only optional.
74  /// @note Coordinates should be in range [0,1].
76 
77  /// The vertex color buffer stores vertex colors as an array of tuples.
78  /// Each vertex texture coordinate is described a RGBA tuple (red, green, blue, alpha) of four 8bit unsigned chars.
79  /// This buffer is only optional.
80  /// @note Coordinates should be in range [0,1].
82 
83  /// The triangle index buffer stores triangles as an array of vertex indices.
84  /// Each triangle is described by tuple (v0, v1, v2) of three 32bit integer vertex indices that are zero based.
85  /// This buffer is always present.
87 
88  /// The vertex quality buffer stores a quality value for each vertex.
89  /// This buffer is only optional.
90  /// @note Quality values should be in range [0,1].
92 };
93 
94 
95 //=============================================================================
96 /// @name Classes and functions related to MotionInfo.
97 /// @{
98 //=============================================================================
99 
100 /// Provides user knowledge about the motion between two scans.
101 /// In most cases the motion can be described by a simple rotation around an axis,
102 /// where the pitch along the (motion=rotation) axis is zero.
103 /// The following helper functions are available:
104 /// - david::GetMotionInfo_Free
105 /// - david::GetMotionInfo_OnTable
106 /// - david::GetMotionInfo_AngleOnly
107 /// - david::GetMotionInfo_TurntablePartlyCalibrated
109 {
110  bool angleKnown; ///< Is rotation 'angle' around motion axis known?.
111  bool axisDirKnown; ///< Is direction vector 'axisDir' of motion axis is known?
112  double angleDeg; ///< Angle of rotation in degrees.
113  double angleToleranceDeg; ///< Tolerance of angleDeg in degrees. Won't work well with too low tolerances; recommended: 2 deg.
114  double axisDir[3]; ///< 3D direction vector (x,y,z) of motion axis w.r.t. world coordinates.
115 
116  /// Standard constructor. Initializes with #GetMotionInfo_Free.
117  MotionInfo();
118 };
119 
120 
121 /// Nothing is known. All parameters are set to unknown.
122 /// @return MotionInfo
124 
125 /// Object was moved (translated and rotated) on a planar table without lifting it.
126 /// @param[in] axisDir 3D vector w.r.t. to world coordinates describing a vector orthogonal to the table plane.
127 /// @return MotionInfo
128 MotionInfo GetMotionInfo_OnTable(const double axisDir[3]);
129 
130 /// Only rotation angle is known. Axis is unknown.
131 /// @param[in] angleDeg Angle in degrees.
132 /// @param[in] angleToleranceDeg Tolerance of angleDeg in degrees. Won't work well with too low tolerances; recommended: >=2 deg.
133 /// @return MotionInfo
134 MotionInfo GetMotionInfo_AngleOnly(double angleDeg, double angleToleranceDeg=2.0);
135 
136 /// Object was rotated with the help of a turntable.
137 /// The direction of the rotation axis is known, but not the position of the rotation axis.
138 /// @param[in] angleDeg Angle in degrees.
139 /// @param[in] axisDir Direction vector of the turntable w.r.t. to world coordinates (orthogonal to the turntable surface plane).
140 /// @param[in] angleToleranceDeg Tolerance of angleDeg in degrees. Won't work well with too low tolerances; recommended: >=2 deg.
141 /// @return MotionInfo
142 MotionInfo GetMotionInfo_TurntablePartlyCalibrated(double angleDeg, const double axisDir[3], double angleToleranceDeg=2.0);
143 
144 
145 //=============================================================================
146 // Contact Regions for Alignment
147 //=============================================================================
148 /// Index to define a vertex in a submesh
150 {
151  int submeshIndex; ///< which submesh contains the vertex
152  int vertexIndex; ///< vertex index in that submesh
153 
154  SubmeshVertexIndex(); ///< Standard constructor. Initializes with indices with -1 = invalid
155  SubmeshVertexIndex(int submeshID, int vertexID); ///< Constructor that directly assigns values
156 };
157 
158 
159 /// A pair of contact regions, defined as lists of SubmeshVertexIndex
161 {
162  std::vector<SubmeshVertexIndex> vertexIndices1; ///< indices in 'mesh1', the mesh to be aligned/moved
163  std::vector<SubmeshVertexIndex> vertexIndices2; ///< indices in 'mesh2', the other/fixed mesh
164 };
165 
166 
167 /// A list of poses (given as 4*4 matrices) plus tolerance values for translation and rotation.
169 {
170  std::vector<double> poses; ///< List of poses, each a 4*4 matrix of doubles (column by column).
171  double toleranceTrans; ///< Translational tolerance [mm] of the poses (0 to deactivate).
172  double toleranceDeg; ///< Rotational tolerance [degree] of the poses (0 to deactivate).
173 
174  PosesWithTolerances(); ///< Standard constructor.
175 };
176 
177 
178 /// Parameter set for Coarse Alignment, see IShapeFusion::AlignPairCoarse.
180 {
181  MotionInfo motionInfo; ///< Additional information about motion between the two meshes. See MotionInfo for more details.
182  int texturePercentage; ///< Percentage of texture influence on alignment (0-99). Only used if value is higher than 0.
183  float qualityFactor; ///< 1 is recommended. Larger values like 5 or 10 may create better results for symmetric objects, but increase computation time. Lower values like 0.01 to 0.1 decrease computation time, but may result in wrong alignment results.
184 
185  ContactRegionPair contactRegionPair; ///< Pair of Contact Regions, one region on mesh '1' and one on mesh '2' which are to be in contact with the other mesh. Empty lists mean: Use entire mesh.
186 
187  PosesWithTolerances blacklist1; ///< Blacklist of (rough) poses that mesh1 may not be moved to (can be empty).
188  PosesWithTolerances whitelist1; ///< Whitelist of (rough) poses that mesh1 must be moved to (can be empty)
189 
190  /// Constructors:
192 };
193 
194 
195 /// Parameter set for Fine Alignment, see IShapeFusion::AlignPairFine.
197 {
198  int maxNumIterations; ///< Number of iterations to run maximally (recommended: 100)
199  int texturePercentage; ///< Percentage of texture influence on alignment. Only used if value is higher than 0.
200  double maxTranslation; ///< Maximum allowed drift[mm] of mesh center (0 = no limit). Alignment will stop when this limit is reached.
201  double maxRot_deg; ///< Maximum allowed rotation of mesh in degree (0 = no limit). Alignment will stop when this limit is reached.
202 
203  /// Constructors:
204  FineAlignParams(int maxNumIterations=100, int texturePercentage=0, double maxTranslation=0, double maxRot_deg=0);
205 };
206 
207 
208 /// Parameter set for Global Fine Alignment, see IShapeFusion::AlignGlobalFine.
210 {
211  int texturePercentage; ///< Percentage of texture influence on alignment. Only used if value is higher than 0.
212  int numIterations; ///< Number of iterations to run (recommended: 20)
213  double maxTranslation; ///< Maximum allowed drift[mm] of any mesh center (0 = no limit). Global Fine Alignment will not move any scan more than this.
214  double maxRot_deg; ///< Maximum allowed rotation of any mesh in degree (0 = no limit). Global Fine Alignment will not rotate any scan more than this.
215 
216  /// Constructors:
217  GlobalFineAlignParams(); ///< Standard constructor.
218 };
219 
220 /// @}
221 
222 //=============================================================================
223 // IShapeFusion
224 //=============================================================================
225 
226 /// Interface class for 'Shape Fusion'.
227 /// Example:
228 /// @include SimpleShapeFusion.cpp
230 {
231 public:
232  //-------------------------------------------------------------------------
233  /// @name Construction, import, export, deconstruction
234  /// @{
235  //-------------------------------------------------------------------------
236 
237  /// Destructor.
238  virtual ~IShapeFusion() {}
239 
240  /// Exports the selected mesh.
241  /// See documentation of DAVID software for supported file formats.
242  ///
243  /// @warning File paths like "c:\\meshes\\myobject.obj" are interpreted as files located on the server.
244  /// For files located on the client you have to use a shared network path like "\\\\mycomputer\\meshes\\myobject.obj".
245  ///
246  /// @param[in] meshID ID of the mesh.
247  /// @param[in] filename Filename of the mesh to be exported.
248  /// @exception david::Error_NoAccess (david::FunctionException) No access to path.
249  /// @exception david::Error_InvalidPath (david::FunctionException) Specified path is invalid.
250  /// @exception david::Error_MissingFilename (david::FunctionException) Specified path misses file name.
251  /// @exception david::Error_DirectoryNotFound (david::FunctionException) Specified directory does not exist.
252  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
253  virtual void ExportMesh(int meshID, const std::string& filename) = 0;
254 
255  /// Imports a mesh into the mesh list from a file given by 'filename'.
256  /// See documentation of DAVID software for supported file formats.
257  ///
258  /// @warning File paths like "c:\\meshes\\myobject.obj" are interpreted as files located on the server.
259  /// For files located on the client you have to use a shared network path like "\\\\mycomputer\\meshes\\myobject.obj".
260  ///
261  /// @param[in] filename Filename of the mesh to be imported.
262  /// @return ID of the imported mesh.
263  /// @exception david::Error_NoAccess (david::FunctionException) No access to path.
264  /// @exception david::Error_InvalidPath (david::FunctionException) Specified path is invalid.
265  /// @exception david::Error_MissingFilename (david::FunctionException) Specified path misses file name.
266  /// @exception david::Error_DirectoryNotFound (david::FunctionException) Specified directory does not exist.
267  /// @exception david::Error_FileNotFound (david::FunctionException) Specified file does not exist.
268  virtual int ImportMesh(const std::string& filename) = 0;
269 
270  /// Create a new empty mesh.
271  /// @return ID of the created mesh.
272  virtual int NewMesh() = 0;
273 
274  /// Duplicate mesh with mesh ID 'sourceMeshID'.
275  /// @param[in] sourceMeshID ID of the mesh to be duplicated.
276  /// @return ID of newly created mesh.
277  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
278  virtual int DuplicateMesh(int sourceMeshID) = 0;
279 
280  /// Deletes all meshes in the mesh list.
281  virtual void DeleteAllMeshes() = 0;
282 
283  /// Deletes a specific mesh of the mesh list.
284  /// @param[in] meshID ID of the mesh to be deleted.
285  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
286  virtual void DeleteMesh(int meshID) = 0;
287 
288  /// @}
289 
290  //-------------------------------------------------------------------------
291  /// @name High level access to vertices and triangles
292  /// @note These functions treat a mesh group with submeshes as single mesh to the user.
293  /// @{
294  //-------------------------------------------------------------------------
295 
296  /// Gets the vertex positions of a specific mesh.
297  /// @param[out] positions For each vertex float triples are written to this array. (x1,y1,z1,...,xn,yn,zn).
298  /// @param[in] meshID ID of the mesh.
299  /// @param[in] coordinateSystem 'positions' should be relative to which coordinate system? See CoordinateSystem.
300  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
301  /// @exception david::Error_InconsistentBuffer (david::FunctionException) Buffer size differs from expected buffer size.
302  virtual void GetVertexPositions(std::vector<float>& positions, int meshID, enum CoordinateSystem coordinateSystem = WorldCoordinates) = 0;
303 
304  /// Gets the vertex qualities [0..1] of a specific mesh.
305  /// Vertex qualities are not always available. At this time, only a Fusion result has vertex qualities.
306  /// @param[out] qualities For each vertex, a float value [0..1] is written to this array
307  /// @param[in] meshID ID of the mesh.
308  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
309  /// @exception david::Error_MissingObject (david::FunctionException) Mesh does not have vertex qualities.
310  /// @exception david::Error_InconsistentBuffer (david::FunctionException) Buffer size differs from expected buffer size.
311  virtual void GetVertexQualities(std::vector<float>& qualities, int meshID) = 0;
312 
313  /// Gets the vertex normals of a specific mesh.
314  /// @param[out] normals For each vertex float triples are written to this array. (x1,y1,z1,...,xn,yn,zn).
315  /// @param[in] meshID ID of the mesh.
316  /// @param[in] coordinateSystem 'normals' should be relative to which coordinate system? See CoordinateSystem.
317  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
318  /// @exception david::Error_InconsistentBuffer (david::FunctionException) Buffer size differs from expected buffer size.
319  virtual void GetVertexNormals(std::vector<float>& normals, int meshID, enum CoordinateSystem coordinateSystem = WorldCoordinates) = 0;
320 
321  /// Gets the vertex texture coordinates (u,v) of a specific mesh. All texture coords are in [0,1].
322  /// @param[out] texCoords For each vertex, a pair of floats is written to this array. (u1,v1, u2,v2, ..., un,vn).
323  /// @param[in] meshID ID of the mesh.
324  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
325  /// @exception david::Error_InconsistentBuffer (david::FunctionException) Buffer size differs from expected buffer size.
326  virtual void GetVertexTexCoords(std::vector<float>& texCoords, int meshID) = 0;
327 
328  /// Gets the triangles of a specific mesh as an indexed face set.
329  /// Each triangle is defined by a triple of vertex indices (a,b,c).
330  /// @param[out] triangles For each triangle int triples are written to this array. (a1,b1,c1,...,an,bn,cn).
331  /// @param[in] meshID ID of the mesh.
332  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
333  /// @exception david::Error_InconsistentBuffer (david::FunctionException) Buffer size differs from expected buffer size.
334  virtual void GetTriangles(std::vector<int>& triangles, int meshID) = 0;
335 
336  /// @}
337 
338  //-------------------------------------------------------------------------
339  /// @name Access to texture data
340  /// @{
341  //-------------------------------------------------------------------------
342 
343 
344  /// Get the texture image of a mesh as binary data.
345  /// Each pixel is represented according to the pixel format in #GetTextureImageFormat.
346  /// The pixels are ordered row by row, from top to bottom, each row from left to right.
347  ///
348  /// Usage example for pixelFormat == david::RGB24:
349  /// @code
350  /// // Import a mesh:
351  /// int meshID = david.fusion().ImportMesh("C:\\Scans\\someScan.obj"); // Import mesh (should have a texture)
352  ///
353  /// // Get texture format:
354  /// int width, height;
355  /// david::PixelFormat pixelFormat;
356  /// bool hasTexture = david.fusion().GetTextureImageFormat(width, height, pixelFormat, meshID);
357  /// if (!hasTexture || pixelFormat != david::RGB24) return;
358  ///
359  /// // Get texture data:
360  /// std::vector<unsigned char> imgData(david::GetImageSize(width, height, pixelFormat));
361  /// david.fusion().GetTextureImageData(imgData.data(), imgData.size(), meshID); // Retrieve texture image
362  /// printf("Texture size is %i*%i\n", width, height);
363  ///
364  /// // Print some example pixel colors in the middle:
365  /// int x=width/2, y=height/2;
366  /// unsigned char* myPixel = &imgData[(y*width+x)*3];
367  /// unsigned char blue = myPixel[0];
368  /// unsigned char green = myPixel[1];
369  /// unsigned char red = myPixel[2];
370  /// printf("Pixel XY(%i,%i) has color BGR(%u,%u,%u)\n", x,y, blue,green,red);
371  ///
372  /// @endcode
373  ///
374  /// @param[out] data Valid pointer to an array that will be filled with the pixel data.
375  /// @param[in] dataSizeInBytes Size of 'data' in bytes. Has to be in compliance with #GetTextureImageFormat.
376  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
377  /// @param[in] meshID ID of the mesh.
378  virtual void GetTextureImageData(void* data, size_t dataSizeInBytes, int meshID, int submeshIndex = 0) = 0;
379 
380  /// Get the format of the texture image.
381  /// @param[out] width Width of the image in [px]
382  /// @param[out] height Height of the image in [px]
383  /// @param[out] pixelFormat See #PixelFormat. Will be david::UnknownPixelFormat, if no texture is set.
384  /// @param[in] meshID ID of the mesh.
385  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
386  /// @return True, if texture is available. False, if no texture is available.
387  virtual bool GetTextureImageFormat(int& width, int& height, enum PixelFormat& pixelFormat, int meshID, int submeshIndex = 0) = 0;
388 
389  /// Set texture of a mesh.
390  /// @param[in] data Valid pointer to an array of pixel data.
391  /// @param[in] dataSizeInBytes Size of 'data' in bytes. Has to be in compliance with given texture format.
392  /// @param[in] width Width of the image in [px]
393  /// @param[in] height Height of the image in [px]
394  /// @param[in] pixelFormat See #PixelFormat. Will be david::UnknownPixelFormat, if no texture is set.
395  /// @param[in] meshID ID of the mesh.
396  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
397  virtual void SetTexture(const void* data, size_t dataSizeInBytes, int width, int height, enum PixelFormat pixelFormat, int meshID, int submeshIndex = 0) = 0;
398 
399  /// @}
400 
401  //-------------------------------------------------------------------------
402  /// @name Object pose and transformations
403  /// @{
404  //-------------------------------------------------------------------------
405 
406  /// Get the position and orientation of a mesh as a homogeneous transformation matrix.
407  /// @param[out] world_T_local Valid pointer to an array of 16 doubles representing a homogeneous transformation matrix
408  /// that transforms local coordinates into world coordinates: p_world = world_T_local * p_local.
409  /// Values will be stored in the following order: nx, ny, nz, 0, ox, oy, oz, 0, ax, ay, az, 0, px, py, pz, 1.
410  /// @param[in] meshID ID of the mesh.
411  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
412  virtual void GetPose(double world_T_local[16], int meshID) = 0;
413 
414  /// Set the position and orientation of a mesh as a homogeneous transformation matrix.
415  /// @param[out] world_T_local Valid pointer to an array of 16 doubles representing a homogeneous transformation matrix
416  /// that transforms local coordinates into world coordinates: p_world = world_T_local * p_local.
417  /// Values will be stored in the following order: nx, ny, nz, 0, ox, oy, oz, 0, ax, ay, az, 0, px, py, pz, 1.
418  /// @param[in] meshID ID of the mesh.
419  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
420  virtual void SetPose(const double world_T_local[16], int meshID) = 0;
421 
422  /// Rotate a mesh around specified axis by given degrees.
423  /// @param[in] meshID ID of mesh to be transformed.
424  /// @param[in] transformType Type of transform. See david::TransformType.
425  /// @param[in] degrees Amount of rotation in degrees.
426  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
427  /// @exception david::Error_InvalidArgument (david::FunctionException) Invalid transform type.
428  virtual void Rotate(int meshID, enum TransformType transformType, double degrees) = 0;
429 
430  /// Translate a mesh along specified axis by given amount.
431  /// @param[in] meshID ID of mesh to be transformed.
432  /// @param[in] transformType Type of transform. See david::TransformType.
433  /// @param[in] amount Amount of translation. Typically in mm.
434  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
435  /// @exception david::Error_InvalidArgument (david::FunctionException) Invalid transform type.
436  virtual void Translate(int meshID, enum TransformType transformType, double amount) = 0;
437 
438  /// @}
439 
440  //-------------------------------------------------------------------------
441  /// @name Filters
442  /// @{
443  //-------------------------------------------------------------------------
444 
445  /// Reduce the density of a mesh.
446  /// @param[in] meshID ID of mesh to be transformed.
447  /// @param[in] factor Factor of reduction, between 0 and 1.
448  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
449  /// @exception david::Error_InvalidArgument (david::FunctionException) Invalid factor value.
450  virtual void ReduceMeshDensity(int meshID, float factor) = 0;
451 
452  /// Remove any vertex i that when projected into a virtual camera view has a mask value of 'mask[i]==true'.
453  /// Vertices outside view or with a mask value fo 'mask[i]==false' are not removed.
454  /// If a vertex is removed, its referenced triangles are also removed.
455  /// The virtual camera is described by a perspective camera model:
456  /// - Central z axis goes through center of image --> Center is at (width/2, height/2).
457  /// - Image plane has a size in x-direction of 'width and a size of 'height' in y-direction.
458  /// - x-axis is from left to right and y-axis from top to down (with respect to image).
459  /// - Camera looks along the positive z-axis.
460  /// - Visible points are on positive side of z-axis.
461  /// - Focal length is given by 'f'.
462  /// - Pose of the camera with respect to world coordinates is given by 'world_T_cam'.
463  ///
464  /// @param[in] mask Valid pointer to an boolean array of size 'width*height'. True: Vertex should be removed. False: Keep vertex.
465  /// @param[in] width Width of the mask image [pixel]. Has to be > 0.
466  /// @param[in] height Height of the mask image [pixel]. Has to be > 0.
467  /// @param[in] f Focal length (distance of image plane to origin camera coordinate system).
468  /// @param[in] world_T_cam Position and orientation (pose) of the camera with respect to world coordinates.
469  /// The pose is represented as a homogenenous transformation matrix.
470  /// See #d4mesh_getPose for more information.
471  /// @exception david::Error_InvalidArgument (david::FunctionException) At least one of the arguments is invalid.
472  virtual void RemoveVerticesByVirtualCamMask(const std::vector<bool>& mask, int width, int height, double f, const double world_T_cam[16]) = 0;
473 
474  /// Remove selected vertices.
475  /// @param[in] selectedVertices Index array of selected vertices.
476  /// @param[in] meshID ID of mesh that 'selectedVertices' references.
477  /// @exception david::Error_InvalidArgument (david::FunctionException) At least one of the arguments is invalid.
478  virtual void RemoveSelectedVertices(const std::vector<SubmeshVertexIndex>& selectedVertices, int meshID) = 0;
479 
480  /// Invert orientation of all triangles in given mesh.
481  /// @param[in] meshID ID of mesh to be transformed.
482  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
483  virtual void InvertTriangleOrientation(int meshID) = 0;
484 
485  /// @}
486 
487  //-------------------------------------------------------------------------
488  /// @name Alignment
489  /// @{
490  //-------------------------------------------------------------------------
491 
492  /// Coarse alignment of mesh '1' to another mesh '2'.
493  /// @param[in] meshID1 ID of the mesh that is to be aligned.
494  /// @param[in] meshID2 ID of the other mesh.
495  /// @param[in] params Alignment parameter set. See CoarseAlignParams.
496  /// @return Quality of Alignment result in range [0,1]=[bad,good].
497  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
498  /// @exception david::Error_AlignFailed (david::FunctionException) Alignment could not find a solution.
499  virtual double AlignPairCoarse(int meshID1, int meshID2, const CoarseAlignParams &params) = 0;
500 
501  /// Fine alignment of mesh '1' to another mesh '2'.
502  /// @param[in] meshID1 ID of the mesh that is to be aligned.
503  /// @param[in] meshID2 ID of the other mesh.
504  /// @param[in] params Alignment parameter set. See FineAlignParams.
505  /// @exception david::Error_InvalidMeshId (david::FunctionException) Specified meshID does not exist.
506  /// @exception david::Error_AlignFailed (david::FunctionException) Alignment could not find a solution.
507  virtual void AlignPairFine(int meshID1, int meshID2, const FineAlignParams &params) = 0;
508 
509  /// Global fine alignment of all meshes.
510  /// @param[in] params Alignment parameter set. See GlobalFineAlignParams.
511  virtual void AlignGlobalFine(const GlobalFineAlignParams &params) = 0;
512 
513  /// @}
514 
515  //-------------------------------------------------------------------------
516  /// @name Fusion
517  /// @{
518  //-------------------------------------------------------------------------
519 
520  /// Fuse all visible meshes of the mesh list.
521  /// @param[in] resolution Limits the maximum resolution and thus the required memory usage.
522  /// @param 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.
523  /// @param[in] sharpness Fusion sharpness in [-3,+5]. Negative values for smoothing. Default is 1.
524  /// @return Mesh ID of the fusion result.
525  virtual int Fuse(int resolution, float holeSizeThresRel=1.f, int sharpness=1) = 0;
526 
527  /// Converts a metric resolution value into a resolution value required by #Fuse.
528  /// It uses the maximum bounding box length of all meshes to be fused.
529  /// @param[in] metricResolution Smallest possible element size in units (e.g. 0.1 [mm]).
530  /// @param[in] maxResolution Returned value is bounded by this value (e.g. 2000).
531  /// @return Resolution value that can be used in #Fuse.
532  virtual int GetFuseResolution(double metricResolution, int maxResolution) = 0;
533 
534  /// @}
535 
536  //-------------------------------------------------------------------------
537  /// @name Combine and uncombine of meshes
538  /// Multiple meshes can be combined into one mesh group.
539  /// A mesh within a mesh group is called submesh. Normally, a mesh has one submesh.
540  /// @{
541  //-------------------------------------------------------------------------
542 
543  /// Combines several meshes into one group.
544  /// @param[in] meshIDs List of the IDs of the meshes to be combined.
545  /// @return Mesh ID of the combined mesh.
546  virtual int CombineMeshes(const std::vector<int> &meshIDs) = 0;
547 
548  /// Uncombines a group of meshes into separate meshes.
549  /// @param[in] meshIDgroup Mesh ID of the mesh group to be separated.
550  /// @return List of the IDs of the separated meshes.
551  virtual std::vector<int> UncombineMeshes(int meshIDgroup) = 0;
552 
553  /// Get the number of submeshes (combined meshes) in 'mesh'.
554  /// A mesh has at least one submesh. This is also the standard case unless #CombineMeshes was used.
555  /// @param[in] meshID Valid mesh ID.
556  /// @return Number of submeshes (combined) meshes.
557  /// @exception david::Error_InvalidArgument (david::FunctionException)
558  virtual int GetSubmeshCount(int meshID) = 0;
559 
560  /// Set the number of submeshes (combined meshes) in 'mesh'.
561  /// A mesh has at least one submesh. This is also the standard case unless #CombineMeshes was used.
562  /// @param[in] count New number of submeshes (>0).
563  /// @param[in] meshID Valid mesh ID.
564  /// @exception david::Error_InvalidArgument (david::FunctionException)
565  virtual void SetSubmeshCount(int count, int meshID) = 0;
566 
567  /// @}
568 
569  //-------------------------------------------------------------------------
570  /// @name Direct access to submesh data
571  /// @{
572  //-------------------------------------------------------------------------
573 
574  /// Copy requested buffer ('bufferType') content into 'data'.
575  /// You can use #GetSubmeshVertexCount, #GetSubmeshTriangleCount, and #GetSubmeshBufferSize to
576  /// compute the correct size of 'data'.
577  /// Coordinates are given with respect to local coordinate system.
578  /// @param[out] data Valid pointer to data buffer.
579  /// @param[in] size Size of 'data' buffer in bytes.
580  /// @param[in] bufferType Desired data buffer, see #SubmeshBufferType.
581  /// @param[in] meshID Valid mesh ID.
582  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
583  /// @exception david::Error_InvalidArgument (david::FunctionException)
584  virtual void GetSubmeshBuffer(void* data, size_t size, enum SubmeshBufferType bufferType, int meshID, int submeshIndex) = 0;
585 
586  /// Copy 'data' into the desired buffer ('bufferType').
587  /// You can use #GetSubmeshVertexCount, #GetSubmeshTriangleCount, and #GetSubmeshBufferSize to
588  /// compute the correct size of 'data'.
589  /// Coordinates have to be given with respect to local coordinate system.
590  /// @param[in] data Valid pointer to data buffer.
591  /// @param[in] size Size of 'data' buffer in bytes.
592  /// @param[in] bufferType Desired data buffer, see #d4mesh_BufferType.
593  /// @param[in] meshID Valid mesh ID.
594  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
595  /// @exception david::Error_InvalidArgument (david::FunctionException)
596  virtual void SetSubmeshBuffer(const void* data, size_t size, enum SubmeshBufferType bufferType, int meshID, int submeshIndex) = 0;
597 
598  /// Is the buffer 'bufferType' available?
599  /// See #SubmeshBufferType for information about which buffers are optional.
600  /// @param[in] bufferType Desired data buffer, see #d4mesh_BufferType.
601  /// @param[in] meshID Valid mesh ID.
602  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
603  /// @return True, if submesh has a buffer of type 'bufferType'. False otherwise.
604  /// @exception david::Error_InvalidArgument (david::FunctionException)
605  virtual bool HasSubmeshBuffer(enum SubmeshBufferType bufferType, int meshID, int submeshIndex) = 0;
606 
607  /// Get size of buffer 'bufferType' in bytes.
608  /// @param[in] bufferType Desired data buffer, see #SubmeshBufferType.
609  /// @param[in] meshID Valid mesh ID.
610  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
611  /// @return Size of the buffer in bytes. It will be set to zero if buffer is not available.
612  /// @exception david::Error_InvalidArgument (david::FunctionException)
613  virtual size_t GetSubmeshBufferSize(enum SubmeshBufferType bufferType, int meshID, int submeshIndex) = 0;
614 
615  /// Get the number of vertices in submesh.
616  /// @param[in] meshID Valid mesh ID.
617  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
618  /// @return Number of vertices in submesh.
619  /// @exception david::Error_InvalidArgument (david::FunctionException)
620  virtual int GetSubmeshVertexCount(int meshID, int submeshIndex) = 0;
621 
622  /// Set the number of vertices in submesh.
623  /// @param[in] vertexCount New number of vertices in submesh. Old data remains in buffers, if 'vertexCount' increases.
624  /// @param[in] meshID Valid mesh ID.
625  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
626  virtual void SetSubmeshVertexCount(int vertexCount, int meshID, int submeshIndex) = 0;
627 
628  /// Get the number of triangles in submesh.
629  /// @param[in] meshID Valid mesh ID.
630  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
631  /// @return Number of triangles in submesh.
632  /// @exception david::Error_InvalidArgument (david::FunctionException)
633  virtual int GetSubmeshTriangleCount(int meshID, int submeshIndex) = 0;
634 
635  /// Set the number of triangles in submesh.
636  /// @param[in] triangleCount New number of triangles in submesh.
637  /// @param[in] meshID Valid mesh ID.
638  /// @param[in] submeshIndex Zero based index to a submesh of 'mesh'. Also see #GetSubmeshCount.
639  /// @exception david::Error_InvalidArgument (david::FunctionException)
640  virtual void SetSubmeshTriangleCount(int triangleCount, int meshID, int submeshIndex) = 0;
641 
642  /// @}
643 };
644 
645 /// @} // ShapeFusionGroup
646 /// @} // InterfaceGroup
647 
648 } // namespace
649 
650 #endif // DAVID_SDK_I_SHAPE_FUSION_H