--- a/src/linetypes/modelobject.cpp Sun Jun 10 17:17:42 2018 +0300 +++ b/src/linetypes/modelobject.cpp Sun Jun 10 21:48:58 2018 +0300 @@ -210,24 +210,39 @@ // ============================================================================= // -LDPolygon* LDObject::getPolygon() +LDPolygon LDObject::getPolygon() { LDObjectType ot = type(); - int num = (ot == LDObjectType::EdgeLine) ? 2 - : (ot == LDObjectType::Triangle) ? 3 - : (ot == LDObjectType::Quadrilateral) ? 4 - : (ot == LDObjectType::ConditionalEdge) ? 5 - : 0; + LDPolygon::Type polygonType; + + switch (ot) + { + case LDObjectType::EdgeLine: + polygonType = LDPolygon::Type::EdgeLine; + break; + + case LDObjectType::Triangle: + polygonType = LDPolygon::Type::Triangle; + break; - if (num == 0) - return nullptr; + case LDObjectType::Quadrilateral: + polygonType = LDPolygon::Type::Quadrilateral; + break; + + case LDObjectType::ConditionalEdge: + polygonType = LDPolygon::Type::ConditionalEdge; + break; - LDPolygon* data = new LDPolygon; - data->num = num; - data->color = color().index(); + default: + return {}; + } - for (int i = 0; i < data->numVertices(); ++i) - data->vertices[i] = vertex (i); + LDPolygon data; + data.type = polygonType; + data.color = color(); + + for (int i = 0; i < data.numVertices(); ++i) + data.vertices[i] = vertex(i); return data; } @@ -480,7 +495,7 @@ parms.append (pointAt (1.0)); LDPolygon poly; poly.color = color().index(); - poly.num = 2; + poly.type = LDPolygon::Type::EdgeLine; for (int i = 0; i < segments; ++i) {