33#include <NDEVR/BaseValues.h>
34#include <NDEVR/Buffer.h>
35#include <NDEVR/Vertex.h>
36#include <NDEVR/Bounds.h>
37#include <NDEVR/LineSegment.h>
51 template<u
int01 t_dims,
class t_type,
class t_vertex = Vertex<t_dims, t_type>>
66 : m_vertices(polygon.m_vertices)
67 , m_cache_bounds(polygon.m_cache_bounds)
68 , m_cache_length(polygon.m_cache_length)
75 std::swap(m_vertices, polygon.m_vertices);
76 std::swap(m_cache_bounds, polygon.m_cache_bounds);
77 std::swap(m_cache_length, polygon.m_cache_length);
100 return m_cache_bounds;
105 return m_vertices.
begin();
109 return m_vertices.
begin();
114 return m_vertices.
begin(index);
118 return m_vertices.
begin(index);
123 return m_vertices.
end();
125 decltype(
auto)
end()
const
127 return m_vertices.
end();
145 return m_vertices[index];
193 return m_vertices.
size();
208 if (m_vertices.
size() == 0)
211 return m_vertices.
size() - 1;
284 if (
segment(index).
template isParallel<t_type>(
segment(index - 1), 0.00001))
291 if (
segment(index - 1).
template isParallel<t_type>(
segment(index - 2), 0.00001))
314 if (m_vertices[index] !=
vertex)
316 m_vertices[index] =
vertex;
349 return m_vertices.
last();
381 else if (i > 0 &&
segment(i).
template isParallel<t_type>(
segment(i - 1), 0.00001))
411 template<u
int01 t_new_dims,
class t_new_type,
class t_new_vertex_type = Vertex<t_new_dims, t_new_type>>
431 template<
class t_precision>
450 return m_cache_length;
466 template<
class t_
inter_type>
467 constexpr inline t_vertex
pointAt(t_inter_type value)
const
477 fltp08 accumulated_distance = 0;
481 if (accumulated_distance + local_distance > value)
483 fltp08 line_percent =
clip((value - accumulated_distance) / local_distance, 0.0, 1.0);
488 accumulated_distance += local_distance;
508 return (m_vertices == polygon.m_vertices);
512 m_vertices = polygon.m_vertices;
513 m_cache_length = polygon.m_cache_length;
514 m_cache_bounds = polygon.m_cache_bounds;
519 std::swap(m_vertices, polygon.m_vertices);
520 m_cache_length = polygon.m_cache_length;
521 m_cache_bounds = polygon.m_cache_bounds;
530 t_type remainder_distance(0);
535 if (seg_length + remainder_distance >
length)
537 t_type local_accumulation =
length - remainder_distance;
538 lib_assert(local_accumulation > 0.0,
"Bad accumulation");
539 auto ray =
segment(i).ray().template normalized<fltp08>();
543 local_accumulation +=
length;
544 }
while (local_accumulation < seg_length);
545 remainder_distance =
length + seg_length - local_accumulation;
549 remainder_distance += seg_length;
556 t_type dist_squared = d * d;
570 if(ap != 0.0 && !
equals(ab, ap, 0.000001) && !
equals(ab, -ap, 0.000001))
574 t_type sum = (ab * ap).sum();
579 new_poly.add(new_distance * normal + p0);
584 new_poly.add(d * normal + new_poly.lastVertex());
598 t_type accumulated_distance = 0;
602 while (accumulated_distance + local_distance > max_distance)
604 auto direction = (
vertex(i) - new_poly.lastVertex()).
template normalized<t_type>();
605 t_type adjusted_distance = max_distance - accumulated_distance;
607 auto final_vertex = adjusted_distance * direction + new_poly.lastVertex();
608 new_poly.add(final_vertex);
609 new_polys.
add(new_poly);
612 new_poly.add(final_vertex);
613 local_distance = local_distance - adjusted_distance;
614 accumulated_distance = 0.0;
618 accumulated_distance += local_distance;
620 new_polys.
add(new_poly);
634 line = intersection(
bounds, line);
637 if (polyline.vertexCount() == 0 || polyline.lastVertex() != line.vertex(
A))
638 polyline.add(line.vertex(
A));
639 polyline.add(line.vertex(
B));
655 inline void invalidateCache()
const
672 void updateVertices(
const Buffer<t_vertex>&
vertices)
679 Buffer<t_vertex> m_vertices;
689 mutable Bounds<t_dims, t_type, t_vertex> m_cache_bounds;
699 mutable t_type m_cache_length;
#define lib_assert(expression, message)
Definition LibAssert.h:61
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:52
constexpr void addToBounds(const t_vertex &vector)
Definition Bounds.hpp:390
constexpr bool contains(const t_type &value) const
Query if this object contains the given value. t_allow_bounds - whether or not to allow boundary case...
Definition Bounds.hpp:237
constexpr bool intersects(const Bounds< t_dims, t_type, t_other_vertex_type > &bounds) const
Definition Bounds.hpp:611
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
void add(t_type &&object)
Adds object to the end of the buffer.
Definition Buffer.hpp:186
constexpr t_index_type size() const
Definition Buffer.hpp:823
decltype(auto) last()
Definition Buffer.hpp:588
decltype(auto) end()
Definition Buffer.hpp:507
void removeIndex(t_index_type location)
Definition Buffer.hpp:606
decltype(auto) begin()
Definition Buffer.hpp:402
void clear()
Definition Buffer.hpp:422
void removeLast()
Definition Buffer.hpp:629
A line segment represented by two vertices, a start and end.
Definition Line.hpp:49
constexpr t_vertex ray() const
Definition Line.hpp:120
Definition MemoryManager.h:261
A polyline which stores vertex information for many points along a given path.
Definition CoordinateProjectionManager.h:44
Polyline(Buffer< t_vertex > &vertices)
Definition PolyLine.hpp:60
void simplify()
Definition PolyLine.hpp:370
Polyline & operator=(const Polyline &polygon)
Definition PolyLine.hpp:510
Polyline & operator=(Polyline &&polygon) noexcept
Definition PolyLine.hpp:517
t_precision length() const
Definition PolyLine.hpp:432
Buffer< Polyline< t_dims, t_type >, uint04, ObjectAllocator< false > > breakIntoPolylinesByLength(t_type max_distance) const
Definition PolyLine.hpp:591
decltype(auto) begin(uint04 index)
Definition PolyLine.hpp:116
Bounds< t_dims, t_type, t_vertex > bounds() const
Definition PolyLine.hpp:90
uint04 vertexCount() const
Definition PolyLine.hpp:191
void replace(uint04 index, const t_vertex &vertex)
Definition PolyLine.hpp:312
constexpr t_vertex pointAtLength(fltp08 value) const
Definition PolyLine.hpp:473
uint04 segmentCount() const
Definition PolyLine.hpp:206
Polyline(Polyline &&polygon) noexcept
Definition PolyLine.hpp:70
void removeLastVertex()
Definition PolyLine.hpp:359
bool operator==(const Polyline &polygon) const
Definition PolyLine.hpp:506
void addAndSimplify(uint04 index, const t_vertex &vertex)
Definition PolyLine.hpp:268
void setVertices(const Buffer< t_vertex > &vertices)
Definition PolyLine.hpp:225
void remove(uint04 index)
Definition PolyLine.hpp:332
decltype(auto) end()
Definition PolyLine.hpp:121
Polyline< t_dims, t_type > clipPolyline(const Bounds< t_vertex::NumberOfDimensions(), t_type > &bounds) const
Definition PolyLine.hpp:624
Polyline< t_dims, t_type > breakIntoSegmentsByDistance(t_type d) const
Definition PolyLine.hpp:554
Polyline(uint04 size=0)
Definition PolyLine.hpp:55
Polyline< t_dims, t_type > breakIntoSegmentsByLength(t_type length) const
Definition PolyLine.hpp:524
LineSegment< t_dims, t_type, t_vertex > segment(uint04 index) const
Definition PolyLine.hpp:161
decltype(auto) begin()
Definition PolyLine.hpp:103
constexpr t_vertex pointAt(t_inter_type value) const
Definition PolyLine.hpp:467
decltype(auto) begin(uint04 index) const
Definition PolyLine.hpp:112
void add(const t_vertex &vertex)
Definition PolyLine.hpp:241
void clear()
Definition PolyLine.hpp:396
void addAndSimplify(const t_vertex &vertex)
Definition PolyLine.hpp:246
decltype(auto) begin() const
Definition PolyLine.hpp:107
Polyline< t_dims, t_new_type, t_new_vertex_type > as() const
Definition PolyLine.hpp:412
const t_vertex & vertex(uint04 index) const
Definition PolyLine.hpp:143
const t_vertex & lastVertex() const
Definition PolyLine.hpp:347
const Buffer< t_vertex > & vertices() const
Definition PolyLine.hpp:176
decltype(auto) end() const
Definition PolyLine.hpp:125
void add(uint04 index, const t_vertex &vertex)
Definition PolyLine.hpp:263
Polyline(const Polyline &polygon) noexcept
Definition PolyLine.hpp:65
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
constexpr t_type magnitudeSquared() const
Definition Vector.hpp:426
constexpr bool IsInvalid(const t_type &value)
Query if 'value' is valid or invalid. Invalid values should return invalid if used for calculations o...
Definition BaseFunctions.hpp:170
constexpr t_type clip(const t_type &value, const t_type &lower_bound, const t_type &upper_bound)
Clips the value given so that that the returned value falls between upper and lower bound.
Definition BaseFunctions.hpp:207
t_type distanceSquared(const Bounds< t_dims, t_type, t_vertex > &bounds, const Vector< t_dims, t_type > &vertex)
Definition Distance.hpp:46
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
t_type sqrt(const t_type &value)
Definition VectorFunctions.hpp:1225
constexpr t_to cast(const Angle< t_from > &value)
Definition Angle.h:375
constexpr t_type distance(const t_vertex &vertex, const LineSegment< t_dims, t_type, t_vertex > &line)
Definition Distance.hpp:171
constexpr bool equals(const LineSegment< t_dims, t_type, t_vertex > &left, const LineSegment< t_dims, t_type, t_vertex > &right, const t_type &epsilon=cast< t_type >(0))
Definition Line.hpp:757
@ B
Definition BaseValues.hpp:170
@ A
Definition BaseValues.hpp:168
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Definition BaseValues.hpp:233