MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/OpenColorIO / read

Method read

src/OpenColorIO/fileformats/FileFormatVF.cpp:92–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90}
91
92CachedFileRcPtr LocalFileFormat::read(std::istream & istream,
93 const std::string & fileName,
94 Interpolation interp) const
95{
96 // this shouldn't happen
97 if(!istream)
98 {
99 throw Exception ("File stream empty when trying to read .vf LUT");
100 }
101
102 // Validate the file type
103 std::string line;
104 int lineNumber = 1;
105 if(!nextline(istream, line) ||
106 !StringUtils::StartsWith(StringUtils::Lower(line), "#inventor"))
107 {
108 ThrowErrorMessage("Expecting '#Inventor V2.1 ascii'.",
109 fileName, lineNumber, line);
110 }
111
112 // Parse the file
113 std::vector<float> raw3d;
114 int size3d[] = { 0, 0, 0 };
115 std::vector<float> global_transform;
116
117 {
118 StringUtils::StringVec parts;
119 std::vector<float> tmpfloats;
120
121 bool in3d = false;
122
123 while(nextline(istream, line))
124 {
125 ++lineNumber;
126
127 // Strip, lowercase, and split the line
128 parts = StringUtils::SplitByWhiteSpaces(StringUtils::Lower(StringUtils::Trim(line)));
129
130 if(parts.empty()) continue;
131
132 if(StringUtils::StartsWith(parts[0],'#')) continue;
133
134 if(!in3d)
135 {
136 if(parts[0] == "grid_size")
137 {
138 if(parts.size() != 4 ||
139 !StringToInt( &size3d[0], parts[1].c_str()) ||
140 !StringToInt( &size3d[1], parts[2].c_str()) ||
141 !StringToInt( &size3d[2], parts[3].c_str()))
142 {
143 ThrowErrorMessage(
144 "Malformed grid_size tag.",
145 fileName, lineNumber, line);
146 }
147
148 // TODO: Support nununiformly sized LUTs.
149 if (size3d[0] != size3d[1] ||

Callers 2

CreateFromFileMethod · 0.45
LoadFileUncachedFunction · 0.45

Calls 15

nextlineFunction · 0.85
StartsWithFunction · 0.85
LowerFunction · 0.85
SplitByWhiteSpacesFunction · 0.85
eraseMethod · 0.80
getValuesMethod · 0.80
TrimFunction · 0.50
StringToIntFunction · 0.50
StringVecToFloatVecFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected