opensubdiv_converter_internal.cc 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. // Copyright 2018 Blender Foundation. All rights reserved.
  2. //
  3. // This program is free software; you can redistribute it and/or
  4. // modify it under the terms of the GNU General Public License
  5. // as published by the Free Software Foundation; either version 2
  6. // of the License, or (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software Foundation,
  15. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. //
  17. // Author: Sergey Sharybin
  18. #ifdef _MSC_VER
  19. # include <iso646.h>
  20. #endif
  21. #include "internal/opensubdiv_converter_internal.h"
  22. #include <opensubdiv/sdc/crease.h>
  23. #include <cassert>
  24. namespace opensubdiv_capi {
  25. OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type)
  26. {
  27. switch (type) {
  28. case OSD_SCHEME_BILINEAR:
  29. return OpenSubdiv::Sdc::SCHEME_BILINEAR;
  30. case OSD_SCHEME_CATMARK:
  31. return OpenSubdiv::Sdc::SCHEME_CATMARK;
  32. case OSD_SCHEME_LOOP:
  33. return OpenSubdiv::Sdc::SCHEME_LOOP;
  34. }
  35. assert(!"Unknown scheme type passed via C-API");
  36. return OpenSubdiv::Sdc::SCHEME_CATMARK;
  37. }
  38. OpenSubdiv::Sdc::Options::FVarLinearInterpolation getFVarLinearInterpolationFromCAPI(
  39. OpenSubdiv_FVarLinearInterpolation linear_interpolation)
  40. {
  41. typedef OpenSubdiv::Sdc::Options Options;
  42. switch (linear_interpolation) {
  43. case OSD_FVAR_LINEAR_INTERPOLATION_NONE:
  44. return Options::FVAR_LINEAR_NONE;
  45. case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY:
  46. return Options::FVAR_LINEAR_CORNERS_ONLY;
  47. case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1:
  48. return Options::FVAR_LINEAR_CORNERS_PLUS1;
  49. case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2:
  50. return Options::FVAR_LINEAR_CORNERS_PLUS2;
  51. case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES:
  52. return Options::FVAR_LINEAR_BOUNDARIES;
  53. case OSD_FVAR_LINEAR_INTERPOLATION_ALL:
  54. return Options::FVAR_LINEAR_ALL;
  55. }
  56. assert(!"Unknown fvar linear interpolation passed via C-API");
  57. return Options::FVAR_LINEAR_NONE;
  58. }
  59. OpenSubdiv_FVarLinearInterpolation getCAPIFVarLinearInterpolationFromOSD(
  60. OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation)
  61. {
  62. typedef OpenSubdiv::Sdc::Options Options;
  63. switch (linear_interpolation) {
  64. case Options::FVAR_LINEAR_NONE:
  65. return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
  66. case Options::FVAR_LINEAR_CORNERS_ONLY:
  67. return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
  68. case Options::FVAR_LINEAR_CORNERS_PLUS1:
  69. return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1;
  70. case Options::FVAR_LINEAR_CORNERS_PLUS2:
  71. return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2;
  72. case Options::FVAR_LINEAR_BOUNDARIES:
  73. return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES;
  74. case Options::FVAR_LINEAR_ALL:
  75. return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
  76. }
  77. assert(!"Unknown fvar linear interpolation passed via C-API");
  78. return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
  79. }
  80. } // namespace opensubdiv_capi