Blender V5.0
ViewMapBuilder.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 "GridDensityProvider.h"
15#include "Silhouette.h"
17#include "ViewEdgeXBuilder.h"
18#include "ViewMap.h"
19
20#include "../geometry/Geom.h"
22#include "../geometry/Grid.h"
24
27
31#include "../system/TimeUtils.h"
32
35
36#include "MEM_guardedalloc.h"
37
38namespace Freestyle {
39
40using namespace Geometry;
41
43 private:
44 ViewMap *_ViewMap; // result
45 // SilhouetteGeomEngine _GeomEngine;
46 ProgressBar *_pProgressBar;
47 RenderMonitor *_pRenderMonitor;
48 Vec3r _viewpoint;
49 bool _orthographicProjection;
50 Grid *_Grid;
51 ViewEdgeXBuilder *_pViewEdgeBuilder;
52 bool _EnableQI;
53 double _epsilon;
54
55 // tmp values:
56 int _currentId;
57 int _currentFId;
58 int _currentSVertexId;
59
60 public:
61 typedef enum {
64
74
76 {
77 _pProgressBar = nullptr;
78 _pRenderMonitor = nullptr;
79 _Grid = nullptr;
80 _currentId = 1;
81 _currentFId = 0;
82 _currentSVertexId = 0;
83 _pViewEdgeBuilder = new ViewEdgeXBuilder;
84 _EnableQI = true;
85 }
86
88 {
89 if (_pViewEdgeBuilder) {
90 delete _pViewEdgeBuilder;
91 _pViewEdgeBuilder = nullptr;
92 }
93 }
94
95 /* Build Grid for ray casting */
97 void BuildGrid(WingedEdge &we, const BBox<Vec3r> &bbox, uint sceneNumFaces);
98
101
103 void computeCusps(ViewMap *ioViewMap);
104
108 void DetectCusps(ViewEdge *ioEdge);
109
111 inline void setViewpoint(const Vec3r &ivp)
112 {
113 _viewpoint = ivp;
115 }
116
125 inline void setTransform(const real iModelViewMatrix[4][4],
126 const real iProjectionMatrix[4][4],
127 const int iViewport[4],
128 real iFocalLength,
129 real /*iAspect*/,
130 real /*iFovy*/)
131 {
132 _orthographicProjection = (iProjectionMatrix[3][3] != 0.0);
134 iModelViewMatrix, iProjectionMatrix, iViewport, iFocalLength);
135 }
136
137 inline void setFrustum(real iZnear, real iZfar)
138 {
140 }
141
148 visibility_algo iAlgo,
149 real epsilon,
150 const BBox<Vec3r> &bbox,
151 uint sceneNumFaces);
152
153 void CullViewEdges(ViewMap *ioViewMap,
154 real viewProscenium[4],
155 real occluderProscenium[4],
156 bool extensiveFEdgeSearch = true);
157
166 void ComputeIntersections(ViewMap *ioViewMap,
168 real epsilon = 1.0e-06);
169
174 void ComputeEdgesVisibility(ViewMap *ioViewMap,
175 WingedEdge &we,
176 const BBox<Vec3r> &bbox,
177 uint sceneNumFaces,
179 real epsilon = 1.0e-6);
180
181 void setGrid(Grid *iGrid)
182 {
183 _Grid = iGrid;
184 }
185
187
189 inline void setProgressBar(ProgressBar *iProgressBar)
190 {
191 _pProgressBar = iProgressBar;
192 }
193
194 inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
195 {
196 _pRenderMonitor = iRenderMonitor;
197 }
198
199 inline void setEnableQI(bool iBool)
200 {
201 _EnableQI = iBool;
202 }
203
204 protected:
206 void ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsilon = 1.0e-6);
207
214 void ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
215 void ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
216 void ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
217
218 void ComputeCumulativeVisibility(ViewMap *ioViewMap,
219 WingedEdge &we,
220 const BBox<Vec3r> &bbox,
221 real epsilon,
222 bool cull,
224 void ComputeDetailedVisibility(ViewMap *ioViewMap,
225 WingedEdge &we,
226 const BBox<Vec3r> &bbox,
227 real epsilon,
228 bool cull,
230
247 Grid *iGrid,
248 real epsilon,
249 set<ViewShape *> &oOccluders,
250 Polygon3r **oaPolygon,
251 uint timestamp);
252 // FIXME
253 void FindOccludee(FEdge *fe, Grid *iGrid, real epsilon, Polygon3r **oaPolygon, uint timestamp);
254 void FindOccludee(FEdge *fe,
255 Grid *iGrid,
256 real epsilon,
257 Polygon3r **oaPolygon,
258 uint timestamp,
259 Vec3r &u,
260 Vec3r &A,
261 Vec3r &origin,
262 Vec3r &edgeDir,
263 vector<WVertex *> &faceVertices);
264
265 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewMapBuilder")
266};
267
268} /* namespace Freestyle */
unsigned int uint
Configuration definitions.
Various tools for geometry.
Vectors and Matrices (useful type definitions).
Class to define a cell grid surrounding the projected image of a scene.
Base class to define a cell grid surrounding the bounding box of the scene.
Read Guarded memory(de)allocation.
Class to represent a group node. This node can contains several children.
Class to encapsulate a progress bar.
Classes defining the basic "Iterator" design pattern.
Class to perform all geometric operations dedicated to silhouette. That, for example,...
Classes to define a silhouette structure.
Class to define a Sweep Line.
Class to measure elapsed time.
Class to define the representation of a triangle.
Class to build view edges and the underlying chains of feature edges...
Classes to define a View Map (ViewVertex, ViewEdge, etc.).
Classes to define a Winged Edge data structure.
Classes to define an Extended Winged Edge data structure.
#define A
static void setViewpoint(const Vec3r &ivp)
static void setFrustum(real iZNear, real iZFar)
static void setTransform(const real iModelViewMatrix[4][4], const real iProjectionMatrix[4][4], const int iViewport[4], real iFocal)
void ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon=1.0e-6)
void ComputeCumulativeVisibility(ViewMap *ioViewMap, WingedEdge &we, const BBox< Vec3r > &bbox, real epsilon, bool cull, GridDensityProviderFactory &factory)
void setTransform(const real iModelViewMatrix[4][4], const real iProjectionMatrix[4][4], const int iViewport[4], real iFocalLength, real, real)
void setGrid(Grid *iGrid)
void BuildGrid(WingedEdge &we, const BBox< Vec3r > &bbox, uint sceneNumFaces)
ViewMap * BuildViewMap(WingedEdge &we, visibility_algo iAlgo, real epsilon, const BBox< Vec3r > &bbox, uint sceneNumFaces)
void CullViewEdges(ViewMap *ioViewMap, real viewProscenium[4], real occluderProscenium[4], bool extensiveFEdgeSearch=true)
void setEnableQI(bool iBool)
void computeInitialViewEdges(WingedEdge &)
void ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilon=1.0e-6)
void FindOccludee(FEdge *fe, Grid *iGrid, real epsilon, Polygon3r **oaPolygon, uint timestamp)
void ComputeEdgesVisibility(ViewMap *ioViewMap, WingedEdge &we, const BBox< Vec3r > &bbox, uint sceneNumFaces, visibility_algo iAlgo=ray_casting, real epsilon=1.0e-6)
void setViewpoint(const Vec3r &ivp)
void computeCusps(ViewMap *ioViewMap)
void setFrustum(real iZnear, real iZfar)
void setProgressBar(ProgressBar *iProgressBar)
void setRenderMonitor(RenderMonitor *iRenderMonitor)
void DetectCusps(ViewEdge *ioEdge)
void ComputeIntersections(ViewMap *ioViewMap, intersection_algo iAlgo=sweep_line, real epsilon=1.0e-06)
void ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsilon=1.0e-6)
void ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon=1.0e-6)
void ComputeDetailedVisibility(ViewMap *ioViewMap, WingedEdge &we, const BBox< Vec3r > &bbox, real epsilon, bool cull, GridDensityProviderFactory &factory)
VecMat::Vec3< real > Vec3r
Definition Geom.h:30
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14