-
-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathPolyTree.cpp
More file actions
55 lines (46 loc) · 2.95 KB
/
PolyTree.cpp
File metadata and controls
55 lines (46 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*******************************************************************************
* *
* Author : Angus Johnson *
* Version : 5.1.6 *
* Date : 23 May 2013 *
* Website : http://www.angusj.com *
* Copyright : Angus Johnson 2010-2013 *
* *
* License: *
* Use, modification & distribution is subject to Boost Software License Ver 1.*
* http://www.boost.org/LICENSE_1_0.txt *
* *
* Attributions: *
* The code in this library is an extension of Bala Vatti's clipping algorithm:*
* "A generic solution to polygon clipping" *
* Communications of the ACM, Vol 35, Issue 7 (July 1992) pp 56-63. *
* http://portal.acm.org/citation.cfm?id=129906 *
* *
* Computer graphics and geometric modeling: implementation and algorithms *
* By Max K. Agoston *
* Springer; 1 edition (January 4, 2005) *
* http://books.google.com/books?q=vatti+clipping+agoston *
* *
* See also: *
* "Polygon Offsetting by Computing Winding Numbers" *
* Paper no. DETC2005-85513 pp. 565-575 *
* ASME 2005 International Design Engineering Technical Conferences *
* and Computers and Information in Engineering Conference (IDETC/CIE2005) *
* September 24-28, 2005 , Long Beach, California, USA *
* http://www.me.berkeley.edu/~mcmains/pubs/DAC05OffsetPolygon.pdf *
* *
******************************************************************************/
#include "PolyTree.h"
using namespace ClipperLib;
PolyNode *PolyTree::GetFirst() const {return Childs.empty() ? 0 : Childs[0];}
void PolyTree::Clear() {
for (PolyNodes::size_type i = 0; i < AllNodes.size(); i++)
delete AllNodes[i];
AllNodes.resize(0);
Childs.resize(0);
}
void PolyTree::ToPolygons(Polygons &polygons) const {
polygons.resize(0);
polygons.reserve(Total());
AddToPolygons(polygons);
}