41 virtual void stream(std::ostream&)
const = 0;
50 virtual void stream(std::ostream&
os)
const override;
59 virtual void stream(std::ostream&
os)
const override;
68 virtual void stream(std::ostream&
os)
const override;
107 void ortho(
double left,
double right,
double bottom,
double top);
110 void viewport(
int x,
int y,
int width,
int height);
130 for(
const auto& vertex : shape.vertices()) {
131 vertices.push_back(vertex);
134 for(
auto e : shape.edges()) {
135 auto p1 =
Vector3{vertices[e.vertices[0]].position, 0.0};
136 auto p2 =
Vector3{vertices[e.vertices[1]].position, 0.0};
142 for(
auto v : vertices) {
144 auto p2 =
Vector3{
v.position + 0.1 *
v.tangent, 0.0};
145 auto p3 =
Vector3{
v.position + 0.1 *
v.normal(), 0.0};
153 for(
auto v : shape.vertices()) {
163 for(
const auto&
temp : path.vertices()) {
164 vertices.push_back(
temp);
168 for(
const auto&
v : path.vertices()) {
169 writeLine(
v.position,
v.position + 0.1 *
v.tangent, {0.0, 0.0, 1.0});
170 writeLine(
v.position,
v.position + 0.1 *
v.normal, {1.0, 0.0, 0.0});
171 writeLine(
v.position,
v.position + 0.1 *
v.binormal(), {0.0, 1.0, 0.0});
176 for(
const auto&
v : path.vertices()) {
181 for(
const auto& e : path.edges()) {
182 writeLine(vertices[e.vertices[0]].position, vertices[e.vertices[1]].position);
189 for(
const MeshVertex& vertex : mesh.vertices()) {
190 vertices.push_back(vertex);
194 writeTriangle(vertices[
t.vertices[0]].position, vertices[
t.vertices[1]].position, vertices[
t.vertices[2]].position);
198 for(
const auto&
v : vertices) {
205 for(
const auto&
v : vertices) {
206 writeLine(
v.position,
v.position + 0.1 *
v.normal, {0.0, 0.0, 1.0});
Definition MeshVertex.hpp:14
Definition SvgWriter.hpp:30
BaseElem(double z, const Vector3 &color)
double z_
Definition SvgWriter.hpp:32
Vector3 color_
Definition SvgWriter.hpp:34
virtual void stream(std::ostream &) const =0
Definition SvgWriter.hpp:53
virtual void stream(std::ostream &os) const override
Vector3 p1_
Definition SvgWriter.hpp:55
Vector3 p2_
Definition SvgWriter.hpp:55
LineElem(const Vector3 &p1, const Vector3 &p2, const Vector3 &color)
Definition SvgWriter.hpp:62
virtual void stream(std::ostream &os) const override
Array< Vector3, 3 > p_
Definition SvgWriter.hpp:64
TriangleElem(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &color)
Definition SvgWriter.hpp:44
virtual void stream(std::ostream &os) const override
VertexElem(const Vector3 &p, const Vector3 &color)
Vector3 p_
Definition SvgWriter.hpp:46
A simple svg writer class for generating preview and debug images.
Definition SvgWriter.hpp:28
void writeLine(const Vector3 &p1, const Vector3 &p2, const Vector3 &color={0.0, 0.0, 0.0})
Write one line.
void viewport(int x, int y, int width, int height)
Sets the viewport. Default fills the whole image.
void writeShape(const Shape &shape, bool writeVertices=false, bool writeAxis=false)
Write all shaped edges and optionally vertices, tangents and normals.
Definition SvgWriter.hpp:128
Vector3 normalToColor(const Vector3 &normal) const
Vector3 project(const Vector3 &p) const
Matrix4 projMatrix_
Definition SvgWriter.hpp:78
Vector2i size_
Definition SvgWriter.hpp:75
void writePath(const Path &path, const bool writeVertices=false, const bool writeAxis=false)
Write all path edges as lines and optionally vertices, tangents, normals and binormals.
Definition SvgWriter.hpp:161
Matrix4 viewMatrix_
Definition SvgWriter.hpp:77
Vector2i viewportSize_
Definition SvgWriter.hpp:81
Vector3 lightDir_
Definition SvgWriter.hpp:83
bool cullface_
Definition SvgWriter.hpp:85
Vector2i viewportOrigin_
Definition SvgWriter.hpp:80
Vector< UPtr< BaseElem > > elems_
Definition SvgWriter.hpp:87
void writeTriangle(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const Vector3 &color)
Write one triangle.
std::string str() const
Generates svg xml from the data written so far.
void ortho(double left, double right, double bottom, double top)
Sets the projection mode to orthographic projection.
SvgWriter(int width, int height)
void writeTriangle(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3)
Write one triangle with color automatically calculated from light.
void perspective(double fovy, double aspect, double zNear, double zFar)
Sets the projection mode to perspective projection.
Matrix4 viewProjMatrix_
Definition SvgWriter.hpp:79
void modelView(const Matrix4 &matrix)
Sets the model view matrix. Default is the identity matrix.
void writePoint(const Vector3 &p, const Vector3 &color={0.0, 0.0, 0.0})
Write one point. Drawn as a circle.
void cullface(bool cullface)
Sets if backfacing triangles should be culled. Default is true.
void writeMesh(const Mesh &mesh, const bool writeVertices=false, const bool writeNormals=false)
Write all triangles from a mesh.
Definition SvgWriter.hpp:187
Definition Triangle.hpp:14
A base class for all mesh implementations.
Definition Mesh.hpp:112
A type that describes a conjunction of shapes that can be filled and stroked.
Definition Shape.hpp:198
Definition AnyGenerator.hpp:12
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
std::array< T, N > Array
Array is a container that encapsulates fixed size arrays.
Definition Array.hpp:17
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25