1 #ifndef MESHING_RASTERIZE_H 2 #define MESHING_RASTERIZE_H 4 #include <KrisLibrary/structs/array2d.h> 5 #include <KrisLibrary/math3d/Triangle2D.h> 6 #include <KrisLibrary/math3d/AABB2D.h> 7 #include <KrisLibrary/math3d/Polygon2D.h> 8 #include <KrisLibrary/utils/IntPair.h> 52 void Rasterize(
const AABB2D& b);
53 void ClippedRasterize(
const AABB2D& t,
const AABB2D& aabb);
58 void RasterizeVerticalSegment(
int i,Real y1,Real y2,
const Vector3& baryA,
const Vector3& baryB);
62 virtual void VisitCell(
const Vector3& params,
int i,
int j)=0;
73 inline void Rasterize(
const Triangle2D& tri) { Rasterizer2D::Rasterize(tri); }
75 inline void Rasterize(
const Triangle2D& tri,
const T& val) {
77 Rasterizer2D::Rasterize(tri);
80 inline void Rasterize(
const AABB2D& b,
const T& val) {
82 Rasterizer2D::Rasterize(b);
85 virtual void VisitCell(
const Vector3& bary,
int i,
int j)
87 if(grid&& i>=0 && j>=0 && i<grid->m && j<grid->n) {
88 Fill(bary,(*grid)(i,j));
92 virtual void Fill(
const Vector3& params,T&cell) { cell = fillVal; }
106 inline void Rasterize(
const Triangle2D& tri,
const T& flatColor) {
107 fillA = fillB = fillC = flatColor;
108 Rasterizer2D::Rasterize(tri);
111 inline void Rasterize(
const Triangle2D& tri,
const T& a,
const T& b,
const T& c) {
115 Rasterizer2D::Rasterize(tri);
118 virtual void Fill(
const Vector3& bary,T& cell) { cell = bary.x*fillA+bary.y*fillB+bary.z*fillC; }
The namespace for all classes/functions in the Meshing package.
Definition: AnyGeometry.h:11
A 3D vector class.
Definition: math3d/primitives.h:136
A 2D triangle class.
Definition: Triangle2D.h:25
A rasterizer that flat-fills elements of a grid.
Definition: Rasterize.h:67
A two-dimensional m x n array.
Definition: array2d.h:30
A 2D segment class.
Definition: Segment2D.h:17
Contains all the definitions in the Math3D package.
Definition: AnyGeometry.h:13
void GetTriangleCells(const Triangle2D &t, vector< IntPair > &cells)
Returns a list of cells that the triangle overlaps, given an infinite unit grid.
Definition: Rasterize.cpp:295
A smooth-fill rasterizer.
Definition: Rasterize.h:102
void GetTriangleCells_Clipped(const Triangle2D &torig, std::vector< IntPair > &cells, int imin, int jmin, int imax, int jmax)
Returns a list of cells that the triangle overlaps, in a unit grid from [imin,imax)x[jmin,jmax)
Definition: Rasterize.cpp:99
A 2D axis-aligned bounding box.
Definition: AABB2D.h:13
void GetSegmentCells(const Segment2D &s, vector< IntPair > &cells)
Returns a list of cells that the segment overlaps, given an infinite unit grid.
Definition: Rasterize.cpp:54
A base class that allows rasterizing of 2D triangles into a grid.
Definition: Rasterize.h:47