Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: solvespace/solvespace
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7366a6c53deb
Choose a base ref
...
head repository: solvespace/solvespace
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a52d88bc3dae
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on May 6, 2020

  1. Copy the full SHA
    88a0e55 View commit details
  2. Copy the full SHA
    a52d88b View commit details
Showing with 19 additions and 25 deletions.
  1. +18 −24 src/polygon.cpp
  2. +1 −1 src/polygon.h
42 changes: 18 additions & 24 deletions src/polygon.cpp
Original file line number Diff line number Diff line change
@@ -224,15 +224,15 @@ void SEdgeList::AddEdge(Vector a, Vector b, int auxA, int auxB, int tag) {
}

bool SEdgeList::AssembleContour(Vector first, Vector last, SContour *dest,
SEdge *errorAt, bool keepDir) const
SEdge *errorAt, bool keepDir, int start) const
{
int i;

dest->AddPoint(first);
dest->AddPoint(last);

do {
for(i = 0; i < l.n; i++) {
for(i = start; i < l.n; i++) {
/// @todo fix const!
SEdge *se = const_cast<SEdge*>(&(l[i]));
if(se->tag) continue;
@@ -269,31 +269,25 @@ bool SEdgeList::AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir) co
dest->Clear();

bool allClosed = true;
for(;;) {
Vector first = Vector::From(0, 0, 0);
Vector last = Vector::From(0, 0, 0);
int i;
for(i = 0; i < l.n; i++) {
if(!l[i].tag) {
first = l[i].a;
last = l[i].b;
/// @todo fix const!
const_cast<SEdge*>(&(l[i]))->tag = 1;
break;
Vector first = Vector::From(0, 0, 0);
Vector last = Vector::From(0, 0, 0);
int i;
for(i = 0; i < l.n; i++) {
if(!l[i].tag) {
first = l[i].a;
last = l[i].b;
/// @todo fix const!
const_cast<SEdge*>(&(l[i]))->tag = 1;
// Create a new empty contour in our polygon, and finish assembling
// into that contour.
dest->AddEmptyContour();
if(!AssembleContour(first, last, dest->l.Last(), errorAt, keepDir, i+1)) {
allClosed = false;
}
// But continue assembling, even if some of the contours are open
}
if(i >= l.n) {
return allClosed;
}

// Create a new empty contour in our polygon, and finish assembling
// into that contour.
dest->AddEmptyContour();
if(!AssembleContour(first, last, dest->l.Last(), errorAt, keepDir)) {
allClosed = false;
}
// But continue assembling, even if some of the contours are open
}
return allClosed;
}

//-----------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion src/polygon.h
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ class SEdgeList {
void AddEdge(Vector a, Vector b, int auxA=0, int auxB=0, int tag=0);
bool AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir=false) const;
bool AssembleContour(Vector first, Vector last, SContour *dest,
SEdge *errorAt, bool keepDir) const;
SEdge *errorAt, bool keepDir, int start) const;
int AnyEdgeCrossings(Vector a, Vector b,
Vector *pi=NULL, SPointList *spl=NULL) const;
bool ContainsEdgeFrom(const SEdgeList *sel) const;