Free Electron
s_hull.h
1 #ifndef _structures_h
2 #define _structures_h
3 
4 
5 
6 
7 // for FILE
8 
9 #include <stdlib.h>
10 #include <vector>
11 #include <set>
12 
13 
14 
15 /*
16  for use in s_hull.C
17 
18 S-hull, Copyright (c) 2010
19 Dr David SInclair
20 Cambridge, UK
21 
22 email david@s-hull.org
23 
24 The software includes the S-hull programs.
25 S-hull is copyrighted as above.
26 S-hull is free software and may be obtained from www.s-hull.org.
27 It may be freely copied, modified,
28 and redistributed under the following conditions:
29 
30 S-hull is free software and may be obtained from www.s-hull.org.
31 It may be freely copied, modified,
32 and redistributed under the following conditions which might loosely be termed a contribtors beerware license:
33 1. All copyright notices must remain intact in all files.
34 2. A copy of this text file must be distributed along with any copies
35  of S-hull that you redistribute; this includes copies that you have
36  modified, or copies of programs or other software products that
37  include S-hull where distributed as source.
38 
39 3. If you modify S-hull, you must include a notice giving the
40  name of the person performing the modification, the date of
41  modification, and the reason for such modification.
42 
43 4. If you are distributing a binary or compiled version of s-hull it
44  is not necessary to include any acknowledgement or reference
45  to s-hull.
46 5. There is no warranty or other guarantee of fitness for S-hull, it is
47  provided solely "as is". Bug reports or fixes may be sent to
48  bugs@s-hull.org; the authors may or may not act on them as
49  they desire.
50 6. By copying or compliing the code for S-hull you explicitly indemnify
51 the copyright holder against any liability he may incur as a result of you
52 copying the code.
53 
54 7. If you meet any of the contributors to the code you used from s-hull.org
55  in a pub or a bar, and you think the source code they contributed to is worth it,
56  you can buy them a beer.
57 
58  If your principles run against beer a bacon-double-cheeseburger would do just as nicely
59  or you could email david@s-hull.org and arrange to make a donation of 10 of your local currancy units
60  to support s-hull.org.
61 
62 
63 */
64 
65 struct Triad
66 {
67  int a,b, c;
68  int ab, bc, ac; // adjacent edges index to neighbouring triangle.
69  float ro, R,C;
70  //std::set<int> idx;
71  Triad() {};
72 Triad(int x, int y) : a(x), b(y),c(0), ab(-1), bc(-1), ac(-1), ro(-1), R(0), C(0) {};
73 Triad(int x, int y, int z) : a(x), b(y), c(z), ab(-1), bc(-1), ac(-1), ro(-1), R(0), C(0) {};
74 Triad(const Triad &p) : a(p.a), b(p.b), c(p.c), ab(p.ab), bc(p.bc), ac(p.ac), ro(p.ro), R(p.R), C(p.C) {};
75 
76  Triad &operator=(const Triad &p)
77  {
78  a = p.a;
79  b = p.b;
80  c = p.c;
81 
82  ab = p.ab;
83  bc = p.bc;
84  ac = p.ac;
85 
86  ro = p.ro;
87  R = p.R;
88  C = p.C;
89 
90  return *this;
91  };
92  void prnt(){
93  cerr << a << " " << b << " " << c << " " << ab << " " << ac << " " << bc << endl;
94  };
95 };
96 
97 
98 
99 /* point structure for s_hull only.
100  has to keep track of triangle ids as hull evolves.
101 
102 
103 */
104 
105 
106 struct Shx
107 {
108  int id, trid;
109  float r,c , tr, tc;
110  float ro;
111  Shx() {};
112  Shx(int a, int b) : r(a), c(b), ro(0), id(-1) {};
113  Shx(int a, int b, float x) : r(a), c(b), ro(x), id(-1) {};
114  Shx(const Shx &p) : id(p.id), trid(p.trid), r(p.r), c(p.c), tr(p.tr), tc(p.tc), ro(p.ro) {};
115 
116  Shx &operator=(const Shx &p)
117  {
118  id = p.id;
119  trid = p.trid;
120  r = p.r;
121  c = p.c;
122  tr = p.tr;
123  tc = p.tc;
124  ro = p.ro;
125  return *this;
126  };
127 
128 };
129 
130 //inline bool operator==(const Shx &a, const Shx &b)
131 //{
132 // return a.r == b.r && a.c == b.c;
133 //};
134 
135 // sort into descending order (for use in corner responce ranking).
136 inline bool operator<(const Shx &a, const Shx &b)
137 {
138  if( a.ro == b.ro)
139  return a.r < b.r;
140  return a.ro < b.ro;
141 };
142 
143 
144 
145 // from s_hull.C
146 
147 
148 void s_hull_del_ray2( std::vector<Shx> &pts, std::vector<Triad> &triads);
149 void circle_cent2(float r1,float c1, float r2,float c2, float r3,float c3,float &r,float &c, float &ro2);
150 void circle_cent4(float r1,float c1, float r2,float c2, float r3,float c3,float &r,float &c, float &ro2);
151 void write_Shx(std::vector<Shx> &pts, char * fname);
152 void write_Triads(std::vector<Triad> &ts, char * fname);
153 void T_flip2( std::vector<Shx> &pts, std::vector<Triad> &triads, int *slump, int numt, int start);
154 void T_flip3( std::vector<Shx> &pts, std::vector<Triad> &triads, int *slump, int numt, int start,std::set<int> &ids );
155 void T_flip4( std::vector<Shx> &pts, std::vector<Triad> &triads, int *slump, std::set<int> &ids);
156 
157 
158 
159 #endif
void T_flip4(std::vector< Shx > &pts, std::vector< Triad > &triads, int *slump, std::set< int > &ids)
Definition: PointConnect.cc:1159