![]() |
Sorting Network Verify and Draw
Check Whether Comparator Networks Sort and Draw Them
|
Renderable comparator network. More...
#include <RenderableComparatorNet.h>
Public Member Functions | |
~CRenderableComparatorNet () | |
Destructor. More... | |
void | Draw (const eDrawStyle) |
Draw to a Gdiplus::Bitmap . More... | |
HRESULT | ExportToPNG (LPWSTR) |
Export in PNG format. More... | |
HRESULT | ExportToTex (LPWSTR) |
Export in TeX format. More... | |
HRESULT | ExportToSVG (LPWSTR) |
Export in SVG format. More... | |
Gdiplus::Bitmap * | GetBitmap () |
Get bitmap pointer. More... | |
![]() | |
~CComparatorNetwork () | |
Destructor. More... | |
virtual bool | Read (LPWSTR) |
Read from file. More... | |
void | Prune (const UINT) |
Prune down number of inputs. More... | |
const UINT | GetNumInputs () const |
Get number of inputs. More... | |
const UINT | GetDepth () const |
Get depth. More... | |
const UINT | GetSize () const |
Get size. More... | |
const bool | FirstNormalForm () const |
Test for first normal form. More... | |
Protected Member Functions | |
Gdiplus::REAL | ComputeBitmapHeight () |
Compute bitmap height. More... | |
void | DrawChannels (const float fLen) |
Draw channels. More... | |
void | DrawComparator (const UINT, const UINT, const float, bool=false) |
Draw a comparator. More... | |
void | DrawComparators () |
Draw all comparators. More... | |
![]() | |
void | InsertComparator (UINT, UINT, UINT) |
Insert comparator. More... | |
void | CreateMatchArray (UINT, UINT) |
Create match array. More... | |
void | ComputeSize () |
Compute size. More... | |
Protected Attributes | |
const Gdiplus::REAL | m_fPenWidth = 2.0f |
Pen width in pixels. More... | |
const Gdiplus::REAL | m_fXDelta = 24.0f |
Gap between channels in pixels. More... | |
const Gdiplus::REAL | m_fYDelta = 16.0f |
Vertical comparator gap in pixels. More... | |
const Gdiplus::REAL | m_fYDelta2 = 8.0f |
Extra vertical gap between layers in pixels. More... | |
const Gdiplus::REAL | m_fDiameter = 8.0f |
Diameter of circles in pixels. More... | |
Gdiplus::Bitmap * | m_pBitmap = nullptr |
Pointer to a bitmap image. More... | |
eDrawStyle | m_eDrawStyle = eDrawStyle::Horizontal |
Drawing style. More... | |
Gdiplus::Graphics * | m_pGraphics = nullptr |
Pointer to graphics object. More... | |
Gdiplus::Pen * | m_pPen = nullptr |
Pointer to graphics pen. More... | |
Gdiplus::Pen * | m_pRedPen = nullptr |
Pointer to graphics pen. More... | |
Gdiplus::SolidBrush * | m_pBrush = nullptr |
Pointer to graphics brush. More... | |
Gdiplus::SolidBrush * | m_pRedBrush = nullptr |
Pointer to graphics brush. More... | |
FILE * | m_pOutput = nullptr |
File pointer. More... | |
eExport | m_eExportType = eExport::Png |
Export type. More... | |
![]() | |
UINT ** | m_nMatch = nullptr |
Matchings at each level. More... | |
bool ** | m_bUsed = nullptr |
Whether comparators are used when sorting. More... | |
UINT | m_nInputs = 0 |
Number of inputs. More... | |
UINT | m_nDepth = 0 |
Depth. More... | |
UINT | m_nSize = 0 |
Size. More... | |
bool | m_bSorts = false |
True if it sorts, false if it doesn't or unknown. More... | |
A comparator network that can be rendered to a Gdiplus::Bitmap
or exported in one of several graphics file formats. Uses GDI+, obviously.
Definition at line 37 of file RenderableComparatorNet.h.
CRenderableComparatorNet::~CRenderableComparatorNet | ( | ) |
< Delete the bitmap.
Definition at line 33 of file RenderableComparatorNet.cpp.
|
protected |
Compute the bitmap height when drawn in vertical draw mode. Note that this does not actually draw the comparator network to a bitmap, but it goes through the motions and tallies up the height that would be used.
Definition at line 42 of file RenderableComparatorNet.cpp.
void CRenderableComparatorNet::Draw | ( | const eDrawStyle | d | ) |
Draw the comparator network in black with a transparent background to a new Gdiplus::Bitmap
of the right size. The comparator network is drawn either vertically or horzontally depending on the draw mode m_eDrawStyle
. The calling function is responsible for deleting the bitmap when it is no longer needed. Note that m_eExportType
is set to eExport::Png
so that the calls to DrawComparators()
and DrawChannels()draw to the bitmap pointed to by
m_pBitmap`.
d | Draw style. |
Definition at line 297 of file RenderableComparatorNet.cpp.
|
protected |
Draw channels. The behaviour of this function depends on the value of m_eExportType
. If it is m_eExportType::Png
, then we draw the channels to the bitmap pointed to by m_pBitmap
via the graphics object pointed to by m_pGraphics
. Otherwise we output the vector graphics commands to draw the channels (a line for each channel) to the file pointed to by m_pOutput
.
fLen | Length of channels in pixels. |
Definition at line 234 of file RenderableComparatorNet.cpp.
|
protected |
Draw a comparator. The behaviour of this function depends on the value of m_eExportType
. If it is m_eExportType::Png
, then we draw the comparator to the bitmap pointed to by m_pBitmap
via the graphics object pointed to by m_pGraphics
. Otherwise we output the vector graphics commands to draw the comparator (a line and two filled circles) to the file pointed to by m_pOutput
.
src | Source (min) channel. |
dest | Destination (max) channel. |
fDist | Distance along channel to comparator in pixels. |
bRed | True if comparator is to be drawn red (PNG only). |
Definition at line 85 of file RenderableComparatorNet.cpp.
|
protected |
Draw all comparators. Calls DrawComparator()
once for each comparator. The behaviour of this function depends on the value of m_eExportType
. If it is m_eExportType::Png
, then we draw the comparators to the bitmap pointed to by m_pBitmap
via the graphics object pointed to by m_pGraphics
. Otherwise we output the vector graphics commands to draw the comparators (lines and filled circles) to the file pointed to by m_pOutput
.
Definition at line 176 of file RenderableComparatorNet.cpp.
HRESULT CRenderableComparatorNet::ExportToPNG | ( | LPWSTR | lpwstr | ) |
Export to an PNG file. This simply involves using GDI+ to save the bitmap pointed to by m_pBitmap
to a file.
lpwstr | Null terminated wide file name. |
Definition at line 334 of file RenderableComparatorNet.cpp.
HRESULT CRenderableComparatorNet::ExportToSVG | ( | LPWSTR | lpwstr | ) |
Export to an SVG file. Note that m_eExportType
is set to eExport::Svg
so that the calls to DrawComparators()
and DrawChannels()` output the necessary vector graphics commands in SVG format to the file pointed to by m_pOutput
.
lpwstr | Null terminated wide file name. |
Definition at line 403 of file RenderableComparatorNet.cpp.
HRESULT CRenderableComparatorNet::ExportToTex | ( | LPWSTR | lpwstr | ) |
Export to a TeX file. Note that m_eExportType
is set to eExport::TeX
so that the calls to DrawComparators()
and DrawChannels()` output the necessary vector graphics commands in TeX format to the file pointed to by m_pOutput
.
lpwstr | Null terminated wide file name. |
Definition at line 354 of file RenderableComparatorNet.cpp.
Gdiplus::Bitmap * CRenderableComparatorNet::GetBitmap | ( | ) |
Reader function for bitmap pointer.
Definition at line 460 of file RenderableComparatorNet.cpp.
|
protected |
Definition at line 47 of file RenderableComparatorNet.h.
|
protected |
Definition at line 56 of file RenderableComparatorNet.h.
|
protected |
Definition at line 43 of file RenderableComparatorNet.h.
|
protected |
Definition at line 39 of file RenderableComparatorNet.h.
|
protected |
Definition at line 40 of file RenderableComparatorNet.h.
|
protected |
Definition at line 41 of file RenderableComparatorNet.h.
|
protected |
Definition at line 42 of file RenderableComparatorNet.h.
|
protected |
Definition at line 45 of file RenderableComparatorNet.h.
|
protected |
Definition at line 52 of file RenderableComparatorNet.h.
|
protected |
Definition at line 49 of file RenderableComparatorNet.h.
|
protected |
Definition at line 55 of file RenderableComparatorNet.h.
|
protected |
Definition at line 50 of file RenderableComparatorNet.h.
|
protected |
Definition at line 53 of file RenderableComparatorNet.h.
|
protected |
Definition at line 51 of file RenderableComparatorNet.h.