HOG2
VoxelGrid.cpp
Go to the documentation of this file.
1 //
2 // VoxelGrid.cpp
3 // hog2 glut
4 //
5 // Created by Nathan Sturtevant on 3/7/16.
6 // Copyright © 2016 University of Denver. All rights reserved.
7 //
8 
9 #include <stdio.h>
10 #include <deque>
11 #include "VoxelGrid.h"
12 #include <unordered_map>
14 #include <iostream>
15 
16 bool operator==(const voxelGridState &v1, const voxelGridState &v2)
17 {
18  return v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
19 }
20 
21 std::ostream &operator<<(std::ostream &out, const voxelGridState &v)
22 {
23  out << "(" << v.x << ", " << v.y << ", " << v.z << ")";
24  return out;
25 }
26 
27 
28 VoxelGrid::VoxelGrid(int x, int y, int z)
29 {
30  xWidth = x;
31  yWidth = y;
32  zWidth = z;
33  efficient = false;
34  voxels.resize(xWidth*yWidth*zWidth);
35 }
36 
37 VoxelGrid::VoxelGrid(const char *filename)
38 {
39  efficient = false;
40  FILE *f = fopen(filename, "r");
41  if (f == 0)
42  {
43  printf("Error opening file\n");
44  exit(0);
45  }
46  int cnt = fscanf(f, "voxel %d %d %d\n", &xWidth, &yWidth, &zWidth);
47  if (cnt != 3)
48  {
49  printf("Error reading dimensions\n");
50  return;
51  }
52  voxels.resize(xWidth*yWidth*zWidth);
53  int a, b, c;
54  while ((cnt = fscanf(f, "%d %d %d\n", &a, &b, &c)) == 3)
55  {
56  voxels[GetIndex(a, b, c)] = true;
57  }
58 
59  fclose(f);
60 
61 }
62 
64 {
65 
66 }
67 
69 {
70  for (int y = 0; y < yWidth; y++)
71  {
72  for (int z = 0; z < zWidth; z++)
73  {
74  for (int x = 0; x < xWidth; x++)
75  {
76  SetBlocked(x, y, z, IsBlocked(x, y, z) && g->IsBlocked(x, y, z));
77  }
78  }
79  }
80 }
81 
83 {
84  for (int y = 0; y < yWidth; y++)
85  {
86  for (int z = 0; z < zWidth; z++)
87  {
88  for (int x = 0; x < xWidth; x++)
89  {
90  if (g->IsBlocked(x, y, z))
91  SetBlocked(x, y, z, true);
92  }
93  }
94  }
95 }
96 
97 void VoxelGrid::Save(const char *filename)
98 {
99  FILE *f = fopen(filename, "w+");
100  if (f == 0)
101  {
102  printf("Error opening file\n");
103  exit(0);
104  }
105  fprintf(f, "voxel %d %d %d\n", xWidth, yWidth, zWidth);
106  for (int x = 0; x < xWidth; x++)
107  {
108  for (int y = 0; y < yWidth; y++)
109  {
110  for (int z = 0; z < zWidth; z++)
111  {
112  if (IsBlocked(x, y, z))
113  fprintf(f, "%d %d %d\n", x, y, z);
114  }
115  }
116  }
117  fclose(f);
118 }
119 
120 void VoxelGrid::SaveInMinBB(const char *filename)
121 {
122  int xMax = 0;
123  int yMax = 0;
124  int zMax = 0;
125  int xMin = xWidth;
126  int yMin = yWidth;
127  int zMin = zWidth;
128 
129  for (int x = 0; x < xWidth; x++)
130  {
131  for (int y = 0; y < yWidth; y++)
132  {
133  for (int z = 0; z < zWidth; z++)
134  {
135  if (IsBlocked(x, y, z))
136  {
137  xMax = std::max(xMax, x);
138  xMin = std::min(xMin, x);
139  yMax = std::max(yMax, y);
140  yMin = std::min(yMin, y);
141  zMax = std::max(zMax, z);
142  zMin = std::min(zMin, z);
143  }
144  }
145  }
146  }
147 
148  FILE *f = fopen(filename, "w+");
149  if (f == 0)
150  {
151  printf("Error opening file\n");
152  exit(0);
153  }
154  fprintf(f, "voxel %d %d %d\n", xMax-xMin+1, yMax-yMin+1, zMax-zMin+1);
155  for (int x = 0; x < xWidth; x++)
156  {
157  for (int y = 0; y < yWidth; y++)
158  {
159  for (int z = 0; z < zWidth; z++)
160  {
161  if (IsBlocked(x, y, z))
162  fprintf(f, "%d %d %d\n", x-xMin, y-yMin, z-zMin);
163  }
164  }
165  }
166  fclose(f);
167 }
168 
170 {
171  if ((s.x < xWidth) && (s.y < yWidth) && (s.z < zWidth))
172  return voxels[GetIndex(s)];
173  return true;
174 }
175 
176 void VoxelGrid::SetBlocked(const voxelGridState &s, bool block)
177 {
178  if ((s.x < xWidth) && (s.y < yWidth) && (s.z < zWidth))
179  voxels[GetIndex(s)] = block;
180 }
181 
183 {
184  return GetIndex(s.x, s.y, s.z);
185 }
186 
187 int VoxelGrid::GetIndex(int x, int y, int z) const
188 {
189  return xWidth*(y*zWidth+z)+x;
190 }
191 
192 void VoxelGrid::GetCoordinates(int index, voxelGridState &s) const
193 {
194  s.x = index%xWidth;
195  index /= xWidth;
196  s.z = index%zWidth;
197  s.y = index/zWidth;
198 }
199 
200 void VoxelGrid::GetCoordinates(int index, int &x, int &y, int &z) const
201 {
202  x = index%xWidth;
203  index /= xWidth;
204  z = index%zWidth;
205  y = index/zWidth;
206 }
207 
208 bool VoxelGrid::Legal(const voxelGridState &s) const
209 {
210  return ((s.x < xWidth) && (s.y < yWidth) && (s.z < zWidth));
211 }
212 
213 bool VoxelGrid::CanMove(const voxelGridState &s1, const voxelGridState &s2) const
214 {
215  return (IsBlocked(s1) ||
216  IsBlocked(s2) ||
217  IsBlocked({s2.x, s1.y, s1.z}) ||
218  IsBlocked({s1.x, s2.y, s1.z}) ||
219  IsBlocked({s1.x, s1.y, s2.z}) ||
220  IsBlocked({s2.x, s2.y, s1.z}) ||
221  IsBlocked({s2.x, s1.y, s2.z}) ||
222  IsBlocked({s1.x, s2.y, s2.z})) == false;
223 }
224 
226 {
227  std::deque<voxelGridState> q;
228  q.push_back(s);
229  while (!q.empty())
230  {
231  voxelGridState n = q.front();
232  q.pop_front();
233  if (IsBlocked(n)) // blocked already
234  continue;
235  voxels[GetIndex(n)] = true;
236  //std::cout << "Inverted " << n << "\n";
237  q.push_back(voxelGridState(n.x+1, n.y, n.z));
238  q.push_back(voxelGridState(n.x-1, n.y, n.z));
239  q.push_back(voxelGridState(n.x, n.y+1, n.z));
240  q.push_back(voxelGridState(n.x, n.y-1, n.z));
241  q.push_back(voxelGridState(n.x, n.y, n.z+1));
242  q.push_back(voxelGridState(n.x, n.y, n.z-1));
243  }
244  if (efficient)
246 }
247 
249 {
250  for (size_t x = 0; x < voxels.size(); x++)
251  voxels[x] = !voxels[x];
252  if (efficient)
254 }
255 
256 
257 void VoxelGrid::GetActionOffsets(voxelGridAction a, int &x, int &y, int &z) const
258 {
259  x = (a>>4)&3;
260  y = (a>>2)&3;
261  z = (a>>0)&3;
262  x--;
263  y--;
264  z--;
265 }
266 
267 voxelGridAction VoxelGrid::MakeAction(int &x, int &y, int &z) const
268 {
269  voxelGridAction v = 0;
270  v |= (((x+1)&3)<<4);
271  v |= (((y+1)&3)<<2);
272  v |= (((z+1)&3)<<0);
273  return v;
274 }
275 
276 
277 void VoxelGrid::GetSuccessors(const voxelGridState &nodeID, std::vector<voxelGridState> &neighbors) const
278 {
279  assert(voxels[GetIndex(nodeID)] == false);
280  neighbors.resize(0);
281  for (int x = -1; x <= 1; x++)
282  {
283  for (int y = -1; y <= 1; y++)
284  {
285  for (int z = -1; z <= 1; z++)
286  {
287  // This is simple code, but inefficient, because the CanMove checks repeat a lot of tests
288  if ((x|y|z) == 0)
289  continue;
290  voxelGridState s =
291  {static_cast<uint16_t>(nodeID.x+x),
292  static_cast<uint16_t>(nodeID.y+y),
293  static_cast<uint16_t>(nodeID.z+z)};
294  if (CanMove(nodeID, s))
295  neighbors.push_back(s);
296  }
297  }
298  }
299 }
300 
301 void VoxelGrid::GetActions(const voxelGridState &nodeID, std::vector<voxelGridAction> &actions) const
302 {
303  assert(voxels[GetIndex(nodeID)] == false);
304  actions.resize(0);
305 
306  for (int x = -1; x <= 1; x++)
307  {
308  for (int y = -1; y <= 1; y++)
309  {
310  for (int z = -1; z <= 1; z++)
311  {
312  if ((x|y|z) == 0)
313  continue;
314  voxelGridState s =
315  {static_cast<uint16_t>(nodeID.x+x),
316  static_cast<uint16_t>(nodeID.y+y),
317  static_cast<uint16_t>(nodeID.z+z)};
318  if (CanMove(nodeID, s))
319  actions.push_back(MakeAction(x, y, z));
320  }
321  }
322  }
323 }
324 
326 {
327  int x, y, z;
328  GetActionOffsets(a, x, y, z);
329  s.x+=x;
330  s.y+=y;
331  s.z+=z;
332 }
333 
335 {
336  return false;
337 }
338 
339 
341 double VoxelGrid::HCost(const voxelGridState &node1, const voxelGridState &node2) const
342 {
343  double xd = abs(node1.x-node2.x);
344  double yd = abs(node1.y-node2.y);
345  double zd = abs(node1.z-node2.z);
346  double three = std::min(xd, std::min(yd, zd));
347  xd -= three;
348  yd -= three;
349  zd -= three;
350  double two;
351  if (zd == 0)
352  {
353  two = std::min(xd, yd);
354  xd-=two;
355  yd-=two;
356  }
357  else if (xd == 0)
358  {
359  two = std::min(zd, yd);
360  zd-=two;
361  yd-=two;
362  }
363  else if (yd == 0)
364  {
365  two = std::min(xd, zd);
366  xd-=two;
367  zd-=two;
368  }
369  else {
370  assert(!"Should not be able to get here.");
371  }
372  return three*ROOT_THREE + two*ROOT_TWO + xd+yd+zd;
373 }
374 
375 double VoxelGrid::GCost(const voxelGridState &node1, const voxelGridState &node2) const
376 {
377  int diff = 0;
378  if (node1.x != node2.x)
379  diff++;
380  if (node1.y != node2.y)
381  diff++;
382  if (node1.z != node2.z)
383  diff++;
384  double v[4] = {0, 1, ROOT_TWO, ROOT_THREE};
385  return v[diff];
386 }
387 
388 double VoxelGrid::GCost(const voxelGridState &node, const voxelGridAction &act) const
389 {
390  assert(!"Action consts not implemented yet");
391  return 1;
392 }
393 
394 bool VoxelGrid::GoalTest(const voxelGridState &node, const voxelGridState &goal) const
395 {
396  return node == goal;
397 }
398 
399 
401 {
402  voxelGridState v;
403  do {
404  v.x = random()%xWidth;
405  v.y = random()%yWidth;
406  v.z = random()%zWidth;
407  } while (voxels[GetIndex(v)] == true);
408  return v;
409 }
410 
411 
413 {
414  return (uint64_t(node.x)<<32)|(uint64_t(node.y)<<16)|uint64_t(node.z);
415 }
416 
418 {
419  s.z = parent&0xFFFF;
420  s.y = (parent>>16)&0xFFFF;
421  s.x = (parent>>32)&0xFFFF;
422 }
423 
424 
426 {
427  return (int)act;
428 }
429 
431 {
432  const double range = std::max(xWidth, std::max(yWidth, zWidth));
433  p.x = 2.0*v.x/range-1.0+(-xWidth+range)/range + 1.0/range;
434  p.y = 2.0*v.y/range-1.0+(-yWidth+range)/range + 1.0/range;
435  p.z = 2.0*v.z/range-1.0+(-zWidth+range)/range + 1.0/range;
436 }
437 
439 {
440  const double range = std::max(xWidth, std::max(yWidth, zWidth));
441  p.x = 2.0*v.x/range-1.0+(-xWidth+range)/range;
442  p.y = 2.0*v.y/range-1.0+(-yWidth+range)/range;
443  p.z = 2.0*v.z/range-1.0+(-zWidth+range)/range;
444 }
445 
446 
448 {
449  printf("Building pre-computed draw buffers\n");
450  vertices.resize(0);
451  indices.resize(0);
452  std::vector<VoxelUtils::triangle> data;
453  VoxelUtils::GetTriangles(this, data);
454  std::unordered_map<VoxelUtils::vn, int> index;
455  int next = 0;
456  for (size_t x = 0; x < data.size(); x++)
457  {
458  for (int y = 0; y < 3; y++)
459  {
460  VoxelUtils::vn v = data[x].GetVN(y);
461  auto i = index.find(v);
462  if (i == index.end())
463  {
464  index[v] = next;
465  next++;
466 
467  point3d p;
468  GetGLCornerCoordinate({v.v[0], v.v[1], v.v[2]}, p);
469 
470  vertices.push_back(p.x);
471  vertices.push_back(p.y);
472  vertices.push_back(p.z);
473  vertices.push_back(v.normal[0]);
474  vertices.push_back(v.normal[1]);
475  vertices.push_back(v.normal[2]);
476  const double range = std::max(xWidth, std::max(yWidth, zWidth))*2;
477  if (v.normal[0])
478  {
479  vertices.push_back(1.0-2.0*v.v[0]/range);
480  vertices.push_back(0.0+2.0*v.v[1]/range);
481  vertices.push_back(0.5+v.v[2]/range);
482  }
483  else if (v.normal[1])
484  {
485  vertices.push_back(0.0+2.0*v.v[1]/range);
486  vertices.push_back(0.5+v.v[2]/range);
487  vertices.push_back(1.0-2.0*v.v[0]/range);
488  }
489  else {
490  vertices.push_back(0.5+v.v[2]/range);
491  vertices.push_back(1.0-2.0*v.v[0]/range);
492  vertices.push_back(0.0+2.0*v.v[1]/range);
493  }
494  }
495  }
496  }
497  printf("%d individual items\n", next);
498  // get list of surface triangles, normals, and colors
499  for (size_t x = 0; x < data.size(); x++)
500  {
501  for (int y = 0; y < 3; y++)
502  {
503  indices.push_back(index[data[x].GetVN(y)]);
504  }
505  }
506 }
507 
509 {
510 // glEnable(GL_NORMALIZE);
511  // enable and specify pointers to vertex arrays
512  glEnable(GL_LIGHTING);
513  glEnableClientState(GL_VERTEX_ARRAY);
514  glEnableClientState(GL_NORMAL_ARRAY);
515  glEnableClientState(GL_COLOR_ARRAY);
516  glVertexPointer(3, GL_FLOAT, 9 * sizeof(GLfloat), &vertices[0]);
517  glNormalPointer(GL_FLOAT, 9 * sizeof(GLfloat), &vertices[0] + 3);
518  glColorPointer(3, GL_FLOAT, 9 * sizeof(GLfloat), &vertices[0] + 6);
519 
520  glDrawElements(GL_TRIANGLES, indices.size(), GL_UNSIGNED_INT, &indices[0]);
521 
522  glDisableClientState(GL_VERTEX_ARRAY); // disable vertex arrays
523  glDisableClientState(GL_COLOR_ARRAY);
524  glDisableClientState(GL_NORMAL_ARRAY);
525  glDisable(GL_LIGHTING);
526 // glDisable(GL_NORMALIZE);
527 }
528 
530 {
531  if (efficient)
532  {
533  EfficientDraw();
534  }
535  else {
536  glEnable(GL_LIGHTING);
537  glColor3f(0.0, 1.0, 0.0);
538  const double range = std::max(xWidth, std::max(yWidth, zWidth));
539  for (uint16_t x = 0; x < xWidth; x++)
540  {
541  for (uint16_t y = 0; y < yWidth; y++)
542  {
543  for (uint16_t z = 0; z < zWidth; z++)
544  {
545  if (voxels[GetIndex(x, y, z)])
546  {
547  GLfloat rr, gg, bb;
548  rr = 1-(2.0*x/range-1.0+(-xWidth+range)/range);
549  gg = 1+(2.0*y/range-1.0+(-yWidth+range)/range);
550  bb = 1-(2.0*z/range-1.0+(-zWidth+range)/range);
551  // 7?
552  rr = Colors::GetColor(rr, 0, 2, 7).r;
553  gg = Colors::GetColor(bb, 0, 2, 9).g*0.9;
554  bb = Colors::GetColor(bb, 0, 2, 9).b;
555  glColor3f(gg, rr, bb);
556 
557  point3d p;
558  GetGLCoordinate({x, y, z}, p);
559  DrawBox(p.x, p.y, p.z, 1/range);
560  }
561  }
562  }
563  }
564  glDisable(GL_LIGHTING);
565  }
566 }
567 
569 {
570 
571 }
572 
573 void VoxelGrid::OpenGLDraw(const voxelGridState&, const voxelGridState&, float) const
574 {
575 
576 }
577 
579 {
580 
581 }
582 
583 void VoxelGrid::GLLabelState(const voxelGridState&, const char *) const
584 {
585 
586 }
587 
589 {
590  point3d p1, p2;
591  GetGLCoordinate(x, p1);
592  GetGLCoordinate(y, p2);
593  glBegin(GL_LINES);
594  glVertex3f(p1.x, p1.y, p1.z);
595  glVertex3f(p2.x, p2.y, p2.z);
596  glEnd();
597 }
598 
599 void VoxelGrid::Draw(Graphics::Display &display) const
600 {
601  const float range = std::max(xWidth, std::max(yWidth, zWidth));
602  uint16_t minz = zWidth;
603  uint16_t maxz = 0;
604  display.FillRect({-1, -1, 1, 1}, Colors::white);
605  for (uint16_t x = 0; x < xWidth; x++)
606  {
607  for (uint16_t y = 0; y < yWidth; y++)
608  {
609  for (uint16_t z = 0; z < zWidth; z++)
610  {
611  if (voxels[GetIndex(x, y, z)])
612  {
613  minz = std::min(minz, z);
614  maxz = std::max(maxz, z);
615  break;
616  }
617  }
618  }
619  }
620  if (minz == maxz)
621  {
622  maxz++;
623  minz--;
624  }
625  for (uint16_t x = 0; x < xWidth; x++)
626  {
627  for (uint16_t y = 0; y < yWidth; y++)
628  {
629  for (uint16_t z = 0; z < zWidth; z++)
630  {
631  if (voxels[GetIndex(x, y, z)])
632  {
633  rgbColor c = {0.0f, 0.0f, 0.0f};
634  c.b = 1.0f-(z-minz)/(float)(maxz-minz);
635  c.r = c.b/2.0f;
636  c.g = c.b/2.0f;
637 
638  point3d p;
639  GetGLCoordinate({x, y, z}, p);
640  Graphics::rect r(p.x-1.f/range, p.y-1.f/range, p.x+1.f/range, p.y+1.f/range); // 1% larger to cover rounding on borders
641  //printf("(%d, %d) -> (%f, %f)\n", x, y, p.x, p.y);
642  display.FillRect(r, c);
643  break;
644  }
645  }
646  }
647  }
648 }
649 
651 {
652  BitMapPic *b = new BitMapPic(xWidth, yWidth);
653  const float range = std::max(xWidth, std::max(yWidth, zWidth));
654  uint16_t minz = zWidth;
655  uint16_t maxz = 0;
656  for (uint16_t x = 0; x < xWidth; x++)
657  {
658  for (uint16_t y = 0; y < yWidth; y++)
659  {
660  for (uint16_t z = 0; z < zWidth; z++)
661  {
662  if (voxels[GetIndex(x, y, z)])
663  {
664  minz = std::min(minz, z);
665  maxz = std::max(maxz, z);
666  break;
667  }
668  }
669  }
670  }
671  if (minz == maxz)
672  {
673  maxz++;
674  minz--;
675  }
676  for (uint16_t x = 0; x < xWidth; x++)
677  {
678  for (uint16_t y = 0; y < yWidth; y++)
679  {
680  b->SetPixel(x, yWidth-y-1, 255, 255, 255);
681  for (uint16_t z = 0; z < zWidth; z++)
682  {
683  if (voxels[GetIndex(x, y, z)])
684  {
685  rgbColor c = {0.0f, 0.0f, 0.0f};
686  c.b = 1.0f-(z-minz)/(float)(maxz-minz);
687  c.r = c.b/2.0f;
688  c.g = c.b/2.0f;
689 
690 // point3d p;
691 // GetGLCoordinate({x, y, z}, p);
692  //Graphics::rect r(p.x-1.f/range, p.y-1.f/range, p.x+1.f/range, p.y+1.f/range); // 1% larger to cover rounding on borders
693  //printf("(%d, %d) -> (%f, %f)\n", x, y, p.x, p.y);
694  b->SetPixel(x, yWidth-y-1, 255*c.r, 255*c.g, 255*c.b);
695  //display.FillRect(r, c);
696  break;
697  }
698  }
699  }
700  }
701  return b;
702 }
Colors::GetColor
rgbColor GetColor(float v, float vmin, float vmax, int type)
Given min/max values, get a color from a color schema.
Definition: Colors.cpp:24
VoxelGrid::MakeAction
voxelGridAction MakeAction(int &x, int &y, int &z) const
Definition: VoxelGrid.cpp:267
voxelGridState::z
uint16_t z
Definition: VoxelGrid.h:20
BitMapPic
Definition: BitMap.h:46
VoxelGrid::GLLabelState
void GLLabelState(const voxelGridState &, const char *) const
Definition: VoxelGrid.cpp:583
rgbColor::b
float b
Definition: Colors.h:71
rgbColor
A color; r/g/b are between 0...1.
Definition: Colors.h:17
VoxelGrid::GetImage
BitMapPic * GetImage(int face)
Definition: VoxelGrid.cpp:650
VoxelGrid::GetActionOffsets
void GetActionOffsets(voxelGridAction a, int &x, int &y, int &z) const
Definition: VoxelGrid.cpp:257
VoxelGrid::SetBlocked
void SetBlocked(const voxelGridState &s, bool block)
Definition: VoxelGrid.cpp:176
VoxelGrid::Draw
void Draw(Graphics::Display &display) const
Definition: VoxelGrid.cpp:599
operator==
bool operator==(const voxelGridState &v1, const voxelGridState &v2)
Definition: VoxelGrid.cpp:16
min
double min(double a, double b)
Definition: FPUtil.h:35
VoxelGrid::Fill
void Fill(voxelGridState)
Definition: VoxelGrid.cpp:225
voxelGridAction
uint8_t voxelGridAction
Definition: VoxelGrid.h:39
VoxelGrid::~VoxelGrid
~VoxelGrid()
Definition: VoxelGrid.cpp:63
VoxelUtils::vn::v
uint16_t v[3]
Definition: VoxelTriangleExtraction.h:20
VoxelGrid::GetActions
void GetActions(const voxelGridState &nodeID, std::vector< voxelGridAction > &actions) const
Definition: VoxelGrid.cpp:301
VoxelGrid::GetStateFromHash
void GetStateFromHash(uint64_t parent, voxelGridState &s)
Definition: VoxelGrid.cpp:417
VoxelGrid::And
void And(VoxelGrid *g)
Definition: VoxelGrid.cpp:68
Graphics::rect
Definition: Graphics.h:94
operator<<
std::ostream & operator<<(std::ostream &out, const voxelGridState &v)
Definition: VoxelGrid.cpp:21
VoxelGrid::GetGLCornerCoordinate
void GetGLCornerCoordinate(const voxelGridState &, point3d &) const
Definition: VoxelGrid.cpp:438
VoxelGrid::Or
void Or(VoxelGrid *g)
Definition: VoxelGrid.cpp:82
VoxelGrid::SetUpDrawBuffers
void SetUpDrawBuffers()
Definition: VoxelGrid.cpp:447
rgbColor::g
float g
Definition: Colors.h:71
VoxelGrid::GLDrawLine
void GLDrawLine(const voxelGridState &x, const voxelGridState &y) const
Definition: VoxelGrid.cpp:588
VoxelUtils::vn::normal
uint16_t normal[3]
Definition: VoxelTriangleExtraction.h:19
VoxelGrid::Legal
bool Legal(const voxelGridState &s) const
Definition: VoxelGrid.cpp:208
VoxelGrid::Save
void Save(const char *filename)
Definition: VoxelGrid.cpp:97
VoxelGrid
Definition: VoxelGrid.h:41
VoxelGrid::ApplyAction
void ApplyAction(voxelGridState &s, voxelGridAction a) const
Definition: VoxelGrid.cpp:325
voxelGridState::y
uint16_t y
Definition: VoxelGrid.h:20
VoxelGrid::GoalTest
bool GoalTest(const voxelGridState &node, const voxelGridState &goal) const
Definition: VoxelGrid.cpp:394
point3d
#define point3d
Definition: GLUtil.h:123
VoxelGrid::zWidth
int zWidth
Definition: VoxelGrid.h:108
VoxelGrid::GetSuccessors
void GetSuccessors(const voxelGridState &nodeID, std::vector< voxelGridState > &neighbors) const
Definition: VoxelGrid.cpp:277
Graphics::Display
Definition: Graphics.h:146
VoxelGrid::GCost
double GCost(const voxelGridState &node1, const voxelGridState &node2) const
Definition: VoxelGrid.cpp:375
ROOT_TWO
static const double ROOT_TWO
Definition: GLUtil.h:61
VoxelUtils::vn
Definition: VoxelTriangleExtraction.h:18
VoxelGrid::CanMove
bool CanMove(const voxelGridState &s1, const voxelGridState &s2) const
Definition: VoxelGrid.cpp:213
BitMapPic::SetPixel
void SetPixel(int x, int y, uint8_t redByte, uint8_t greenByte, uint8_t blueByte, uint8_t alphaByte=0)
Definition: BitMap.cpp:193
max
#define max(a, b)
Definition: MinimalSectorAbstraction.cpp:40
VoxelGrid::GetGLCoordinate
void GetGLCoordinate(const voxelGridState &, point3d &) const
Definition: VoxelGrid.cpp:430
rgbColor::r
float r
Definition: Colors.h:71
VoxelGrid::EfficientDraw
void EfficientDraw() const
Definition: VoxelGrid.cpp:508
VoxelGrid::IsBlocked
bool IsBlocked(const voxelGridState &s) const
Definition: VoxelGrid.cpp:169
DrawBox
void DrawBox(GLfloat xx, GLfloat yy, GLfloat zz, GLfloat rad)
Definition: GLUtil.cpp:285
VoxelGrid::OpenGLDraw
void OpenGLDraw() const
Definition: VoxelGrid.cpp:529
VoxelTriangleExtraction.h
VoxelGrid.h
VoxelGrid::GetStateHash
uint64_t GetStateHash(const voxelGridState &node) const
Definition: VoxelGrid.cpp:412
VoxelGrid::GetActionHash
uint64_t GetActionHash(voxelGridAction act) const
Definition: VoxelGrid.cpp:425
VoxelGrid::indices
std::vector< uint32_t > indices
Definition: VoxelGrid.h:110
ROOT_THREE
static const double ROOT_THREE
Definition: GLUtil.h:63
VoxelGrid::efficient
bool efficient
Definition: VoxelGrid.h:97
Colors::white
const rgbColor white
Definition: Colors.h:120
voxelGridState::x
uint16_t x
Definition: VoxelGrid.h:20
VoxelGrid::VoxelGrid
VoxelGrid(int x, int y, int z)
Definition: VoxelGrid.cpp:28
VoxelUtils::GetTriangles
void GetTriangles(VoxelGrid *s, std::vector< triangle > &data)
Definition: VoxelTriangleExtraction.cpp:73
VoxelGrid::voxels
std::vector< bool > voxels
Definition: VoxelGrid.h:107
voxelGridState
Definition: VoxelGrid.h:16
VoxelGrid::GetRandomState
voxelGridState GetRandomState()
Definition: VoxelGrid.cpp:400
VoxelGrid::GetIndex
int GetIndex(const voxelGridState &s) const
Definition: VoxelGrid.cpp:182
Graphics::Display::FillRect
void FillRect(rect r, rgbColor c)
Definition: Graphics.cpp:101
VoxelGrid::vertices
std::vector< GLfloat > vertices
Definition: VoxelGrid.h:109
VoxelGrid::InvertAction
bool InvertAction(voxelGridAction &a) const
Definition: VoxelGrid.cpp:334
VoxelGrid::GetCoordinates
void GetCoordinates(int index, int &x, int &y, int &z) const
Definition: VoxelGrid.cpp:200
VoxelGrid::yWidth
int yWidth
Definition: VoxelGrid.h:108
VoxelGrid::xWidth
int xWidth
Definition: VoxelGrid.h:108
VoxelGrid::SaveInMinBB
void SaveInMinBB(const char *filename)
Definition: VoxelGrid.cpp:120
VoxelGrid::Invert
void Invert()
Definition: VoxelGrid.cpp:248
node
Nodes to be stored within a Graph.
Definition: Graph.h:170
VoxelGrid::HCost
double HCost(const voxelGridState &node1, const voxelGridState &node2) const
Heuristic value between two arbitrary nodes.
Definition: VoxelGrid.cpp:341