OrcaSlicer latest
OrcaSlicer
Loading...
Searching...
No Matches
Slic3r::SurfaceCollection Class Reference

#include </home/runner/work/OrcaSlicer/OrcaSlicer/src/libslic3r/SurfaceCollection.hpp>

Collaboration diagram for Slic3r::SurfaceCollection:

Public Member Functions

 SurfaceCollection ()=default
 SurfaceCollection (const Surfaces &surfaces)
 SurfaceCollection (Surfaces &&surfaces)
void simplify (double tolerance)
void group (std::vector< SurfacesPtr > *retval)
template<class T>
bool any_internal_contains (const T &item) const
template<class T>
bool any_bottom_contains (const T &item) const
SurfacesPtr filter_by_type (const SurfaceType type) const
SurfacesPtr filter_by_types (std::initializer_list< SurfaceType > types) const
void keep_type (const SurfaceType type)
void keep_types (std::initializer_list< SurfaceType > types)
void remove_type (const SurfaceType type)
void remove_types (std::initializer_list< SurfaceType > types)
void filter_by_type (SurfaceType type, Polygons *polygons) const
void remove_type (const SurfaceType type, ExPolygons *polygons)
void set_type (SurfaceType type)
void change_to_new_type (SurfaceType old_type, SurfaceType new_type)
void clear ()
bool empty () const
size_t size () const
bool has (SurfaceType type) const
Surfaces::const_iterator cbegin () const
Surfaces::const_iterator cend () const
Surfaces::const_iterator begin () const
Surfaces::const_iterator end () const
Surfaces::iterator begin ()
Surfaces::iterator end ()
void set (const SurfaceCollection &coll)
void set (SurfaceCollection &&coll)
void set (const ExPolygons &src, SurfaceType surfaceType)
void set (const ExPolygons &src, const Surface &surfaceTempl)
void set (const Surfaces &src)
void set (ExPolygons &&src, SurfaceType surfaceType)
void set (ExPolygons &&src, const Surface &surfaceTempl)
void set (Surfaces &&src)
void append (const SurfaceCollection &coll)
void append (SurfaceCollection &&coll)
void append (const ExPolygons &src, SurfaceType surfaceType)
void append (const ExPolygons &src, const Surface &surfaceTempl)
void append (const Surfaces &src)
void append (ExPolygons &&src, SurfaceType surfaceType)
void append (ExPolygons &&src, const Surface &surfaceTempl)
void append (Surfaces &&src)
void export_to_svg (const char *path, bool show_labels)

Public Attributes

Surfaces surfaces

Detailed Description

Constructor & Destructor Documentation

◆ SurfaceCollection() [1/3]

Slic3r::SurfaceCollection::SurfaceCollection ( )
default

Referenced by append(), append(), set(), and set().

Here is the caller graph for this function:

◆ SurfaceCollection() [2/3]

Slic3r::SurfaceCollection::SurfaceCollection ( const Surfaces & surfaces)
inline
20: surfaces(surfaces) {};
Surfaces surfaces
Definition SurfaceCollection.hpp:17

References surfaces.

◆ SurfaceCollection() [3/3]

Slic3r::SurfaceCollection::SurfaceCollection ( Surfaces && surfaces)
inline
21: surfaces(std::move(surfaces)) {};

References surfaces.

Member Function Documentation

◆ any_bottom_contains()

template<class T>
bool Slic3r::SurfaceCollection::any_bottom_contains ( const T & item) const
inline
29 {
30 for (const Surface &surface : this->surfaces) if (surface.is_bottom() && surface.expolygon.contains(item)) return true;
31 return false;
32 }

◆ any_internal_contains()

template<class T>
bool Slic3r::SurfaceCollection::any_internal_contains ( const T & item) const
inline
25 {
26 for (const Surface &surface : this->surfaces) if (surface.is_internal() && surface.expolygon.contains(item)) return true;
27 return false;
28 }

◆ append() [1/8]

void Slic3r::SurfaceCollection::append ( const ExPolygons & src,
const Surface & surfaceTempl )
inline
80{ surfaces_append(this->surfaces, src, surfaceTempl); }
void surfaces_append(Surfaces &dst, const ExPolygons &src, SurfaceType surfaceType)
Definition Surface.hpp:254

References Slic3r::surfaces_append().

Here is the call graph for this function:

◆ append() [2/8]

void Slic3r::SurfaceCollection::append ( const ExPolygons & src,
SurfaceType surfaceType )
inline
79{ surfaces_append(this->surfaces, src, surfaceType); }

References Slic3r::surfaces_append().

Here is the call graph for this function:

◆ append() [3/8]

void Slic3r::SurfaceCollection::append ( const SurfaceCollection & coll)
inline
77{ this->append(coll.surfaces); }
void append(const SurfaceCollection &coll)
Definition SurfaceCollection.hpp:77

References SurfaceCollection(), append(), and surfaces.

Referenced by append(), Slic3r::PrintObject::clip_fill_surfaces(), Slic3r::PrintObject::discover_horizontal_shells(), Slic3r::PrintObject::discover_vertical_shells(), Slic3r::Layer::make_perimeters(), set(), set(), set(), set(), set(), and set().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append() [4/8]

void Slic3r::SurfaceCollection::append ( const Surfaces & src)
inline
81{ surfaces_append(this->surfaces, src); }

References Slic3r::surfaces_append().

Here is the call graph for this function:

◆ append() [5/8]

void Slic3r::SurfaceCollection::append ( ExPolygons && src,
const Surface & surfaceTempl )
inline
83{ surfaces_append(this->surfaces, std::move(src), surfaceTempl); }

References Slic3r::surfaces_append().

Here is the call graph for this function:

◆ append() [6/8]

void Slic3r::SurfaceCollection::append ( ExPolygons && src,
SurfaceType surfaceType )
inline
82{ surfaces_append(this->surfaces, std::move(src), surfaceType); }

References Slic3r::surfaces_append().

Here is the call graph for this function:

◆ append() [7/8]

void Slic3r::SurfaceCollection::append ( SurfaceCollection && coll)
inline
78{ this->append(std::move(coll.surfaces)); }

References SurfaceCollection(), and append().

Referenced by append().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ append() [8/8]

void Slic3r::SurfaceCollection::append ( Surfaces && src)
inline
84{ surfaces_append(this->surfaces, std::move(src)); }

References Slic3r::surfaces_append().

Here is the call graph for this function:

◆ begin() [1/2]

Surfaces::iterator Slic3r::SurfaceCollection::begin ( )
inline
65{ return this->surfaces.begin(); }

◆ begin() [2/2]

Surfaces::const_iterator Slic3r::SurfaceCollection::begin ( ) const
inline
63{ return this->surfaces.cbegin(); }

◆ cbegin()

Surfaces::const_iterator Slic3r::SurfaceCollection::cbegin ( ) const
inline
61{ return this->surfaces.cbegin(); }

◆ cend()

Surfaces::const_iterator Slic3r::SurfaceCollection::cend ( ) const
inline
62{ return this->surfaces.cend(); }

◆ change_to_new_type()

void Slic3r::SurfaceCollection::change_to_new_type ( SurfaceType old_type,
SurfaceType new_type )
inline
46 {
47 for (Surface& surface : this->surfaces)
48 if (surface.surface_type == old_type)
49 surface.surface_type = new_type;
50 }

◆ clear()

void Slic3r::SurfaceCollection::clear ( )
inline
52{ surfaces.clear(); }

References surfaces.

Referenced by set(), set(), set(), set(), set(), and set().

Here is the caller graph for this function:

◆ empty()

bool Slic3r::SurfaceCollection::empty ( ) const
inline
53{ return surfaces.empty(); }

References surfaces.

◆ end() [1/2]

Surfaces::iterator Slic3r::SurfaceCollection::end ( )
inline
66{ return this->surfaces.end(); }

◆ end() [2/2]

Surfaces::const_iterator Slic3r::SurfaceCollection::end ( ) const
inline
64{ return this->surfaces.cend(); }

◆ export_to_svg()

void Slic3r::SurfaceCollection::export_to_svg ( const char * path,
bool show_labels )
151{
152 BoundingBox bbox;
153 for (Surfaces::const_iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface)
154 bbox.merge(get_extents(surface->expolygon));
156 Point legend_pos(bbox.min(0), bbox.max(1));
157 bbox.merge(Point(std::max(bbox.min(0) + legend_size(0), bbox.max(0)), bbox.max(1) + legend_size(1)));
158
159 SVG svg(path, bbox);
160 const float transparency = 0.5f;
161 for (Surfaces::const_iterator surface = this->surfaces.begin(); surface != this->surfaces.end(); ++surface) {
162 svg.draw(surface->expolygon, surface_type_to_color_name(surface->surface_type), transparency);
163 if (show_labels) {
164 int idx = int(surface - this->surfaces.begin());
165 char label[64];
166 sprintf(label, "%d", idx);
167 svg.draw_text(surface->expolygon.contour.points.front(), label, "black");
168 }
169 }
170 export_surface_type_legend_to_svg(svg, legend_pos);
171 svg.Close();
172}
Kernel::Point_3 Point
Definition MeshRepair.cpp:81
BoundingBox get_extents(const ExPolygonsWithIds &e)
Definition Emboss.cpp:1374
const char * surface_type_to_color_name(const SurfaceType surface_type)
Definition Surface.cpp:39
void export_surface_type_legend_to_svg(SVG &svg, const Point &pos)
Definition Surface.cpp:59
Point export_surface_type_legend_to_svg_box_size()
Definition Surface.cpp:54

References Slic3r::SVG::Close(), Slic3r::SVG::draw(), Slic3r::SVG::draw_text(), Slic3r::export_surface_type_legend_to_svg(), Slic3r::export_surface_type_legend_to_svg_box_size(), Slic3r::get_extents(), Slic3r::BoundingBoxBase< PointType, APointsType >::max, Slic3r::BoundingBoxBase< PointType, APointsType >::merge(), Slic3r::BoundingBoxBase< PointType, APointsType >::min, Slic3r::surface_type_to_color_name(), and surfaces.

Referenced by Slic3r::LayerRegion::process_external_surfaces().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filter_by_type() [1/2]

SurfacesPtr Slic3r::SurfaceCollection::filter_by_type ( const SurfaceType type) const
56{
57 SurfacesPtr ss;
58 for (const Surface &surface : this->surfaces)
59 if (surface.surface_type == type)
60 ss.push_back(&surface);
61 return ss;
62}
std::vector< const Surface * > SurfacesPtr
Definition Surface.hpp:124

References surfaces.

Referenced by Slic3r::PrintObject::discover_horizontal_shells(), and Slic3r::PrintObject::discover_vertical_shells().

Here is the caller graph for this function:

◆ filter_by_type() [2/2]

void Slic3r::SurfaceCollection::filter_by_type ( SurfaceType type,
Polygons * polygons ) const
74{
75 for (const Surface &surface : this->surfaces)
76 if (surface.surface_type == type)
77 polygons_append(*polygons, to_polygons(surface.expolygon));
78}
Polygons to_polygons(const ExPolygon &src)
Definition ExPolygon.hpp:307
void polygons_append(Polygons &dst, const ExPolygon &src)
Definition ExPolygon.hpp:411

References Slic3r::polygons_append(), surfaces, and Slic3r::to_polygons().

Here is the call graph for this function:

◆ filter_by_types()

SurfacesPtr Slic3r::SurfaceCollection::filter_by_types ( std::initializer_list< SurfaceType > types) const
65{
66 SurfacesPtr ss;
67 for (const Surface &surface : this->surfaces)
68 if (std::find(types.begin(), types.end(), surface.surface_type) != types.end())
69 ss.push_back(&surface);
70 return ss;
71}

References surfaces.

Referenced by Slic3r::PrintObject::discover_vertical_shells().

Here is the caller graph for this function:

◆ group()

void Slic3r::SurfaceCollection::group ( std::vector< SurfacesPtr > * retval)
36{
37 for (Surfaces::iterator it = this->surfaces.begin(); it != this->surfaces.end(); ++it) {
38 // find a group with the same properties
39 SurfacesPtr* group = NULL;
40 for (std::vector<SurfacesPtr>::iterator git = retval->begin(); git != retval->end(); ++git)
41 if (! git->empty() && surfaces_could_merge(*git->front(), *it)) {
42 group = &*git;
43 break;
44 }
45 // if no group with these properties exists, add one
46 if (group == NULL) {
47 retval->resize(retval->size() + 1);
48 group = &retval->back();
49 }
50 // append surface to group
51 group->push_back(&*it);
52 }
53}
void group(std::vector< SurfacesPtr > *retval)
Definition SurfaceCollection.cpp:35
bool surfaces_could_merge(const Surface &s1, const Surface &s2)
Definition Surface.hpp:301

References group(), surfaces, and Slic3r::surfaces_could_merge().

Referenced by Slic3r::PrintObject::discover_horizontal_shells(), and group().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ has()

bool Slic3r::SurfaceCollection::has ( SurfaceType type) const
inline
55 {
56 for (const Surface &surface : this->surfaces)
57 if (surface.surface_type == type) return true;
58 return false;
59 }

◆ keep_type()

void Slic3r::SurfaceCollection::keep_type ( const SurfaceType type)
81{
82 size_t j = 0;
83 for (size_t i = 0; i < surfaces.size(); ++ i) {
84 if (surfaces[i].surface_type == type) {
85 if (j < i)
86 std::swap(surfaces[i], surfaces[j]);
87 ++ j;
88 }
89 }
90 if (j < surfaces.size())
91 surfaces.erase(surfaces.begin() + j, surfaces.end());
92}

References surfaces.

◆ keep_types()

void Slic3r::SurfaceCollection::keep_types ( std::initializer_list< SurfaceType > types)
95{
96 size_t j = 0;
97 for (size_t i = 0; i < surfaces.size(); ++ i)
98 if (std::find(types.begin(), types.end(), surfaces[i].surface_type) != types.end()) {
99 if (j < i)
100 std::swap(surfaces[i], surfaces[j]);
101 ++ j;
102 }
103 if (j < surfaces.size())
104 surfaces.erase(surfaces.begin() + j, surfaces.end());
105}

References surfaces.

Referenced by Slic3r::PrintObject::discover_horizontal_shells(), and Slic3r::PrintObject::discover_vertical_shells().

Here is the caller graph for this function:

◆ remove_type() [1/2]

void Slic3r::SurfaceCollection::remove_type ( const SurfaceType type)
108{
109 size_t j = 0;
110 for (size_t i = 0; i < surfaces.size(); ++ i) {
111 if (surfaces[i].surface_type != type) {
112 if (j < i)
113 std::swap(surfaces[i], surfaces[j]);
114 ++ j;
115 }
116 }
117 if (j < surfaces.size())
118 surfaces.erase(surfaces.begin() + j, surfaces.end());
119}

References surfaces.

◆ remove_type() [2/2]

void Slic3r::SurfaceCollection::remove_type ( const SurfaceType type,
ExPolygons * polygons )
122{
123 size_t j = 0;
124 for (size_t i = 0; i < surfaces.size(); ++ i) {
125 if (Surface &surface = surfaces[i]; surface.surface_type == type) {
126 polygons->emplace_back(std::move(surface.expolygon));
127 } else {
128 if (j < i)
129 std::swap(surfaces[i], surfaces[j]);
130 ++ j;
131 }
132 }
133 if (j < surfaces.size())
134 surfaces.erase(surfaces.begin() + j, surfaces.end());
135}

References surfaces.

◆ remove_types()

void Slic3r::SurfaceCollection::remove_types ( std::initializer_list< SurfaceType > types)
138{
139 size_t j = 0;
140 for (size_t i = 0; i < surfaces.size(); ++ i)
141 if (std::find(types.begin(), types.end(), surfaces[i].surface_type) == types.end()) {
142 if (j < i)
143 std::swap(surfaces[i], surfaces[j]);
144 ++ j;
145 }
146 if (j < surfaces.size())
147 surfaces.erase(surfaces.begin() + j, surfaces.end());
148}

References surfaces.

Referenced by Slic3r::PrintObject::clip_fill_surfaces().

Here is the caller graph for this function:

◆ set() [1/8]

void Slic3r::SurfaceCollection::set ( const ExPolygons & src,
const Surface & surfaceTempl )
inline
71{ clear(); this->append(src, surfaceTempl); }
void clear()
Definition SurfaceCollection.hpp:52

References append(), and clear().

Here is the call graph for this function:

◆ set() [2/8]

void Slic3r::SurfaceCollection::set ( const ExPolygons & src,
SurfaceType surfaceType )
inline
70{ clear(); this->append(src, surfaceType); }

References append(), and clear().

Here is the call graph for this function:

◆ set() [3/8]

void Slic3r::SurfaceCollection::set ( const SurfaceCollection & coll)
inline
68{ surfaces = coll.surfaces; }

References SurfaceCollection(), and surfaces.

Referenced by Slic3r::PrintObject::discover_horizontal_shells(), and Slic3r::Layer::restore_untyped_slices_no_extra_perimeters().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set() [4/8]

void Slic3r::SurfaceCollection::set ( const Surfaces & src)
inline
72{ clear(); this->append(src); }

References append(), and clear().

Here is the call graph for this function:

◆ set() [5/8]

void Slic3r::SurfaceCollection::set ( ExPolygons && src,
const Surface & surfaceTempl )
inline
74{ clear(); this->append(std::move(src), surfaceTempl); }

References append(), and clear().

Here is the call graph for this function:

◆ set() [6/8]

void Slic3r::SurfaceCollection::set ( ExPolygons && src,
SurfaceType surfaceType )
inline
73{ clear(); this->append(std::move(src), surfaceType); }

References append(), and clear().

Here is the call graph for this function:

◆ set() [7/8]

void Slic3r::SurfaceCollection::set ( SurfaceCollection && coll)
inline
69{ surfaces = std::move(coll.surfaces); }

References SurfaceCollection(), and surfaces.

Here is the call graph for this function:

◆ set() [8/8]

void Slic3r::SurfaceCollection::set ( Surfaces && src)
inline
75{ clear(); this->append(std::move(src)); }

References append(), and clear().

Here is the call graph for this function:

◆ set_type()

void Slic3r::SurfaceCollection::set_type ( SurfaceType type)
inline
41 {
42 for (Surface &surface : this->surfaces)
43 surface.surface_type = type;
44 }

◆ simplify()

void Slic3r::SurfaceCollection::simplify ( double tolerance)
20{
21 Surfaces ss;
22 for (Surfaces::const_iterator it_s = this->surfaces.begin(); it_s != this->surfaces.end(); ++it_s) {
23 ExPolygons expp;
24 it_s->expolygon.simplify(tolerance, &expp);
25 for (ExPolygons::const_iterator it_e = expp.begin(); it_e != expp.end(); ++it_e) {
26 Surface s = *it_s;
27 s.expolygon = *it_e;
28 ss.push_back(s);
29 }
30 }
31 this->surfaces = ss;
32}
std::vector< ExPolygon > ExPolygons
Definition ExPolygon.hpp:20
std::vector< Surface > Surfaces
Definition Surface.hpp:123

References Slic3r::Surface::expolygon, and surfaces.

◆ size()

size_t Slic3r::SurfaceCollection::size ( ) const
inline
54{ return surfaces.size(); }

References surfaces.

Referenced by Slic3r::group_fills().

Here is the caller graph for this function:

Member Data Documentation

◆ surfaces


The documentation for this class was generated from the following files: