File: find_cusp.c

package info (click to toggle)
regina-normal 4.93-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 28,576 kB
  • sloc: cpp: 86,815; ansic: 13,030; xml: 9,089; perl: 951; sh: 380; python: 273; makefile: 103
file content (41 lines) | stat: -rw-r--r-- 1,020 bytes parent folder | download
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
/*
 *	find_cusp.c
 *
 *	This function provides the following utility for use within the kernel.
 *
 *		Cusp *find_cusp(Triangulation *manifold, int cusp_index);
 *
 *	The UI refers to cusps by their indices, because it doesn't know about
 *	the Cusp data structure.  When a kernel function receives a cusp_index,
 *	it may call the function find_cusp() to convert the index to an actual
 *	pointer to the corresponding Cusp data structure.  If find_cusp() cannot
 *	find a Cusp with the given cusp_index, it calls uFatalError().
 */

#include "kernel.h"

Cusp *find_cusp(
	Triangulation	*manifold,
	int				cusp_index)
{
	Cusp	*cusp;

	for (cusp = manifold->cusp_list_begin.next;
		 cusp != &manifold->cusp_list_end;
		 cusp = cusp->next)

		if (cusp->index == cusp_index)

			return cusp;

	/*
	 *	No Cusp with the given index was found.
	 */
	uFatalError("find_cusp", "find_cusp.c");

	/*
	 *	The C++ compiler would like a return value, even though
	 *	we never return from the uFatalError() call.
	 */
	return NULL;
}