Atoms Crowd  7.0.0
BoxEdge.h
1 /*
2 Copyright (c) 2010 University of Illinois
3 All rights reserved.
4 
5 Developed by: DeNovo group, Graphis@Illinois
6 University of Illinois
7 http://denovo.cs.illinois.edu
8 http://graphics.cs.illinois.edu
9 
10 Permission is hereby granted, free of charge, to any person obtaining a
11 copy of this software and associated documentation files (the
12 "Software"), to deal with the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17 
18 * Redistributions of source code must retain the above copyright
19 notice, this list of conditions and the following disclaimers.
20 
21 * Redistributions in binary form must reproduce the above
22 copyright notice, this list of conditions and the following disclaimers
23 in the documentation and/or other materials provided with the
24 distribution.
25 
26 * Neither the names of DeNovo group, Graphics@Illinois,
27 University of Illinois, nor the names of its contributors may be used to
28 endorse or promote products derived from this Software without specific
29 prior written permission.
30 
31 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34 IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR
35 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37 SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
38 */
39 
40 #pragma once
41 
42 #include <iostream>
43 namespace AtomsUtils
44 {
45  class BoxEdge
46  {
47  public:
48  BoxEdge() {}
49 
50  BoxEdge(float f, unsigned int t, bool edgeType, char axis) :
51  t(f), triangleIndex(t), edgeType(edgeType), axis(axis) {}
52 
53  bool operator<(const BoxEdge &RHS) const
54  {
55  if (this->t == RHS.t)
56  {
57  if (this->triangleIndex != RHS.triangleIndex)
58  {
59  return this->triangleIndex < RHS.triangleIndex;
60  }
61  else // at this point we have two edges with equal t and index
62  {
63  // resolve by comparing edge type
64  return (int)(this->edgeType) < (int)(RHS.edgeType);
65  }
66  }
67  else
68  {
69  return this->t < RHS.t;
70  }
71  }
72 
73  public:
74 
75  float t;
76 
77  unsigned int triangleIndex;
78 
79  bool edgeType;
80 
81  char axis;
82  };
83 }
84 
85 namespace std {
86  template<>
87  class less<AtomsUtils::BoxEdge>
88  {
89  public:
90  bool operator()(const AtomsUtils::BoxEdge& x, const AtomsUtils::BoxEdge& y) const
91  {
92  if (x.t == y.t)
93  {
94  if (x.triangleIndex != y.triangleIndex)
95  {
96  return x.triangleIndex < y.triangleIndex;
97  }
98  else
99  {
100  return (int)x.edgeType < (int)y.edgeType;
101  }
102  }
103  else
104  {
105  return x.t < y.t;
106  }
107  }
108 
109  bool operator()(const AtomsUtils::BoxEdge* x, const AtomsUtils::BoxEdge* y) const
110  {
111  if (x->t == y->t)
112  {
113  if (x->triangleIndex != y->triangleIndex)
114  {
115  return x->triangleIndex < y->triangleIndex;
116  }
117  else
118  {
119  return (int)x->edgeType < (int)y->edgeType;
120  }
121  }
122  else
123  {
124  return x->t < y->t;
125  }
126  }
127  };
128 }
129 
Definition: BoxEdge.h:46
AtomsCore namespace.
Definition: Base64.h:13