MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / parseObjTextureVertex

Function parseObjTextureVertex

source/MRMesh/MRMeshLoadObj.cpp:202–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200}
201
202Expected<void> parseObjTextureVertex( const std::string_view& str, UVCoord& vt )
203{
204 using namespace boost::spirit::x3;
205
206 std::array<float, 3> coords{ 0.f, 0.f, 0.f };
207 int i = 0;
208 auto coord = [&] ( auto& ctx )
209 {
210 coords[i++] = _attr( ctx );
211 };
212
213 bool r = phrase_parse(
214 str.begin(),
215 str.end(),
216 ( lit( "vt" ) >> float_[coord] >> -( float_[coord] >> -( float_[coord] ) ) ),
217 ascii::space
218 );
219
220 static constexpr int MaxErrorStringLen = 80;
221 if ( !r )
222 return unexpected( "Failed to parse vertex in OBJ-file: " + std::string( trimRight( str.substr( 0, MaxErrorStringLen ) ) ) );
223
224 vt = { coords[0], coords[1] };
225 return {};
226}
227
228struct ObjFaceInfo
229{

Callers 1

loadModelsFromObjFunction · 0.85

Calls 4

trimRightFunction · 0.85
unexpectedFunction · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected