aboutsummaryrefslogtreecommitdiff
path: root/advtrains_interlocking/models/at_il_tcb_node.obj
blob: bb6aab50b405ef0a5b6960d93359738c9ec4e419 (plain)
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# Blender v2.76 (sub 0) OBJ File: ''
# www.blender.org
mtllib at_il_tcb_node.mtl
o Cube
v 0.038370 -0.500000 -0.038370
v 0.038370 -0.500000 0.038370
v -0.038370 -0.500000 0.038370
v -0.038370 -0.500000 -0.038370
v 0.038370 0.098086 -0.038370
v 0.038370 0.098086 0.038370
v -0.038370 0.098086 0.038370
v -0.038370 0.098086 -0.038370
v -0.182395 0.065479 0.099357
v -0.182395 0.182395 0.099357
v -0.182395 0.065479 -0.171034
v -0.182395 0.182395 -0.171034
v 0.182395 0.065479 0.099357
v 0.182395 0.182395 0.099357
v 0.182395 0.065479 -0.171034
v 0.182395 0.182395 -0.171034
v -0.112374 0.070035 -0.139406
v -0.112374 -0.500000 -0.139406
v 0.112189 -0.500000 -0.139406
v 0.112189 0.070035 -0.139406
v 0.122883 -0.500000 -0.137278
v 0.122883 0.070035 -0.137278
v 0.131950 -0.500000 -0.131220
v 0.131950 0.070035 -0.131220
v 0.138008 -0.500000 -0.122154
v 0.138008 0.070035 -0.122154
v 0.140135 -0.500000 -0.111459
v 0.140135 0.070035 -0.111459
v 0.138008 -0.500000 -0.100765
v 0.138008 0.070035 -0.100765
v 0.131950 -0.500000 -0.091698
v 0.131950 0.070035 -0.091698
v 0.122883 -0.500000 -0.085640
v 0.122883 0.070035 -0.085640
v 0.112189 -0.500000 -0.083513
v 0.112189 0.070035 -0.083513
v 0.101494 -0.500000 -0.085640
v 0.101494 0.070035 -0.085640
v 0.092428 -0.500000 -0.091698
v 0.092428 0.070035 -0.091698
v 0.086370 -0.500000 -0.100765
v 0.086370 0.070035 -0.100765
v 0.084242 -0.500000 -0.111459
v 0.084242 0.070035 -0.111459
v 0.086370 -0.500000 -0.122154
v 0.086370 0.070035 -0.122154
v 0.092428 -0.500000 -0.131220
v 0.092428 0.070035 -0.131220
v 0.101494 -0.500000 -0.137278
v 0.101494 0.070035 -0.137278
v -0.101679 -0.500000 -0.137278
v -0.101679 0.070035 -0.137278
v -0.092613 -0.500000 -0.131220
v -0.092613 0.070035 -0.131220
v -0.086555 -0.500000 -0.122154
v -0.086555 0.070035 -0.122154
v -0.084428 -0.500000 -0.111459
v -0.084428 0.070035 -0.111459
v -0.086555 -0.500000 -0.100765
v -0.086555 0.070035 -0.100765
v -0.092613 -0.500000 -0.091698
v -0.092613 0.070035 -0.091698
v -0.101679 -0.500000 -0.085640
v -0.101679 0.070035 -0.085640
v -0.112374 -0.500000 -0.083513
v -0.112374 0.070035 -0.083513
v -0.123069 -0.500000 -0.085640
v -0.123069 0.070035 -0.085640
v -0.132135 -0.500000 -0.091698
v -0.132135 0.070035 -0.091698
v -0.138193 -0.500000 -0.100765
v -0.138193 0.070035 -0.100765
v -0.140320 -0.500000 -0.111459
v -0.140320 0.070035 -0.111459
v -0.138193 -0.500000 -0.122154
v -0.138193 0.070035 -0.122154
v -0.132135 -0.500000 -0.131220
v -0.132135 0.070035 -0.131220
v -0.123069 -0.500000 -0.137278
v -0.123069 0.070035 -0.137278
vt 0.876073 0.266665
vt 0.876073 0.977812
vt 0.784827 0.977812
vt 0.784827 0.266665
vt 0.693582 0.977812
vt 0.693582 0.266665
vt 0.602336 0.977812
vt 0.602336 0.266665
vt 0.967319 0.266665
vt 0.967319 0.977812
vt 0.147929 0.032040
vt 0.469434 0.032040
vt 0.469434 0.171057
vt 0.147929 0.171057
vt 0.903184 0.032040
vt 0.903184 0.171057
vt 0.147929 0.032751
vt 0.469434 0.032751
vt 0.469434 0.171768
vt 0.147929 0.171768
vt 0.903184 0.032751
vt 0.903183 0.171768
vt 0.263807 0.270252
vt 0.585312 0.270252
vt 0.585312 0.704001
vt 0.263807 0.704001
vt 0.584297 0.703059
vt 0.262792 0.703059
vt 0.262793 0.269309
vt 0.584297 0.269309
vt 0.108472 0.980897
vt 0.108473 0.303114
vt 0.121438 0.303114
vt 0.121438 0.980897
vt 0.081877 0.980125
vt 0.081879 0.302342
vt 0.094844 0.302342
vt 0.094843 0.980125
vt 0.095507 0.980897
vt 0.095508 0.303114
vt 0.107809 0.302342
vt 0.107808 0.980125
vt 0.082541 0.980897
vt 0.082543 0.303114
vt 0.120774 0.302342
vt 0.120774 0.980125
vt 0.069575 0.980897
vt 0.069577 0.303114
vt 0.133739 0.302342
vt 0.133740 0.980125
vt 0.056609 0.980897
vt 0.056612 0.303114
vt 0.146705 0.302342
vt 0.146706 0.980125
vt 0.043643 0.980897
vt 0.043647 0.303114
vt 0.159670 0.302342
vt 0.159672 0.980125
vt 0.030677 0.980897
vt 0.030682 0.303113
vt 0.172635 0.302342
vt 0.172638 0.980125
vt 0.017711 0.980897
vt 0.017717 0.303113
vt 0.185600 0.302342
vt 0.185604 0.980125
vt 0.212200 0.980896
vt 0.212195 0.303113
vt 0.225160 0.303113
vt 0.225166 0.980896
vt 0.198565 0.302342
vt 0.198570 0.980125
vt 0.199234 0.980897
vt 0.199230 0.303114
vt 0.211531 0.302342
vt 0.211536 0.980125
vt 0.186268 0.980897
vt 0.186264 0.303114
vt 0.224496 0.302342
vt 0.224502 0.980125
vt 0.173302 0.980897
vt 0.173299 0.303114
vt 0.017047 0.980125
vt 0.017052 0.302342
vt 0.030018 0.302342
vt 0.030013 0.980125
vt 0.134403 0.303114
vt 0.134404 0.980897
vt 0.160336 0.980897
vt 0.160334 0.303114
vt 0.042983 0.302342
vt 0.042979 0.980125
vt 0.147369 0.303114
vt 0.147370 0.980897
vt 0.055948 0.302342
vt 0.055945 0.980125
vt 0.068911 0.980125
vt 0.068913 0.302342
vn 1.000000 0.000000 0.000000
vn -0.000000 -0.000000 1.000000
vn -1.000000 -0.000000 -0.000000
vn 0.000000 0.000000 -1.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn -0.831500 0.000000 -0.555600
vn 0.195100 0.000000 -0.980800
vn -0.980800 0.000000 -0.195100
vn 0.555600 0.000000 -0.831500
vn -0.980800 0.000000 0.195100
vn 0.831500 0.000000 -0.555600
vn -0.831500 0.000000 0.555600
vn 0.980800 0.000000 -0.195100
vn -0.555600 0.000000 0.831500
vn 0.980800 0.000000 0.195100
vn -0.195100 0.000000 0.980800
vn 0.831500 0.000000 0.555600
vn 0.195100 0.000000 0.980800
vn 0.555600 0.000000 0.831500
vn -0.555600 0.000000 -0.831500
vn -0.195100 0.000000 -0.980800
usemtl Material
s off
f 1/1/1 5/2/1 6/3/1 2/4/1
f 2/4/2 6/3/2 7/5/2 3/6/2
f 3/6/3 7/5/3 8/7/3 4/8/3
f 5/2/4 1/1/4 4/9/4 8/10/4
f 10/11/3 12/12/3 11/13/3 9/14/3
f 12/12/4 16/15/4 15/16/4 11/13/4
f 16/17/1 14/18/1 13/19/1 15/20/1
f 14/18/2 10/21/2 9/22/2 13/19/2
f 9/23/5 11/24/5 15/25/5 13/26/5
f 14/27/6 16/28/6 12/29/6 10/30/6
f 75/31/7 76/32/7 78/33/7 77/34/7
f 19/35/8 20/36/8 22/37/8 21/38/8
f 73/39/9 74/40/9 76/32/9 75/31/9
f 21/38/10 22/37/10 24/41/10 23/42/10
f 71/43/11 72/44/11 74/40/11 73/39/11
f 23/42/12 24/41/12 26/45/12 25/46/12
f 69/47/13 70/48/13 72/44/13 71/43/13
f 25/46/14 26/45/14 28/49/14 27/50/14
f 67/51/15 68/52/15 70/48/15 69/47/15
f 27/50/16 28/49/16 30/53/16 29/54/16
f 65/55/17 66/56/17 68/52/17 67/51/17
f 29/54/18 30/53/18 32/57/18 31/58/18
f 63/59/19 64/60/19 66/56/19 65/55/19
f 31/58/20 32/57/20 34/61/20 33/62/20
f 61/63/20 62/64/20 64/60/20 63/59/20
f 33/62/19 34/61/19 36/65/19 35/66/19
f 59/67/18 60/68/18 62/69/18 61/70/18
f 35/66/17 36/65/17 38/71/17 37/72/17
f 57/73/16 58/74/16 60/68/16 59/67/16
f 37/72/15 38/71/15 40/75/15 39/76/15
f 55/77/14 56/78/14 58/74/14 57/73/14
f 39/76/13 40/75/13 42/79/13 41/80/13
f 53/81/12 54/82/12 56/78/12 55/77/12
f 41/83/11 42/84/11 44/85/11 43/86/11
f 77/34/21 78/33/21 80/87/21 79/88/21
f 51/89/10 52/90/10 54/82/10 53/81/10
f 43/86/9 44/85/9 46/91/9 45/92/9
f 79/88/22 80/87/22 17/93/22 18/94/22
f 18/94/8 17/93/8 52/90/8 51/89/8
f 45/92/7 46/91/7 48/95/7 47/96/7
f 49/97/22 50/98/22 20/36/22 19/35/22
f 47/96/21 48/95/21 50/98/21 49/97/21
id='n483' href='#n483'>483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
/*
** $Id: ltable.c,v 2.32.1.2 2007/12/28 15:32:23 roberto Exp $
** Lua tables (hash)
** See Copyright Notice in lua.h
*/


/*
** Implementation of tables (aka arrays, objects, or hash tables).
** Tables keep its elements in two parts: an array part and a hash part.
** Non-negative integer keys are all candidates to be kept in the array
** part. The actual size of the array is the largest `n' such that at
** least half the slots between 0 and n are in use.
** Hash uses a mix of chained scatter table with Brent's variation.
** A main invariant of these tables is that, if an element is not
** in its main position (i.e. the `original' position that its hash gives
** to it), then the colliding element is in its own main position.
** Hence even when the load factor reaches 100%, performance remains good.
*/

#include <math.h>
#include <string.h>

#define ltable_c
#define LUA_CORE

#include "lua.h"

#include "ldebug.h"
#include "ldo.h"
#include "lgc.h"
#include "lmem.h"
#include "lobject.h"
#include "lstate.h"
#include "ltable.h"


/*
** max size of array part is 2^MAXBITS
*/
#if LUAI_BITSINT > 26
#define MAXBITS		26
#else
#define MAXBITS		(LUAI_BITSINT-2)
#endif

#define MAXASIZE	(1 << MAXBITS)


#define hashpow2(t,n)      (gnode(t, lmod((n), sizenode(t))))
  
#define hashstr(t,str)  hashpow2(t, (str)->tsv.hash)
#define hashboolean(t,p)        hashpow2(t, p)


/*
** for some types, it is better to avoid modulus by power of 2, as
** they tend to have many 2 factors.
*/
#define hashmod(t,n)	(gnode(t, ((n) % ((sizenode(t)-1)|1))))


#define hashpointer(t,p)	hashmod(t, IntPoint(p))


/*
** number of ints inside a lua_Number
*/
#define numints		cast_int(sizeof(lua_Number)/sizeof(int))



#define dummynode		(&dummynode_)

static const Node dummynode_ = {
  {{NULL}, LUA_TNIL},  /* value */
  {{{NULL}, LUA_TNIL, NULL}}  /* key */
};


/*
** hash for lua_Numbers
*/
static Node *hashnum (const Table *t, lua_Number n) {
  unsigned int a[numints];
  int i;
  if (luai_numeq(n, 0))  /* avoid problems with -0 */
    return gnode(t, 0);
  memcpy(a, &n, sizeof(a));
  for (i = 1; i < numints; i++) a[0] += a[i];
  return hashmod(t, a[0]);
}



/*
** returns the `main' position of an element in a table (that is, the index
** of its hash value)
*/
static Node *mainposition (const Table *t, const TValue *key) {
  switch (ttype(key)) {
    case LUA_TNUMBER:
      return hashnum(t, nvalue(key));
    case LUA_TSTRING:
      return hashstr(t, rawtsvalue(key));
    case LUA_TBOOLEAN:
      return hashboolean(t, bvalue(key));
    case LUA_TLIGHTUSERDATA:
      return hashpointer(t, pvalue(key));
    default:
      return hashpointer(t, gcvalue(key));
  }
}


/*
** returns the index for `key' if `key' is an appropriate key to live in
** the array part of the table, -1 otherwise.
*/
static int arrayindex (const TValue *key) {
  if (ttisnumber(key)) {
    lua_Number n = nvalue(key);
    int k;
    lua_number2int(k, n);
    if (luai_numeq(cast_num(k), n))
      return k;
  }
  return -1;  /* `key' did not match some condition */
}


/*
** returns the index of a `key' for table traversals. First goes all
** elements in the array part, then elements in the hash part. The
** beginning of a traversal is signalled by -1.
*/
static int findindex (lua_State *L, Table *t, StkId key) {
  int i;
  if (ttisnil(key)) return -1;  /* first iteration */
  i = arrayindex(key);
  if (0 < i && i <= t->sizearray)  /* is `key' inside array part? */
    return i-1;  /* yes; that's the index (corrected to C) */
  else {
    Node *n = mainposition(t, key);
    do {  /* check whether `key' is somewhere in the chain */
      /* key may be dead already, but it is ok to use it in `next' */
      if (luaO_rawequalObj(key2tval(n), key) ||
            (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) &&
             gcvalue(gkey(n)) == gcvalue(key))) {
        i = cast_int(n - gnode(t, 0));  /* key index in hash table */
        /* hash elements are numbered after array ones */
        return i + t->sizearray;
      }
      else n = gnext(n);
    } while (n);
    luaG_runerror(L, "invalid key to " LUA_QL("next"));  /* key not found */
    return 0;  /* to avoid warnings */
  }
}


int luaH_next (lua_State *L, Table *t, StkId key) {
  int i = findindex(L, t, key);  /* find original element */
  for (i++; i < t->sizearray; i++) {  /* try first array part */
    if (!ttisnil(&t->array[i])) {  /* a non-nil value? */
      setnvalue(key, cast_num(i+1));
      setobj2s(L, key+1, &t->array[i]);
      return 1;
    }
  }
  for (i -= t->sizearray; i < sizenode(t); i++) {  /* then hash part */
    if (!ttisnil(gval(gnode(t, i)))) {  /* a non-nil value? */
      setobj2s(L, key, key2tval(gnode(t, i)));
      setobj2s(L, key+1, gval(gnode(t, i)));
      return 1;
    }
  }
  return 0;  /* no more elements */
}


/*
** {=============================================================
** Rehash
** ==============================================================
*/


static int computesizes (int nums[], int *narray) {
  int i;
  int twotoi;  /* 2^i */
  int a = 0;  /* number of elements smaller than 2^i */
  int na = 0;  /* number of elements to go to array part */
  int n = 0;  /* optimal size for array part */
  for (i = 0, twotoi = 1; twotoi/2 < *narray; i++, twotoi *= 2) {
    if (nums[i] > 0) {
      a += nums[i];
      if (a > twotoi/2) {  /* more than half elements present? */
        n = twotoi;  /* optimal size (till now) */
        na = a;  /* all elements smaller than n will go to array part */
      }
    }
    if (a == *narray) break;  /* all elements already counted */
  }
  *narray = n;
  lua_assert(*narray/2 <= na && na <= *narray);
  return na;
}


static int countint (const TValue *key, int *nums) {
  int k = arrayindex(key);
  if (0 < k && k <= MAXASIZE) {  /* is `key' an appropriate array index? */
    nums[ceillog2(k)]++;  /* count as such */
    return 1;
  }
  else
    return 0;
}


static int numusearray (const Table *t, int *nums) {
  int lg;
  int ttlg;  /* 2^lg */
  int ause = 0;  /* summation of `nums' */
  int i = 1;  /* count to traverse all array keys */
  for (lg=0, ttlg=1; lg<=MAXBITS; lg++, ttlg*=2) {  /* for each slice */
    int lc = 0;  /* counter */
    int lim = ttlg;
    if (lim > t->sizearray) {
      lim = t->sizearray;  /* adjust upper limit */
      if (i > lim)
        break;  /* no more elements to count */
    }
    /* count elements in range (2^(lg-1), 2^lg] */
    for (; i <= lim; i++) {
      if (!ttisnil(&t->array[i-1]))
        lc++;
    }
    nums[lg] += lc;
    ause += lc;
  }
  return ause;
}


static int numusehash (const Table *t, int *nums, int *pnasize) {
  int totaluse = 0;  /* total number of elements */
  int ause = 0;  /* summation of `nums' */
  int i = sizenode(t);
  while (i--) {
    Node *n = &t->node[i];
    if (!ttisnil(gval(n))) {
      ause += countint(key2tval(n), nums);
      totaluse++;
    }
  }
  *pnasize += ause;
  return totaluse;
}


static void setarrayvector (lua_State *L, Table *t, int size) {
  int i;
  luaM_reallocvector(L, t->array, t->sizearray, size, TValue);
  for (i=t->sizearray; i<size; i++)
     setnilvalue(&t->array[i]);
  t->sizearray = size;
}


static void setnodevector (lua_State *L, Table *t, int size) {
  int lsize;
  if (size == 0) {  /* no elements to hash part? */
    t->node = cast(Node *, dummynode);  /* use common `dummynode' */
    lsize = 0;
  }
  else {
    int i;
    lsize = ceillog2(size);
    if (lsize > MAXBITS)
      luaG_runerror(L, "table overflow");
    size = twoto(lsize);
    t->node = luaM_newvector(L, size, Node);
    for (i=0; i<size; i++) {
      Node *n = gnode(t, i);
      gnext(n) = NULL;
      setnilvalue(gkey(n));
      setnilvalue(gval(n));
    }
  }
  t->lsizenode = cast_byte(lsize);
  t->lastfree = gnode(t, size);  /* all positions are free */
}


static void resize (lua_State *L, Table *t, int nasize, int nhsize) {
  int i;