Blender V4.3
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
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#ifdef WITH_CXX_GUARDEDALLOC
37# include "MEM_guardedalloc.h"
38#endif
39
40namespace Freestyle {
41
42using namespace Geometry;
43
45 private:
46 ViewMap *_ViewMap; // result
47 // SilhouetteGeomEngine _GeomEngine;
48 ProgressBar *_pProgressBar;
49 RenderMonitor *_pRenderMonitor;
50 Vec3r _viewpoint;
51 bool _orthographicProjection;
52 Grid *_Grid;
53 ViewEdgeXBuilder *_pViewEdgeBuilder;
54 bool _EnableQI;
55 double _epsilon;
56
57 // tmp values:
58 int _currentId;
59 int _currentFId;
60 int _currentSVertexId;
61
62 public:
63 typedef enum {
66
76
78 {
79 _pProgressBar = nullptr;
80 _pRenderMonitor = nullptr;
81 _Grid = nullptr;
82 _currentId = 1;
83 _currentFId = 0;
84 _currentSVertexId = 0;
85 _pViewEdgeBuilder = new ViewEdgeXBuilder;
86 _EnableQI = true;
87 }
88
90 {
91 if (_pViewEdgeBuilder) {
92 delete _pViewEdgeBuilder;
93 _pViewEdgeBuilder = nullptr;
94 }
95 }
96
97 /* Build Grid for ray casting */
99 void BuildGrid(WingedEdge &we, const BBox<Vec3r> &bbox, uint sceneNumFaces);
100
103
105 void computeCusps(ViewMap *ioViewMap);
106
110 void DetectCusps(ViewEdge *ioEdge);
111
113 inline void setViewpoint(const Vec3r &ivp)
114 {
115 _viewpoint = ivp;
117 }
118
127 inline void setTransform(const real iModelViewMatrix[4][4],
128 const real iProjectionMatrix[4][4],
129 const int iViewport[4],
130 real iFocalLength,
131 real /*iAspect*/,
132 real /*iFovy*/)
133 {
134 _orthographicProjection = (iProjectionMatrix[3][3] != 0.0);
136 iModelViewMatrix, iProjectionMatrix, iViewport, iFocalLength);
137 }
138
139 inline void setFrustum(real iZnear, real iZfar)
140 {
142 }
143
150 visibility_algo iAlgo,
151 real epsilon,
152 const BBox<Vec3r> &bbox,
153 uint sceneNumFaces);
154
155 void CullViewEdges(ViewMap *ioViewMap,
156 real viewProscenium[4],
157 real occluderProscenium[4],
158 bool extensiveFEdgeSearch = true);
159
168 void ComputeIntersections(ViewMap *ioViewMap,
170 real epsilon = 1.0e-06);
171
176 void ComputeEdgesVisibility(ViewMap *ioViewMap,
177 WingedEdge &we,
178 const BBox<Vec3r> &bbox,
179 uint sceneNumFaces,
181 real epsilon = 1.0e-6);
182
183 void setGrid(Grid *iGrid)
184 {
185 _Grid = iGrid;
186 }
187
191 inline void setProgressBar(ProgressBar *iProgressBar)
192 {
193 _pProgressBar = iProgressBar;
194 }
195
196 inline void setRenderMonitor(RenderMonitor *iRenderMonitor)
197 {
198 _pRenderMonitor = iRenderMonitor;
199 }
200
201 inline void setEnableQI(bool iBool)
202 {
203 _EnableQI = iBool;
204 }
205
206 protected:
208 void ComputeSweepLineIntersections(ViewMap *ioViewMap, real epsilon = 1.0e-6);
209
216 void ComputeRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
217 void ComputeFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
218 void ComputeVeryFastRayCastingVisibility(ViewMap *ioViewMap, real epsilon = 1.0e-6);
219
220 void ComputeCumulativeVisibility(ViewMap *ioViewMap,
221 WingedEdge &we,
222 const BBox<Vec3r> &bbox,
223 real epsilon,
224 bool cull,
226 void ComputeDetailedVisibility(ViewMap *ioViewMap,
227 WingedEdge &we,
228 const BBox<Vec3r> &bbox,
229 real epsilon,
230 bool cull,
232
249 Grid *iGrid,
250 real epsilon,
251 set<ViewShape *> &oOccluders,
252 Polygon3r **oaPolygon,
253 uint timestamp);
254 // FIXME
255 void FindOccludee(FEdge *fe, Grid *iGrid, real epsilon, Polygon3r **oaPolygon, uint timestamp);
256 void FindOccludee(FEdge *fe,
257 Grid *iGrid,
258 real epsilon,
259 Polygon3r **oaPolygon,
260 uint timestamp,
261 Vec3r &u,
262 Vec3r &A,
263 Vec3r &origin,
264 Vec3r &edgeDir,
265 vector<WVertex *> &faceVertices);
266
267#ifdef WITH_CXX_GUARDEDALLOC
268 MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:ViewMapBuilder")
269#endif
270};
271
272} /* 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.
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)
inherits from class Rep
Definition AppCanvas.cpp:20
double real
Definition Precision.h:14