bWidgets
Core widget toolkit designed for Blender
bwPolygon.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5namespace bWidgets {
6
7/* TODO for (2D-)polygons, we should actually use ints, not floats. Prevents precision and rounding
8 * errors. */
9using bwPointVec = std::vector<class bwPoint>;
10
11class bwPolygon {
12 public:
13 bwPolygon() = default;
14 bwPolygon(const bwPolygon& poly) = default;
16 explicit bwPolygon(const unsigned int reserve_vertex_count);
17
18 void addVertex(class bwPoint vertex);
19 void addVertex(const float x, const float y);
20 void addVertex(const int x, const int y);
21 void reserve(const unsigned int count);
22 auto getVertices() const -> const bwPointVec&;
23
24 auto operator[](const unsigned int index) -> bwPoint&;
25
26 auto isDrawable() const -> bool;
27
28 protected:
30 size_t vert_count{0};
31};
32
33} // namespace bWidgets
Definition: bwPoint.h:7
Definition: bwPolygon.h:11
auto getVertices() const -> const bwPointVec &
Definition: bwPolygon.cc:40
void addVertex(class bwPoint vertex)
Definition: bwPolygon.cc:19
void reserve(const unsigned int count)
Definition: bwPolygon.cc:35
size_t vert_count
Definition: bwPolygon.h:30
bwPointVec vertices
Definition: bwPolygon.h:29
bwPolygon(const bwPolygon &poly)=default
auto isDrawable() const -> bool
Definition: bwPolygon.cc:50
Definition: bwContext.h:3
std::vector< class bwPoint > bwPointVec
Definition: bwPolygon.h:9