SheafSystem  0.0.0.0
d_bounding_box.impl.h
Go to the documentation of this file.
1 
2 //
3 // Copyright (c) 2014 Limit Point Systems, Inc.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 
20 
21 #ifndef D_BOUNDING_BOX_IMPL_H
22 #define D_BOUNDING_BOX_IMPL_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef D_BOUNDING_BOX_H
29 #include "SheafSystem/d_bounding_box.h"
30 #endif
31 
32 #ifndef ASSERT_CONTRACT_H
33 #include "SheafSystem/assert_contract.h"
34 #endif
35 
36 namespace geometry
37 {
38 
39 // ============================================================================
40 // CANONICAL FACET
41 // ============================================================================
42 
43 // PUBLIC MEMBER FUNCTIONS
44 
45 template <int DC, int DB>
48 {
49  // Bounds initialized by default.
50 
51  _member_id.invalidate();
52 
53  _dofs_index = 0;
54  _dof_ct = 0;
55  _evaluator = 0;
56 
57  // Postconditions:
58 
59  ensure(invariant());
60  ensure(lb() == 0);
61  ensure(ub() == 0);
62 
63  ensure(!member_id().is_valid());
64 
65  ensure(evaluator() == 0);
66  ensure(dofs_index() == 0);
67  ensure(dof_ct() == 0);
68 
69 }
70 
71 template <int DC, int DB>
74 {
75  // Preconditions:
76 
77  // Body:
78 
79  (*this) = xbox;
80 
81  // Postconditions:
82 
83  ensure(invariant());
84  ensure(lb() == xbox.lb());
85  ensure(ub() == xbox.ub());
86  ensure(member_id() == xbox.member_id());
87  ensure(evaluator() == xbox.evaluator());
88  ensure(dofs_index() == xbox.dofs_index());
89  ensure(dof_ct() == xbox.dof_ct());
90 }
91 
92 template <int DC, int DB>
96 {
97  // Preconditions:
98 
99  // Body:
100 
101  if(this != &xbox)
102  {
103  _lb = xbox._lb;
104  _ub = xbox._ub;
105  _member_id = xbox._member_id;
106  _evaluator = xbox._evaluator;
107  _dofs_index = xbox._dofs_index;
108  _dof_ct = xbox._dof_ct;
109  }
110 
111  // Postconditions:
112 
113  ensure(invariant());
114  ensure(lb() == xbox.lb());
115  ensure(ub() == xbox.ub());
116  ensure(member_id() == xbox.member_id());
117  ensure(evaluator() == xbox.evaluator());
118  ensure(dofs_index() == xbox.dofs_index());
119  ensure(dof_ct() == xbox.dof_ct());
120 
121  return *this;
122 }
123 
124 template <int DC, int DB>
127 {
128  // Nothing to do.
129 }
130 
131 
132 template <int DC, int DB>
133 bool
135 invariant() const
136 {
137 
138  bool result = true;
139 
140  return result;
141 }
142 
143 template <int DC, int DB>
144 bool
147 {
148  // Preconditions:
149 
150  // Body:
151 
152  bool result = true;
153 
154  if(this != &xbox)
155  {
156  result = result && (_lb == xbox._lb);
157  result = result && (_ub == xbox._ub);
158  result = result && (_member_id == xbox._member_id);
159  result = result && (_evaluator == xbox._evaluator);
160  result = result && (_dofs_index == xbox._dofs_index);
161  result = result && (_dof_ct == xbox._dof_ct);
162  }
163 
164  // Postconditions:
165 
166  ensure(invariant());
167 
168  return result;
169 }
170 
171 
172 // ============================================================================
173 // D_BOUNDING_BOX FACET
174 // ============================================================================
175 
176 // PUBLIC MEMBER FUNCTIONS
177 
178 template <int DC, int DB>
179 bool
182 {
183  // Preconditions:
184 
185  // Body:
186 
187  bool result = ((_lb <= xpt) && (xpt <= _ub));
188 
189  // Postconditions:
190 
191  ensure(invariant());
192 
193  // Exit:
194 
195  return result;
196 }
197 
198 template <int DC, int DB>
199 void
201 to_stream(std::ostream& xos) const
202 {
203  // Preconditions:
204 
205  // Body:
206 
207  using namespace std;
208 
209  xos << "d_bounding_box: " << endl
210  << " lower_bounds: " << lb() << endl
211  << " upper_bounds: " << ub() << endl
212  << " member_id: " << member_id() << endl
213  << " dofs_index: " << dofs_index() << endl
214  << " dof_ct: " << dof_ct() << endl;
215 
216 
217  // Postconditions:
218 
219  ensure(invariant());
220 
221 }
222 
223 template <int DC, int DB>
226 lb() const
227 {
228  return _lb;
229 }
230 
231 template <int DC, int DB>
232 void
235 {
236  // Preconditions:
237 
238  // Body:
239 
240  _lb = xlb;
241 
242  // Postconditions:
243 
244  ensure(lb() == xlb);
245 
246  // Exit:
247 
248  return;
249 }
250 
251 template <int DC, int DB>
254 ub() const
255 {
256  return _ub;
257 }
258 
259 template <int DC, int DB>
260 void
263 {
264  // Preconditions:
265 
266  // Body:
267 
268  _ub = xub;
269 
270  // Postconditions:
271 
272  ensure(ub() == xub);
273 
274  // Exit:
275 
276  return;
277 }
278 
279 template <int DC, int DB>
280 const scoped_index&
282 member_id() const
283 {
284  // Preconditions:
285 
286  // Body:
287 
288  const scoped_index& result = _member_id;
289 
290  // Postconditions:
291 
292  return result;
293 }
294 
295 template <int DC, int DB>
296 void
299 {
300  // Preconditions:
301 
302  // Body:
303 
304  _member_id = xid;
305 
306  // Postconditions:
307 
308  ensure(member_id() == xid);
309 
310 }
311 
312 template <int DC, int DB>
313 const scoped_index&
315 branch_id() const
316 {
317  // Preconditions:
318 
319  // Body:
320 
321  const scoped_index& result = _branch_id;
322 
323  // Postconditions:
324 
325  return result;
326 }
327 
328 template <int DC, int DB>
329 void
332 {
333  // Preconditions:
334 
335  // Body:
336 
337  _branch_id = xid;
338 
339  // Postconditions:
340 
341  ensure(branch_id() == xid);
342 
343 }
344 
345 template <int DC, int DB>
348 evaluator() const
349 {
350  // Preconditions:
351 
352  // Body:
353 
354  section_evaluator* result = _evaluator;
355 
356  // Postconditions:
357 
358  return result;
359 }
360 
361 template <int DC, int DB>
362 void
365 {
366  // Preconditions:
367 
368  // Body:
369 
370  _evaluator = xevaluator;
371 
372  // Postconditions:
373 
374  ensure(evaluator() == xevaluator);
375 
376 }
377 
378 template <int DC, int DB>
379 size_type
381 dofs_index() const
382 {
383  // Preconditions:
384 
385  // Body:
386 
387  size_type result = _dofs_index;
388 
389  // Postconditions:
390 
391  return result;
392 }
393 
394 template <int DC, int DB>
395 void
398 {
399  // Preconditions:
400 
401  // Body:
402 
403  _dofs_index = xindex;
404 
405  // Postconditions:
406 
407  ensure(dofs_index() == xindex);
408 
409 }
410 
411 template <int DC, int DB>
412 size_type
414 dof_ct() const
415 {
416  // Preconditions:
417 
418  // Body:
419 
420  size_type result = _dof_ct;
421 
422  // Postconditions:
423 
424  return result;
425 }
426 
427 template <int DC, int DB>
428 void
431 {
432  // Preconditions:
433 
434  // Body:
435 
436  _dof_ct = xct;
437 
438  // Postconditions:
439 
440  ensure(dof_ct() == xct);
441 
442 }
443 
444 template <int DC, int DB>
445 void
448 {
449  // Preconditions:
450 
451  // Body:
452 
453  xresult = _ub;
454  xresult -= _lb;
455 
456  // Postconditions:
457 
458  // Exit:
459 
460  return;
461 }
462 
463 
464 template <int DC, int DB>
465 int
467 dc()
468 {
469  int result;
470 
471  // Preconditions:
472 
473 
474  // Body:
475 
476  result = DC;
477 
478  // Postconditions:
479 
480  ensure(result == DC);
481 
482  // Exit:
483 
484  return result;
485 }
486 
487 // ===========================================================
488 // NON-MEMBER FUNCTIONS
489 // ===========================================================
490 
491 template <int DC, int DB>
492 std::ostream&
493 operator<<(std::ostream& xos, const d_bounding_box<DC, DB>& xbox)
494 {
495  xbox.to_stream(xos);
496  return xos;
497 }
498 
499 } // namespace geometry
500 
501 #endif // D_BOUNDING_BOX_IMPL_H
502 
bool operator==(const d_bounding_box< DC, DB > &xbox) const
Equality operator.
const scoped_index & member_id() const
Index of the evaluation member this bounds.
void put_lb(const d_bin_coordinates< DC, DB > &xlb)
Copies the contents of xlb to lb().
bool invariant() const
Class invariant.
void put_dof_ct(size_type xct)
Sets dof_ct() to xct.
STL namespace.
const d_bin_coordinates< DC, DB > & ub() const
The upper bound; the upper, right, rear corner.
Fixed point relative coordinates for a tree domain.
static int dc()
The number of spatial dimensions.
sheaf::size_type size_type
An unsigned integral type used to represent sizes and capacities.
bool contains_point(const d_bin_coordinates< DC, DB > &xpt) const
True if this contains point xpt.
size_type dof_ct() const
The number of dofs in the gathered dofs array for the evaluation member this bounds.
size_type dofs_index() const
Index into the gathered dofs array for the evaluation member this bounds.
void put_member_id(const scoped_index &xid)
Sets member_id() to xid.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
const d_bin_coordinates< DC, DB > & lb() const
The lower bound; the lower, left, front corner.
A bounding box that can be strung together into a list.
void put_dofs_index(size_type xindex)
Sets dofs_index() to xindex.
An abstract local section evaluator; a map from {local coordinates x dofs} to section value...
d_bounding_box()
Default constructor.
section_evaluator * evaluator() const
Evaluator for the evaluation member this bounds.
void put_evaluator(section_evaluator *xevaluator)
Sets evaluator() to xevaluator.
d_bounding_box< DC, DB > & operator=(const d_bounding_box< DC, DB > &xbox)
Assignment operator.
void size_pa(d_bin_coordinates< DC, DB > &xresult) const
The size of each side of the box; pre-allocated.
void put_ub(const d_bin_coordinates< DC, DB > &xub)
Copies the contents of xub to ub().
const scoped_index & branch_id() const
Index of the branch that contains the evaluation member this bounds.
void put_branch_id(const scoped_index &xid)
Sets branch_id() to xid.
void to_stream(std::ostream &xos) const
Insert this into stream xos.
SHEAF_DLL_SPEC bool is_valid(pod_index_type xpod_index)
True if an only if xpod_index is valid.
Definition: pod_types.cc:37
Namespace for geometry component of sheaf system.
Definition: field_vd.h:54