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

Function parseObjCoordinate

source/MRMesh/MRIOParsing.cpp:185–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183
184template <typename T>
185Expected<void> parseObjCoordinate( const std::string_view& str, Vector3<T>& v, Vector3<T>* c )
186{
187 using namespace boost::spirit::x3;
188
189 int i = 0;
190 auto coord = [&] ( auto& ctx ) { v[i++] = _attr( ctx ); };
191 int j = 0;
192 auto color = [&] ( auto& ctx ) { if ( c ) ( *c )[j++] = _attr( ctx ); };
193
194 bool r;
195 if ( c != nullptr )
196 {
197 r = phrase_parse(
198 str.begin(),
199 str.end(),
200 ( 'v' >> floatT[coord] >> floatT[coord] >> floatT[coord] >> -( floatT[color] >> floatT[color] >> floatT[color] ) ),
201 ascii::space
202 );
203 }
204 else
205 {
206 r = phrase_parse(
207 str.begin(),
208 str.end(),
209 ( 'v' >> floatT[coord] >> floatT[coord] >> floatT[coord] ),
210 ascii::space
211 );
212 }
213 if ( !r )
214 return unexpected( "Failed to parse vertex: " + std::string( trimRight( str.substr( 0, MaxErrorStringLen ) ) ) );
215
216 return {};
217}
218
219template <typename T>
220Expected<void> parsePtsCoordinate( const std::string_view& str, Vector3<T>& v, Color* c, Vector3<T>* n )

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