Skip to content

Commit 6727810

Browse files
committed
Finalize code cleaning and documentation
CURA-12361
1 parent e181857 commit 6727810

File tree

12 files changed

+342
-84
lines changed

12 files changed

+342
-84
lines changed

doc/bridging_skin_support.svg

Lines changed: 139 additions & 0 deletions
Loading

include/LayerPlanBuffer.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,13 @@ class LayerPlanBuffer
8585
*/
8686
void flush();
8787

88+
/*!
89+
* Gets the layer plan for the given layer, once it has been completed. It will wait for completion if necessary
90+
* @param layer_nr The layer number to get the plan for
91+
* @return The completed layer plan
92+
* @warning Make sure you always ask for a layer plan below the one that is being processed. Since the layers processing is started bottom to top and the engine can be run
93+
* mono-threaded, asking for a layer above could lead to a deadlock because the processing of this layer will never start.
94+
*/
8895
const LayerPlan* getCompletedLayerPlan(const LayerIndex& layer_nr) const;
8996

9097
private:

include/geometry/Point2LL.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ namespace cura
3232
{
3333

3434
class Point3LL;
35-
class AngleRadians;
3635

3736
/* 64bit Points are used mostly throughout the code, these are the 2D points from ClipperLib */
3837
using Point2LL = ClipperLib::IntPoint;
@@ -195,8 +194,6 @@ INLINE coord_t cross(const Point2LL& p0, const Point2LL& p1)
195194
return p0.X * p1.Y - p0.Y * p1.X;
196195
}
197196

198-
AngleRadians vAngle(const Point2LL& vector);
199-
200197
// Identity function, used to be able to make templated algorithms where the input is sometimes points, sometimes things that contain or can be converted to points.
201198
INLINE const Point2LL& make_point(const Point2LL& p)
202199
{
@@ -220,6 +217,7 @@ inline Point2LL lerp(const Point2LL& a, const Point2LL& b, const double t)
220217
return Point2LL(lerp(a.X, b.X, t), lerp(a.Y, b.Y, t));
221218
}
222219

220+
/*! Returns true if the points are equal or close enough to each other to be considered equal */
223221
inline bool fuzzy_equal(const Point2LL& a, const Point2LL& b)
224222
{
225223
return fuzzy_equal(a.X, b.X) && fuzzy_equal(a.Y, b.Y);

include/geometry/PointsSet.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,9 @@ class PointsSet
7373
return points_.size();
7474
}
7575

76-
bool push_back(const Point2LL& point, const bool only_if_forming_segment = false)
76+
void push_back(const Point2LL& point)
7777
{
78-
if (only_if_forming_segment && ! points_.empty() && fuzzy_equal(point, points_.back()))
79-
{
80-
return false;
81-
}
82-
8378
points_.push_back(point);
84-
return true;
8579
}
8680

8781
/*! \brief Pushes an entire set at the end */

include/geometry/Polygon.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,6 @@ class Polygon : public ClosedPolyline
9090
return ClipperLib::Area(getPoints());
9191
}
9292

93-
[[nodiscard]] bool isHole() const
94-
{
95-
return area() < 0.0;
96-
}
97-
9893
[[nodiscard]] Point2LL centerOfMass() const;
9994

10095
[[nodiscard]] Shape offset(int distance, ClipperLib::JoinType join_type = ClipperLib::jtMiter, double miter_limit = 1.2) const;

include/geometry/Polyline.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,23 @@ class Polyline : public PointsSet
130130

131131
[[nodiscard]] bool shorterThan(const coord_t check_length) const;
132132

133+
/*!
134+
* Adds a point to this set, but only if it forms a proper new segment i.r.t the current points in the set
135+
* @param point The point to be added
136+
* @return True if the point has actually been added, false otherwise
137+
* @note The point will also be added if the current list is empty
138+
*/
139+
bool pushBackIfFormingSegment(const Point2LL& point)
140+
{
141+
if (getPoints().empty() || ! fuzzy_equal(point, getPoints().back()))
142+
{
143+
push_back(point);
144+
return true;
145+
}
146+
147+
return false;
148+
}
149+
133150
void reverse()
134151
{
135152
ClipperLib::ReversePath(getPoints());

include/settings/types/Angle.h

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ class AngleRadians
105105
/*
106106
* \brief Default constructor setting the angle to 0.
107107
*/
108-
constexpr AngleRadians() noexcept = default;
108+
AngleRadians() noexcept = default;
109109

110110
/*!
111111
* \brief Converts an angle from degrees into radians.
112112
*/
113-
constexpr AngleRadians(const AngleDegrees& value);
113+
AngleRadians(const AngleDegrees& value);
114114

115115
/*
116116
* \brief Translate the double value in degrees to an AngleRadians instance.
@@ -166,16 +166,11 @@ inline AngleDegrees::AngleDegrees(const AngleRadians& value)
166166
{
167167
}
168168

169-
constexpr inline AngleRadians::AngleRadians(const AngleDegrees& value)
169+
inline AngleRadians::AngleRadians(const AngleDegrees& value)
170170
: value_(value.value_ * TAU / 360.0)
171171
{
172172
}
173173

174-
inline double normalizeTo(const double angle, const double max)
175-
{
176-
return std::fmod(std::fmod(angle, max) + max, max);
177-
}
178-
179174
/*!
180175
* \brief Safe call to "std::tan" which limits the higher angle value to something slightly less that π/2 so that when
181176
* the given angle is higher that this value, the returned value is not a huge number
@@ -189,14 +184,6 @@ inline double boundedTan(const AngleRadians& angle)
189184
return std::tan(std::min(static_cast<double>(angle), std::numbers::pi / 2.0 - 0.001));
190185
}
191186

192-
inline AngleDegrees nonOrientedDelta(const AngleDegrees& angle1, const AngleDegrees& angle2)
193-
{
194-
const double normalized_angle1 = normalizeTo(angle1.value_, 180);
195-
const double normalized_angle2 = normalizeTo(angle2.value_, 180);
196-
const double diff = std::fabs(normalized_angle1 - normalized_angle2);
197-
return std::min(diff, 180.0 - diff);
198-
}
199-
200187
} // namespace cura
201188

202189
#endif // ANGLE_H

include/utils/Coord_t.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,43 @@ template<utils::floating_point FactorType>
3838
return std::llrint(std::lerp(static_cast<double>(a), static_cast<double>(b), t));
3939
}
4040

41+
/*! Returns true if the given value is null or small enough to be considered null */
4142
[[nodiscard]] inline bool fuzzy_is_null(const coord_t value)
4243
{
4344
return std::abs(value) <= EPSILON;
4445
}
4546

47+
/*! Returns true if the given values are equal or close enough to be considered equal */
4648
[[nodiscard]] inline bool fuzzy_equal(const coord_t a, const coord_t b)
4749
{
4850
return fuzzy_is_null(b - a);
4951
}
5052

53+
/*! Returns true if the given values are not equal and different enough to be considered not equal */
5154
[[nodiscard]] inline bool fuzzy_not_equal(const coord_t a, const coord_t b)
5255
{
5356
return ! fuzzy_equal(a, b);
5457
}
5558

59+
/*! Returns true if the given \a value is greater enough to \b to be considered greater */
5660
[[nodiscard]] inline bool fuzzy_is_greater(const coord_t a, const coord_t b)
5761
{
5862
return a - b > EPSILON;
5963
}
6064

65+
/*! Returns true if the given \a value is greater or close enough to \b to be considered greater or equal */
6166
[[nodiscard]] inline bool fuzzy_is_greater_or_equal(const coord_t a, const coord_t b)
6267
{
6368
return a > b - EPSILON;
6469
}
6570

71+
/*! Returns true if the given \a value is lesser enough to \b to be considered lesser */
6672
[[nodiscard]] inline bool fuzzy_is_lesser(const coord_t a, const coord_t b)
6773
{
6874
return b - a > EPSILON;
6975
}
7076

77+
/*! Returns true if the given \a value is lesser or close enough to \b to be considered lesser or equal */
7178
[[nodiscard]] inline bool fuzzy_is_lesser_or_equal(const coord_t a, const coord_t b)
7279
{
7380
return b > a - EPSILON;

include/utils/linearAlg2D.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,22 @@ class LinearAlg2D
8686

8787
static bool lineLineIntersection(const Point2LL& a, const Point2LL& b, const Point2LL& c, const Point2LL& d, Point2LL& output);
8888

89+
/*!
90+
* Computes the intersection between a line and a horizontal line
91+
* @param p1 One point on the line
92+
* @param p2 An other point on the line
93+
* @param line_y The Y coordinates of the horizontal line to intersect with
94+
* @return The x coordinate of the intersection, or nullopt if they don't intersect
95+
*/
8996
static std::optional<coord_t> lineHorizontalLineIntersection(const Point2LL& p1, const Point2LL& p2, const coord_t line_y);
9097

98+
/*!
99+
* Computes the intersection between a segment and a horizontal line
100+
* @param p1 The segment start point
101+
* @param p2 The segment end point
102+
* @param line_y The Y coordinates of the horizontal line to intersect with
103+
* @return The x coordinate of the intersection, or nullopt if they don't intersect
104+
*/
91105
static std::optional<coord_t> segmentHorizontalLineIntersection(const Point2LL& p1, const Point2LL& p2, const coord_t line_y);
92106

93107
/*!

include/utils/math.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ template<utils::floating_point T>
143143
return std::abs(value) < (std::numeric_limits<T>::epsilon() * 100.0);
144144
}
145145

146+
/*!
147+
* Calculates the sign of a numeric value, 1 if positive and -1 if negative
148+
* @note 0 is also considered as positive
149+
*/
146150
template<utils::numeric T>
147151
[[nodiscard]] int8_t sign(T value)
148152
{

0 commit comments

Comments
 (0)