Click here to Skip to main content
12,557,750 members (50,126 online)
Click here to Skip to main content


122 bookmarked

A C++ implementation of Douglas-Peucker Line Approximation Algorithm

, 3 Mar 2003
DP Line approximation algorithm is a well-known method to approximate 2D lines. It is quite fast, O(nlog_2(n)) for a n-points line and can drastically compress a data curve. Here, a fully OOP implementation is given.
// CustomizeDialog.h: interface for the CCustomizeDialog class.
// Copyright (c) 2001 by Nikolay Denisov. All rights reserved.
// This code is free for personal and commercial use, providing this 
// notice remains intact in the source files and all eventual changes are
// clearly marked with comments.
// You must obtain the author's consent before you can include this code
// in a software library.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
// Please email bug reports, bug fixes, enhancements, requests and
// comments to:


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

enum TextOptions
    toNone          = -1,
    toTextLabels    =  0,
    toTextOnRight   =  1,
    toNoTextLabels  =  2,

enum IconOptions
    ioNone          = -1,
    ioSmallIcons    =  0,
    ioLargeIcons    =  1,

// Customize dialog
#define IDD_CUSTOMIZE                   0x7900

// Customize dialog controls
#define IDC_CB_TEXTOPTIONS              1000
#define IDC_CB_ICONOPTIONS              1001

class CToolBarEx;

// CCustomizeDialog dialog

class CCustomizeDialog : public CWnd
    DECLARE_DYNAMIC( CCustomizeDialog );

// Construction
    CCustomizeDialog( CToolBarEx* pToolBar,
                      TextOptions eTextOptions,
                      IconOptions eIconOptions );

// Operations
    void SetTextOptions( TextOptions eTextOptions);
    void SetIconOptions( IconOptions eIconOptions);
    TextOptions  GetTextOptions() { return m_eTextOptions; }
    IconOptions GetIconOptions() { return m_eIconOptions; }

// Overrides
    // ClassWizard generated virtual function overrides
	virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);

// Implementation
// Implementation data
    CToolBarEx*     m_pToolBar;

// Generated message map functions
	CComboBox m_wndIconOptions;
	CComboBox m_wndTextOptions;
	CStatic m_wndIconOptionsText;
	CStatic m_wndTextOptionsText;
    TextOptions m_eTextOptions;
    IconOptions m_eIconOptions;

    afx_msg void OnTextOptions();
    afx_msg void OnIconOptions();
    LRESULT OnInitDialog( WPARAM wParam, LPARAM lParam );

#endif  // !__CUSTOMIZEDIALOG_H__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jonathan de Halleux
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.161026.1 | Last Updated 4 Mar 2003
Article Copyright 2002 by Jonathan de Halleux
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid