dualcon.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * This program is free software; you can redistribute it and/or
  3. * modify it under the terms of the GNU General Public License
  4. * as published by the Free Software Foundation; either version 2
  5. * of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program; if not, write to the Free Software Foundation,
  14. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef __DUALCON_H__
  17. #define __DUALCON_H__
  18. #ifdef WITH_CXX_GUARDEDALLOC
  19. # include "MEM_guardedalloc.h"
  20. #endif
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. typedef float (*DualConCo)[3];
  25. typedef unsigned int (*DualConTri)[3];
  26. typedef unsigned int(*DualConLoop);
  27. typedef struct DualConInput {
  28. DualConLoop mloop;
  29. DualConCo co;
  30. int co_stride;
  31. int totco;
  32. DualConTri looptri;
  33. int tri_stride;
  34. int tottri;
  35. int loop_stride;
  36. float min[3], max[3];
  37. } DualConInput;
  38. /* callback for allocating memory for output */
  39. typedef void *(*DualConAllocOutput)(int totvert, int totquad);
  40. /* callback for adding a new vertex to the output */
  41. typedef void (*DualConAddVert)(void *output, const float co[3]);
  42. /* callback for adding a new quad to the output */
  43. typedef void (*DualConAddQuad)(void *output, const int vert_indices[4]);
  44. typedef enum {
  45. DUALCON_FLOOD_FILL = 1,
  46. } DualConFlags;
  47. typedef enum {
  48. /* blocky */
  49. DUALCON_CENTROID,
  50. /* smooth */
  51. DUALCON_MASS_POINT,
  52. /* keeps sharp edges */
  53. DUALCON_SHARP_FEATURES,
  54. } DualConMode;
  55. /* Usage:
  56. *
  57. * The three callback arguments are used for creating the output
  58. * mesh. The alloc_output callback takes the total number of vertices
  59. * and faces (quads) that will be in the output. It should allocate
  60. * and return a structure to hold the output mesh. The add_vert and
  61. * add_quad callbacks will then be called for each new vertex and
  62. * quad, and the callback should add the new mesh elements to the
  63. * structure.
  64. */
  65. void *dualcon(const DualConInput *input_mesh,
  66. /* callbacks for output */
  67. DualConAllocOutput alloc_output,
  68. DualConAddVert add_vert,
  69. DualConAddQuad add_quad,
  70. /* flags and settings to control the remeshing
  71. * algorithm */
  72. DualConFlags flags,
  73. DualConMode mode,
  74. float threshold,
  75. float hermite_num,
  76. float scale,
  77. int depth);
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif /* __DUALCON_H__ */