2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * ***** END GPL LICENSE BLOCK *****
21 #ifndef __FREESTYLE_FEDGE_X_DETECTOR_H__
22 #define __FREESTYLE_FEDGE_X_DETECTOR_H__
24 /** \file blender/freestyle/intern/view_map/FEdgeXDetector.h
26 * \brief Detects/flags/builds extended features edges on the WXEdge structure
27 * \author Stephane Grabli
33 #include "../geometry/Geom.h"
35 #include "../system/FreestyleConfig.h"
36 #include "../system/ProgressBar.h"
37 #include "../system/RenderMonitor.h"
39 #include "../winged_edge/Curvature.h"
40 #include "../winged_edge/WXEdge.h"
44 #ifdef WITH_CXX_GUARDEDALLOC
45 #include "MEM_guardedalloc.h"
50 using namespace Geometry;
52 /*! This class takes as input a WXEdge structure and fills it */
59 _pRenderMonitor = NULL;
60 _computeViewIndependent = true;
65 _computeRidgesAndValleys = true;
66 _computeSuggestiveContours = true;
67 _computeMaterialBoundaries = true;
69 _orthographicProjection = false;
70 _faceSmoothness = false;
72 _kr_derivative_epsilon = 0.0;
73 _creaseAngle = 0.7; // angle of 134.43 degrees
76 virtual ~FEdgeXDetector() {}
78 /*! Process shapes from a WingedEdge containing a list of WShapes */
79 virtual void processShapes(WingedEdge&);
82 virtual void preProcessShape(WXShape *iShape);
83 virtual void preProcessFace(WXFace *iFace);
84 virtual void computeCurvatures(WXVertex *iVertex);
87 virtual void processSilhouetteShape(WXShape *iShape);
88 virtual void ProcessSilhouetteFace(WXFace *iFace);
89 virtual void ProcessSilhouetteEdge(WXEdge *iEdge);
92 virtual void processCreaseShape(WXShape *iShape);
93 virtual void ProcessCreaseEdge(WXEdge *iEdge);
95 /*! Sets the minimum angle for detecting crease edges
97 * The angular threshold in degrees (between 0 and 180) for detecting crease edges. An edge is considered
98 * a crease edge if the angle between two faces sharing the edge is smaller than the given threshold.
100 // XXX angle should be in radian...
101 inline void setCreaseAngle(real angle)
105 else if (angle > 180.0)
107 angle = cos(M_PI * (180.0 - angle) / 180.0);
108 if (angle != _creaseAngle) {
109 _creaseAngle = angle;
115 virtual void processBorderShape(WXShape *iShape);
116 virtual void ProcessBorderEdge(WXEdge *iEdge);
118 // RIDGES AND VALLEYS
119 virtual void processRidgesAndValleysShape(WXShape *iShape);
120 virtual void ProcessRidgeFace(WXFace *iFace);
122 // SUGGESTIVE CONTOURS
123 virtual void processSuggestiveContourShape(WXShape *iShape);
124 virtual void ProcessSuggestiveContourFace(WXFace *iFace);
125 virtual void postProcessSuggestiveContourShape(WXShape *iShape);
126 virtual void postProcessSuggestiveContourFace(WXFace *iFace);
127 /*! Sets the minimal derivative of the radial curvature for suggestive contours
129 * The minimal derivative of the radial curvature
131 inline void setSuggestiveContourKrDerivativeEpsilon(real dkr)
133 if (dkr != _kr_derivative_epsilon) {
134 _kr_derivative_epsilon = dkr;
140 virtual void processMaterialBoundaryShape(WXShape *iWShape);
141 virtual void ProcessMaterialBoundaryEdge(WXEdge *iEdge);
144 virtual void processEdgeMarksShape(WXShape *iShape);
145 virtual void ProcessEdgeMarks(WXEdge *iEdge);
148 virtual void buildSmoothEdges(WXShape *iShape);
150 /*! Sets the current viewpoint */
151 inline void setViewpoint(const Vec3r& ivp)
156 inline void enableOrthographicProjection(bool b)
158 _orthographicProjection = b;
161 inline void enableRidgesAndValleysFlag(bool b)
163 _computeRidgesAndValleys = b;
166 inline void enableSuggestiveContours(bool b)
168 _computeSuggestiveContours = b;
171 inline void enableMaterialBoundaries(bool b)
173 _computeMaterialBoundaries = b;
176 inline void enableFaceSmoothness(bool b)
178 if (b != _faceSmoothness) {
184 inline void enableFaceMarks(bool b)
186 if (b != _faceMarks) {
192 /*! Sets the radius of the geodesic sphere around each vertex (for the curvature computation)
194 * The radius of the sphere expressed as a ratio of the mean edge size
196 inline void setSphereRadius(real r)
198 if (r != _sphereRadius) {
204 inline void setProgressBar(ProgressBar *iProgressBar)
206 _pProgressBar = iProgressBar;
209 inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
211 _pRenderMonitor = iRenderMonitor;
217 real _bbox_diagonal; // diagonal of the current processed shape bbox
220 bool _computeViewIndependent;
229 bool _orthographicProjection;
231 bool _computeRidgesAndValleys;
232 bool _computeSuggestiveContours;
233 bool _computeMaterialBoundaries;
234 bool _faceSmoothness;
236 real _sphereRadius; // expressed as a ratio of the mean edge size
237 real _creaseAngle; // [-1, 1] compared with the inner product of face normals
240 real _kr_derivative_epsilon;
242 ProgressBar *_pProgressBar;
243 RenderMonitor *_pRenderMonitor;
245 #ifdef WITH_CXX_GUARDEDALLOC
246 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FEdgeXDetector")
250 } /* namespace Freestyle */
252 #endif // __FREESTYLE_FEDGE_X_DETECTOR_H__