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

Earclip #6

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3810491
earclip compiles
elalish Sep 14, 2023
0025354
some tests passing
elalish Sep 14, 2023
ecb9df6
46 tests passing
elalish Sep 14, 2023
c568e84
refactor
elalish Sep 15, 2023
79c556b
cleanup
elalish Sep 15, 2023
c2477a9
new cost
elalish Sep 15, 2023
3be3fa7
cleanup
elalish Sep 15, 2023
056d4ce
fixed TouchingHole
elalish Sep 15, 2023
99fef15
more fixes
elalish Sep 15, 2023
c7b7c8e
only 5 tests failing
elalish Sep 15, 2023
86b5940
fixed short sides
elalish Sep 16, 2023
a80731d
fixed Sponge2
elalish Sep 16, 2023
c6f24f2
better cost
elalish Sep 19, 2023
4229a04
improved keyholing
elalish Sep 25, 2023
76e72f1
Moved Rect to public
elalish Sep 25, 2023
8e21f10
added top/bottom check
elalish Sep 25, 2023
11b1ab5
fixed bBox
elalish Sep 25, 2023
26094e3
Polygon tests pass
elalish Sep 25, 2023
7168d8a
fixed Sponge3a
elalish Sep 26, 2023
2f652e6
another fix, another test
elalish Sep 26, 2023
caee668
keyhole refactor
elalish Sep 28, 2023
fbc037c
Added ClipDegenerates
elalish Sep 28, 2023
e2d4c36
Refactor FindStarts
elalish Sep 28, 2023
6f2bbb7
fixed bugs
elalish Sep 28, 2023
3a2f876
fixed Sponge4
elalish Sep 28, 2023
f589204
refactor clipped
elalish Sep 28, 2023
0c523b4
another bug, another test
elalish Sep 28, 2023
fc0d12a
another bug, another test
elalish Sep 28, 2023
8cd0c0a
Sponge4 passing
elalish Sep 29, 2023
27df515
all tests passing
elalish Sep 29, 2023
c3e66d4
removed old triangulator
elalish Sep 29, 2023
03065bf
fix isfinite
elalish Sep 29, 2023
85e9a59
debug checks
elalish Sep 29, 2023
f3c8cae
remove 2-manifold check
elalish Sep 29, 2023
6cff414
added comments
elalish Sep 29, 2023
6f5ab8e
fixed missing point bug
elalish Sep 29, 2023
1bff99a
another test, another fix
elalish Sep 29, 2023
5335856
two tests added and fixed
elalish Oct 3, 2023
e5890c8
fix build
elalish Oct 3, 2023
a37578c
fixed CoplanarProp
elalish Oct 3, 2023
dcf0db4
fixed seg fault
elalish Oct 3, 2023
c658b51
reenable 2-manifold check
elalish Oct 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions bindings/c/include/manifoldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,6 @@ ManifoldRect *manifold_rect_mul(void *mem, ManifoldRect *r, float x, float y);
int manifold_rect_does_overlap_rect(ManifoldRect *a, ManifoldRect *r);
int manifold_rect_is_empty(ManifoldRect *r);
int manifold_rect_is_finite(ManifoldRect *r);
ManifoldCrossSection *manifold_rect_as_cross_section(void *mem,
ManifoldRect *r);

// Bounding Box

Expand Down
6 changes: 0 additions & 6 deletions bindings/c/rect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,3 @@ int manifold_rect_does_overlap_rect(ManifoldRect *a, ManifoldRect *r) {
int manifold_rect_is_empty(ManifoldRect *r) { return from_c(r)->IsEmpty(); }

int manifold_rect_is_finite(ManifoldRect *r) { return from_c(r)->IsFinite(); }

ManifoldCrossSection *manifold_rect_as_cross_section(void *mem,
ManifoldRect *r) {
auto cs = from_c(r)->AsCrossSection();
return to_c(new (mem) CrossSection(cs));
}
62 changes: 0 additions & 62 deletions src/cross_section/include/cross_section.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

namespace manifold {

class Rect;

/** @addtogroup Core
* @{
*/
Expand Down Expand Up @@ -172,64 +170,4 @@ class CrossSection {
std::shared_ptr<const PathImpl> GetPaths() const;
};
/** @} */

/** @addtogroup Connections
* @{
*/

/**
* Axis-aligned rectangular bounds.
*/
class Rect {
public:
glm::vec2 min = glm::vec2(0);
glm::vec2 max = glm::vec2(0);

/** @name Creation
* Constructors
*/
///@{
Rect();
~Rect();
Rect(const Rect& other);
Rect& operator=(const Rect& other);
Rect(Rect&&) noexcept;
Rect& operator=(Rect&&) noexcept;
Rect(const glm::vec2 a, const glm::vec2 b);
///@}

/** @name Information
* Details of the rectangle
*/
///@{
glm::vec2 Size() const;
float Area() const;
float Scale() const;
glm::vec2 Center() const;
bool Contains(const glm::vec2& pt) const;
bool Contains(const Rect& other) const;
bool DoesOverlap(const Rect& other) const;
bool IsEmpty() const;
bool IsFinite() const;
///@}

/** @name Modification
*/
///@{
void Union(const glm::vec2 p);
Rect Union(const Rect& other) const;
Rect operator+(const glm::vec2 shift) const;
Rect& operator+=(const glm::vec2 shift);
Rect operator*(const glm::vec2 scale) const;
Rect& operator*=(const glm::vec2 scale);
Rect Transform(const glm::mat3x2& m) const;
///@}

/** @name Conversion
*/
///@{
CrossSection AsCrossSection() const;
///@}
};
/** @} */
} // namespace manifold
163 changes: 0 additions & 163 deletions src/cross_section/src/cross_section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -742,167 +742,4 @@ Polygons CrossSection::ToPolygons() const {
}
return polys;
}

// Rect

/**
* Default constructor is an empty rectangle..
*/
Rect::Rect() {}

Rect::~Rect() = default;
Rect::Rect(Rect&&) noexcept = default;
Rect& Rect::operator=(Rect&&) noexcept = default;
Rect::Rect(const Rect& other) {
min = glm::vec2(other.min);
max = glm::vec2(other.max);
}

/**
* Create a rectangle that contains the two given points.
*/
Rect::Rect(const glm::vec2 a, const glm::vec2 b) {
min = glm::min(a, b);
max = glm::max(a, b);
}

/**
* Return the dimensions of the rectangle.
*/
glm::vec2 Rect::Size() const { return max - min; }

/**
* Return the area of the rectangle.
*/
float Rect::Area() const {
auto sz = Size();
return sz.x * sz.y;
}

/**
* Returns the absolute-largest coordinate value of any contained
* point.
*/
float Rect::Scale() const {
glm::vec2 absMax = glm::max(glm::abs(min), glm::abs(max));
return glm::max(absMax.x, absMax.y);
}

/**
* Returns the center point of the rectangle.
*/
glm::vec2 Rect::Center() const { return 0.5f * (max + min); }

/**
* Does this rectangle contain (includes on border) the given point?
*/
bool Rect::Contains(const glm::vec2& p) const {
return glm::all(glm::greaterThanEqual(p, min)) &&
glm::all(glm::greaterThanEqual(max, p));
}

/**
* Does this rectangle contain (includes equal) the given rectangle?
*/
bool Rect::Contains(const Rect& rect) const {
return glm::all(glm::greaterThanEqual(rect.min, min)) &&
glm::all(glm::greaterThanEqual(max, rect.max));
}

/**
* Does this rectangle overlap the one given (including equality)?
*/
bool Rect::DoesOverlap(const Rect& rect) const {
return min.x <= rect.max.x && min.y <= rect.max.y && max.x >= rect.min.x &&
max.y >= rect.min.y;
}

/**
* Is the rectangle empty (containing no space)?
*/
bool Rect::IsEmpty() const { return max.y <= min.y || max.x <= min.x; };

/**
* Does this recangle have finite bounds?
*/
bool Rect::IsFinite() const {
return glm::all(glm::isfinite(min)) && glm::all(glm::isfinite(max));
}

/**
* Expand this rectangle (in place) to include the given point.
*/
void Rect::Union(const glm::vec2 p) {
min = glm::min(min, p);
max = glm::max(max, p);
}

/**
* Expand this rectangle to include the given Rect.
*/
Rect Rect::Union(const Rect& rect) const {
Rect out;
out.min = glm::min(min, rect.min);
out.max = glm::max(max, rect.max);
return out;
}

/**
* Shift this rectangle by the given vector.
*/
Rect Rect::operator+(const glm::vec2 shift) const {
Rect out;
out.min = min + shift;
out.max = max + shift;
return out;
}

/**
* Shift this rectangle in-place by the given vector.
*/
Rect& Rect::operator+=(const glm::vec2 shift) {
min += shift;
max += shift;
return *this;
}

/**
* Scale this rectangle by the given vector.
*/
Rect Rect::operator*(const glm::vec2 scale) const {
Rect out;
out.min = min * scale;
out.max = max * scale;
return out;
}

/**
* Scale this rectangle in-place by the given vector.
*/
Rect& Rect::operator*=(const glm::vec2 scale) {
min *= scale;
max *= scale;
return *this;
}

/**
* Transform the rectangle by the given axis-aligned affine transform.
*
* Ensure the transform passed in is axis-aligned (rotations are all
* multiples of 90 degrees), or else the resulting rectangle will no longer
* bound properly.
*/
Rect Rect::Transform(const glm::mat3x2& m) const {
Rect rect;
rect.min = m * glm::vec3(min, 1);
rect.max = m * glm::vec3(max, 1);
return rect;
}

/**
* Return a CrossSection with an outline defined by this axis-aligned
* rectangle.
*/
CrossSection Rect::AsCrossSection() const { return CrossSection(*this); }

} // namespace manifold
Loading
Loading