Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engraving #394

Merged
merged 4 commits into from
May 13, 2019
Merged

Engraving #394

merged 4 commits into from
May 13, 2019

Conversation

bcmpinc
Copy link
Contributor

@bcmpinc bcmpinc commented Apr 16, 2019

I mostly use solvespace for designing stuff that I then cut out using a laser cutter. For that purpose I always use the section export function. In the past I used Inkscape to add text or line segments, but I would prefer to be able to model these in solvespace, especially when positioning is important.

For custom line styles, there is an option "export these objects", which I hoped meant that these lines are included in the section export, but they aren't. This patch changes that, such that they are included. To get it to work properly I had to change some parts of the code for which I'm not sure whether I got them correct.

I don't know what "export these objects" is supposed to do, so I guess this is not entirely the right place for configuring a style for section export and that a new flag might be more appropriate.

Please let me know what you think of it.

P.S. I thought that it would be useful to add a way to disable the closed contour check for these custom line styles, but this is already possible by turning them into construction line segments (although those are visually indistinguishable).

bcmpinc added 3 commits April 16, 2019 19:22

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
src/export.cpp Outdated
@@ -92,8 +91,27 @@ void SolveSpaceUI::ExportSectionTo(const Platform::Path &filename) {
sb->auxA = Style::SOLID_EDGE;
}

el.CullExtraneousEdges();
bl.CullIdenticalBeziers();
el.CullExtraneousEdges(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to have /*both=*/ here and elsewhere because it looks quite puzzling otherwise.

@@ -156,7 +156,7 @@ class SBezierLoopSet {
static SBezierLoopSet From(SBezierList *spcl, SPolygon *poly,
double chordTol,
bool *allClosed, SEdge *errorAt,
SBezierList *openContours);
SBezierLoopSet *openContours);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand why this is needed. Could you elaborate on it? That would also make a good commit message.

Sorry, something went wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to their different style, the engravings end up in the list of open contours during FindOuterFacesFrom, regardless of whether they form a closed contour or not. Considering that openContours is a list of segments, open loops have to be added per segment, thereby losing their connectivity. For example, an engraved circle will be exported as 4 separate arcs (at least for SVG). To fix this, I had to change the type of open contours to a loopset, which does retain connectivity.

Sorry, something went wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still confused. Aren't open contours, by definition, not bezier loops?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess. Though SBezierLoop::FromCurves returns open loops and there is SBezierLoop::IsClosed() to tell if a loop is closed. So I assumed that it's okay for loops to be open. And in every other aspect, that class does exactly what I need from it. If you want, I can rename SBezierLoop to SBezierContour, to make it more consistent.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right. SBezierLoop doesn't have to be closed. That's OK then.

}
openContours->l.Add(loop);
} else {
loop->Clear();
Copy link
Contributor Author

@bcmpinc bcmpinc Apr 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is where the open loops used to be exploded into separate segments.

@whitequark whitequark merged commit 7d181f0 into solvespace:master May 13, 2019
@whitequark
Copy link
Contributor

@bcmpinc Thank you for the PR, and sorry for the delay in merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants