Blender V5.0
StrokeTesselator.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10#include "StrokeTesselator.h"
12
16
17namespace Freestyle {
18
20{
21 if (nullptr == iStroke) {
22 return nullptr;
23 }
24
25 LineRep *line;
26 line = new OrientedLineRep();
27
29 if (2 == iStroke->vertices_size()) {
31 v = iStroke->vertices_begin();
32 StrokeVertex *svA = (*v);
33 v++;
34 StrokeVertex *svB = (*v);
35 Vec3r A((*svA)[0], (*svA)[1], 0);
36 Vec3r B((*svB)[0], (*svB)[1], 0);
37 line->AddVertex(A);
38 line->AddVertex(B);
39 }
40 else {
41 if (_overloadFrsMaterial) {
42 line->setFrsMaterial(_FrsMaterial);
43 }
44
46
47 for (v = iStroke->vertices_begin(), vend = iStroke->vertices_end(); v != vend; v++) {
48 StrokeVertex *sv = (*v);
49 Vec3r V((*sv)[0], (*sv)[1], 0);
50 line->AddVertex(V);
51 }
52 }
53 line->setId(iStroke->getId());
54 line->ComputeBBox();
55
56 return line;
57}
58
59template<class StrokeVertexIterator>
60NodeGroup *StrokeTesselator::Tesselate(StrokeVertexIterator begin, StrokeVertexIterator end)
61{
62 NodeGroup *group = new NodeGroup;
63 NodeShape *tshape = new NodeShape;
64 group->AddChild(tshape);
65 // tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
66 tshape->setFrsMaterial(_FrsMaterial);
67
68 for (StrokeVertexIterator c = begin, cend = end; c != cend; c++) {
69 tshape->AddRep(Tesselate(*c));
70 }
71
72 return group;
73}
74
75} /* namespace Freestyle */
Class to represent a group node. This node can contains several children.
Class to build a shape node. It contains a Rep, which is the shape geometry.
Class to display an oriented line representation.
Iterators used to iterate over the elements of the Stroke. Can't be used in python.
Class to build a Node Tree designed to be displayed from a set of strokes structure.
iter begin(iter)
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define A
void AddVertex(const Vec3r &iVertex)
Definition LineRep.h:97
void setStyle(const LINES_STYLE iStyle)
Definition LineRep.h:92
virtual void ComputeBBox()
Definition LineRep.cpp:14
virtual void AddChild(Node *iChild)
Definition NodeGroup.cpp:16
virtual void AddRep(Rep *iRep)
Definition NodeShape.h:39
void setFrsMaterial(const FrsMaterial &iMaterial)
Definition NodeShape.h:55
void setId(const Id &id)
Definition Rep.h:142
void setFrsMaterial(const FrsMaterial &iMaterial)
Definition Rep.h:157
LineRep * Tesselate(Stroke *iStroke)
const_vertex_iterator vertices_begin() const
embedding vertex iterator
Definition Stroke.cpp:741
virtual Id getId() const
Definition Stroke.h:494
StrokeInternal::vertex_iterator_base< StrokeInternal::vertex_nonconst_traits > vertex_iterator
Definition Stroke.h:510
int vertices_size() const
Definition Stroke.h:666
const_vertex_iterator vertices_end() const
Definition Stroke.cpp:746
#define B
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
inherits from class Rep
Definition AppCanvas.cpp:20
static uint c
Definition RandGen.cpp:87
CCL_NAMESPACE_BEGIN struct Window V