Blender  V3.3
Chain.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include "Chain.h"
9 
10 #include "../view_map/ViewMapAdvancedIterators.h"
11 #include "../view_map/ViewMapIterators.h"
12 
13 namespace Freestyle {
14 
15 void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
16 {
20  Vec3r previous, current;
21  if (true == orientation) {
22  v = iViewEdge->vertices_begin();
23  vfirst = v;
24  vend = iViewEdge->vertices_end();
25  }
26  else {
27  v = iViewEdge->vertices_last();
28  vfirst = v;
29  vend = iViewEdge->vertices_end();
30  }
31 
32  if (!_Vertices.empty()) {
33  previous = _Vertices.back()->point2d();
34  if (orientation) {
35  ++v;
36  }
37  else {
38  --v;
39  }
40  // Ensure the continuity of underlying FEdges
41  CurvePoint *cp =
42  _Vertices.back(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.0f);
43  SVertex *sv_first = (*vfirst);
44  FEdge *fe = _fedgeB->duplicate();
45  fe->setTemporary(true);
46  fe->setVertexB(sv_first);
47  fe->vertexA()->shape()->AddEdge(fe);
48  fe->vertexA()->AddFEdge(fe);
49  fe->vertexB()->AddFEdge(fe);
50  cp->setA(sv_first);
51  }
52  else {
53  previous = (*v)->point2d();
54  }
55  do {
56  current = (*v)->point2d();
58  //_Length += (current - previous).norm();
59  previous = current;
60  if (orientation) {
61  ++v;
62  }
63  else {
64  --v;
65  }
66  } while ((v != vend) && (v != vfirst));
67 
68  if (v == vfirst) {
69  // Add last one:
70  current = (*v)->point2d();
72  //_Length += (current - previous).norm();
73  }
74 
75  _fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
76 }
77 
78 void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
79 {
80  orientation = !orientation;
84  Vec3r previous, current;
85  if (true == orientation) {
86  v = iViewEdge->vertices_begin();
87  vfirst = v;
88  vend = iViewEdge->vertices_end();
89  }
90  else {
91  v = iViewEdge->vertices_last();
92  vfirst = v;
93  vend = iViewEdge->vertices_end();
94  }
95 
96  if (!_Vertices.empty()) {
97  previous = _Vertices.front()->point2d();
98  if (orientation) {
99  ++v;
100  }
101  else {
102  --v;
103  }
104  // Ensure the continuity of underlying FEdges
105  CurvePoint *cp =
106  _Vertices.front(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.0f);
107  SVertex *sv_last = cp->A();
108  SVertex *sv_curr = (*v);
109  FEdge *fe = (orientation) ? iViewEdge->fedgeA() : iViewEdge->fedgeB();
110  FEdge *fe2 = fe->duplicate();
111  fe2->setTemporary(true);
112  fe2->setVertexA(sv_curr);
113  fe2->setVertexB(sv_last);
114  sv_last->AddFEdge(fe2);
115  sv_curr->AddFEdge(fe2);
116  sv_curr->shape()->AddEdge(fe2);
117  }
118  else {
119  previous = (*v)->point2d();
120  }
121  do {
122  current = (*v)->point2d();
124  //_Length += (current - previous).norm();
125  previous = current;
126  if (orientation) {
127  ++v;
128  }
129  else {
130  --v;
131  }
132  } while ((v != vend) && (v != vfirst));
133 
134  if (v == vfirst) {
135  // Add last one:
136  current = (*v)->point2d();
138  //_Length += (current - previous).norm();
139  }
140 
141  if (!_fedgeB) {
142  _fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
143  }
144 }
145 
146 } /* namespace Freestyle */
Class to define a chain of viewedges.
ATTR_WARN_UNUSED_RESULT const BMVert * v
void push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
Definition: Chain.cpp:78
void push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
Definition: Chain.cpp:15
FEdge * _fedgeB
Definition: Chain.h:24
void setA(SVertex *iA)
Definition: Curve.h:261
SVertex * A()
Definition: Curve.h:235
void push_vertex_back(Vertex *iVertex)
Definition: Curve.h:425
vertex_container _Vertices
Definition: Curve.h:379
void push_vertex_front(Vertex *iVertex)
Definition: Curve.h:449
void setTemporary(bool iFlag)
Definition: Silhouette.h:816
void setVertexB(SVertex *vB)
Definition: Silhouette.h:729
virtual FEdge * duplicate()
Definition: Silhouette.h:589
SVertex * vertexA()
Definition: Silhouette.h:597
SVertex * vertexB()
Definition: Silhouette.h:603
void setVertexA(SVertex *vA)
Definition: Silhouette.h:723
void AddEdge(FEdge *iEdge)
Definition: Silhouette.h:1551
SShape * shape()
Definition: Silhouette.h:263
void AddFEdge(FEdge *iFEdge)
Definition: Silhouette.h:359
const_vertex_iterator vertices_end() const
Definition: ViewMap.cpp:727
FEdge * fedgeB()
Definition: ViewMap.h:1085
FEdge * fedgeA()
Definition: ViewMap.h:1079
const_vertex_iterator vertices_last() const
Definition: ViewMap.cpp:717
const_vertex_iterator vertices_begin() const
embedding vertex iterator
Definition: ViewMap.cpp:707
inherits from class Rep
Definition: AppCanvas.cpp:18