Blender V4.3
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
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()) {
30 line->setStyle(LineRep::LINES);
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
45 line->setStyle(LineRep::LINE_STRIP);
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.
ATTR_WARN_UNUSED_RESULT const BMVert * v
#define A
virtual void AddRep(Rep *iRep)
Definition NodeShape.h:39
void setFrsMaterial(const FrsMaterial &iMaterial)
Definition NodeShape.h:55
LineRep * Tesselate(Stroke *iStroke)
const_vertex_iterator vertices_begin() const
embedding vertex iterator
Definition Stroke.cpp:741
virtual Id getId() const
Definition Stroke.h:500
int vertices_size() const
Definition Stroke.h:672
const_vertex_iterator vertices_end() const
Definition Stroke.cpp:746
#define B
inherits from class Rep
Definition AppCanvas.cpp:20
static uint c
Definition RandGen.cpp:87
CCL_NAMESPACE_BEGIN struct Window V