Commit e9ac434f authored by Barak Itkin's avatar Barak Itkin Committed by Michael Natterer

Add a local copy of poly2tri-c for use by seamless-cloning as a fallback

parent 4e0e8067
......@@ -1019,20 +1019,24 @@ AC_SUBST(UMFPACK_LIBS)
# Check for poly2tri-c
######################
AC_ARG_WITH(p2tc, AS_HELP_STRING([--without-p2tc], [build without poly2tri-c support]))
have_p2tc="no"
if test "x$with_p2tc" != "xno"; then
PKG_CHECK_MODULES(P2TC, poly2tri-c >= poly2tri-c_required_version,
have_p2tc="yes",
have_p2tc="no (poly2tri-c not found)")
fi
PKG_CHECK_MODULES(P2TC, poly2tri-c >= poly2tri-c_required_version,
have_p2tc="yes",
have_p2tc="yes (installed poly2tri-c not found, using local version)")
AM_CONDITIONAL(HAVE_P2TC, test "$have_p2tc" = "yes")
AC_SUBST(P2TC_CFLAGS)
AC_SUBST(P2TC_LIBS)
# If no poly2tri-c version is installed, we should use the local version
# we have cached in the libs directory
if test "x$have_p2tc" != "xyes"; then
AC_SUBST(P2TC_SRC_DIR, "`cd $srcdir; pwd`/libs/poly2tri-c")
AC_SUBST(P2TC_CFLAGS, "-I\"$P2TC_SRC_DIR\"")
AC_SUBST(P2TC_LIBS, "-L\"$P2TC_SRC_DIR/poly2tri-c\" -lpoly2tri-c")
fi
#######################
# Check for other items
#######################
......@@ -1098,6 +1102,13 @@ gegl/property-types/Makefile
gegl/opencl/Makefile
libs/Makefile
libs/rgbe/Makefile
libs/poly2tri-c/Makefile
libs/poly2tri-c/poly2tri-c/Makefile
libs/poly2tri-c/poly2tri-c/render/Makefile
libs/poly2tri-c/poly2tri-c/p2t/sweep/Makefile
libs/poly2tri-c/poly2tri-c/p2t/common/Makefile
libs/poly2tri-c/poly2tri-c/p2t/Makefile
libs/poly2tri-c/poly2tri-c/refine/Makefile
operations/Makefile
operations/core/Makefile
operations/common/Makefile
......
SUBDIRS = rgbe
SUBDIRS = rgbe poly2tri-c
*.la
*.lo
*Makefile
*Makefile.in
*.deps/
*.libs/
The Poly2Tri-C is a three-part library, where all parts are licensed
under the same license - The BSD 3-Clause License (also known as "New
BSD License" or "Modified BSD License"):
1. Constrained Delaunay Triangulation - Based on the code of Poly2Tri
(Poly2Tri is licensed under the same license)
2. Delaunay Refinement - New code implemented in this library
3. Mesh Rendering - New code implemented in this library
The first part of the library is a port of the Poly2Tri library from C++
to C (with GLib). This port can be found inside the poly2tri-c/p2t
directory of this source code distribution.
Poly2Tri - A 2D constrained Delaunay triangulation library
Homepage: http://code.google.com/p/poly2tri/
Code License File: LICENSE-Poly2Tri.txt
The second part of the library is an implementaiton of a Delaunay
Refinement algorithm named "The Terminator" which appears in a paper
written by Jonathan Richard Shewchuk.
The implementation of the algorithm in C was done by Barak Itkin, and it
can be found inside the poly2tri-c/refine directory of this source code
distribution.
Algorithm Author:
Jonathan Richard Shewchuk
http://www.cs.berkeley.edu/~jrs/
Algorithm Paper:
Delaunay Refinement Algorithms for Triangular Mesh Generation
http://www.cs.berkeley.edu/~jrs/papers/2dj.pdf
Code License File: LICENSE-Poly2Tri-C.txt
Finally, the third part of the library contains various techniques to
render mesh objects as raster/vector images. This part is 'original' and
is not based on any other reference. This code can be found inside the
poly2tri-c/render directory of this source code distribution.
Code License File: LICENSE-Poly2Tri-C.txt
Poly2Tri-C Copyright (c) 2011-2012, Barak Itkin
http://code.google.com/p/poly2tri-c/
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Poly2Tri-C nor the names of its contributors may
be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
http://code.google.com/p/poly2tri/
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Poly2Tri nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if HAVE_P2TC
SUBDIRS =
else
SUBDIRS = poly2tri-c
AM_CFLAGS = -I $(CURDIR) $(GLIB_CFLAGS)
export AM_CFLAGS
AM_LIBS = $(GLIB_LIBS)
export AM_LIBS
endif
========================================================================
==== Poly2Tri-C: A library for generating, refining and rendering ====
==== 2-Dimensional Constrained Delaunay Triangulations ====
========================================================================
This is a minimal version of the Poly2Tri-C library, required to compile
the seamless cloning operation. For more information, and in order to
get the full library, see http://code.google.com/p/poly2tri-c
Poly2Tri-C Version info:
CURRENT REVISION: b27c5b79df2ffa4e2cb37f9e5536831f16afb11b
CACHED ON: August 11th, 2012
SUBDIRS = p2t refine render
noinst_LTLIBRARIES = libpoly2tri-c.la
libpoly2tri_c_la_LIBADD = p2t/libp2tc.la refine/libp2tc-refine.la render/libp2tc-render.la
libpoly2tri_c_la_SOURCES =
SUBDIRS = sweep common
noinst_LTLIBRARIES = libp2tc.la
P2TC_P2T_publicdir = $(P2TC_publicdir)/p2t
export P2TC_P2T_publicdir
P2TC_P2T_public_HEADERS = poly2tri.h
libp2tc_la_LIBADD = common/libp2tc-common.la sweep/libp2tc-sweep.la
libp2tc_la_SOURCES =
noinst_LTLIBRARIES = libp2tc-common.la
libp2tc_common_la_SOURCES = cutils.h poly2tri-private.h shapes.c shapes.h utils.c utils.h
P2TC_P2T_COMMON_publicdir = $(P2TC_P2T_publicdir)/common
P2TC_P2T_COMMON_public_HEADERS = cutils.h poly2tri-private.h shapes.h utils.h
/*
* This file is a part of the C port of the Poly2Tri library
* Porting to C done by (c) Barak Itkin <lightningismyname@gmail.com>
* http://code.google.com/p/poly2tri-c/
*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __P2TC_P2T_CUTILS_H__
#define __P2TC_P2T_CUTILS_H__
#include <glib.h>
#include "poly2tri-private.h"
#ifdef __cplusplus
extern "C"
{
#endif
#define DEBUG FALSE
typedef GPtrArray* P2tEdgePtrArray;
#define edge_index(array,index_) ((P2tEdge*)g_ptr_array_index(array,index_))
typedef GPtrArray* P2tPointPtrArray;
#define point_index(array,index_) ((P2tPoint*)g_ptr_array_index(array,index_))
typedef GPtrArray* P2tTrianglePtrArray;
#define triangle_index(array,index_) ((P2tTriangle*)g_ptr_array_index(array,index_))
typedef GPtrArray* P2tNodePtrArray;
#define node_index(array,index_) ((P2tNode*)g_ptr_array_index(array,index_))
typedef GList* P2tTrianglePtrList;
#define triangle_val(list) ((P2tTriangle*)((list)->data))
#define g_ptr_array_index_cyclic(array,index_) g_ptr_array_index(array,(index_)%((array)->len))
#ifdef __cplusplus
}
#endif
#endif /* CUTILS_H */
/*
* This file is a part of the C port of the Poly2Tri library
* Porting to C done by (c) Barak Itkin <lightningismyname@gmail.com>
* http://code.google.com/p/poly2tri-c/
*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __P2TC_P2T_POLY2TRI_PRIVATE_H__
#define __P2TC_P2T_POLY2TRI_PRIVATE_H__
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct _P2tNode P2tNode;
typedef struct AdvancingFront_ P2tAdvancingFront;
typedef struct CDT_ P2tCDT;
typedef struct _P2tEdge P2tEdge;
typedef struct _P2tPoint P2tPoint;
typedef struct _P2tTriangle P2tTriangle;
typedef struct SweepContext_ P2tSweepContext;
typedef struct Sweep_ P2tSweep;
typedef struct P2tSweepContextBasin_ P2tSweepContextBasin;
typedef struct P2tSweepContextEdgeEvent_ P2tSweepContextEdgeEvent;
#ifdef __cplusplus
}
#endif
#endif /* POLY2TRI_PRIVATE_H */
/*
* This file is a part of the C port of the Poly2Tri library
* Porting to C done by (c) Barak Itkin <lightningismyname@gmail.com>
* http://code.google.com/p/poly2tri-c/
*
* Poly2Tri Copyright (c) 2009-2010, Poly2Tri Contributors
* http://code.google.com/p/poly2tri/
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Poly2Tri nor the names of its contributors may be
* used to endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "shapes.h"
#include <stdio.h>
#include <stdlib.h>
/** Default constructor does nothing (for performance). */
void
p2t_point_init (P2tPoint* THIS)
{
THIS->x = 0;
THIS->y = 0;
THIS->edge_list = g_ptr_array_new ();
}
P2tPoint*
p2t_point_new ()
{
P2tPoint* THIS = g_slice_new (P2tPoint);
p2t_point_init (THIS);
return THIS;
}
/** Construct using coordinates. */
void
p2t_point_init_dd (P2tPoint* THIS, double x, double y)
{
THIS->x = x;
THIS->y = y;
THIS->edge_list = g_ptr_array_new ();
}
P2tPoint*
p2t_point_new_dd (double x, double y)
{
P2tPoint* THIS = g_slice_new (P2tPoint);
p2t_point_init_dd (THIS, x, y);
return THIS;
}
void
p2t_point_destroy (P2tPoint* THIS)
{
g_ptr_array_free (THIS->edge_list, TRUE);
}
void
p2t_point_free (P2tPoint* THIS)
{
p2t_point_destroy (THIS);
g_slice_free (P2tPoint, THIS);
}
/** Constructor */
void
p2t_edge_init (P2tEdge* THIS, P2tPoint* p1, P2tPoint* p2)
{
THIS->p = p1;
THIS->q = p2;
if (p1->y > p2->y)
{
THIS->q = p1;
THIS->p = p2;
}
else if (p1->y == p2->y)
{
if (p1->x > p2->x)
{
THIS->q = p1;
THIS->p = p2;
}
else if (p1->x == p2->x)
{
/* Repeat points */
assert (FALSE);
}
}
g_ptr_array_add (THIS->q->edge_list, THIS);
}
P2tEdge*
p2t_edge_new (P2tPoint* p1, P2tPoint* p2)
{
P2tEdge* THIS = g_slice_new (P2tEdge);
p2t_edge_init (THIS, p1, p2);
return THIS;
}
void
p2t_edge_destroy (P2tEdge* THIS) { }
void
p2t_edge_free (P2tEdge* THIS)
{
p2t_edge_destroy (THIS);
g_slice_free (P2tEdge, THIS);
}
P2tTriangle*
p2t_triangle_new (P2tPoint* a, P2tPoint* b, P2tPoint* c)
{
P2tTriangle *tr = g_new (P2tTriangle, 1);
p2t_triangle_init (tr, a, b, c);
return tr;
}
void
p2t_triangle_init (P2tTriangle* THIS, P2tPoint* a, P2tPoint* b, P2tPoint* c)
{
THIS->points_[0] = a;
THIS->points_[1] = b;
THIS->points_[2] = c;
THIS->neighbors_[0] = NULL;
THIS->neighbors_[1] = NULL;
THIS->neighbors_[2] = NULL;
THIS->constrained_edge[0] = THIS->constrained_edge[1] = THIS->constrained_edge[2] = FALSE;
THIS->delaunay_edge[0] = THIS->delaunay_edge[1] = THIS->delaunay_edge[2] = FALSE;
THIS->interior_ = FALSE;
}
/* Update neighbor pointers */
void
p2t_triangle_mark_neighbor_pt_pt_tr (P2tTriangle* THIS, P2tPoint* p1, P2tPoint* p2, P2tTriangle* t)
{
if ((p1 == THIS->points_[2] && p2 == THIS->points_[1]) || (p1 == THIS->points_[1] && p2 == THIS->points_[2]))
THIS->neighbors_[0] = t;
else if ((p1 == THIS->points_[0] && p2 == THIS->points_[2]) || (p1 == THIS->points_[2] && p2 == THIS->points_[0]))
THIS->neighbors_[1] = t;
else if ((p1 == THIS->points_[0] && p2 == THIS->points_[1]) || (p1 == THIS->points_[1] && p2 == THIS->points_[0]))
THIS->neighbors_[2] = t;
else
assert (0);
}
/* Exhaustive search to update neighbor pointers */
void
p2t_triangle_mark_neighbor_tr (P2tTriangle* THIS, P2tTriangle *t)
{
if (p2t_triangle_contains_pt_pt (t, THIS->points_[1], THIS->points_[2]))
{
THIS->neighbors_[0] = t;
p2t_triangle_mark_neighbor_pt_pt_tr (t, THIS->points_[1], THIS->points_[2], THIS);
}
else if (p2t_triangle_contains_pt_pt (t, THIS->points_[0], THIS->points_[2]))
{
THIS->neighbors_[1] = t;
p2t_triangle_mark_neighbor_pt_pt_tr (t, THIS->points_[0], THIS->points_[2], THIS);
}
else if (p2t_triangle_contains_pt_pt (t, THIS->points_[0], THIS->points_[1]))
{
THIS->neighbors_[2] = t;
p2t_triangle_mark_neighbor_pt_pt_tr (t, THIS->points_[0], THIS->points_[1], THIS);
}
}
/**
* Clears all references to all other triangles and points
*/
void
p2t_triangle_clear (P2tTriangle* THIS)
{
int i;
P2tTriangle *t;
for (i = 0; i < 3; i++)
{
t = THIS->neighbors_[i];
if (t != NULL)
{
p2t_triangle_clear_neighbor_tr (t, THIS);
}
}
p2t_triangle_clear_neighbors (THIS);
THIS->points_[0] = THIS->points_[1] = THIS->points_[2] = NULL;
}
void
p2t_triangle_clear_neighbor_tr (P2tTriangle* THIS, P2tTriangle *triangle)
{
if (THIS->neighbors_[0] == triangle)
{
THIS->neighbors_[0] = NULL;
}
else if (THIS->neighbors_[1] == triangle)
{
THIS->neighbors_[1] = NULL;
}
else
{
THIS->neighbors_[2] = NULL;
}
}
void
p2t_triangle_clear_neighbors (P2tTriangle* THIS)
{
THIS->neighbors_[0] = NULL;
THIS->neighbors_[1] = NULL;
THIS->neighbors_[2] = NULL;
}
void
p2t_triangle_clear_delunay_edges (P2tTriangle* THIS)
{
THIS->delaunay_edge[0] = THIS->delaunay_edge[1] = THIS->delaunay_edge[2] = FALSE;
}
P2tPoint*
p2t_triangle_opposite_point (P2tTriangle* THIS, P2tTriangle* t, P2tPoint* p)
{
P2tPoint *cw = p2t_triangle_point_cw (t, p);
/*double x = cw->x;
double y = cw->y;
x = p->x;
y = p->y;
P2tPoint* ham = */p2t_triangle_point_cw (THIS, cw);
return p2t_triangle_point_cw (THIS, cw);
}
/* Legalized triangle by rotating clockwise around point(0) */
void
p2t_triangle_legalize_pt (P2tTriangle* THIS, P2tPoint *point)
{
THIS->points_[1] = THIS->points_[0];
THIS->points_[0] = THIS->points_[2];
THIS->points_[2] = point;
}
/* Legalize triagnle by rotating clockwise around oPoint */
void
p2t_triangle_legalize_pt_pt (P2tTriangle* THIS, P2tPoint *opoint, P2tPoint *npoint)
{
if (opoint == THIS->points_[0])
{
THIS->points_[1] = THIS->points_[0];
THIS->points_[0] = THIS->points_[2];
THIS->points_[2] = npoint;
}
else if (opoint == THIS->points_[1])
{
THIS->points_[2] = THIS->points_[1];
THIS->points_[1] = THIS->points_[0];
THIS->points_[0] = npoint;
}
else if (opoint == THIS->points_[2])
{
THIS->points_[0] = THIS->points_[2];
THIS->points_[2] = THIS->points_[1];
THIS->points_[1] = npoint;
}
else
{
assert (0);
}
}
int
p2t_triangle_index (P2tTriangle* THIS, const P2tPoint* p)
{
if (p == THIS->points_[0])
{
return 0;
}
else if (p == THIS->points_[1])
{
return 1;
}
else if (p == THIS->points_[2])
{
return 2;
}
assert (0);
}
int
p2t_triangle_edge_index (P2tTriangle* THIS, const P2tPoint* p1, const P2tPoint* p2)
{
if (THIS->points_[0] == p1)
{
if (THIS->points_[1] == p2)
{
return 2;
}
else if (THIS->points_[2] == p2)
{
return 1;
}
}
else if (THIS->points_[1] == p1)
{
if (THIS->points_[2] == p2)
{
return 0;
}
else if (THIS->points_[0] == p2)
{
return 2;
}
}
else if (THIS->points_[2] == p1)
{
if (THIS->points_[0] == p2)
{
return 1;
}
else if (THIS->points_[1] == p2)
{
return 0;
}
}
return -1;
}
void
p2t_triangle_mark_constrained_edge_i (P2tTriangle* THIS, const int index)
{
THIS->constrained_edge[index] = TRUE;
}
void