39Winding Outline::computeWinding() const noexcept {
43bool Outline::computeIsComplex() const noexcept {
57void OutlineShape::sortOutlines() {
61uint32_t OutlineShape::generateVertexIds() {
62 uint32_t maxVertexId = 0;
63 for(
size_type i=0; i<m_outlines.size(); ++i) {
66 vertice.id() = maxVertexId++;
86 outline.addVertex(index, Vertex(v1,
false));
87 outline.addVertex(index+2, Vertex(v3,
false));
89 m_addedVertexCount += 2;
94 for (
size_type cc = 0; cc < count; ++cc) {
98 Vertex& currV = ol.
vertex(i);
99 if( !currV.
onCurve() && currV != a && currV != b && currV != c) {
104 if(prevV != c && nextV != a) {
121void OutlineShape::checkOverlaps() {
124 bool firstpass =
true;
126 for (
size_type cc = 0; cc < count; ++cc) {
130 Vertex& currentVertex = ol.
vertex(i);
131 if ( !currentVertex.
onCurve()) {
141 overlap = checkTriOverlaps0(prevV, currentVertex, nextV);
148 subdivideTriangle(ol, prevV, currentVertex, nextV, i);
151 m_addedVertexCount+=2;
153 if(overlap && !overlap->
onCurve()) {
155 overlaps.push_back(*overlap);
163 }
while( !overlaps.empty() );
166void OutlineShape::cleanupOutlines() {
169 for (
size_type cc = 0; cc < count; ++cc) {
173 if( transformOutlines2Quadratic ) {
175 Vertex& currentVertex = ol.
vertex(i);
177 Vertex& nextVertex = ol.
vertex(j);
185 ++m_addedVertexCount;
204void OutlineShape::triangulateImpl() {
205 if( 0 < m_outlines.size() ) {
210 tess::impl::CDTriangulator2D triangulator2d;
212 for(Outline& ol : m_outlines) {
213 triangulator2d.
addCurve(m_triangles, ol, m_sharpness);
215 triangulator2d.
generate(m_triangles);
217 triangulator2d.
reset();
222 bool updated =
false;
236 jau::PLAIN_PRINT(
true,
"OutlineShape.getTriangles().X: %u, updated %d", m_triangles.size(), updated);
252 bool updated =
false;
255 for(
const Outline& ol : m_outlines) {
263 jau::PLAIN_PRINT(
true,
"OutlineShape.getVertices().X: %u, updated %d", m_vertices.size(), updated);
266 for(
Vertex& v : m_vertices) {
const VertexList & getVertices()
Return list of concatenated vertices associated with all Outlines of this object.
size_type outlineCount() const noexcept
Returns the number of Outlines.
bool isComplex() const noexcept
Returns cached or computed result if at least one polyline outline(size_type) is a complex shape,...
@ triangles
<Modified shape, requires to update the vertices and triangles, here: vertices
size_type vertexCount() const noexcept
Returns the total vertex number of all Outlines.
const Outline & outline(size_type i) const noexcept
const TriangleRefList & getTriangles(VertexState destinationType=VertexState::quadratic_nurbs)
Triangulate the OutlineShape generating a list of triangles, while transformOutlines(VerticesState) b...
Define a single continuous stroke by control vertices.
void addVertex(const Vertex &vertex)
Appends a vertex to the outline loop/strip.
constexpr const VertexList & vertices() const noexcept
constexpr const Vertex & vertex(size_type i) const noexcept
constexpr size_type vertexCount() const noexcept
int compareTo(const Outline &other) const noexcept
Compare two outline's Bounding Box size.
void removeVertex(size_type position)
Removes the Vertex element at the given position.
const Vertex & lastVertex() const noexcept
constexpr const Vec3f & coord() const noexcept
constexpr bool onCurve() const noexcept
void addCurve(TriangleRefList &sink, Outline &polyline, float sharpness)
constexpr void reset() noexcept
void generate(TriangleRefList &sink)
constexpr void setComplexShape(bool complex) noexcept
constexpr size_t getAddedVerticeCount() const noexcept
constexpr iterator end() noexcept
constexpr void push_back(const value_type &x)
Like std::vector::push_back(), copy.
constexpr iterator begin() noexcept
static struct SizeDescending sizeDescending
constexpr bool contains(InputArray &array, const T &value) noexcept
Return true if value is contained in array.
constexpr bool eraseFirst(InputArray &array, const T &value)
constexpr bool is_set(const E mask, const E bits) noexcept
static constexpr bool isConvex1(const VertexList &polyline, bool shortIsConvex) noexcept
Returns whether the given on-curve polyline points denotes a convex shape with O(n) complexity.
constexpr bool testTri2SegIntersection2D(const Vertex &a, const Vertex &b, const Vertex &c, const Vertex &d, const Vertex &e)
Check if a segment intersects with a triangle using FloatUtil#EPSILON w/o considering collinear-case.
constexpr Winding getWinding(const VertexList &vertices) noexcept
Compute the winding using the area2D() function over all vertices for complex shapes.
jau::darray< Vertex, uint32_t > VertexList
std::shared_ptr< Triangle > TriangleRef
jau::darray< TriangleRef, uint32_t > TriangleRefList
constexpr Vec3f midpoint(const Vec3f &a, const Vec3f &b) noexcept
std::string to_string(const math_error_t v) noexcept
Returns std::string representation of math_error_t.
constexpr bool isInTriangle3(const Vec3f &a, const Vec3f &b, const Vec3f &c, const Vec3f &p1, const Vec3f &p2, const Vec3f &p3) noexcept
Check if one of three vertices are in triangle using barycentric coordinates computation.
Author: Sven Gothel sgothel@jausoft.com Copyright Gothel Software e.K.
void PLAIN_PRINT(const bool printPrefix, const char *format,...) noexcept
Use for unconditional plain messages, prefix '[elapsed_time] ' if printPrefix == true.
bool operator()(Outline &a, Outline &b) const