Blender V4.3
Chain.cpp
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10#include "Chain.h"
11
14
15namespace Freestyle {
16
17void Chain::push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
18{
22 Vec3r previous, current;
23 if (true == orientation) {
24 v = iViewEdge->vertices_begin();
25 vfirst = v;
26 vend = iViewEdge->vertices_end();
27 }
28 else {
29 v = iViewEdge->vertices_last();
30 vfirst = v;
31 vend = iViewEdge->vertices_end();
32 }
33
34 if (!_Vertices.empty()) {
35 previous = _Vertices.back()->point2d();
36 if (orientation) {
37 ++v;
38 }
39 else {
40 --v;
41 }
42 // Ensure the continuity of underlying FEdges
43 CurvePoint *cp =
44 _Vertices.back(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.0f);
45 SVertex *sv_first = (*vfirst);
46 FEdge *fe = _fedgeB->duplicate();
47 fe->setTemporary(true);
48 fe->setVertexB(sv_first);
49 fe->vertexA()->shape()->AddEdge(fe);
50 fe->vertexA()->AddFEdge(fe);
51 fe->vertexB()->AddFEdge(fe);
52 cp->setA(sv_first);
53 }
54 else {
55 previous = (*v)->point2d();
56 }
57 do {
58 current = (*v)->point2d();
59 Curve::push_vertex_back(*v);
60 //_Length += (current - previous).norm();
61 previous = current;
62 if (orientation) {
63 ++v;
64 }
65 else {
66 --v;
67 }
68 } while ((v != vend) && (v != vfirst));
69
70 if (v == vfirst) {
71 // Add last one:
72 current = (*v)->point2d();
73 Curve::push_vertex_back(*v);
74 //_Length += (current - previous).norm();
75 }
76
77 _fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
78}
79
80void Chain::push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
81{
82 orientation = !orientation;
86 Vec3r previous, current;
87 if (true == orientation) {
88 v = iViewEdge->vertices_begin();
89 vfirst = v;
90 vend = iViewEdge->vertices_end();
91 }
92 else {
93 v = iViewEdge->vertices_last();
94 vfirst = v;
95 vend = iViewEdge->vertices_end();
96 }
97
98 if (!_Vertices.empty()) {
99 previous = _Vertices.front()->point2d();
100 if (orientation) {
101 ++v;
102 }
103 else {
104 --v;
105 }
106 // Ensure the continuity of underlying FEdges
107 CurvePoint *cp =
108 _Vertices.front(); // assumed to be instantiated as new CurvePoint(iSVertex, 0, 0.0f);
109 SVertex *sv_last = cp->A();
110 SVertex *sv_curr = (*v);
111 FEdge *fe = (orientation) ? iViewEdge->fedgeA() : iViewEdge->fedgeB();
112 FEdge *fe2 = fe->duplicate();
113 fe2->setTemporary(true);
114 fe2->setVertexA(sv_curr);
115 fe2->setVertexB(sv_last);
116 sv_last->AddFEdge(fe2);
117 sv_curr->AddFEdge(fe2);
118 sv_curr->shape()->AddEdge(fe2);
119 }
120 else {
121 previous = (*v)->point2d();
122 }
123 do {
124 current = (*v)->point2d();
125 Curve::push_vertex_front(*v);
126 //_Length += (current - previous).norm();
127 previous = current;
128 if (orientation) {
129 ++v;
130 }
131 else {
132 --v;
133 }
134 } while ((v != vend) && (v != vfirst));
135
136 if (v == vfirst) {
137 // Add last one:
138 current = (*v)->point2d();
139 Curve::push_vertex_front(*v);
140 //_Length += (current - previous).norm();
141 }
142
143 if (!_fedgeB) {
144 _fedgeB = (orientation) ? iViewEdge->fedgeB() : iViewEdge->fedgeA();
145 }
146}
147
148} /* namespace Freestyle */
Class to define a chain of view-edges.
Iterators used to iterate over the various elements of the ViewMap. These iterators can't be exported...
Iterators used to iterate over the various elements of the ViewMap.
ATTR_WARN_UNUSED_RESULT const BMVert * v
void push_viewedge_front(ViewEdge *iViewEdge, bool orientation)
Definition Chain.cpp:80
void push_viewedge_back(ViewEdge *iViewEdge, bool orientation)
Definition Chain.cpp:17
FEdge * _fedgeB
Definition Chain.h:26
void setA(SVertex *iA)
Definition Curve.h:263
SVertex * A()
Definition Curve.h:237
vertex_container _Vertices
Definition Curve.h:381
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)
void AddFEdge(FEdge *iFEdge)
Definition Silhouette.h:361
const_vertex_iterator vertices_end() const
Definition ViewMap.cpp:744
const_vertex_iterator vertices_last() const
Definition ViewMap.cpp:734
const_vertex_iterator vertices_begin() const
embedding vertex iterator
Definition ViewMap.cpp:724
inherits from class Rep
Definition AppCanvas.cpp:20