KiCad PCB EDA Suite
SutherlandHodgman::ClipStage< Boundary, Stage > Class Template Reference
Inheritance diagram for SutherlandHodgman::ClipStage< Boundary, Stage >:

Public Member Functions

 ClipStage (Stage &nextStage, REAL position)
 
void HandleVertex (const PointF &pntCurrent)
 
void Finalize ()
 

Private Attributes

Stage & m_NextStage
 
bool m_bFirst
 
PointF m_pntFirst
 
PointF m_pntPrevious
 
bool m_bPreviousInside
 

Detailed Description

template<class Boundary, class Stage>
class SutherlandHodgman::ClipStage< Boundary, Stage >

Definition at line 182 of file SutherlandHodgmanClipPoly.h.

Constructor & Destructor Documentation

template<class Boundary, class Stage>
SutherlandHodgman::ClipStage< Boundary, Stage >::ClipStage ( Stage &  nextStage,
REAL  position 
)
inline

Definition at line 185 of file SutherlandHodgmanClipPoly.h.

185  :
186  Boundary( position ) , m_NextStage( nextStage ), m_bFirst( true ), m_bPreviousInside( false )
187  { }

Member Function Documentation

template<class Boundary, class Stage>
void SutherlandHodgman::ClipStage< Boundary, Stage >::Finalize ( )
inline

Definition at line 223 of file SutherlandHodgmanClipPoly.h.

Referenced by SutherlandHodgman::Clip().

224  {
225  HandleVertex( m_pntFirst ); // Close the polygon.
226  m_NextStage.Finalize(); // Delegate to the next stage.
227  }
void HandleVertex(const PointF &pntCurrent)
template<class Boundary, class Stage>
void SutherlandHodgman::ClipStage< Boundary, Stage >::HandleVertex ( const PointF pntCurrent)
inline

Definition at line 190 of file SutherlandHodgmanClipPoly.h.

Referenced by SutherlandHodgman::Clip(), and SutherlandHodgman::ClipStage< BoundaryBottom, OutputStage >::Finalize().

191  {
192  bool bCurrentInside = this->IsInside( pntCurrent ); // See if vertex is inside the boundary.
193 
194  if( m_bFirst ) // If this is the first vertex...
195  {
196  m_pntFirst = pntCurrent; // ... just remember it,...
197 
198  m_bFirst = false;
199  }
200  else // Common cases, not the first vertex.
201  {
202  if( bCurrentInside ) // If this vertex is inside...
203  {
204  if( !m_bPreviousInside ) // ... and the previous one was outside
205  m_NextStage.HandleVertex( this->Intersect( m_pntPrevious, pntCurrent ) );
206 
207  // ... first output the intersection point.
208 
209  m_NextStage.HandleVertex( pntCurrent ); // Output the current vertex.
210  }
211  else if( m_bPreviousInside ) // If this vertex is outside, and the previous one was inside...
212  m_NextStage.HandleVertex( this->Intersect( m_pntPrevious, pntCurrent ) );
213 
214  // ... output the intersection point.
215 
216  // If neither current vertex nor the previous one are inside, output nothing.
217  }
218  m_pntPrevious = pntCurrent; // Be prepared for next vertex.
219  m_bPreviousInside = bCurrentInside;
220  }

Member Data Documentation

template<class Boundary, class Stage>
bool SutherlandHodgman::ClipStage< Boundary, Stage >::m_bFirst
private
template<class Boundary, class Stage>
bool SutherlandHodgman::ClipStage< Boundary, Stage >::m_bPreviousInside
private
template<class Boundary, class Stage>
Stage& SutherlandHodgman::ClipStage< Boundary, Stage >::m_NextStage
private
template<class Boundary, class Stage>
PointF SutherlandHodgman::ClipStage< Boundary, Stage >::m_pntPrevious
private

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