Skip to content

Commit baf8a1c

Browse files
committed
Move structures to their own files and convert to classes
CURA-12361
1 parent 17f4221 commit baf8a1c

15 files changed

+730
-434
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ endif ()
4343

4444
set(engine_SRCS # Except main.cpp.
4545
src/Application.cpp
46-
src/bridge.cpp
4746
src/ConicalOverhang.cpp
4847
src/ExtruderPlan.cpp
4948
src/ExtruderTrain.cpp
@@ -99,6 +98,12 @@ set(engine_SRCS # Except main.cpp.
9998
src/BeadingStrategy/WideningBeadingStrategy.cpp
10099
src/BeadingStrategy/OuterWallInsetBeadingStrategy.cpp
101100

101+
src/bridge/bridge.cpp
102+
src/bridge/ExpansionRange.cpp
103+
src/bridge/SegmentOverlappingData.cpp
104+
src/bridge/TransformedSegment.cpp
105+
src/bridge/TransformedShape.cpp
106+
102107
src/communication/ArcusCommunication.cpp
103108
src/communication/ArcusCommunicationPrivate.cpp
104109
src/communication/CommandLine.cpp

doc/bridging_skin_support.svg

Lines changed: 5 additions & 5 deletions
Loading

include/bridge/ExpansionRange.h

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Copyright (c) 2025 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#ifndef BRIDGE_EXPANSIONRANGE_H
5+
#define BRIDGE_EXPANSIONRANGE_H
6+
7+
#include <optional>
8+
9+
#include "bridge/TransformedSegment.h"
10+
11+
namespace cura
12+
{
13+
14+
struct SegmentOverlapping;
15+
16+
/*! Helper structure containing a vertical range that has been projected (or not) for a segment */
17+
class ExpansionRange
18+
{
19+
public:
20+
/*!
21+
* Constructs a range that has been projected to an infill line
22+
* @param segment The actual projected segment, cropped to the range
23+
* @param supporting_segment The infill line which is supporting this segment
24+
*/
25+
ExpansionRange(const TransformedSegment& segment, const TransformedSegment* supporting_segment)
26+
: data_{ .segment = segment }
27+
, supporting_segment_(supporting_segment)
28+
, is_projected_(true)
29+
{
30+
}
31+
32+
/*!
33+
* Constructs a range that has not been projected
34+
* @param min_y The range bottom Y coordinate
35+
* @param max_y The range maximum Y coordinate
36+
* @param expanded_segment The segment being expanded
37+
*/
38+
ExpansionRange(const coord_t min_y, const coord_t max_y, const TransformedSegment* expanded_segment)
39+
: data_{ .range = { .min_y = min_y, .max_y = max_y } }
40+
, supporting_segment_(expanded_segment)
41+
, is_projected_(false)
42+
{
43+
}
44+
45+
coord_t minY() const
46+
{
47+
return is_projected_ ? data_.segment.minY() : data_.range.min_y;
48+
}
49+
50+
coord_t maxY() const
51+
{
52+
return is_projected_ ? data_.segment.maxY() : data_.range.max_y;
53+
}
54+
55+
/*!
56+
* Calculate the horizontal overlapping between this range and an other segment, given the expand direction. Overlapping means that the new segment is on the right (or left)
57+
* of the actual segment on a horizontal band formed by the segment top and bottom
58+
* @param other The other segment that may be overlapping
59+
* @param expand_direction The expand direction, 1 means expand to the right, -1 expand to the left
60+
* @return The overlapping details if the segment actually overlap, or nullopt if it doesn't
61+
*/
62+
std::optional<SegmentOverlapping> calculateOverlapping(const TransformedSegment& other, const int8_t expand_direction) const;
63+
64+
/*! Move the range maximum Y coordinate down, actually cropping it */
65+
void cropTop(const coord_t new_max_y)
66+
{
67+
if (is_projected_)
68+
{
69+
data_.segment.cropTop(new_max_y);
70+
}
71+
else
72+
{
73+
data_.range.max_y = new_max_y;
74+
}
75+
}
76+
77+
/*! Move the segment minimum Y coordinate up, actually cropping it */
78+
void cropBottom(const coord_t new_min_y)
79+
{
80+
if (is_projected_)
81+
{
82+
data_.segment.cropBottom(new_min_y);
83+
}
84+
else
85+
{
86+
data_.range.min_y = new_min_y;
87+
}
88+
}
89+
90+
/*! Indicates if the range is still valid, e.g. doesn't have a (almost) null height */
91+
bool isValid() const
92+
{
93+
return fuzzy_not_equal(maxY(), minY());
94+
}
95+
96+
void setProjectedEnd(const Point2LL& end)
97+
{
98+
data_.segment.setEnd(end);
99+
}
100+
101+
const TransformedSegment* getSupportingSegment() const
102+
{
103+
return supporting_segment_;
104+
}
105+
106+
bool isProjected() const
107+
{
108+
return is_projected_;
109+
}
110+
111+
const TransformedSegment& getProjectedSegment() const
112+
{
113+
return data_.segment;
114+
}
115+
116+
private:
117+
union
118+
{
119+
// The segment that has been projected
120+
TransformedSegment segment;
121+
// The range that has not been projected
122+
struct
123+
{
124+
coord_t min_y;
125+
coord_t max_y;
126+
} range;
127+
} data_;
128+
129+
// The supporting segment that this range is based upon, or the segment being expanded if it has not been projected
130+
const TransformedSegment* supporting_segment_;
131+
132+
// True if this range has been projected to a supported infill line, in which case you can use data.segment. Otherwise the range has not been projected and only contains
133+
// its Y range in data.range.
134+
bool is_projected_;
135+
};
136+
137+
} // namespace cura
138+
139+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2025 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#ifndef BRIDGE_SEGMENTOVERLAPPING_H
5+
#define BRIDGE_SEGMENTOVERLAPPING_H
6+
7+
#include "bridge/SegmentOverlappingType.h"
8+
#include "bridge/TransformedSegment.h"
9+
10+
namespace cura
11+
{
12+
13+
struct SegmentOverlapping
14+
{
15+
SegmentOverlappingType type;
16+
TransformedSegment other_overlapping_part;
17+
};
18+
19+
} // namespace cura
20+
21+
#endif
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// Copyright (c) 2025 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#ifndef BRIDGE_SEGMENTOVERLAPPINGDATA_H
5+
#define BRIDGE_SEGMENTOVERLAPPINGDATA_H
6+
7+
#include "geometry/Point2LL.h"
8+
#include "utils/Coord_t.h"
9+
10+
namespace cura
11+
{
12+
13+
class TransformedSegment;
14+
15+
/*! Helper structure that calculate the basic coordinates data to be used to perform segments overlapping calculation */
16+
struct SegmentOverlappingData
17+
{
18+
coord_t y_min;
19+
coord_t y_max;
20+
coord_t this_x_min;
21+
coord_t this_x_max;
22+
coord_t other_x_min;
23+
coord_t other_x_max;
24+
25+
/*!
26+
* Builds the basic segment overlapping data
27+
* @param this_min_y The minimum Y coordinate of the original segment
28+
* @param this_max_y The maximum Y coordinate of the original segment
29+
* @param other_min_y The minimum Y coordinate of the tested segment
30+
* @param other_max_y The maximum Y coordinate of the tested segment
31+
* @param this_start The actual start position of the original segment, which may be null
32+
* @param this_end The actual end position of the original segment, which may be null
33+
* @param other_start The actual start position of the tested segment
34+
* @param other_end The actual end position of the tested segment
35+
*/
36+
SegmentOverlappingData(
37+
const coord_t this_min_y,
38+
const coord_t this_max_y,
39+
const coord_t other_min_y,
40+
const coord_t other_max_y,
41+
const Point2LL* this_start,
42+
const Point2LL* this_end,
43+
const Point2LL& other_start,
44+
const Point2LL& other_end);
45+
46+
/*! Make the cropped segment that is actually overlapping over the original segment, which may be part of all of the initial segment */
47+
TransformedSegment makeOtherOverlappingPart() const;
48+
};
49+
50+
} // namespace cura
51+
52+
#endif
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright (c) 2025 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#ifndef BRIDGE_SEGMENTOVERLAPPINGTYPE_H
5+
#define BRIDGE_SEGMENTOVERLAPPINGTYPE_H
6+
7+
namespace cura
8+
{
9+
10+
/*! Enumeration containing the overlapping type of two segments in the bridging projection direction */
11+
enum class SegmentOverlappingType
12+
{
13+
Full, // The segment fully overlaps with the base segment
14+
Bottom, // The segment overlaps with the base segment only on its bottom part
15+
Top, // The segment overlaps with the base segment only on its top part
16+
Middle, // The segment overlaps with the base segment somewhere in the middle, but not top neither bottom
17+
};
18+
19+
} // namespace cura
20+
21+
#endif
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
// Copyright (c) 2025 Ultimaker B.V.
2+
// CuraEngine is released under the terms of the AGPLv3 or higher.
3+
4+
#ifndef BRIDGE_TRANSFORMEDSEGMENT_H
5+
#define BRIDGE_TRANSFORMEDSEGMENT_H
6+
7+
#include <optional>
8+
9+
#include "geometry/Point2LL.h"
10+
11+
namespace cura
12+
{
13+
14+
enum class SegmentOverlappingType;
15+
struct SegmentOverlapping;
16+
class PointMatrix;
17+
18+
/*! Base structure tha represents a segment that has been transformed in the space where the bridging lines are horizontal */
19+
class TransformedSegment
20+
{
21+
public:
22+
TransformedSegment() = default;
23+
24+
TransformedSegment(const Point2LL& transformed_start, const Point2LL& transformed_end)
25+
: start_(transformed_start)
26+
, end_(transformed_end)
27+
{
28+
updateMinMax();
29+
}
30+
31+
TransformedSegment(const Point2LL& start, const Point2LL& end, const PointMatrix& matrix);
32+
33+
void setStart(const Point2LL& transformed_start)
34+
{
35+
start_ = transformed_start;
36+
updateMinMax();
37+
}
38+
39+
void setEnd(const Point2LL& transformed_end)
40+
{
41+
end_ = transformed_end;
42+
updateMinMax();
43+
}
44+
45+
void updateMinMax();
46+
47+
coord_t minY() const
48+
{
49+
return min_y_;
50+
}
51+
52+
coord_t maxY() const
53+
{
54+
return max_y_;
55+
}
56+
57+
const Point2LL& getStart() const
58+
{
59+
return start_;
60+
}
61+
62+
const Point2LL& getEnd() const
63+
{
64+
return end_;
65+
}
66+
67+
/*!
68+
* Calculate the horizontal overlapping between this segment and an other segment, given the expand direction. Overlapping means that the new segment is on the right (or left)
69+
* of the actual segment on a horizontal band formed by the segment top and bottom
70+
* @param other The other segment that may be overlapping
71+
* @param expand_direction The expand direction, 1 means expand to the right, -1 expand to the left
72+
* @return The overlapping details if the segment actually overlap, or nullopt if it doesn't
73+
*/
74+
std::optional<SegmentOverlapping> calculateOverlapping(const TransformedSegment& other, const int8_t expand_direction) const;
75+
76+
/*! Move the segment maximum Y coordinate down, actually cropping it */
77+
void cropTop(const coord_t new_max_y);
78+
79+
/*! Move the segment minimum Y coordinate up, actually cropping it */
80+
void cropBottom(const coord_t new_min_y);
81+
82+
/*! Calculate an overlapping type, given whether the segments overlap on the top, bottom or both. Only in case there is no segment intersection. */
83+
static SegmentOverlappingType makeNonIntersectingOverlapping(const bool overlap_top, const bool overlap_bottom);
84+
85+
private:
86+
Point2LL start_;
87+
Point2LL end_;
88+
coord_t min_y_{ 0 };
89+
coord_t max_y_{ 0 };
90+
};
91+
92+
} // namespace cura
93+
94+
#endif

0 commit comments

Comments
 (0)