277 { |
277 { |
278 throw BodyParseError{"colour was not an integer value"}; |
278 throw BodyParseError{"colour was not an integer value"}; |
279 } |
279 } |
280 } |
280 } |
281 |
281 |
282 static Vertex vertexFromStrings( |
282 static Point3D vertexFromStrings( |
283 const QStringList& tokens, |
283 const QStringList& tokens, |
284 const int startingPosition) |
284 const int startingPosition) |
285 { |
285 { |
286 bool ok_x; |
286 bool ok_x; |
287 const float x = tokens[startingPosition].toFloat(&ok_x); |
287 const float x = tokens[startingPosition].toFloat(&ok_x); |
345 if (tokens.size() != 15) |
345 if (tokens.size() != 15) |
346 { |
346 { |
347 throw BodyParseError{"wrong amount of tokens in a type-1 line"}; |
347 throw BodyParseError{"wrong amount of tokens in a type-1 line"}; |
348 } |
348 } |
349 const Color color = colorFromString(tokens[colorPosition]); |
349 const Color color = colorFromString(tokens[colorPosition]); |
350 const Vertex position = vertexFromStrings(tokens, positionPosition); |
350 const Point3D position = vertexFromStrings(tokens, positionPosition); |
351 const Matrix3x3 transform = matrixFromStrings(tokens, transformPosition); |
351 const Matrix3x3 transform = matrixFromStrings(tokens, transformPosition); |
352 const QString& name = tokens[namePosition]; |
352 const QString& name = tokens[namePosition]; |
353 return std::make_unique<linetypes::SubfileReference>(position, transform, name, color); |
353 return std::make_unique<linetypes::SubfileReference>(position, transform, name, color); |
354 } |
354 } |
355 |
355 |
364 if (tokens.size() != 2 + 3 * NumVertices) |
364 if (tokens.size() != 2 + 3 * NumVertices) |
365 { |
365 { |
366 throw BodyParseError{"wrong amount of tokens"}; |
366 throw BodyParseError{"wrong amount of tokens"}; |
367 } |
367 } |
368 const Color color = colorFromString(tokens[colorPosition]); |
368 const Color color = colorFromString(tokens[colorPosition]); |
369 QVector<Vertex> vertices; |
369 QVector<Point3D> vertices; |
370 vertices.reserve(NumVertices); |
370 vertices.reserve(NumVertices); |
371 for (int i = 0; i < NumVertices; i += 1) |
371 for (int i = 0; i < NumVertices; i += 1) |
372 { |
372 { |
373 vertices.append(vertexFromStrings(tokens, vertexPosition(i))); |
373 vertices.append(vertexFromStrings(tokens, vertexPosition(i))); |
374 } |
374 } |