catmullclark_coefficients.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "catmullclark_coefficients.h"
  17. namespace embree
  18. {
  19. CatmullClarkPrecomputedCoefficients CatmullClarkPrecomputedCoefficients::table;
  20. CatmullClarkPrecomputedCoefficients::CatmullClarkPrecomputedCoefficients()
  21. {
  22. /* precompute cosf(2.0f*M_PI/n) */
  23. for (size_t n=0; n<=MAX_RING_FACE_VALENCE; n++)
  24. table_cos_2PI_div_n[n] = set_cos_2PI_div_n(n);
  25. /* precompute limit tangents coefficients */
  26. for (size_t n=0; n<=MAX_RING_FACE_VALENCE; n++)
  27. {
  28. table_limittangent_a[n] = new float[n];
  29. table_limittangent_b[n] = new float[n];
  30. for (size_t i=0; i<n; i++) {
  31. table_limittangent_a[n][i] = set_limittangent_a(i,n);
  32. table_limittangent_b[n][i] = set_limittangent_b(i,n);
  33. }
  34. }
  35. for (size_t n=0; n<=MAX_RING_FACE_VALENCE; n++)
  36. table_limittangent_c[n] = set_limittangent_c(n);
  37. }
  38. CatmullClarkPrecomputedCoefficients::~CatmullClarkPrecomputedCoefficients()
  39. {
  40. for (size_t n=0; n<=MAX_RING_FACE_VALENCE; n++)
  41. {
  42. delete [] table_limittangent_a[n];
  43. delete [] table_limittangent_b[n];
  44. }
  45. }
  46. }