1 /* Copyright (C) 1992-1998 The Geometry Center
2  * Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips
3  *
4  * This file is part of Geomview.
5  *
6  * Geomview is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published
8  * by the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * Geomview is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Geomview; see the file COPYING.  If not, write
18  * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139,
19  * USA, or visit http://www.gnu.org.
20  */
21 
22 #if HAVE_CONFIG_H
23 # include "config.h"
24 #endif
25 
26 #if 0
27 static char copyright[] = "Copyright (C) 1992-1998 The Geometry Center\n\
28 Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips";
29 #endif
30 
31 #include "discgrpP.h"
32 
33 static int constraint_depth;
34 static float constraint_stored, constraint_printd;
35 
36 void
DiscGrpInitStandardConstraint(int depth,float ind0,float ind1)37 DiscGrpInitStandardConstraint(int depth, float ind0, float ind1)
38 {
39     constraint_depth = depth;
40     constraint_stored = ind0;
41     constraint_printd = ind1;
42 }
43 
44 	static HPoint3 origin = {0.0, 0.0, 0.0, 1.0};
45 int
DiscGrpStandardConstraint(DiscGrpEl * dgel)46 DiscGrpStandardConstraint(DiscGrpEl *dgel)
47 {
48  	int big=0, l;
49 	float d;
50 	HPoint3 image;
51 	int metric = dgel->attributes & DG_METRIC_BITS;
52 	extern double getnorm();
53 
54 	if ((l = strlen(dgel->word)) > constraint_depth)
55 		return(DG_CONSTRAINT_LONG);
56 	if (l == constraint_depth) big |= DG_CONSTRAINT_MAXLEN;
57 
58 	/* find hyperbolic distance of image from origin: take short cut */
59 	HPt3Transform(dgel->tform, &origin, &image);
60 	d = HPt3SpaceDistance(&origin, &image, metric);
61 
62 	if ( d < constraint_stored)	{
63 	    big |= DG_CONSTRAINT_STORE;
64 	    if ( d < constraint_printd)	{
65 	        big |= DG_CONSTRAINT_PRINT;
66 		}
67 	    }
68 	else		{
69 		big |= DG_CONSTRAINT_TOOFAR;
70 		}
71 
72 	return(big);
73 }
74 
75