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

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

Collaboration diagram for Slic3r::MutablePolygon:

Classes

class  const_iterator
class  iterator
class  range
struct  LinkedPoint

Public Types

using IndexType = int32_t
using PointType = Point

Public Member Functions

 MutablePolygon ()=default
 MutablePolygon (const Polygon &rhs, size_t reserve=0)
 MutablePolygon (std::initializer_list< Point > rhs, size_t reserve=0)
template<typename IT>
 MutablePolygon (IT begin, IT end, size_t reserve=0)
template<typename IT>
void assign (IT begin, IT end, size_t reserve=0)
void assign (const Polygon &rhs, size_t reserve=0)
void polygon (Polygon &out) const
Polygon polygon () const
bool empty () const
size_t size () const
size_t capacity () const
bool valid () const
void clear ()
iterator begin ()
const_iterator cbegin () const
const_iterator begin () const
iterator end ()
const_iterator cend () const
const_iterator end () const
iterator remove (const iterator it)
iterator insert (const iterator it, const PointType pt)

Private Member Functions

LinkedPoint & at (IndexType i)
const LinkedPoint & at (IndexType i) const
template<typename IT>
void assign_inner (IT begin, IT end, size_t reserve)
IndexType remove (const IndexType i)
IndexType insert (const IndexType i, const Point pt)

Private Attributes

std::vector< LinkedPoint > m_data
IndexType m_size { 0 }
IndexType m_head { IndexType(-1) }
IndexType m_head_free { IndexType(-1) }

Detailed Description


Class Documentation

◆ Slic3r::MutablePolygon::LinkedPoint

struct Slic3r::MutablePolygon::LinkedPoint
Collaboration diagram for Slic3r::MutablePolygon::LinkedPoint:
Class Members
IndexType next
PointType point
IndexType prev

Member Typedef Documentation

◆ IndexType

◆ PointType

Constructor & Destructor Documentation

◆ MutablePolygon() [1/4]

Slic3r::MutablePolygon::MutablePolygon ( )
default

Referenced by MutablePolygon(), MutablePolygon(), and Slic3r::MutablePolygon::range::range().

Here is the caller graph for this function:

◆ MutablePolygon() [2/4]

Slic3r::MutablePolygon::MutablePolygon ( const Polygon & rhs,
size_t reserve = 0 )
inline
136: MutablePolygon(rhs.points.begin(), rhs.points.end(), reserve) {}

References MutablePolygon(), begin(), and end().

Here is the call graph for this function:

◆ MutablePolygon() [3/4]

Slic3r::MutablePolygon::MutablePolygon ( std::initializer_list< Point > rhs,
size_t reserve = 0 )
inline
137: MutablePolygon(rhs.begin(), rhs.end(), reserve) {}

References MutablePolygon(), begin(), and end().

Here is the call graph for this function:

◆ MutablePolygon() [4/4]

template<typename IT>
Slic3r::MutablePolygon::MutablePolygon ( IT begin,
IT end,
size_t reserve = 0 )
inline
140 {
141 this->assign_inner(begin, end, reserve);
142 };
void assign_inner(IT begin, IT end, size_t reserve)
Definition MutablePolygon.hpp:214
iterator end()
Definition MutablePolygon.hpp:183
iterator begin()
Definition MutablePolygon.hpp:179

References assign_inner(), begin(), and end().

Here is the call graph for this function:

Member Function Documentation

◆ assign() [1/2]

void Slic3r::MutablePolygon::assign ( const Polygon & rhs,
size_t reserve = 0 )
inline
152 {
153 assign(rhs.points.begin(), rhs.points.end(), reserve);
154 }
void assign(IT begin, IT end, size_t reserve=0)
Definition MutablePolygon.hpp:145

References assign(), and Slic3r::MultiPoint::points.

Here is the call graph for this function:

◆ assign() [2/2]

template<typename IT>
void Slic3r::MutablePolygon::assign ( IT begin,
IT end,
size_t reserve = 0 )
inline
145 {
146 m_data.clear();
147 m_head = IndexType(-1);
148 m_head_free = { IndexType(-1) };
149 this->assign_inner(begin, end, reserve);
150 };
IndexType m_head
Definition MutablePolygon.hpp:206
int32_t IndexType
Definition MutablePolygon.hpp:24
std::vector< LinkedPoint > m_data
Definition MutablePolygon.hpp:203
IndexType m_head_free
Definition MutablePolygon.hpp:208

References assign_inner(), begin(), end(), m_data, m_head, and m_head_free.

Referenced by assign(), Slic3r::remove_duplicates(), Slic3r::smooth_outward(), and Slic3r::smooth_outward().

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

◆ assign_inner()

template<typename IT>
void Slic3r::MutablePolygon::assign_inner ( IT begin,
IT end,
size_t reserve )
inlineprivate
214 {
216 if (m_size > 0) {
217 m_head = 0;
218 m_data.reserve(std::max<size_t>(m_size, reserve));
219 auto i = IndexType(-1);
220 auto j = IndexType(1);
221 for (auto it = begin; it != end; ++ it)
222 m_data.push_back({ *it, i ++, j ++ });
223 m_data.front().prev = m_size - 1;
224 m_data.back ().next = 0;
225 }
226 };
IndexType m_size
Definition MutablePolygon.hpp:205

References begin(), end(), m_data, m_head, and m_size.

Referenced by MutablePolygon(), and assign().

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

◆ at() [1/2]

LinkedPoint & Slic3r::MutablePolygon::at ( IndexType i)
inlineprivate
210{ return m_data[i]; }

References m_data.

Referenced by cend(), end(), insert(), and remove().

Here is the caller graph for this function:

◆ at() [2/2]

const LinkedPoint & Slic3r::MutablePolygon::at ( IndexType i) const
inlineprivate
211{ return m_data[i]; }

References m_data.

◆ begin() [1/2]

iterator Slic3r::MutablePolygon::begin ( )
inline
179{ return { this, m_head }; }

References m_head.

Referenced by MutablePolygon(), MutablePolygon(), MutablePolygon(), assign(), assign_inner(), Slic3r::remove_duplicates(), Slic3r::remove_duplicates(), Slic3r::remove_duplicates(), and Slic3r::smooth_outward().

Here is the caller graph for this function:

◆ begin() [2/2]

const_iterator Slic3r::MutablePolygon::begin ( ) const
inline
181{ return this->cbegin(); }
const_iterator cbegin() const
Definition MutablePolygon.hpp:180

References cbegin().

Here is the call graph for this function:

◆ capacity()

size_t Slic3r::MutablePolygon::capacity ( ) const
inline
175{ return m_data.capacity(); }

References m_data.

◆ cbegin()

const_iterator Slic3r::MutablePolygon::cbegin ( ) const
inline
180{ return { this, m_head }; }

References m_head.

Referenced by begin(), Slic3r::operator==(), and polygon().

Here is the caller graph for this function:

◆ cend()

const_iterator Slic3r::MutablePolygon::cend ( ) const
inline
184{ return { this, this->empty() ? -1 : this->at(m_head).prev }; }
IndexType prev
Definition MutablePolygon.hpp:199
bool empty() const
Definition MutablePolygon.hpp:173
LinkedPoint & at(IndexType i)
Definition MutablePolygon.hpp:210

References at(), empty(), m_head, and Slic3r::MutablePolygon::LinkedPoint::prev.

Referenced by end().

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

◆ clear()

void Slic3r::MutablePolygon::clear ( )
inline
177{ m_data.clear(); m_size = 0; m_head = IndexType(-1); m_head_free = IndexType(-1); }

References m_data, m_head, m_head_free, and m_size.

Referenced by Slic3r::clip_narrow_corner(), Slic3r::remove_duplicates(), and Slic3r::smooth_outward().

Here is the caller graph for this function:

◆ empty()

bool Slic3r::MutablePolygon::empty ( ) const
inline
173{ return m_size == 0; }

References m_size.

Referenced by cend(), end(), Slic3r::operator==(), remove(), Slic3r::remove_duplicates(), and Slic3r::remove_duplicates().

Here is the caller graph for this function:

◆ end() [1/2]

iterator Slic3r::MutablePolygon::end ( )
inline
183{ return { this, this->empty() ? -1 : this->at(m_head).prev }; }

References at(), empty(), m_head, and Slic3r::MutablePolygon::LinkedPoint::prev.

Referenced by MutablePolygon(), MutablePolygon(), MutablePolygon(), assign(), and assign_inner().

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

◆ end() [2/2]

const_iterator Slic3r::MutablePolygon::end ( ) const
inline
185{ return this->cend(); }
const_iterator cend() const
Definition MutablePolygon.hpp:184

References cend().

Here is the call graph for this function:

◆ insert() [1/2]

IndexType Slic3r::MutablePolygon::insert ( const IndexType i,
const Point pt )
inlineprivate
249 {
250 assert(i >= 0);
251 IndexType n;
252 IndexType j = this->at(i).prev;
253 if (m_head_free == -1) {
254 // Allocate a new item.
255 n = IndexType(m_data.size());
256 m_data.push_back({ pt, j, i });
257 } else {
258 n = m_head_free;
259 LinkedPoint &nlp = this->at(n);
260 m_head_free = nlp.next;
261 nlp = { pt, j, i };
262 }
263 this->at(j).next = n;
264 this->at(i).prev = n;
265 ++ m_size;
266 return n;
267 }
IndexType next
Definition MutablePolygon.hpp:201
Definition MutablePolygon.hpp:195

References at(), m_data, m_head_free, m_size, Slic3r::MutablePolygon::LinkedPoint::next, and Slic3r::MutablePolygon::LinkedPoint::prev.

Here is the call graph for this function:

◆ insert() [2/2]

iterator Slic3r::MutablePolygon::insert ( const iterator it,
const PointType pt )
inline
192{ assert(it.m_data == this); return { this, this->insert(it.m_idx, pt) }; }
iterator insert(const iterator it, const PointType pt)
Definition MutablePolygon.hpp:192

References insert(), Slic3r::MutablePolygon::iterator::m_data, and Slic3r::MutablePolygon::iterator::m_idx.

Referenced by insert().

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

◆ polygon() [1/2]

Polygon Slic3r::MutablePolygon::polygon ( ) const
inline
167 {
168 Polygon out;
169 this->polygon(out);
170 return out;
171 };
Polygon polygon() const
Definition MutablePolygon.hpp:167
Slic3r::Polygon Polygon
Definition Emboss.cpp:101

References polygon().

Referenced by polygon().

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

◆ polygon() [2/2]

void Slic3r::MutablePolygon::polygon ( Polygon & out) const
inline
156 {
157 out.points.clear();
158 if (this->valid()) {
159 out.points.reserve(this->size());
160 auto it = this->cbegin();
161 out.points.emplace_back(*it);
162 for (++ it; it != this->cbegin(); ++ it)
163 out.points.emplace_back(*it);
164 }
165 };
bool valid() const
Definition MutablePolygon.hpp:176
size_t size() const
Definition MutablePolygon.hpp:174

References cbegin(), Slic3r::MultiPoint::points, size(), and valid().

Referenced by Slic3r::remove_duplicates(), Slic3r::smooth_outward(), Slic3r::smooth_outward(), and Slic3r::smooth_outward().

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

◆ remove() [1/2]

IndexType Slic3r::MutablePolygon::remove ( const IndexType i)
inlineprivate
228 {
229 assert(i >= 0);
230 assert(m_size > 0);
231 assert(m_head != -1);
232 LinkedPoint &lp = this->at(i);
233 IndexType prev = lp.prev;
234 IndexType next = lp.next;
235 lp.next = m_head_free;
236 m_head_free = i;
237 if (-- m_size == 0)
238 m_head = -1;
239 else if (m_head == i)
240 m_head = next;
241 assert(! this->empty() || (prev == i && next == i));
242 if (this->empty())
243 return IndexType(-1);
244 this->at(prev).next = next;
245 this->at(next).prev = prev;
246 return next;
247 }

References at(), empty(), m_head, m_head_free, m_size, Slic3r::MutablePolygon::LinkedPoint::next, and Slic3r::MutablePolygon::LinkedPoint::prev.

Here is the call graph for this function:

◆ remove() [2/2]

iterator Slic3r::MutablePolygon::remove ( const iterator it)
inline
189{ assert(it.m_data == this); return { this, this->remove(it.m_idx) }; }
iterator remove(const iterator it)
Definition MutablePolygon.hpp:189

References Slic3r::MutablePolygon::iterator::m_data, Slic3r::MutablePolygon::iterator::m_idx, and remove().

Referenced by remove().

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

◆ size()

size_t Slic3r::MutablePolygon::size ( ) const
inline
174{ return m_size; }

References m_size.

Referenced by Slic3r::clip_narrow_corner(), Slic3r::operator==(), polygon(), Slic3r::remove_duplicates(), and Slic3r::smooth_outward().

Here is the caller graph for this function:

◆ valid()

bool Slic3r::MutablePolygon::valid ( ) const
inline
176{ return m_size >= 3; }

References m_size.

Referenced by polygon().

Here is the caller graph for this function:

Member Data Documentation

◆ m_data

std::vector<LinkedPoint> Slic3r::MutablePolygon::m_data
private

◆ m_head

IndexType Slic3r::MutablePolygon::m_head { IndexType(-1) }
private
206{ IndexType(-1) };

Referenced by assign(), assign_inner(), begin(), cbegin(), cend(), clear(), end(), and remove().

◆ m_head_free

IndexType Slic3r::MutablePolygon::m_head_free { IndexType(-1) }
private
208{ IndexType(-1) };

Referenced by assign(), clear(), insert(), and remove().

◆ m_size

IndexType Slic3r::MutablePolygon::m_size { 0 }
private
205{ 0 };

Referenced by assign_inner(), clear(), empty(), insert(), remove(), size(), and valid().


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