Blender  V3.3
Controller.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #pragma once
4 
10 #include <string>
11 
12 #include "../geometry/FastGrid.h"
13 #include "../scene_graph/SceneHash.h"
14 #include "../system/Precision.h"
15 #include "../system/TimeUtils.h"
16 #include "../view_map/FEdgeXDetector.h"
17 #include "../view_map/ViewMapBuilder.h"
18 
19 #ifdef WITH_CXX_GUARDEDALLOC
20 # include "MEM_guardedalloc.h"
21 #endif
22 
23 struct Depsgraph;
24 struct Render;
25 struct ViewLayer;
26 
27 namespace Freestyle {
28 
29 class AppCanvas;
30 class AppView;
31 class Interpreter;
32 class NodeGroup;
33 class ProgressBar;
34 class RenderMonitor;
35 class SShape;
36 class ViewEdge;
37 class ViewMap;
38 
39 class Controller {
40  public:
41  Controller();
42  ~Controller();
43 
44  void setView(AppView *iView);
45  void setRenderMonitor(RenderMonitor *iRenderMonitor);
46  void setPassDiffuse(float *buf, int width, int height);
47  void setPassZ(float *buf, int width, int height);
48  void setContext(bContext *C);
49 
50  // soc
51  void init_options();
52 
53  int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph);
54  int Load3DSFile(const char *iFileName);
55  void CloseFile();
56  void ComputeViewMap();
60  int DrawStrokes();
61  void ResetRenderCount();
62  Render *RenderStrokes(Render *re, bool render);
63  void SwapStyleModules(unsigned i1, unsigned i2);
64  void InsertStyleModule(unsigned index, const char *iFileName);
65  void InsertStyleModule(unsigned index, const char *iName, const char *iBuffer);
66  void InsertStyleModule(unsigned index, const char *iName, struct Text *iText);
67  void AddStyleModule(const char *iFileName);
68  void RemoveStyleModule(unsigned index);
69  void ReloadStyleModule(unsigned index, const char *iFileName);
70  void Clear();
71  void ClearRootNode();
72  void DeleteWingedEdge();
73  void DeleteViewMap(bool freeCache = false);
74  void toggleLayer(unsigned index, bool iDisplay);
75  void setModified(unsigned index, bool iMod);
76  void resetModified(bool iMod = false);
77  void updateCausalStyleModules(unsigned index);
78  void displayDensityCurves(int x, int y);
79 
82  NodeGroup *BuildRep(vector<ViewEdge *>::iterator vedges_begin,
83  vector<ViewEdge *>::iterator vedges_end);
84 
85 #if 0
86  NodeGroup *debugNode()
87  {
88  return _DebugNode;
89  }
90  AppView *view()
91  {
92  return _pView;
93  }
94  NodeGroup *debugScene()
95  {
96  return _DebugNode;
97  }
98  Grid &grid()
99  {
100  return _Grid;
101  }
102 #endif
103 
104  void toggleVisibilityAlgo();
105  void setVisibilityAlgo(int algo);
106  int getVisibilityAlgo();
107 
108  void setViewMapCache(bool iBool);
109  bool getViewMapCache() const;
110  void setQuantitativeInvisibility(bool iBool); // if true, we compute quantitativeInvisibility
111  bool getQuantitativeInvisibility() const;
112  void setFaceSmoothness(bool iBool);
113  bool getFaceSmoothness() const;
114 
116  bool getComputeRidgesAndValleysFlag() const;
121 
122  void setComputeSteerableViewMapFlag(bool iBool);
123  bool getComputeSteerableViewMapFlag() const;
124  void setCreaseAngle(float angle)
125  {
126  _creaseAngle = angle;
127  }
128  float getCreaseAngle() const
129  {
130  return _creaseAngle;
131  }
132  void setSphereRadius(float s)
133  {
134  _sphereRadius = s;
135  }
136  float getSphereRadius() const
137  {
138  return _sphereRadius;
139  }
141  {
142  _suggestiveContourKrDerivativeEpsilon = dkr;
143  }
145  {
146  return _suggestiveContourKrDerivativeEpsilon;
147  }
148 
149  void setModelsDir(const string &dir);
150  string getModelsDir() const;
151  void setModulesDir(const string &dir);
152  string getModulesDir() const;
153 
154  bool hitViewMapCache();
155 
156  void resetInterpreter();
157 
158  public:
159  // Viewmap data structure
161 
162  // Canvas
164 
165  private:
166  // Main Window:
167  // AppMainWindow *_pMainWindow;
168 
169  // List of models currently loaded
170  vector<string> _ListOfModels;
171 
172  // Current directories
173  // ConfigIO* _current_dirs;
174 
175  // View
176  // 3D
177  AppView *_pView;
178 
179  // 2D
180 #if 0
181  Viewer2DWindow *_pView2DWindow;
182  Viewer2D *_pView2D;
183 #endif
184 
185  RenderMonitor *_pRenderMonitor;
186 
187  // Model
188  // Drawing Structure
189  NodeGroup *_RootNode;
190 
191  // Winged-Edge structure
192  WingedEdge *_winged_edge;
193 
194 #if 0
195  // Silhouette structure:
196  std::vector<SShape *> _SShapes;
197  NodeGroup *_SRoot;
198 
199  // Silhouette
200  NodeGroup *_SilhouetteNode;
201  NodeGroup *_ProjectedSilhouette;
202  NodeGroup *_VisibleProjectedSilhouette;
203 
204  // more Debug info
205  NodeGroup *_DebugNode;
206 #endif
207 
208  // debug
209  // NodeUser<ViewMap> *_ViewMapNode; // FIXME
210 
211  // Chronometer:
212  Chronometer _Chrono;
213 
214  // Progress Bar
215  ProgressBar *_ProgressBar;
216 
217  // edges tesselation nature
218  int _edgeTesselationNature;
219 
220  FastGrid _Grid;
221  // HashGrid _Grid;
222 
223  BBox<Vec3r> _Scene3dBBox;
224  unsigned int _SceneNumFaces;
225 #if 0
226  real _minEdgeSize;
227 #endif
228  real _EPSILON;
229  real _bboxDiag;
230 
231  int _render_count;
232 
233  // AppStyleWindow *_pStyleWindow;
234  // AppOptionsWindow *_pOptionsWindow;
235  // AppDensityCurvesWindow *_pDensityCurvesWindow;
236 
237  ViewMapBuilder::visibility_algo _VisibilityAlgo;
238 
239  // Script Interpreter
240  Interpreter *_inter;
241 
242  string _help_index;
243  string _browser_cmd;
244 
245  bool _EnableViewMapCache;
246  bool _EnableQI;
247  bool _EnableFaceSmoothness;
248  bool _ComputeRidges;
249  bool _ComputeSuggestive;
250  bool _ComputeMaterialBoundaries;
251  float _creaseAngle;
252  float _sphereRadius;
253  float _suggestiveContourKrDerivativeEpsilon;
254 
255  bool _ComputeSteerableViewMap;
256 
257  FEdgeXDetector edgeDetector;
258 
259  SceneHash sceneHashFunc;
260  real prevSceneHash;
261 
262 #ifdef WITH_CXX_GUARDEDALLOC
263  MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:Controller")
264 #endif
265 };
266 
267 extern Controller *g_pController;
268 
269 } /* namespace Freestyle */
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:35
static AppView * view
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint i1
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:25
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
Definition: btVector3.h:356
Render * RenderStrokes(Render *re, bool render)
Definition: Controller.cpp:890
string getModelsDir() const
void setComputeSuggestiveContoursFlag(bool b)
Definition: Controller.cpp:833
void setPassZ(float *buf, int width, int height)
Definition: Controller.cpp:195
bool getFaceSmoothness() const
Definition: Controller.cpp:818
void updateCausalStyleModules(unsigned index)
Definition: Controller.cpp:983
bool getComputeMaterialBoundariesFlag() const
Definition: Controller.cpp:848
bool getComputeSteerableViewMapFlag() const
Definition: Controller.cpp:858
void toggleLayer(unsigned index, bool iDisplay)
Definition: Controller.cpp:971
void setSphereRadius(float s)
Definition: Controller.h:132
void setComputeMaterialBoundariesFlag(bool b)
Definition: Controller.cpp:843
void setVisibilityAlgo(int algo)
Definition: Controller.cpp:742
void AddStyleModule(const char *iFileName)
Definition: Controller.cpp:945
void setComputeRidgesAndValleysFlag(bool b)
Definition: Controller.cpp:823
void setFaceSmoothness(bool iBool)
Definition: Controller.cpp:813
void setPassDiffuse(float *buf, int width, int height)
Definition: Controller.cpp:188
ViewEdge * SelectViewEdge(real x, real y)
void saveSteerableViewMapImages()
Definition: Controller.cpp:719
int Load3DSFile(const char *iFileName)
void toggleEdgeTesselationNature(Nature::EdgeNature iNature)
void SwapStyleModules(unsigned i1, unsigned i2)
Definition: Controller.cpp:966
float getSphereRadius() const
Definition: Controller.h:136
void RemoveStyleModule(unsigned index)
Definition: Controller.cpp:950
void ReloadStyleModule(unsigned index, const char *iFileName)
Definition: Controller.cpp:960
bool getQuantitativeInvisibility() const
Definition: Controller.cpp:808
FEdge * SelectFEdge(real x, real y)
void setModulesDir(const string &dir)
void DeleteViewMap(bool freeCache=false)
Definition: Controller.cpp:406
int LoadMesh(Render *re, ViewLayer *view_layer, Depsgraph *depsgraph)
Definition: Controller.cpp:220
bool getComputeSuggestiveContoursFlag() const
Definition: Controller.cpp:838
string getModulesDir() const
NodeGroup * BuildRep(vector< ViewEdge * >::iterator vedges_begin, vector< ViewEdge * >::iterator vedges_end)
Definition: Controller.cpp:999
void setViewMapCache(bool iBool)
Definition: Controller.cpp:793
void setQuantitativeInvisibility(bool iBool)
Definition: Controller.cpp:803
void setContext(bContext *C)
Definition: Controller.cpp:202
void setSuggestiveContourKrDerivativeEpsilon(float dkr)
Definition: Controller.h:140
void setComputeSteerableViewMapFlag(bool iBool)
Definition: Controller.cpp:853
void setCreaseAngle(float angle)
Definition: Controller.h:124
float getCreaseAngle() const
Definition: Controller.h:128
void setModified(unsigned index, bool iMod)
Definition: Controller.cpp:976
void InsertStyleModule(unsigned index, const char *iFileName)
Definition: Controller.cpp:922
bool getComputeRidgesAndValleysFlag() const
Definition: Controller.cpp:828
float getSuggestiveContourKrDerivativeEpsilon() const
Definition: Controller.h:144
void setView(AppView *iView)
Definition: Controller.cpp:173
void resetModified(bool iMod=false)
Definition: Controller.cpp:993
void setRenderMonitor(RenderMonitor *iRenderMonitor)
Definition: Controller.cpp:183
bool getViewMapCache() const
Definition: Controller.cpp:798
void displayDensityCurves(int x, int y)
AppCanvas * _Canvas
Definition: Controller.h:163
void setModelsDir(const string &dir)
const Depsgraph * depsgraph
unsigned short EdgeNature
Definition: Nature.h:32
inherits from class Rep
Definition: AppCanvas.cpp:18
static unsigned x[3]
Definition: RandGen.cpp:73
Controller * g_pController
double real
Definition: Precision.h:12
static const pxr::TfToken b("b", pxr::TfToken::Immortal)