50 bool BoxGrid::Cell::compareOccludersByShallowestPoint(
const BoxGrid::OccluderData *
a,
51 const BoxGrid::OccluderData *b)
53 return a->shallowest < b->shallowest;
56 void BoxGrid::Cell::indexPolygons()
59 sort(
faces.begin(),
faces.end(), compareOccludersByShallowestPoint);
72 cout <<
"Searching for occluders of edge centered at " << _target <<
" in cell ["
73 << 1_cell->boundary[0] <<
", " << _cell->boundary[1] <<
", " << _cell->boundary[2] <<
", "
74 << _cell->boundary[3] <<
"] (" << _cell->faces.size() <<
" occluders)" << endl;
79 _current = _cell->faces.begin();
94 cout <<
"Generate Cell structure" << endl;
100 cout <<
"Distribute occluders" << endl;
106 cout <<
"Reorganize cells" << endl;
111 cout <<
"Ready to use BoxGrid" << endl;
122 _cellsX = density.
cellsX();
123 _cellsY = density.
cellsY();
127 cout <<
"Using " << _cellsX <<
"x" << _cellsY <<
" cells of size " << _cellSize <<
" square."
129 cout <<
"Cell origin: " << _cellOrigin[0] <<
", " << _cellOrigin[1] << endl;
133 _cells.resize(_cellsX * _cellsY);
134 for (cellContainer::iterator i = _cells.begin(), end = _cells.end(); i != end; ++i) {
140 for (ViewMap::fedges_container::iterator f = fedges.begin(), fend = fedges.end(); f != fend;
142 if ((*f)->isInImage()) {
145 getCellCoordinates(point, i, j);
146 if (_cells[i * _cellsY + j] ==
nullptr) {
150 x = _cellOrigin[0] + _cellSize * i;
153 y = _cellOrigin[1] + _cellSize * j;
157 Cell *b = _cells[i * _cellsY + j] =
new Cell();
166 unsigned long nFaces = 0;
167 unsigned long nKeptFaces = 0;
174 _faces.push_back(occluder);
189 cout <<
"Distributed " << nFaces <<
" occluders. Retained " << nKeptFaces <<
"." << endl;
196 for (vector<Cell *>::iterator i = _cells.begin(), end = _cells.end(); i != end; ++i) {
198 (*i)->indexPolygons();
203 void BoxGrid::getCellCoordinates(
const Vec3r &point,
unsigned &
x,
unsigned &
y)
205 x =
min(_cellsX - 1, (
unsigned)
floor(
max((
double)0.0f, point[0] - _cellOrigin[0]) / _cellSize));
206 y =
min(_cellsY - 1, (
unsigned)
floor(
max((
double)0.0f, point[1] - _cellOrigin[1]) / _cellSize));
212 getCellCoordinates(point,
x,
y);
213 return _cells[
x * _cellsY +
y];
233 return Vec3r(point[0], point[1], -point[2]);
Class to define a cell grid surrounding the projected image of a scene.
NSNotificationCenter * center
_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
_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
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
void sort(btMatrix3x3 &U, btVector3 &sigma, btMatrix3x3 &V, int t)
Helper function of 3X3 SVD for sorting singular values.
void assignCells(OccluderSource &source, GridDensityProvider &density, ViewMap *viewMap)
const Vec3r & viewpoint() const
Cell * findCell(const Vec3r &point)
void distributePolygons(OccluderSource &source)
bool insertOccluder(OccluderSource &source, OccluderData *&occluder)
bool orthographicProjection() const
float cellOrigin(int index)
vector< FEdge * > fedges_container
fedges_container & FEdges()
VecMat::Vec3< real > Vec3r
ccl_device_inline float2 floor(const float2 &a)