Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HDS_overlay.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: HDS_overlay.h,v 1.10 2008/12/06 08:43:27 mtcampbe Exp $
24 
25 //==============================================
26 // This file contains definition of the halfedge data structure for
27 // the overlay algorithm.
28 //
29 // Author: Xiangmin Jiao
30 // Optimized: Apr. 4, 2002
31 //==============================================
32 
33 #ifndef HDS_OVERLAY_H
34 #define HDS_OVERLAY_H
35 
36 #include "rfc_basic.h"
37 #include "In_place_list_n.h"
38 #include <iterator>
39 
41 
42 class Vertex_overlay;
43 class Facet_overlay;
44 class Halfedge_overlay;
45 class RFC_Pane_overlay;
46 
48  // defines the maximal vertex functionality including halfedge pointer
49  // and a template parameter for the point.
50 protected:
53 
54 public:
58  typedef Point_3 Point;
59 
60  Vertex_overlay() : hdg(NULL), pn(NULL) {}
61  explicit Vertex_overlay( const Point&) : hdg(NULL), pn(NULL) {}
63 
64  // Use default copy constructor and copy assignment operator.
65  // Vertex_overlay( const Vertex_overlay &v) hdg(v.hdg), pn(v.pn) {}
66  // Self &operator=( const Self &v)
67  // { hdg = v.hdg; pn = v.pn; return *this; }
68 
69  RFC_Pane_overlay *pane() { return pn; }
70  const RFC_Pane_overlay *pane() const { return pn; }
71  void set_pane( RFC_Pane_overlay *p) { pn = p; }
72 
74  const Halfedge_overlay* halfedge() const { return hdg;}
75  void set_halfedge( Halfedge_overlay* h) { hdg = h;}
76 
77  const Point& point() const;
78 };
79 
80 // type declaration for Halfedge_overlay
82 public:
86 
90 
91 protected:
93  char *prv;
96 
97 public:
98  Halfedge_overlay() : nxt(NULL), prv(NULL), f(NULL), v(NULL) {}
99 
100  // Use default copy constructor and copy assignment operator.
101  // Halfedge_overlay( const Halfedge_overlay &h)
102  // : nxt(h.nxt), prv(h.prv), f(h.f), v(f.v) {}
103  // Self &operator=( const Self &h)
104  // { nxt=h.nxt; prv(h.prv), f = h.f; v=h.v; return *this; }
105 
106  Vertex_overlay* vertex() { return v;}
107  const Vertex_overlay* vertex() const { return v;}
108  // the incident vertex.
109 
111  { if ( h>this) set_primary(); else unset_primary(); }
112  void set_next( Halfedge_overlay* h) { nxt = h; }
114  { prv = ((char*)h)+is_primary(); RFC_assertion( prev()==h); }
115  void set_vertex( Vertex_overlay* _v) { v = _v;}
116  void set_facet( Facet_overlay* _f) { f = _f; }
117 
118  Halfedge_overlay* opposite() { return is_primary() ? this+1 : this-1; }
119  const Halfedge_overlay* opposite() const { return is_primary() ? this+1 : this-1; }
120  Halfedge_overlay* next() { return nxt;}
121  const Halfedge_overlay* next() const { return nxt;}
122 
124  { return (Halfedge_overlay*)(prv-is_primary()); }
125  const Halfedge_overlay* prev() const
126  { return (Halfedge_overlay*)(prv-is_primary()); }
127 
128  // the facet to the left.
129  Facet_overlay* facet() { return f; }
130  const Facet_overlay* facet() const { return f;}
131  bool is_border() const { return f==0; }
132 
133  //====== The following functions are added for the overlay algorithm
134  // the origin of the halfedge
135  Vertex_overlay* origin() { return opposite()->vertex(); }
136  const Vertex_overlay* origin() const { return opposite()->vertex(); }
138  const Vertex_overlay* destination() const { return vertex(); }
139 private:
140  bool is_primary() const { return (prv-(char*)0)&1; }
141  void set_primary() { if ( !is_primary()) prv+=1; }
142  void unset_primary() { if ( is_primary()) prv-=1; }
143 };
144 
146 protected:
148 public:
153  typedef void* Plane;
154  typedef void* Normal;
155 
156  Facet_overlay() : hdg(0) {}
158 
159  // Use default copy constructor and copy assignment operator.
160  // Facet_overlay( const Facet_overlay &f) : hdg(f.hdg) {}
161  // This &operator=(const This &f) { hdg = f.hdg; return *this; }
162 
164  const Halfedge_overlay* halfedge() const { return hdg;}
166 };
167 
169 
170 #include <CGAL/Halfedge_data_structure_using_vector.h>
171 
173 
174 // HDS_overlay inherits the implementation of
175 // CGAL::Halfedge_data_structure_using_vector and overwrites
176 // the methods new_vertex, and normalize_border.
177 // Note that this class is neither copy-constructible nor assignable.
178 class HDS_overlay : private CGAL::Halfedge_data_structure_using_vector
179 < Vertex_overlay, Halfedge_overlay, Facet_overlay> {
180 public:
181  typedef HDS_overlay This;
182  typedef CGAL::Halfedge_data_structure_using_vector< Vertex_overlay,
184 
185  // Inherit the following from CGAL::Halfedge_data_structure_using_vector.
186  using Base::Vertex;
187  using Base::Halfedge;
188  using Base::Facet;
189  using Base::Difference;
190  using Base::Size;
191  using Base::Point;
192 
193  using Base::Supports_halfedge_facet;
194  using Base::Supports_vertex_halfedge;
195  using Base::Supports_halfedge_prev;
196  using Base::Supports_halfedge_vertex;
197  using Base::Supports_facet_halfedge;
198  using Base::Supports_vertex_point;
199  using Base::Supports_facet_plane;
200  using Base::Supports_facet_normal;
201  using Base::Supports_removal;
202 
203  using Base::iterator_category;
204  using Base::Vertex_iterator;
205  using Base::Halfedge_iterator;
206  using Base::Facet_iterator;
207 
208  using Base::Vertex_const_iterator;
209  using Base::Halfedge_const_iterator;
210  using Base::Facet_const_iterator;
211 
212  using Base::reserve;
213  using Base::size_of_vertices;
214  using Base::size_of_halfedges;
215  using Base::size_of_facets;
216  using Base::capacity_of_vertices;
217  using Base::capacity_of_halfedges;
218  using Base::capacity_of_facets;
219  using Base::bytes;
220  using Base::bytes_reserved;
221  using Base::vertices_begin;
222  using Base::vertices_end;
223  using Base::halfedges_begin;
224  using Base::halfedges_end;
225  using Base::facets_begin;
226  using Base::facets_end;
227 
228  using Base::new_edge;
229  using Base::new_facet;
230  using Base::delete_all;
231  using Base::vertex_pop_back;
232  using Base::edge_pop_back;
233  using Base::facet_pop_back;
234 
235  using Base::size_of_border_halfedges;
236  using Base::size_of_border_edges;
237  using Base::border_halfedges_begin;
238 
239  // Constructors
240  explicit HDS_overlay( RFC_Pane_overlay *p) : pn(p) {}
242  : Base( hds), pn(p) {
243  for ( Vertex_iterator it=vertices_begin(); it!=vertices_end(); ++it)
244  it->set_pane( p);
245  }
246 
247  // We need no destructor because memory is not dynamically allocated.
248 
249  RFC_Pane_overlay *pane() { return pn; }
250  const RFC_Pane_overlay *pane() const { return pn; }
251 
252  // Perform the standard normalization and also
253  // make every border vertex point to its incident border halfedge.
255 
256  // Insertion
257 //
258 // The following operations overwrites the ones in
259 // CGAL::Halfedge_data_structure_using_vector to initialize the hds fields
260 // in Vertex_overlay, Halfedge_overlay and Facet_overlay.
261  Vertex* new_vertex() {
262  RFC_assertion( vertices.size() < vertices.capacity());
263  vertices.push_back( Vertex()); vertices.back().set_pane(pn);
264  return & (vertices.back());
265  }
266 
267  Vertex* new_vertex( const Vertex* v) {
268  RFC_assertion( vertices.size() < vertices.capacity());
269  vertices.push_back( *v); vertices.back().set_pane(pn);
270  return & (vertices.back());
271  }
272 
273  Vertex* new_vertex( const Point& p) {
274  RFC_assertion( vertices.size() < vertices.capacity());
275  vertices.push_back( Vertex( p)); vertices.back().set_pane(pn);
276  return & (vertices.back());
277  }
278 
279 
280 protected:
282 
283 private:
284  // Explicitly disable the following functions.
285  HDS_overlay();
286  HDS_overlay( const HDS_overlay&);
287  This &operator=( const HDS_overlay&);
288 };
289 
290 struct Host_face {
291  Host_face() : _p(0) {};
293  : _p( (char*)(h) + (int(t)&3))
294  { RFC_assertion( h==halfedge() && t==parent_type()); }
296  { return (Halfedge_overlay*)(_p-parent_type()); }
298  { return Parent_type(std::distance((char*)NULL,_p)&3); }
299  bool operator==( const Host_face &h) const { return _p==h._p; }
300  bool operator!=( const Host_face &h) const { return _p!=h._p; }
301 private:
302  char *_p;
303 };
304 
305 class INode : private In_place_list_n_base<INode,2> {
306 public:
307  typedef INode Self;
310 
311  using Base::next_link;
312  using Base::prev_link;
313 protected:
314  Host_face bp; // Blue parent object
315  Host_face gp; // Green parent object
316  Point_2S b_nc; // The natrual coordinate in the original blue mesh
317  Point_2S g_nc; // The natrual coordinate in the original green mesh
318  int _id;
319 
320 public:
321  INode() : _id(-1) {}
323 
324  bool operator==( const INode &x)
325  { return ( b_nc == x.b_nc && g_nc == x.g_nc && bp == x.bp && gp == x.gp); }
326 
327  const Point_2S &nat_coor( const int color) const {
328  if ( color == BLUE) return b_nc;
329  else { RFC_assertion(color == GREEN); return g_nc; }
330  }
331 
332  void nat_coor( const int color, Point_2 &p) const {
333  if ( color == BLUE) { p[0]=b_nc[0]; p[1]=b_nc[1]; }
334  else { RFC_assertion(color == GREEN); p[0]=g_nc[0]; p[1]=g_nc[1]; }
335  }
336 
337  void set_parent( Halfedge* h, const Point_2& p, int color) {
338  if ( color == BLUE) {
339  bp = Host_face( h, pt(p)); b_nc[0]=p[0]; b_nc[1]=p[1];
340  }
341  else {
342  RFC_assertion( color == GREEN);
343  gp = Host_face( h, pt(p)); g_nc[0]=p[0]; g_nc[1]=p[1];
344  }
345  }
346 
347  int id() const { return _id; }
348  void set_id( int i) { _id = i; }
349 
350  Parent_type parent_type( const int color) const {
351  if ( color == BLUE) { return bp.parent_type(); }
352  else { RFC_assertion( color == GREEN); return gp.parent_type(); }
353  }
356 
357  Halfedge *halfedge( const int color) const {
358  if ( color == BLUE) { return bp.halfedge(); }
359  else { RFC_assertion( color == GREEN); return gp.halfedge(); }
360  }
361  Halfedge* blue_halfedge() const { return bp.halfedge(); }
362  Halfedge* green_halfedge() const { return gp.halfedge(); }
363 
364 private:
365  Parent_type pt( const Point_2 &p) {
366  if ( p[1] != 0) return PARENT_FACE;
367  else if ( p[0] != 0) return PARENT_EDGE;
368  else return PARENT_VERTEX;
369  }
370 };
371 
373 
374 #endif
375 
376 
377 
378 
379 
380 
bool operator==(const INode &x)
Definition: HDS_overlay.h:324
Parent_type parent_type(const int color) const
Definition: HDS_overlay.h:350
char * _p
Definition: HDS_overlay.h:302
bool operator!=(const Host_face &h) const
Definition: HDS_overlay.h:300
HDS_overlay This
Definition: HDS_overlay.h:181
Halfedge_overlay * halfedge()
Definition: HDS_overlay.h:73
Halfedge_overlay * nxt
Definition: HDS_overlay.h:92
RFC_Pane_overlay * pane()
Definition: HDS_overlay.h:69
void set_halfedge(Halfedge_overlay *h)
Definition: HDS_overlay.h:75
Tag_true Supports_vertex_point
Definition: HDS_overlay.h:56
Halfedge_overlay * halfedge() const
Definition: HDS_overlay.h:295
bool is_primary() const
Definition: HDS_overlay.h:140
int id() const
Definition: HDS_overlay.h:347
void set_facet(Facet_overlay *_f)
Definition: HDS_overlay.h:116
Tag_true Supports_vertex_halfedge
Definition: HDS_overlay.h:57
CGAL::Halfedge_data_structure_using_vector< Vertex_overlay, Halfedge_overlay, Facet_overlay > Base
Definition: HDS_overlay.h:183
Halfedge_overlay * hdg
Definition: HDS_overlay.h:147
Vertex_overlay * destination()
Definition: HDS_overlay.h:137
Vertex * new_vertex(const Vertex *v)
Definition: HDS_overlay.h:267
const Halfedge_overlay * prev() const
Definition: HDS_overlay.h:125
Point_2S g_nc
Definition: HDS_overlay.h:317
SURF::Point_2< float > Point_2S
Definition: rfc_basic.h:45
Halfedge_overlay * opposite()
Definition: HDS_overlay.h:118
Vertex * new_vertex(const Point &p)
Definition: HDS_overlay.h:273
This & operator=(const HDS_overlay &)
RFC_Pane_overlay * pane()
Definition: HDS_overlay.h:249
RFC_Pane_overlay * pn
Definition: HDS_overlay.h:281
Halfedge_overlay * halfedge()
Definition: HDS_overlay.h:163
bool is_border() const
Definition: HDS_overlay.h:131
const Color GREEN
Definition: Color.C:59
Parent_type blue_parent_type() const
Definition: HDS_overlay.h:354
Facet_overlay Facet
Definition: HDS_overlay.h:85
Tag_false Supports_facet_normal
Definition: HDS_overlay.h:151
Parent_type parent_type() const
Definition: HDS_overlay.h:297
Vertex_overlay * origin()
Definition: HDS_overlay.h:135
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Tag_true Supports_halfedge_prev
Definition: HDS_overlay.h:87
HDS_overlay(RFC_Pane_overlay *p, const HDS_overlay &hds)
Definition: HDS_overlay.h:241
Vertex_overlay Self
Definition: HDS_overlay.h:55
#define RFC_END_NAME_SPACE
Definition: rfc_basic.h:29
Halfedge * blue_halfedge() const
Definition: HDS_overlay.h:361
void set_next(Halfedge_overlay *h)
Definition: HDS_overlay.h:112
Parent_type
Definition: rfc_basic.h:49
const Point & point() const
Halfedge_overlay * prev()
Definition: HDS_overlay.h:123
const Point_2S & nat_coor(const int color) const
Definition: HDS_overlay.h:327
Host_face(Halfedge_overlay *h, Parent_type t)
Definition: HDS_overlay.h:292
Vertex_overlay * vertex()
Definition: HDS_overlay.h:106
void set_pane(RFC_Pane_overlay *p)
Definition: HDS_overlay.h:71
const Facet_overlay * facet() const
Definition: HDS_overlay.h:130
Host_face bp
Definition: HDS_overlay.h:314
void set_halfedge(Halfedge_overlay *h)
Definition: HDS_overlay.h:165
const Halfedge_overlay * next() const
Definition: HDS_overlay.h:121
const Halfedge_overlay * halfedge() const
Definition: HDS_overlay.h:74
Halfedge * green_halfedge() const
Definition: HDS_overlay.h:362
bool operator==(const Host_face &h) const
Definition: HDS_overlay.h:299
void set_vertex(Vertex_overlay *_v)
Definition: HDS_overlay.h:115
blockLoc i
Definition: read.cpp:79
#define RFC_BEGIN_NAME_SPACE
Definition: rfc_basic.h:28
void int int REAL * x
Definition: read.cpp:74
const RFC_Pane_overlay * pane() const
Definition: HDS_overlay.h:70
Parent_type pt(const Point_2 &p)
Definition: HDS_overlay.h:365
void nat_coor(const int color, Point_2 &p) const
Definition: HDS_overlay.h:332
Halfedge_overlay Self
Definition: HDS_overlay.h:83
INode Self
Definition: HDS_overlay.h:307
const Color BLUE
Definition: Color.C:62
void set_id(int i)
Definition: HDS_overlay.h:348
const Vertex_overlay * origin() const
Definition: HDS_overlay.h:136
Halfedge * halfedge(const int color) const
Definition: HDS_overlay.h:357
Vertex * new_vertex()
Definition: HDS_overlay.h:261
Tag_true Supports_halfedge_facet
Definition: HDS_overlay.h:89
void normalize_border_vertices()
Halfedge_overlay * next()
Definition: HDS_overlay.h:120
Point_2S b_nc
Definition: HDS_overlay.h:316
RFC_Pane_overlay * pn
Definition: HDS_overlay.h:52
#define RFC_assertion_code
Definition: rfc_basic.h:68
Tag_true Supports_halfedge_vertex
Definition: HDS_overlay.h:88
~INode()
Definition: HDS_overlay.h:322
Tag_true Supports_facet_halfedge
Definition: HDS_overlay.h:152
void set_prev(Halfedge_overlay *h)
Definition: HDS_overlay.h:113
Parent_type green_parent_type() const
Definition: HDS_overlay.h:355
Vertex_overlay(const Point &)
Definition: HDS_overlay.h:61
const Halfedge_overlay * halfedge() const
Definition: HDS_overlay.h:164
Facet_overlay This
Definition: HDS_overlay.h:149
Vertex_overlay * v
Definition: HDS_overlay.h:95
Point_3 Point
Definition: HDS_overlay.h:58
void set_opposite(Halfedge_overlay *h)
Definition: HDS_overlay.h:110
In_place_list_n_base< INode, 2 > Base
Definition: HDS_overlay.h:309
Host_face gp
Definition: HDS_overlay.h:315
const RFC_Pane_overlay * pane() const
Definition: HDS_overlay.h:250
Facet_overlay * f
Definition: HDS_overlay.h:94
HDS_overlay(RFC_Pane_overlay *p)
Definition: HDS_overlay.h:240
void unset_primary()
Definition: HDS_overlay.h:142
const Halfedge_overlay * opposite() const
Definition: HDS_overlay.h:119
Halfedge_overlay * hdg
Definition: HDS_overlay.h:51
void set_parent(Halfedge *h, const Point_2 &p, int color)
Definition: HDS_overlay.h:337
Tag_false Supports_facet_plane
Definition: HDS_overlay.h:150
#define RFC_assertion
Definition: rfc_basic.h:65
const Vertex_overlay * vertex() const
Definition: HDS_overlay.h:107
Vertex_overlay Vertex
Definition: HDS_overlay.h:84
int _id
Definition: HDS_overlay.h:318
Facet_overlay * facet()
Definition: HDS_overlay.h:129
const Vertex_overlay * destination() const
Definition: HDS_overlay.h:138
Halfedge_overlay Halfedge
Definition: HDS_overlay.h:308