builder.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // ======================================================================== //
  2. // Copyright 2009-2017 Intel Corporation //
  3. // //
  4. // Licensed under the Apache License, Version 2.0 (the "License"); //
  5. // you may not use this file except in compliance with the License. //
  6. // You may obtain a copy of the License at //
  7. // //
  8. // http://www.apache.org/licenses/LICENSE-2.0 //
  9. // //
  10. // Unless required by applicable law or agreed to in writing, software //
  11. // distributed under the License is distributed on an "AS IS" BASIS, //
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
  13. // See the License for the specific language governing permissions and //
  14. // limitations under the License. //
  15. // ======================================================================== //
  16. #pragma once
  17. #include "default.h"
  18. #include "accel.h"
  19. namespace embree
  20. {
  21. #define MODE_HIGH_QUALITY (1<<8)
  22. /*! virtual interface for all hierarchy builders */
  23. class Builder : public RefCount {
  24. public:
  25. static const size_t DEFAULT_SINGLE_THREAD_THRESHOLD = 1024;
  26. /*! initiates the hierarchy builder */
  27. virtual void build() = 0;
  28. /*! notifies the builder about the deletion of some geometry */
  29. virtual void deleteGeometry(size_t geomID) {};
  30. /*! clears internal builder state */
  31. virtual void clear() = 0;
  32. };
  33. /*! virtual interface for progress monitor class */
  34. struct BuildProgressMonitor {
  35. virtual void operator() (size_t dn) const = 0;
  36. };
  37. /*! build the progress monitor interface from a closure */
  38. template<typename Closure>
  39. struct ProgressMonitorClosure : BuildProgressMonitor
  40. {
  41. public:
  42. ProgressMonitorClosure (const Closure& closure) : closure(closure) {}
  43. void operator() (size_t dn) const { closure(dn); }
  44. private:
  45. const Closure closure;
  46. };
  47. template<typename Closure> __forceinline const ProgressMonitorClosure<Closure> BuildProgressMonitorFromClosure(const Closure& closure) {
  48. return ProgressMonitorClosure<Closure>(closure);
  49. }
  50. struct LineSegments;
  51. struct TriangleMesh;
  52. struct QuadMesh;
  53. class AccelSet;
  54. class Scene;
  55. typedef void (*createLineSegmentsAccelTy)(LineSegments* mesh, AccelData*& accel, Builder*& builder);
  56. typedef void (*createTriangleMeshAccelTy)(TriangleMesh* mesh, AccelData*& accel, Builder*& builder);
  57. typedef void (*createQuadMeshAccelTy)(QuadMesh* mesh, AccelData*& accel, Builder*& builder);
  58. typedef void (*createAccelSetAccelTy)(AccelSet* mesh, AccelData*& accel, Builder*& builder);
  59. }