Blender  V3.3
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Freestyle::Grid Class Referenceabstract

#include <Grid.h>

Inheritance diagram for Freestyle::Grid:
Freestyle::FastGrid Freestyle::HashGrid

Public Member Functions

 Grid ()
 
virtual ~Grid ()
 
virtual void clear ()
 
virtual void configure (const Vec3r &orig, const Vec3r &size, unsigned nb)
 
void getCellCoordinates (const Vec3r &p, Vec3u &res)
 
virtual void fillCell (const Vec3u &coord, Cell &cell)=0
 
virtual CellgetCell (const Vec3u &coord)=0
 
CellgetCell (const Vec3r &p)
 
void getCellOrigin (const Vec3u &cell_coord, Vec3r &orig)
 
void getCellBox (const Vec3u &cell_coord, Vec3r &min_out, Vec3r &max_out)
 
void insertOccluder (Polygon3r *occluder)
 
void addOccluder (Polygon3r *occluder)
 
void castRay (const Vec3r &orig, const Vec3r &end, OccludersSet &occluders, unsigned timestamp)
 
void initAcceleratedRay (const Vec3r &orig, const Vec3r &end, unsigned timestamp)
 
void castInfiniteRay (const Vec3r &orig, const Vec3r &dir, OccludersSet &occluders, unsigned timestamp)
 
bool initAcceleratedInfiniteRay (const Vec3r &orig, const Vec3r &dir, unsigned timestamp)
 
Polygon3rcastRayToFindFirstIntersection (const Vec3r &orig, const Vec3r &dir, double &t, double &u, double &v, unsigned timestamp)
 
void initRay (const Vec3r &orig, const Vec3r &end, unsigned timestamp)
 
bool initInfiniteRay (const Vec3r &orig, const Vec3r &dir, unsigned timestamp)
 
const Vec3rgetOrigin () const
 
Vec3r gridSize () const
 
Vec3r getCellSize () const
 
OccludersSetgetOccluders ()
 
void displayDebug ()
 

Protected Member Functions

void castRayInternal (GridVisitor &visitor)
 
bool nextRayCell (Vec3u &current_cell, Vec3u &next_cell)
 

Protected Attributes

unsigned int _timestamp
 
Vec3u _cells_nb
 
Vec3r _cell_size
 
Vec3r _size
 
Vec3r _orig
 
Vec3r _ray_dir
 
Vec3u _current_cell
 
Vec3r _pt
 
real _t_end
 
real _t
 
OccludersSet _occluders
 

Detailed Description

Definition at line 177 of file Grid.h.

Constructor & Destructor Documentation

◆ Grid()

Freestyle::Grid::Grid ( )
inline

Builds a Grid. Must be followed by a call to configure()

Definition at line 180 of file Grid.h.

◆ ~Grid()

virtual Freestyle::Grid::~Grid ( )
inlinevirtual

Definition at line 184 of file Grid.h.

References clear().

Member Function Documentation

◆ addOccluder()

void Freestyle::Grid::addOccluder ( Polygon3r occluder)
inline

Adds an occluder to the list of occluders

Definition at line 279 of file Grid.h.

◆ castInfiniteRay()

void Freestyle::Grid::castInfiniteRay ( const Vec3r orig,
const Vec3r dir,
OccludersSet occluders,
unsigned  timestamp 
)

Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a given direction. Returns the list of occluders contained in the cells intersected by this ray Starts with a call to InitRay.

Definition at line 293 of file Grid.cpp.

References Freestyle::VecMat::Vec< T, N >::norm().

Referenced by Freestyle::ViewMapBuilder::FindOccludee().

◆ castRay()

void Freestyle::Grid::castRay ( const Vec3r orig,
const Vec3r end,
OccludersSet occluders,
unsigned  timestamp 
)

Casts a ray between a starting point and an ending point Returns the list of occluders contained in the cells intersected by this ray Starts with a call to InitRay.

Definition at line 283 of file Grid.cpp.

Referenced by Freestyle::ViewMapBuilder::ComputeRayCastingVisibility().

◆ castRayInternal()

void Freestyle::Grid::castRayInternal ( GridVisitor visitor)
inlineprotected

◆ castRayToFindFirstIntersection()

Polygon3r * Freestyle::Grid::castRayToFindFirstIntersection ( const Vec3r orig,
const Vec3r dir,
double t,
double u,
double v,
unsigned  timestamp 
)

Casts an infinite ray (still finishing at the end of the grid) from a starting point and in a given direction. Returns the first intersection (occluder,t,u,v) or null. Starts with a call to InitRay.

Definition at line 307 of file Grid.cpp.

References Freestyle::VecMat::Vec< T, N >::norm(), Freestyle::firstIntersectionGridVisitor::occluder(), t, Freestyle::firstIntersectionGridVisitor::t_, Freestyle::firstIntersectionGridVisitor::u_, v, and Freestyle::firstIntersectionGridVisitor::v_.

◆ clear()

void Freestyle::Grid::clear ( )
virtual

clears the grid Deletes all the cells, clears the hashtable, resets size, size of cell, number of cells.

Reimplemented in Freestyle::HashGrid, and Freestyle::FastGrid.

Definition at line 80 of file Grid.cpp.

Referenced by Freestyle::FastGrid::clear(), and Freestyle::HashGrid::clear().

◆ configure()

void Freestyle::Grid::configure ( const Vec3r orig,
const Vec3r size,
unsigned  nb 
)
virtual

Sets the different parameters of the grid orig The grid origin size The grid's dimensions nb The number of cells of the grid

Reimplemented in Freestyle::HashGrid, and Freestyle::FastGrid.

Definition at line 96 of file Grid.cpp.

References blender::math::floor(), min, pow(), and size().

Referenced by Freestyle::FastGrid::configure(), and Freestyle::HashGrid::configure().

◆ displayDebug()

void Freestyle::Grid::displayDebug ( )
inline

Definition at line 342 of file Grid.h.

◆ fillCell()

virtual void Freestyle::Grid::fillCell ( const Vec3u coord,
Cell cell 
)
pure virtual

Fills the case corresponding to coord with the cell

Implemented in Freestyle::HashGrid, and Freestyle::FastGrid.

◆ getCell() [1/2]

Cell* Freestyle::Grid::getCell ( const Vec3r p)
inline

returns the cell containing the point passed as argument. If the cell is empty (contains no occluder), NULL is returned: p The point for which we're looking the cell

Definition at line 237 of file Grid.h.

◆ getCell() [2/2]

virtual Cell* Freestyle::Grid::getCell ( const Vec3u coord)
pure virtual

returns the cell whose coordinates are passed as argument

Implemented in Freestyle::HashGrid, and Freestyle::FastGrid.

◆ getCellBox()

void Freestyle::Grid::getCellBox ( const Vec3u cell_coord,
Vec3r min_out,
Vec3r max_out 
)
inline

Retrieves the box corresponding to the cell whose coordinates are passed as argument: cell_coord i,j,k integer coordinates for the cell min_out The min x,y,x vector of the box. Filled in by the method. max_out The max x,y,z coordinates of the box. Filled in by the method.

Definition at line 266 of file Grid.h.

◆ getCellCoordinates()

void Freestyle::Grid::getCellCoordinates ( const Vec3r p,
Vec3u res 
)
inline

returns a vector of integer containing the coordinates of the cell containing the point passed as argument p The point for which we're looking the cell

Definition at line 209 of file Grid.h.

◆ getCellOrigin()

void Freestyle::Grid::getCellOrigin ( const Vec3u cell_coord,
Vec3r orig 
)
inline

Retrieves the x,y,z coordinates of the origin of the cell whose coordinates (i,j,k) is passed as argument: cell_coord i,j,k integer coordinates for the cell orig x,y,x vector to be filled in with the cell origin's coordinates

Definition at line 251 of file Grid.h.

◆ getCellSize()

Vec3r Freestyle::Grid::getCellSize ( ) const
inline

Definition at line 331 of file Grid.h.

◆ getOccluders()

OccludersSet* Freestyle::Grid::getOccluders ( )
inline

Definition at line 337 of file Grid.h.

◆ getOrigin()

const Vec3r& Freestyle::Grid::getOrigin ( ) const
inline

Accessors

Definition at line 321 of file Grid.h.

Referenced by Freestyle::ViewMapBuilder::ComputeRayCastingVisibility().

◆ gridSize()

Vec3r Freestyle::Grid::gridSize ( ) const
inline

Definition at line 326 of file Grid.h.

Referenced by Freestyle::ViewMapBuilder::ComputeRayCastingVisibility().

◆ initAcceleratedInfiniteRay()

bool Freestyle::Grid::initAcceleratedInfiniteRay ( const Vec3r orig,
const Vec3r dir,
unsigned  timestamp 
)

◆ initAcceleratedRay()

void Freestyle::Grid::initAcceleratedRay ( const Vec3r orig,
const Vec3r end,
unsigned  timestamp 
)

◆ initInfiniteRay()

bool Freestyle::Grid::initInfiniteRay ( const Vec3r orig,
const Vec3r dir,
unsigned  timestamp 
)

Init all structures and values for computing the cells intersected by this infinite ray. Returns false if the ray doesn't intersect the grid.

Definition at line 344 of file Grid.cpp.

References BLI_assert, blender::math::floor(), Freestyle::BBox< Point >::inside(), Freestyle::GeomUtils::intersectRayBBox(), and Freestyle::VecMat::Vec< T, N >::normalize().

◆ initRay()

void Freestyle::Grid::initRay ( const Vec3r orig,
const Vec3r end,
unsigned  timestamp 
)

Init all structures and values for computing the cells intersected by this new ray

Definition at line 328 of file Grid.cpp.

References blender::math::floor(), and Freestyle::VecMat::Vec< T, N >::norm().

◆ insertOccluder()

void Freestyle::Grid::insertOccluder ( Polygon3r occluder)

inserts a convex polygon occluder This method is quite coarse insofar as it adds all cells intersecting the polygon bounding box convex_poly The list of 3D points constituting a convex polygon

Definition at line 140 of file Grid.cpp.

References Freestyle::Cell::addOccluder(), Freestyle::Geometry::Polygon< Point >::getBBox(), Freestyle::Geometry::Polygon< Point >::getVertices(), max, min, Freestyle::firstIntersectionGridVisitor::occluder(), Freestyle::GeomUtils::overlapTriangleBox(), Freestyle::x, y, and z.

Referenced by Freestyle::WFillGrid::fillGrid(), and Freestyle::WSFillGrid::fillGrid().

◆ nextRayCell()

bool Freestyle::Grid::nextRayCell ( Vec3u current_cell,
Vec3u next_cell 
)
protected

returns the cell next to the cell passed as argument.

Definition at line 224 of file Grid.cpp.

References t.

Member Data Documentation

◆ _cell_size

Vec3r Freestyle::Grid::_cell_size
protected

Definition at line 378 of file Grid.h.

◆ _cells_nb

Vec3u Freestyle::Grid::_cells_nb
protected

◆ _current_cell

Vec3u Freestyle::Grid::_current_cell
protected

Definition at line 383 of file Grid.h.

◆ _occluders

OccludersSet Freestyle::Grid::_occluders
protected

Definition at line 391 of file Grid.h.

◆ _orig

Vec3r Freestyle::Grid::_orig
protected

Definition at line 380 of file Grid.h.

◆ _pt

Vec3r Freestyle::Grid::_pt
protected

Definition at line 384 of file Grid.h.

◆ _ray_dir

Vec3r Freestyle::Grid::_ray_dir
protected

Definition at line 382 of file Grid.h.

◆ _size

Vec3r Freestyle::Grid::_size
protected

Definition at line 379 of file Grid.h.

◆ _t

real Freestyle::Grid::_t
protected

Definition at line 387 of file Grid.h.

◆ _t_end

real Freestyle::Grid::_t_end
protected

Definition at line 386 of file Grid.h.

◆ _timestamp

unsigned int Freestyle::Grid::_timestamp
protected

Definition at line 375 of file Grid.h.


The documentation for this class was generated from the following files: