Blender V5.0
FEdgeXDetector.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11
12#include <vector>
13
14#include "../geometry/Geom.h"
15
19
22
23#include "MEM_guardedalloc.h"
24
25namespace Freestyle {
26
27using namespace Geometry;
28
31 public:
33 {
34 _pProgressBar = nullptr;
35 _pRenderMonitor = nullptr;
37#if 0
38 _bbox_diagonal = 1.0;
39#endif
40 _meanEdgeSize = 0;
44 _sphereRadius = 1.0;
46 _faceSmoothness = false;
47 _changes = false;
49 _creaseAngle = 0.7; // angle of 134.43 degrees
50 }
51
52 virtual ~FEdgeXDetector() {}
53
55 virtual void processShapes(WingedEdge &);
56
57 // GENERAL STUFF
58 virtual void preProcessShape(WXShape *iWShape);
59 virtual void preProcessFace(WXFace *iFace);
60 virtual void computeCurvatures(WXVertex *iVertex);
61
62 // SILHOUETTE
63 virtual void processSilhouetteShape(WXShape *iWShape);
64 virtual void ProcessSilhouetteFace(WXFace *iFace);
65 virtual void ProcessSilhouetteEdge(WXEdge *iEdge);
66
67 // CREASE
68 virtual void processCreaseShape(WXShape *iWShape);
69 virtual void ProcessCreaseEdge(WXEdge *iEdge);
70
77 // XXX angle should be in radian...
78 inline void setCreaseAngle(float angle)
79 {
80 if (angle < 0.0) {
81 angle = 0.0;
82 }
83 else if (angle > 180.0) {
84 angle = 180.0;
85 }
86 angle = cos(M_PI * (180.0 - angle) / 180.0);
87 if (angle != _creaseAngle) {
89 _changes = true;
90 }
91 }
92
93 // BORDER
94 virtual void processBorderShape(WXShape *iWShape);
95 virtual void ProcessBorderEdge(WXEdge *iEdge);
96
97 // RIDGES AND VALLEYS
98 virtual void processRidgesAndValleysShape(WXShape *iWShape);
99 virtual void ProcessRidgeFace(WXFace *iFace);
100
101 // SUGGESTIVE CONTOURS
102 virtual void processSuggestiveContourShape(WXShape *iWShape);
103 virtual void ProcessSuggestiveContourFace(WXFace *iFace);
104 virtual void postProcessSuggestiveContourShape(WXShape *iShape);
105 virtual void postProcessSuggestiveContourFace(WXFace *iFace);
111 {
112 if (dkr != _kr_derivative_epsilon) {
114 _changes = true;
115 }
116 }
117
118 // MATERIAL BOUNDARY
119 virtual void processMaterialBoundaryShape(WXShape *iWShape);
120 virtual void ProcessMaterialBoundaryEdge(WXEdge *iEdge);
121
122 // EDGE MARKS
123 virtual void processEdgeMarksShape(WXShape *iShape);
124 virtual void ProcessEdgeMarks(WXEdge *iEdge);
125
126 // EVERYBODY
127 virtual void buildSmoothEdges(WXShape *iShape);
128
130 inline void setViewpoint(const Vec3f &ivp)
131 {
132 _Viewpoint = ivp;
133 }
134
136 {
138 }
139
141 {
143 }
144
145 inline void enableSuggestiveContours(bool b)
146 {
148 }
149
150 inline void enableMaterialBoundaries(bool b)
151 {
153 }
154
155 inline void enableFaceSmoothness(bool b)
156 {
157 if (b != _faceSmoothness) {
159 _changes = true;
160 }
161 }
162
163 inline void enableFaceMarks(bool b)
164 {
165 if (b != _faceMarks) {
166 _faceMarks = b;
167 _changes = true;
168 }
169 }
170
175 inline void setSphereRadius(float r)
176 {
177 if (r != _sphereRadius) {
178 _sphereRadius = r;
179 _changes = true;
180 }
181 }
182
183 inline void setProgressBar(ProgressBar *iProgressBar)
184 {
185 _pProgressBar = iProgressBar;
186 }
187
188 inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
189 {
190 _pRenderMonitor = iRenderMonitor;
191 }
192
193 protected:
195#if 0
196 real _bbox_diagonal; // diagonal of the current processed shape bbox
197#endif
198 // oldtmp values
209
215 float _sphereRadius; // expressed as a ratio of the mean edge size
216 float _creaseAngle; // [-1, 1] compared with the inner product of face normals
218
220
223
224 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FEdgeXDetector")
225};
226
227} /* namespace Freestyle */
#define M_PI
unsigned int uint
GTS - Library for the manipulation of triangulated surfaces.
Configuration definitions.
Vectors and Matrices (useful type definitions).
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
Definition IK_Math.h:117
Read Guarded memory(de)allocation.
Class to encapsulate a progress bar.
Classes defining the basic "Iterator" design pattern.
Classes to define an Extended Winged Edge data structure.
virtual void processRidgesAndValleysShape(WXShape *iWShape)
virtual void ProcessBorderEdge(WXEdge *iEdge)
void enableMaterialBoundaries(bool b)
virtual void processShapes(WingedEdge &)
virtual void ProcessMaterialBoundaryEdge(WXEdge *iEdge)
virtual void processEdgeMarksShape(WXShape *iShape)
virtual void processCreaseShape(WXShape *iWShape)
virtual void ProcessEdgeMarks(WXEdge *iEdge)
void enableSuggestiveContours(bool b)
virtual void ProcessRidgeFace(WXFace *iFace)
virtual void processMaterialBoundaryShape(WXShape *iWShape)
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
virtual void preProcessFace(WXFace *iFace)
void setCreaseAngle(float angle)
virtual void ProcessSilhouetteFace(WXFace *iFace)
void setProgressBar(ProgressBar *iProgressBar)
virtual void buildSmoothEdges(WXShape *iShape)
virtual void preProcessShape(WXShape *iWShape)
RenderMonitor * _pRenderMonitor
virtual void computeCurvatures(WXVertex *iVertex)
void enableOrthographicProjection(bool b)
void setViewpoint(const Vec3f &ivp)
virtual void processSuggestiveContourShape(WXShape *iWShape)
virtual void processSilhouetteShape(WXShape *iWShape)
virtual void ProcessSilhouetteEdge(WXEdge *iEdge)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
virtual void postProcessSuggestiveContourShape(WXShape *iShape)
virtual void ProcessCreaseEdge(WXEdge *iEdge)
void enableRidgesAndValleysFlag(bool b)
virtual void ProcessSuggestiveContourFace(WXFace *iFace)
virtual void postProcessSuggestiveContourFace(WXFace *iFace)
virtual void processBorderShape(WXShape *iWShape)
#define cos
VecMat::Vec3< float > Vec3f
Definition Geom.h:28
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14