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 #ifndef __P2TC_P2T_ADVANCING_FRONT_H__ 37 #define __P2TC_P2T_ADVANCING_FRONT_H__ 38 39 #include "../common/poly2tri-private.h" 40 #include "../common/shapes.h" 41 42 /* Advancing front node */ 43 44 struct _P2tNode 45 { 46 P2tPoint* point; 47 P2tTriangle* triangle; 48 49 struct _P2tNode* next; 50 struct _P2tNode* prev; 51 52 double value; 53 }; 54 55 void p2t_node_init_pt (P2tNode* THIS, P2tPoint* p); 56 P2tNode* p2t_node_new_pt (P2tPoint* p); 57 void p2t_node_init_pt_tr (P2tNode* THIS, P2tPoint* p, P2tTriangle* t); 58 P2tNode* p2t_node_new_pt_tr (P2tPoint* p, P2tTriangle* t); 59 void p2t_node_destroy (P2tNode* THIS); 60 void p2t_node_free (P2tNode* THIS); 61 62 /* Advancing front */ 63 64 struct AdvancingFront_ 65 { 66 /* private: */ 67 68 P2tNode* head_, *tail_, *search_node_; 69 70 }; 71 72 void p2t_advancingfront_init (P2tAdvancingFront* THIS, P2tNode* head, P2tNode* tail); 73 P2tAdvancingFront* p2t_advancingfront_new (P2tNode* head, P2tNode* tail); 74 75 void p2t_advancingfront_destroy (P2tAdvancingFront* THIS); 76 void p2t_advancingfront_free (P2tAdvancingFront* THIS); 77 78 P2tNode* p2t_advancingfront_head (P2tAdvancingFront *THIS); 79 void AdvancingFront_set_head (P2tAdvancingFront *THIS, P2tNode* node); 80 P2tNode* p2t_advancingfront_tail (P2tAdvancingFront *THIS); 81 void p2t_advancingfront_set_tail (P2tAdvancingFront *THIS, P2tNode* node); 82 P2tNode* p2t_advancingfront_search (P2tAdvancingFront *THIS); 83 void p2t_advancingfront_set_search (P2tAdvancingFront *THIS, P2tNode* node); 84 85 /** Locate insertion point along advancing front */ 86 P2tNode* p2t_advancingfront_locate_node (P2tAdvancingFront *THIS, const double x); 87 88 P2tNode* p2t_advancingfront_locate_point (P2tAdvancingFront *THIS, const P2tPoint* point); 89 90 P2tNode* p2t_advancingfront_find_search_node (P2tAdvancingFront *THIS, const double x); 91 92 #endif 93