Skip to content

Commit

Permalink
DXFImporter: support circles
Browse files Browse the repository at this point in the history
  • Loading branch information
carrotIndustries committed Jun 12, 2021
1 parent f868a42 commit f07b2c6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/core/tools/tool_import_dxf.cpp
Expand Up @@ -45,9 +45,6 @@ ToolResponse ToolImportDXF::begin(const ToolArgs &args)
for (const auto &it : unsupported) {
s += std::to_string(it.second) + " ";
switch (it.first) {
case DXFImporter::UnsupportedType::CIRCLE:
s += "Circle";
break;
case DXFImporter::UnsupportedType::ELLIPSE:
s += "Ellipse";
break;
Expand Down
24 changes: 22 additions & 2 deletions src/import_dxf/dxf_importer.cpp
Expand Up @@ -134,9 +134,29 @@ class DXFAdapter : public DL_CreationAdapter {
items_unsupported.emplace(type, 0);
}

void addCircle(const DL_CircleData &) override
void addCircle(const DL_CircleData &c) override
{
add_unsupported(DXFImporter::UnsupportedType::CIRCLE);
auto center = get_or_create_junction(c.cx, c.cy);
auto p1 = get_or_create_junction(c.cx + c.radius, c.cy);
auto p2 = get_or_create_junction(c.cx - c.radius, c.cy);
{
auto arc = core->insert_arc(UUID::random());
arcs_out.insert(arc);
arc->layer = layer;
arc->width = width;
arc->center = center;
arc->from = p1;
arc->to = p2;
}
{
auto arc = core->insert_arc(UUID::random());
arcs_out.insert(arc);
arc->layer = layer;
arc->width = width;
arc->center = center;
arc->from = p2;
arc->to = p1;
}
}

void addEllipse(const DL_EllipseData &) override
Expand Down
2 changes: 1 addition & 1 deletion src/import_dxf/dxf_importer.hpp
Expand Up @@ -17,7 +17,7 @@ class DXFImporter {
std::set<class Line *> lines;
std::set<class Arc *> arcs;

enum class UnsupportedType { CIRCLE, ELLIPSE, SPLINE };
enum class UnsupportedType { ELLIPSE, SPLINE };

const std::map<UnsupportedType, unsigned int> &get_items_unsupported() const;

Expand Down

0 comments on commit f07b2c6

Please sign in to comment.