Blender  V3.3
StrokeTesselator.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include "StrokeTesselator.h"
10 
11 #include "../scene_graph/NodeGroup.h"
12 #include "../scene_graph/NodeShape.h"
13 #include "../scene_graph/OrientedLineRep.h"
14 
15 namespace Freestyle {
16 
18 {
19  if (nullptr == iStroke) {
20  return nullptr;
21  }
22 
23  LineRep *line;
24  line = new OrientedLineRep();
25 
27  if (2 == iStroke->vertices_size()) {
28  line->setStyle(LineRep::LINES);
29  v = iStroke->vertices_begin();
30  StrokeVertex *svA = (*v);
31  v++;
32  StrokeVertex *svB = (*v);
33  Vec3r A((*svA)[0], (*svA)[1], 0);
34  Vec3r B((*svB)[0], (*svB)[1], 0);
35  line->AddVertex(A);
36  line->AddVertex(B);
37  }
38  else {
39  if (_overloadFrsMaterial) {
40  line->setFrsMaterial(_FrsMaterial);
41  }
42 
44 
45  for (v = iStroke->vertices_begin(), vend = iStroke->vertices_end(); v != vend; v++) {
46  StrokeVertex *sv = (*v);
47  Vec3r V((*sv)[0], (*sv)[1], 0);
48  line->AddVertex(V);
49  }
50  }
51  line->setId(iStroke->getId());
52  line->ComputeBBox();
53 
54  return line;
55 }
56 
57 template<class StrokeVertexIterator>
58 NodeGroup *StrokeTesselator::Tesselate(StrokeVertexIterator begin, StrokeVertexIterator end)
59 {
60  NodeGroup *group = new NodeGroup;
61  NodeShape *tshape = new NodeShape;
62  group->AddChild(tshape);
63  // tshape->material().setDiffuse(0.0f, 0.0f, 0.0f, 1.0f);
64  tshape->setFrsMaterial(_FrsMaterial);
65 
66  for (StrokeVertexIterator c = begin, cend = end; c != cend; c++) {
67  tshape->AddRep(Tesselate((*c)));
68  }
69 
70  return group;
71 }
72 
73 } /* namespace Freestyle */
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
void AddVertex(const Vec3r &iVertex)
Definition: LineRep.h:95
void setStyle(const LINES_STYLE iStyle)
Definition: LineRep.h:90
virtual void ComputeBBox()
Definition: LineRep.cpp:12
virtual void AddChild(Node *iChild)
Definition: NodeGroup.cpp:14
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:140
void setFrsMaterial(const FrsMaterial &iMaterial)
Definition: Rep.h:155
LineRep * Tesselate(Stroke *iStroke)
const_vertex_iterator vertices_begin() const
embedding vertex iterator
Definition: Stroke.cpp:735
virtual Id getId() const
Definition: Stroke.h:498
int vertices_size() const
Definition: Stroke.h:670
const_vertex_iterator vertices_end() const
Definition: Stroke.cpp:740
#define B
inherits from class Rep
Definition: AppCanvas.cpp:18
static unsigned c
Definition: RandGen.cpp:83
CCL_NAMESPACE_BEGIN struct Window V