MCPcopy Create free account
hub / github.com/Kitware/VTK / LoadSampler

Method LoadSampler

IO/Geometry/vtkGLTFDocumentLoaderInternals.cxx:930–1032  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

928
929//------------------------------------------------------------------------------
930bool vtkGLTFDocumentLoaderInternals::LoadSampler(
931 const nlohmann::json& root, vtkGLTFDocumentLoader::Sampler& sampler)
932{
933 using Sampler = vtkGLTFDocumentLoader::Sampler;
934 if (!root.is_object())
935 {
936 vtkErrorWithObjectMacro(this->Self, "Invalid sampler object");
937 return false;
938 }
939
940 if (root.empty())
941 {
942 sampler.MagFilter = Sampler::FilterType::LINEAR;
943 sampler.MinFilter = Sampler::FilterType::NEAREST_MIPMAP_LINEAR;
944 sampler.WrapT = Sampler::WrapType::REPEAT;
945 sampler.WrapS = Sampler::WrapType::REPEAT;
946 return true;
947 }
948
949 int tempIntValue = 0;
950 if (!vtkGLTFUtils::GetIntValue(root, "magFilter", tempIntValue))
951 {
952 sampler.MagFilter = vtkGLTFDocumentLoader::Sampler::FilterType::LINEAR;
953 }
954 else
955 {
956 switch (static_cast<vtkGLTFDocumentLoader::Sampler::FilterType>(tempIntValue))
957 {
958 case Sampler::FilterType::LINEAR:
959 case Sampler::FilterType::NEAREST:
960 sampler.MagFilter = static_cast<Sampler::FilterType>(tempIntValue);
961 break;
962 default:
963 sampler.MagFilter = Sampler::FilterType::LINEAR;
964 vtkWarningWithObjectMacro(this->Self, "Invalid sampler.magFilter value.");
965 }
966 }
967
968 if (!vtkGLTFUtils::GetIntValue(root, "minFilter", tempIntValue))
969 {
970 sampler.MinFilter = Sampler::FilterType::NEAREST_MIPMAP_LINEAR;
971 }
972 else
973 {
974 switch (static_cast<Sampler::FilterType>(tempIntValue))
975 {
976 case Sampler::FilterType::LINEAR:
977 case Sampler::FilterType::LINEAR_MIPMAP_LINEAR:
978 case Sampler::FilterType::LINEAR_MIPMAP_NEAREST:
979 case Sampler::FilterType::NEAREST:
980 case Sampler::FilterType::NEAREST_MIPMAP_LINEAR:
981 case Sampler::FilterType::NEAREST_MIPMAP_NEAREST:
982 sampler.MinFilter = static_cast<Sampler::FilterType>(tempIntValue);
983 break;
984 default:
985 sampler.MinFilter = Sampler::FilterType::NEAREST_MIPMAP_LINEAR;
986 vtkWarningWithObjectMacro(this->Self, "Invalid sampler.minFilter value.");
987 }

Callers 1

LoadModelMetaDataMethod · 0.95

Calls 3

GetIntValueFunction · 0.70
GetStringValueFunction · 0.70
emptyMethod · 0.45

Tested by

no test coverage detected