Blender  V3.3
OccluderSource.cpp
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
8 #include <algorithm>
9 
10 #include "OccluderSource.h"
11 
12 #include "BKE_global.h"
13 
14 namespace Freestyle {
15 
16 OccluderSource::OccluderSource(const GridHelpers::Transform &t, WingedEdge &we)
17  : wingedEdge(we), valid(false), transform(t)
18 {
19  begin();
20 }
21 
23 
25 {
26  vector<Vec3r> vertices(GridHelpers::enumerateVertices((*currentFace)->getEdgeList()));
27  // This doesn't work, because our functor's polymorphism won't survive the copy:
28  // std::transform(vertices.begin(), vertices.end(), vertices.begin(), transform);
29  // so we have to do:
30  for (vector<Vec3r>::iterator i = vertices.begin(); i != vertices.end(); ++i) {
31  (*i) = transform(*i);
32  }
33  cachedPolygon = Polygon3r(vertices, transform((*currentFace)->GetNormal()));
34 }
35 
37 {
38  vector<WShape *> &wshapes = wingedEdge.getWShapes();
39  currentShape = wshapes.begin();
40  shapesEnd = wshapes.end();
41  valid = false;
42  if (currentShape != shapesEnd) {
43  vector<WFace *> &wFaces = (*currentShape)->GetFaceList();
44  currentFace = wFaces.begin();
45  facesEnd = wFaces.end();
46 
47  if (currentFace != facesEnd) {
49  valid = true;
50  }
51  }
52 }
53 
55 {
56  if (valid) {
57  ++currentFace;
58  while (currentFace == facesEnd) {
59  ++currentShape;
60  if (currentShape == shapesEnd) {
61  valid = false;
62  return false;
63  }
64 
65  vector<WFace *> &wFaces = (*currentShape)->GetFaceList();
66  currentFace = wFaces.begin();
67  facesEnd = wFaces.end();
68  }
70  return true;
71  }
72  return false;
73 }
74 
76 {
77  // Or:
78  // return currentShapes != shapesEnd && currentFace != facesEnd;
79  return valid;
80 }
81 
83 {
84  return valid ? *currentFace : nullptr;
85 }
86 
88 {
89  return Polygon3r(GridHelpers::enumerateVertices((*currentFace)->getEdgeList()),
90  (*currentFace)->GetNormal());
91 }
92 
94 {
95  return cachedPolygon;
96 }
97 
99 {
100  begin();
101  const Vec3r &initialPoint = cachedPolygon.getVertices()[0];
102  proscenium[0] = proscenium[1] = initialPoint[0];
103  proscenium[2] = proscenium[3] = initialPoint[1];
104  while (isValid()) {
106  next();
107  }
108  if (G.debug & G_DEBUG_FREESTYLE) {
109  cout << "Proscenium: (" << proscenium[0] << ", " << proscenium[1] << ", " << proscenium[2]
110  << ", " << proscenium[3] << ")" << endl;
111  }
112 }
113 
115 {
116  real area = 0.0;
117  unsigned numFaces = 0;
118  for (begin(); isValid(); next()) {
119  Vec3r min, max;
121  area += (max[0] - min[0]) * (max[1] - min[1]);
122  ++numFaces;
123  }
124  area /= numFaces;
125  return area;
126 }
127 
128 } /* namespace Freestyle */
@ G_DEBUG_FREESTYLE
Definition: BKE_global.h:181
_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 GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
Class to define a cell grid surrounding the projected image of a scene.
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
const vector< Point > & getVertices() const
Definition: Polygon.h:67
void getBBox(Point &min, Point &max) const
Definition: Polygon.h:72
vector< WFace * >::const_iterator currentFace
vector< WFace * >::const_iterator facesEnd
virtual real averageOccluderArea()
virtual void getOccluderProscenium(real proscenium[4])
Polygon3r & getGridSpacePolygon()
vector< WShape * >::const_iterator shapesEnd
vector< WShape * >::const_iterator currentShape
const GridHelpers::Transform & transform
vector< WShape * > & getWShapes()
Definition: WEdge.h:1322
#define G(x, y, z)
void expandProscenium(real proscenium[4], const Polygon3r &polygon)
Definition: GridHelpers.h:152
vector< Vec3r > enumerateVertices(const vector< WOEdge * > &fedges)
Definition: GridHelpers.h:138
inherits from class Rep
Definition: AppCanvas.cpp:18
double real
Definition: Precision.h:12
static void area(int d1, int d2, int e1, int e2, float weights[2])
#define min(a, b)
Definition: sort.c:35
float max