FindDegenerates.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2020, 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 post processing step to search all meshes for
  34. degenerated faces */
  35. #ifndef AI_FINDDEGENERATESPROCESS_H_INC
  36. #define AI_FINDDEGENERATESPROCESS_H_INC
  37. #include "Common/BaseProcess.h"
  38. #include <assimp/mesh.h>
  39. class FindDegeneratesProcessTest;
  40. namespace Assimp {
  41. // ---------------------------------------------------------------------------
  42. /** FindDegeneratesProcess: Searches a mesh for degenerated triangles.
  43. */
  44. class ASSIMP_API FindDegeneratesProcess : public BaseProcess {
  45. public:
  46. FindDegeneratesProcess();
  47. ~FindDegeneratesProcess();
  48. // -------------------------------------------------------------------
  49. // Check whether step is active
  50. bool IsActive( unsigned int pFlags) const;
  51. // -------------------------------------------------------------------
  52. // Execute step on a given scene
  53. void Execute( aiScene* pScene);
  54. // -------------------------------------------------------------------
  55. // Setup import settings
  56. void SetupProperties(const Importer* pImp);
  57. // -------------------------------------------------------------------
  58. // Execute step on a given mesh
  59. ///@returns true if the current mesh should be deleted, false otherwise
  60. bool ExecuteOnMesh( aiMesh* mesh);
  61. // -------------------------------------------------------------------
  62. /// @brief Enable the instant removal of degenerated primitives
  63. /// @param enabled true for enabled.
  64. void EnableInstantRemoval(bool enabled);
  65. // -------------------------------------------------------------------
  66. /// @brief Check whether instant removal is currently enabled
  67. /// @return The instant removal state.
  68. bool IsInstantRemoval() const;
  69. // -------------------------------------------------------------------
  70. /// @brief Enable the area check for triangles.
  71. /// @param enabled true for enabled.
  72. void EnableAreaCheck( bool enabled );
  73. // -------------------------------------------------------------------
  74. /// @brief Check whether the area check is enabled.
  75. /// @return The area check state.
  76. bool isAreaCheckEnabled() const;
  77. private:
  78. //! Configuration option: remove degenerates faces immediately
  79. bool mConfigRemoveDegenerates;
  80. //! Configuration option: check for area
  81. bool mConfigCheckAreaOfTriangle;
  82. };
  83. inline
  84. void FindDegeneratesProcess::EnableInstantRemoval(bool enabled) {
  85. mConfigRemoveDegenerates = enabled;
  86. }
  87. inline
  88. bool FindDegeneratesProcess::IsInstantRemoval() const {
  89. return mConfigRemoveDegenerates;
  90. }
  91. inline
  92. void FindDegeneratesProcess::EnableAreaCheck( bool enabled ) {
  93. mConfigCheckAreaOfTriangle = enabled;
  94. }
  95. inline
  96. bool FindDegeneratesProcess::isAreaCheckEnabled() const {
  97. return mConfigCheckAreaOfTriangle;
  98. }
  99. } // Namespace Assimp
  100. #endif // !! AI_FINDDEGENERATESPROCESS_H_INC