-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPolyNode.mm
81 lines (66 loc) · 1.44 KB
/
PolyNode.mm
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// PolyNode.m
// An Objective-C wrapper for the PolyNode object from the Clipper library
// (http://sourceforge.net/projects/polyclipping/)
//
// Created by John Swensen on 3/18/14.
// Copyright (c) 2014 John Swensen. All rights reserved.
//
// License:
// Use, modification & distribution is subject to Boost Software License Ver 1.
// http://www.boost.org/LICENSE_1_0.txt
//
#import "PolyNode.h"
#import "Path.h"
@implementation PolyNode
@synthesize node=_node;
- (PolyNode*) getNext
{
if (_node->GetNext() != NULL)
{
PolyNode* retval = [[PolyNode alloc] init];
retval.node = _node->GetNext();
return retval;
}
else
{
return nil;
}
}
- (int) childCount
{
return _node->ChildCount();
}
- (NSMutableArray*) childs
{
NSMutableArray* retval = [[NSMutableArray alloc] init];
std::vector<ClipperLib::PolyNode*> children = _node->Childs;
for (int i = 0 ; i < children.size() ; i++)
{
PolyNode* tmp = [[PolyNode alloc] init];
tmp.node = children[i];
[retval addObject:tmp];
}
return retval;
}
- (Path*) contour
{
Path* retval = [[Path alloc] init];
retval.path = _node->Contour;
return retval;
}
- (BOOL) isHole
{
return _node->IsHole();
}
- (BOOL) isOpen
{
return _node->IsOpen();
}
- (PolyNode*) parent
{
PolyNode* retval = [[PolyNode alloc] init];
retval.node = _node->Parent;
return retval;
}
@end