27#ifndef EASY3D_ALGO_TESSELLATOR_H
28#define EASY3D_ALGO_TESSELLATOR_H
31#include <easy3d/core/types.h>
59 struct Vertex : std::vector<double> {
75 Vertex(
const FT *data, std::size_t size,
int idx = 0) : std::vector<double>(data, data + size), index(idx) {}
82 explicit Vertex(std::size_t size = 0,
int idx = 0) : std::vector<double>(size), index(idx) {}
89 Vertex(
const Vertex &v,
int idx = 0) : std::vector<double>(v.begin(), v.end()), index(idx) {}
97 template<
typename Vec>
99 for (
int i = 0; i < v.
size(); ++i)
114 WINDING_ODD = 100130,
115 WINDING_NONZERO = 100131,
116 WINDING_POSITIVE = 100132,
117 WINDING_NEGATIVE = 100133,
118 WINDING_ABS_GEQ_TWO = 100134
186 void add_vertex(
const float *data,
unsigned int size,
int idx = 0);
215 const std::vector<Vertex *> &
vertices()
const;
221 const std::vector<std::vector<unsigned int> > &
elements()
const {
return elements_; }
240 void _add_element(
const std::vector<unsigned int> &element);
243 static void beginCallback(
unsigned int w,
void *cbdata);
244 static void endCallback(
void *cbdata);
245 static void vertexCallback(
void *vertex,
void *cbdata);
246 static void combineCallback(
const double coords[3],
void *vertex_data[4],
const float weight[4],
void **dataOut,
void *cbdata);
250 void *vertex_manager_;
253 unsigned int primitive_type_;
257 std::vector<std::vector<unsigned int> > elements_;
260 unsigned int num_elements_in_polygon_;
263 std::vector<unsigned int> vertex_ids_;
266 unsigned int vertex_data_size_;
286 void union_of(std::vector<Polygon2> &polygons);
293 void intersection_of(
const Polygon2& polygon_a,
const Polygon2& polygon_b, std::vector<Polygon2> &result);
301 void difference_of(
const Polygon2& polygon_a,
const Polygon2& polygon_b, std::vector<Polygon2> &result);
Tessellator subdivides concave planar polygons, polygons with holes, or polygons with intersecting ed...
Definition tessellator.h:56
void add_vertex(const Vertex &data)
Add a vertex of a contour to the tessellator.
Definition tessellator.cpp:163
void end_polygon()
Finish the current polygon.
Definition tessellator.cpp:233
void begin_polygon()
Begin the tessellation of a complex polygon.
Definition tessellator.cpp:152
WindingRule
The winding rule (default rule is ODD, modify if needed)
Definition tessellator.h:113
void begin_contour()
Begin a contour of a complex polygon (a polygon may have multiple contours).
Definition tessellator.cpp:158
unsigned int num_elements_in_polygon() const
The number of elements (triangle or contour) in the last polygon.
Definition tessellator.h:227
const std::vector< Vertex * > & vertices() const
The list of vertices in the result.
Definition tessellator.cpp:238
void reset()
Clear all recorded data (triangle list and vertices) and restart index counter. This function is usef...
Definition tessellator.cpp:382
const std::vector< std::vector< unsigned int > > & elements() const
The list of elements (triangle or contour) created over many calls. Each element is represented by it...
Definition tessellator.h:221
void set_winding_rule(WindingRule rule)
Set the wining rule. The new rule will be effective until being changed by calling this function agai...
Definition tessellator.cpp:140
void end_contour()
Finish the current contour of a polygon.
Definition tessellator.cpp:228
void set_boundary_only(bool b)
Set the working mode of the tessellator.
Definition tessellator.cpp:135
Base class for vector types. It provides generic functionality for N dimensional vectors.
Definition vec.h:32
size_t size() const
Returns the dimension/size of this vector.
Definition vec.h:77
Definition collider.cpp:182
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
GenericPolygon< float > Polygon2
A 2D polygon of float type.
Definition types.h:116
Vec< 2, float > vec2
A 2D point/vector of float type.
Definition types.h:42
Vertex(std::size_t size=0, int idx=0)
initialize with a known size but memory is allocated without data initialization.
Definition tessellator.h:82
void append(const Vec &v)
append a property (e.g., color, texture coordinates) to this vertex.
Definition tessellator.h:98
Vertex(const vec3 &xyz, int idx=0)
initialize with xyz coordinates and an optional index.
Definition tessellator.h:66
Vertex(const Vertex &v, int idx=0)
copy constructor.
Definition tessellator.h:89
Vertex(const FT *data, std::size_t size, int idx=0)
initialize from a C-style array.
Definition tessellator.h:75