1 |
/*
|
2 |
* This file is a part of the C port of the Poly2Tri library
|
3 |
* Porting to C done by (c) Barak Itkin <lightningismyname@gmail.com>
|
4 |
* http://code.google.com/p/poly2tri-c/
|
5 |
*
|
6 |
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
|
7 |
* http://code.google.com/p/poly2tri/
|
8 |
*
|
9 |
* All rights reserved.
|
10 |
*
|
11 |
* Redistribution and use in source and binary forms, with or without modification,
|
12 |
* are permitted provided that the following conditions are met:
|
13 |
*
|
14 |
* * Redistributions of source code must retain the above copyright notice,
|
15 |
* this list of conditions and the following disclaimer.
|
16 |
* * Redistributions in binary form must reproduce the above copyright notice,
|
17 |
* this list of conditions and the following disclaimer in the documentation
|
18 |
* and/or other materials provided with the distribution.
|
19 |
* * Neither the name of Poly2Tri nor the names of its contributors may be
|
20 |
* used to endorse or promote products derived from this software without specific
|
21 |
* prior written permission.
|
22 |
*
|
23 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
24 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
25 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
26 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
27 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
28 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
29 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
30 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
31 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
32 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
33 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34 |
*/
|
35 |
|
36 |
#include "cdt.h"
|
37 |
|
38 |
void
|
39 |
p2t_cdt_init (P2tCDT* THIS, P2tPointPtrArray polyline)
|
40 |
{
|
41 |
THIS->sweep_context_ = p2t_sweepcontext_new (polyline);
|
42 |
THIS->sweep_ = p2t_sweep_new ();
|
43 |
}
|
44 |
|
45 |
P2tCDT*
|
46 |
p2t_cdt_new (P2tPointPtrArray polyline)
|
47 |
{
|
48 |
P2tCDT* THIS = g_slice_new (P2tCDT);
|
49 |
p2t_cdt_init (THIS, polyline);
|
50 |
return THIS;
|
51 |
}
|
52 |
|
53 |
void
|
54 |
p2t_cdt_destroy (P2tCDT* THIS)
|
55 |
{
|
56 |
p2t_sweepcontext_delete (THIS->sweep_context_);
|
57 |
p2t_sweep_free (THIS->sweep_);
|
58 |
}
|
59 |
|
60 |
void
|
61 |
p2t_cdt_free (P2tCDT* THIS)
|
62 |
{
|
63 |
p2t_cdt_destroy (THIS);
|
64 |
g_slice_free (P2tCDT, THIS);
|
65 |
}
|
66 |
|
67 |
void
|
68 |
p2t_cdt_add_hole (P2tCDT *THIS, P2tPointPtrArray polyline)
|
69 |
{
|
70 |
p2t_sweepcontext_add_hole (THIS->sweep_context_, polyline);
|
71 |
}
|
72 |
|
73 |
void
|
74 |
p2t_cdt_add_point (P2tCDT *THIS, P2tPoint* point)
|
75 |
{
|
76 |
p2t_sweepcontext_add_point (THIS->sweep_context_, point);
|
77 |
}
|
78 |
|
79 |
void
|
80 |
p2t_cdt_triangulate (P2tCDT *THIS)
|
81 |
{
|
82 |
p2t_sweep_triangulate (THIS->sweep_, THIS->sweep_context_);
|
83 |
}
|
84 |
|
85 |
P2tTrianglePtrArray
|
86 |
p2t_cdt_get_triangles (P2tCDT *THIS)
|
87 |
{
|
88 |
return p2t_sweepcontext_get_triangles (THIS->sweep_context_);
|
89 |
}
|
90 |
|
91 |
P2tTrianglePtrList
|
92 |
p2t_cdt_get_map (P2tCDT *THIS)
|
93 |
{
|
94 |
return p2t_sweepcontext_get_map (THIS->sweep_context_);
|
95 |
}
|