| 331 | } |
| 332 | |
| 333 | Expected<void> parsePolygon( const std::string_view& str, VertId* vertId, int* numPoints) |
| 334 | { |
| 335 | using namespace boost::spirit::x3; |
| 336 | |
| 337 | bool r = false; |
| 338 | size_t vi = 0; |
| 339 | auto v = [&] ( auto& ctx ) { vertId[vi++] = VertId( _attr( ctx ) ); }; |
| 340 | if ( numPoints ) |
| 341 | { |
| 342 | auto n = [&] ( auto& ctx ) { *numPoints = _attr( ctx ); }; |
| 343 | r = phrase_parse( |
| 344 | str.begin(), |
| 345 | str.end(), |
| 346 | int_[n] >> *int_[v], |
| 347 | ascii::space ); |
| 348 | } |
| 349 | else |
| 350 | { |
| 351 | auto n = [&] ( auto& ) { }; |
| 352 | r = phrase_parse( |
| 353 | str.begin(), |
| 354 | str.end(), |
| 355 | int_[n] >> *int_[v], |
| 356 | ascii::space ); |
| 357 | } |
| 358 | |
| 359 | if ( !r ) |
| 360 | { |
| 361 | return unexpected( "Failed to parse face in OFF-file" ); |
| 362 | } |
| 363 | |
| 364 | return {}; |
| 365 | } |
| 366 | |
| 367 | bool hasBom( const std::string_view& str ) |
| 368 | { |
no test coverage detected