| 183 | |
| 184 | template <typename T> |
| 185 | Expected<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 | |
| 219 | template <typename T> |
| 220 | Expected<void> parsePtsCoordinate( const std::string_view& str, Vector3<T>& v, Color* c, Vector3<T>* n ) |
no test coverage detected