Subdivision.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2025, assimp team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the assimp team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the assimp team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. /** @file Defines a helper class to evaluate subdivision surfaces.*/
  34. #pragma once
  35. #ifndef AI_SUBDISIVION_H_INC
  36. #define AI_SUBDISIVION_H_INC
  37. #ifdef __GNUC__
  38. # pragma GCC system_header
  39. #endif
  40. #include <assimp/types.h>
  41. struct aiMesh;
  42. namespace Assimp {
  43. // ------------------------------------------------------------------------------
  44. /** Helper class to evaluate subdivision surfaces. Different algorithms
  45. * are provided for choice. */
  46. // ------------------------------------------------------------------------------
  47. class ASSIMP_API Subdivider {
  48. public:
  49. /** Enumerates all supported subvidision algorithms */
  50. enum Algorithm {
  51. CATMULL_CLARKE = 0x1
  52. };
  53. virtual ~Subdivider();
  54. // ---------------------------------------------------------------
  55. /** Create a subdivider of a specific type
  56. *
  57. * @param algo Algorithm to be used for subdivision
  58. * @return Subdivider instance. */
  59. static Subdivider* Create (Algorithm algo);
  60. // ---------------------------------------------------------------
  61. /** Subdivide a mesh using the selected algorithm
  62. *
  63. * @param mesh First mesh to be subdivided. Must be in verbose
  64. * format.
  65. * @param out Receives the output mesh, allocated by me.
  66. * @param num Number of subdivisions to perform.
  67. * @param discard_input If true is passed, the input mesh is
  68. * deleted after the subdivision is complete. This can
  69. * improve performance because it allows the optimization
  70. * to reuse the existing mesh for intermediate results.
  71. * @pre out!=mesh*/
  72. virtual void Subdivide ( aiMesh* mesh,
  73. aiMesh*& out, unsigned int num,
  74. bool discard_input = false) = 0;
  75. // ---------------------------------------------------------------
  76. /** Subdivide multiple meshes using the selected algorithm. This
  77. * avoids erroneous smoothing on objects consisting of multiple
  78. * per-material meshes. Usually, most 3d modellers smooth on a
  79. * per-object base, regardless the materials assigned to the
  80. * meshes.
  81. *
  82. * @param smesh Array of meshes to be subdivided. Must be in
  83. * verbose format.
  84. * @param nmesh Number of meshes in smesh.
  85. * @param out Receives the output meshes. The array must be
  86. * sufficiently large (at least @c nmesh elements) and may not
  87. * overlap the input array. Output meshes map one-to-one to
  88. * their corresponding input meshes. The meshes are allocated
  89. * by the function.
  90. * @param discard_input If true is passed, input meshes are
  91. * deleted after the subdivision is complete. This can
  92. * improve performance because it allows the optimization
  93. * of reusing existing meshes for intermediate results.
  94. * @param num Number of subdivisions to perform.
  95. * @pre nmesh != 0, smesh and out may not overlap*/
  96. virtual void Subdivide (
  97. aiMesh** smesh,
  98. size_t nmesh,
  99. aiMesh** out,
  100. unsigned int num,
  101. bool discard_input = false) = 0;
  102. };
  103. inline Subdivider::~Subdivider() = default;
  104. } // end namespace Assimp
  105. #endif // !! AI_SUBDISIVION_H_INC