File: canonize_result.c

package info (click to toggle)
snappea 3.0d3-20.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,896 kB
  • ctags: 3,582
  • sloc: ansic: 33,469; sh: 8,293; python: 7,623; makefile: 240
file content (73 lines) | stat: -rw-r--r-- 1,810 bytes parent folder | download | duplicates (8)
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
/*
 *	canonize_result.c
 *
 *	The function
 *
 *		Boolean is_canonical_triangulation(Triangulation *manifold);
 *
 *	accepts a Triangulation which it assumes to be a subdivision of a canonical
 *	cell decomposition (as produced by proto_canonize(), for example), and
 *	says whether it is indeed the canonical cell decomposition itself.
 *	In other words, is_canonical_triangulation() will return TRUE
 *	when the canonical cell decomposition is a triangulation, and FALSE when
 *	it is not.
 *
 *	is_canonical_triangulation() assumes all Tetrahedra in the Triangulation
 *	have valid "tilt" fields, as will be the case following a call to
 *	proto_canonize().
 */


#include "kernel.h"
#include "canonize.h"


Boolean is_canonical_triangulation(
	Triangulation	*manifold)
{
	Tetrahedron	*tet,
				*nbr_tet;
	FaceIndex	f,
				nbr_f;
	double		sum_of_tilts;
	Boolean		result;

	/*
	 *	We'll assume the canonical cell decomposition is a triangulation
	 *	unless we discover otherwise.
	 */
	result = TRUE;

	for (tet = manifold->tet_list_begin.next;
		 tet != &manifold->tet_list_end;
		 tet = tet->next)

		for (f = 0; f < 4; f++)
		{
			nbr_tet	= tet->neighbor[f];
			nbr_f	= EVALUATE(tet->gluing[f], f);

			sum_of_tilts = tet->tilt[f] + nbr_tet->tilt[nbr_f];

			/*
			 *	The sum of the tilts should never be positive, because
			 *	this would mean that we didn't have a subdivision of the
			 *	canonical cell decomposition after all.
			 */
			if (sum_of_tilts > CONCAVITY_EPSILON)
				uFatalError("is_canonical_triangulation", "canonize_result");

			/*
			 *	If the sum of the tilts is zero, then the canonical cell
			 *	decomposition contains cell other than tetrahedra.
			 */
			if (sum_of_tilts > -CONCAVITY_EPSILON)
				result = FALSE;

			/*
			 *	Otherwise we're OK.
			 */
		}

	return result;
}