OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ossimActiveEdgeTable Class Reference

#include <ossimActiveEdgeTable.h>

Public Member Functions

 ossimActiveEdgeTable ()
 
void addPolygon (const ossimPolygon &polygon)
 
const std::list< ossimActiveEdgeTableNode > & getActiveList () const
 
ossim_int32 getCurrentScanLine () const
 
ossim_int32 getYShift () const
 
void initializeActiveList ()
 
void updateActiveEdges ()
 
void mergeCurrentScanLine ()
 
void printActiveEdgeList () const
 

Protected Member Functions

void createTable (const ossimPolygon &polygon)
 
void addEdgeToTable (const ossimActiveEdgeTableNode &edge, ossim_int32 scanLine)
 

Protected Attributes

std::vector< std::list< ossimActiveEdgeTableNode > > theTable
 
std::list< ossimActiveEdgeTableNodetheActiveList
 
ossimIrect theBoundingRect
 
ossimIpt theRectOrigin
 
ossim_int32 theLastScanLine
 
ossim_int32 theCurrentScanLine
 

Friends

class ossimActiveEdgeTableHelper
 

Detailed Description

This class is used in fast efficient scanliine rasterization. It will take a polygon and insert it into the table sorted by y's

Definition at line 64 of file ossimActiveEdgeTable.h.

Constructor & Destructor Documentation

◆ ossimActiveEdgeTable()

ossimActiveEdgeTable::ossimActiveEdgeTable ( )

Definition at line 18 of file ossimActiveEdgeTable.cpp.

19 {
20 
21 }

Member Function Documentation

◆ addEdgeToTable()

void ossimActiveEdgeTable::addEdgeToTable ( const ossimActiveEdgeTableNode edge,
ossim_int32  scanLine 
)
protected

Definition at line 87 of file ossimActiveEdgeTable.cpp.

89 {
90  theTable[scanLine].push_back(edge);
91 }
std::vector< std::list< ossimActiveEdgeTableNode > > theTable

◆ addPolygon()

void ossimActiveEdgeTable::addPolygon ( const ossimPolygon polygon)

Currently will only work on a single polygon. If you call this twice it currently will use the last called polygon and will wipe out the previous one.

Note: this is used for scanline rasterization and will round to integer values all vertices as they are initially added to the Active Edge Table.

Definition at line 23 of file ossimActiveEdgeTable.cpp.

References ossimPolygon::getVertexCount(), x, and y.

24 {
25  createTable(polygon);
26  if(theTable.size())
27  {
28  ossim_int32 iNextY, iY;
30  ossim_uint32 numPts = polygon.getVertexCount();
31  theLastScanLine = 0;
32 
33  for (ossim_uint32 i=0; i<numPts; ++i)
34  {
35  // CURRENT EDGE IS FROM polygon[i] to polygon[(i+1)%numPts]
36  int iNext = (i+1)%numPts; // INDEX FOR SECOND EDGE VERTEX
37  iNextY = ossim::round<ossim_int32>(polygon[iNext].y-theRectOrigin.y);
38  iY = ossim::round<ossim_int32>(polygon[i].y-theRectOrigin.y);
39  int dy = (iNextY - iY);
40  if (dy != 0) // ADD ONLY IF EDGE NOT HORIZONTAL
41  {
42  if (dy> 0) // local max
43  {
44  double m = (polygon[iNext].x-polygon[i].x)/
45  (polygon[iNext].y-polygon[i].y);
46 
47  edge = ossimActiveEdgeTableNode(iNextY+1,
48  m,
49  polygon[i].x);
50 
51  addEdgeToTable(edge, iY);
52 
53  }
54  else // local min so
55  {
56  double m = (polygon[i].x-polygon[iNext].x)/
57  (polygon[i].y-polygon[iNext].y);
58 
59  edge = ossimActiveEdgeTableNode(iY,
60  m,
61  polygon[iNext].x);
62 
63  addEdgeToTable(edge, iNextY);
64  }
65 
66  }
67  }
68  }
69 }
ossim_uint32 x
ossim_uint32 y
void addEdgeToTable(const ossimActiveEdgeTableNode &edge, ossim_int32 scanLine)
ossim_uint32 getVertexCount() const
unsigned int ossim_uint32
std::vector< std::list< ossimActiveEdgeTableNode > > theTable
ossim_int32 y
Definition: ossimIpt.h:142
void createTable(const ossimPolygon &polygon)
int ossim_int32

◆ createTable()

void ossimActiveEdgeTable::createTable ( const ossimPolygon polygon)
protected

Definition at line 71 of file ossimActiveEdgeTable.cpp.

References ossimPolygon::getBoundingRect(), and ossimPolygon::getVertexCount().

72 {
75  if(polygon.getVertexCount() >2)
76  {
77  theTable.clear();
80  {
81  theTable.resize(theBoundingRect.height()+1);
83  }
84  }
85 }
void makeNan()
Definition: ossimIpt.h:56
ossim_uint32 height() const
Definition: ossimIrect.h:487
const ossimIpt & ul() const
Definition: ossimIrect.h:274
ossim_uint32 getVertexCount() const
std::vector< std::list< ossimActiveEdgeTableNode > > theTable
void getBoundingRect(ossimIrect &rect) const
void makeNan()
Definition: ossimIrect.h:329
bool hasNans() const
Definition: ossimIrect.h:337

◆ getActiveList()

const std::list<ossimActiveEdgeTableNode>& ossimActiveEdgeTable::getActiveList ( ) const

◆ getCurrentScanLine()

ossim_int32 ossimActiveEdgeTable::getCurrentScanLine ( ) const
inline

◆ getYShift()

ossim_int32 ossimActiveEdgeTable::getYShift ( ) const
inline

Definition at line 89 of file ossimActiveEdgeTable.h.

References theRectOrigin, and ossimIpt::y.

Referenced by ossimActiveEdgeTableHelper::getYShift().

90  {
91  return theRectOrigin.y;
92  }
ossim_int32 y
Definition: ossimIpt.h:142

◆ initializeActiveList()

void ossimActiveEdgeTable::initializeActiveList ( )

Definition at line 93 of file ossimActiveEdgeTable.cpp.

References size.

Referenced by ossimActiveEdgeTableHelper::advanceScanLine().

94 {
95  int i = 0;
96  for(i=0;i<(int)theTable.size();++i)
97  {
98  if(theTable[i].size())
99  {
100  theActiveList = theTable[i];
101  theTable[i].clear();
102  theCurrentScanLine = i;
103  theActiveList.sort();
104  return;
105  }
106  }
107 }
yy_size_t size
std::vector< std::list< ossimActiveEdgeTableNode > > theTable
std::list< ossimActiveEdgeTableNode > theActiveList

◆ mergeCurrentScanLine()

void ossimActiveEdgeTable::mergeCurrentScanLine ( )

Definition at line 128 of file ossimActiveEdgeTable.cpp.

References size.

Referenced by ossimActiveEdgeTableHelper::advanceScanLine().

129 {
130  if((theCurrentScanLine < (int)theTable.size())&&
132  {
135  theActiveList.sort();
136 
137  theTable[theCurrentScanLine].clear();
138  }
139 }
yy_size_t size
std::vector< std::list< ossimActiveEdgeTableNode > > theTable
std::list< ossimActiveEdgeTableNode > theActiveList

◆ printActiveEdgeList()

void ossimActiveEdgeTable::printActiveEdgeList ( ) const

Definition at line 141 of file ossimActiveEdgeTable.cpp.

References ossimNotify(), and ossimNotifyLevel_INFO.

142 {
143  copy(theActiveList.begin(),
144  theActiveList.end(),
145  ostream_iterator<ossimActiveEdgeTableNode>(ossimNotify(ossimNotifyLevel_INFO) << "->"));
146  ossimNotify(ossimNotifyLevel_INFO) << "NULL\n";
147 }
std::list< ossimActiveEdgeTableNode > theActiveList
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

◆ updateActiveEdges()

void ossimActiveEdgeTable::updateActiveEdges ( )

Definition at line 109 of file ossimActiveEdgeTable.cpp.

Referenced by ossimActiveEdgeTableHelper::advanceScanLine().

110 {
111  std::list<ossimActiveEdgeTableNode>::iterator current = theActiveList.begin();
112 
113  while(current != theActiveList.end())
114  {
115  (*current).theCurrentX += (*current).theSlope;
116 
117  if((*current).theMaxY == theCurrentScanLine)
118  {
119  current = theActiveList.erase(current);
120  }
121  else
122  {
123  ++current;
124  }
125  }
126 };
std::list< ossimActiveEdgeTableNode > theActiveList

Friends And Related Function Documentation

◆ ossimActiveEdgeTableHelper

friend class ossimActiveEdgeTableHelper
friend

Definition at line 67 of file ossimActiveEdgeTable.h.

Member Data Documentation

◆ theActiveList

std::list<ossimActiveEdgeTableNode> ossimActiveEdgeTable::theActiveList
protected

◆ theBoundingRect

ossimIrect ossimActiveEdgeTable::theBoundingRect
protected

Used in computing the number of scanlines of the passed in polygon and is also used to shift the y's relative to 0,0

Definition at line 110 of file ossimActiveEdgeTable.h.

◆ theCurrentScanLine

ossim_int32 ossimActiveEdgeTable::theCurrentScanLine
protected

◆ theLastScanLine

ossim_int32 ossimActiveEdgeTable::theLastScanLine
protected

Definition at line 112 of file ossimActiveEdgeTable.h.

◆ theRectOrigin

ossimIpt ossimActiveEdgeTable::theRectOrigin
protected

Definition at line 111 of file ossimActiveEdgeTable.h.

Referenced by getYShift().

◆ theTable

std::vector< std::list<ossimActiveEdgeTableNode> > ossimActiveEdgeTable::theTable
protected

Definition at line 100 of file ossimActiveEdgeTable.h.


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