SheafSystem  0.0.0.0
db0_point_locator.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 DB0_POINT_LOCATOR_H
22 #define DB0_POINT_LOCATOR_H
23 
24 #ifndef SHEAF_DLL_SPEC_H
25 #include "SheafSystem/sheaf_dll_spec.h"
26 #endif
27 
28 #ifndef POINT_LOCATOR_H
29 #include "SheafSystem/point_locator.h"
30 #endif
31 
32 #ifndef SINGLY_LINKED_LIST_H
33 #include "SheafSystem/singly_linked_list.h"
34 #endif
35 
36 #ifndef STD_QUEUE_H
37 #include "SheafSystem/std_queue.h"
38 #endif
39 
40 #ifndef SECTION_EVAL_ITERATOR_H
41 #include "SheafSystem/section_eval_iterator.h"
42 #endif
43 
44 //#undef DIAGNOSTIC_OUTPUT
45 //#define DIAGNOSTIC_OUTPUT
46 
47 namespace geometry
48 {
49 
56 template<int DC>
57 class SHEAF_DLL_SPEC db0_point_locator : public point_locator
58 {
59 
60  // ===========================================================
62  // ===========================================================
64 
65 public:
66 
70  db0_point_locator(sec_ed& xcoords, const block<size_type>& xbin_ub);
71 
76  db0_point_locator(sec_ed& xcoords, int xavg_occupancy = 2);
77 
81  typedef int bin_coord_type;
82 
86  virtual ~db0_point_locator();
87 
91  const block<size_type>& bin_ub() const;
92 
96  const block<sec_vd_value_type>& bin_size() const;
97 
101  bool is_empty() const;
102 
106  void relative_position(const sec_vd_value_type xpt[],
107  bin_coord_type xresult[]) const;
108 
112  virtual void clear();
113 
114 protected:
115 
120 
125 
129  virtual db0_point_locator& operator=(const point_locator& xother) {return *this;};
130 
134  db0_point_locator& operator=(const db0_point_locator& xother) {return *this;};
135 
139  block<size_type> _bin_ub;
140 
145 
150 
155 
159  virtual void update_bins();
160 
164  struct SHEAF_DLL_SPEC vertex_type
165  {
166  // The id of the vertex.
167 
168  scoped_index disc_id;
169 
170  // The branch containing the vertex
171 
172  scoped_index branch_id;
173 
174  // The coordinates of the vertex in the branch.
175 
176  sec_vd_dof_type coords[DC];
177  };
178 
183 
188 
192  std::queue<int> _search_q;
193 
197  void find_closest_bin(const bin_coord_type xpt_pos[],
198  bin_coord_type xbin_pos[]);
199 
205 
209  bin_coord_type _search_region_lb[DC];
210 
214  bin_coord_type _search_region_ub[DC];
215 
219  void initialize_search_region(const sec_vd_value_type xvalue[]);
220 
224  void expand_search_region(const sec_vd_value_type xvalue[]);
225 
230  void compute_search_region(const sec_vd_value_type xvalue[]);
231 
236  void initialize_search_q();
237 
242  void update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
243 
249  vertex_distance_sq(const sec_vd_value_type xglobal_coords[],
250  const vertex_type& xvertex_entry);
251 
252 
257  void find_closest_vertex(const sec_vd_value_type* xvalue,
258  sec_vd_value_type& xclosest_dist_sq,
259  chart_point& xresult);
260 
263  // closest to the point with value xvalue and closer than _search_radius.
266  void find_closest_vertex_in_bin(int xbin_id,
267  const sec_vd_value_type* xvalue,
268  chart_point& xresult,
269  sec_vd_value_type& xclosest_dist);
270 
271 
275  int bin_id(const bin_coord_type xcoord[]) const;
276 
280  void print_bins(std::ostream& xos, const std::string& xmsg) const;
281 
285  void print_queue(std::ostream& xos, const std::string& xmsg) const;
286 
290  void print_value(std::ostream& xos,
291  const sec_vd_value_type xvalue[],
292  const std::string& xmsg) const;
293 
294 
298  void print_coords(std::ostream& xos,
299  const bin_coord_type xcoords[],
300  const std::string& xmsg) const;
301 
302 
307  sec_vd_value_type max_bin_distance(const sec_vd_value_type xpt[],
308  const bin_coord_type xbin_pos[]) const;
309 
311 
312 
313  // ===========================================================
315  // ===========================================================
317 
318 public:
319 
323  virtual bool invariant() const;
324 
328  virtual void update();
329 
335  virtual void point_at_value(const sec_vd_value_type* xvalue,
336  size_type xvalue_ub,
337  chart_point& xresult);
338 
344  virtual void all_points_at_value(const sec_vd_value_type* xvalue,
345  size_type xvalue_ub,
346  block<chart_point_3d>& xresult);
347 
348 
355  virtual void branch_points_at_value(const sec_vd_value_type* xvalue,
356  size_type xvalue_ub,
357  block<branch_point_pair>& xresult);
358 
360 
361 };
362 
363 // ============================================================================
364 // SPECIALIZATIONS
365 // ============================================================================
366 
367 //
368 // Puts all the bins from/ the search region
369 // onto the search queue; DC = 1 specialization
370 //
371 template<>
372 SHEAF_DLL_SPEC
373 void
376 
377 //
378 // Puts all the bins from the search region
379 // onto the search queue; DC = 2 specialization
380 //
381 template<>
382 SHEAF_DLL_SPEC
383 void
386 
387 //
388 // Puts all the bins from the search region
389 //onto the search queue; DC = 3 specialization
390 //
391 template<>
392 SHEAF_DLL_SPEC
393 void
396 
397 //
398 // Puts previous unsearched bins from the search region
399 // onto the search queue; DC = 1 specialization
400 //
401 template<>
402 SHEAF_DLL_SPEC
403 void
405 update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
406 
407 //
408 // Puts previous unsearched bins from the search region
409 // onto the search queue; DC = 2 specialization
410 //
411 template<>
412 SHEAF_DLL_SPEC
413 void
415 update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
416 
417 //
418 // Puts previous unsearched bins from the search region
419 // onto the search queue; DC = 3 specialization
420 //
421 template<>
422 SHEAF_DLL_SPEC
423 void
425 update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
426 
427 //
428 // The id of the bin with bin coords xcoord; DC = 1 specialization.
429 //
430 template<>
431 SHEAF_DLL_SPEC
432 int
434 bin_id(const bin_coord_type xcoord[]) const;
435 
436 
437 //
438 // The id of the bin with bin coords xcoord; DC = 2 specialization.
439 //
440 template<>
441 SHEAF_DLL_SPEC
442 int
444 bin_id(const bin_coord_type xcoord[]) const;
445 
446 
447 //
448 // The id of the bin with bin coords xcoord; DC = 3 specialization.
449 //
450 template<>
451 SHEAF_DLL_SPEC
452 int
454 bin_id(const bin_coord_type xcoord[]) const;
455 
456 //
457 // The maximum distance from the query point xpt
458 // to any point in the bin with coordinates xbin_pos; DC=1 specialization.
459 //
460 template<>
461 SHEAF_DLL_SPEC
464 max_bin_distance(const sec_vd_value_type xpt[], const bin_coord_type xbin_pos[]) const;
465 
466 //
467 // The maximum distance from the query point xpt
468 // to any point in the bin with coordinates xbin_pos; DC=2 specialization.
469 //
470 template<>
471 SHEAF_DLL_SPEC
474 max_bin_distance(const sec_vd_value_type xpt[], const bin_coord_type xbin_pos[]) const;
475 
476 //
477 // The maximum distance from the query point xpt
478 // to any point in the bin with coordinates xbin_pos; DC=3 specialization.
479 //
480 template<>
481 SHEAF_DLL_SPEC
484 max_bin_distance(const sec_vd_value_type xpt[], const bin_coord_type xbin_pos[]) const;
485 
486 //
487 // Prints the contents of the bins on xos; DC=3 specialization.
488 //
489 template<>
490 SHEAF_DLL_SPEC
491 void
493 print_bins(std::ostream& xos, const std::string& xmsg) const;
494 
499 template<>
500 SHEAF_DLL_SPEC
501 void
504 
505 
510 template<>
511 SHEAF_DLL_SPEC
512 void
515 
516 
521 template<>
522 SHEAF_DLL_SPEC
523 void
526 
530 //
531 template<>
532 SHEAF_DLL_SPEC
533 void
535 update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
536 
540 //
541 template<>
542 SHEAF_DLL_SPEC
543 void
545 update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
546 
550 //
551 template<>
552 SHEAF_DLL_SPEC
553 void
555 update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[]);
556 
557 
558 
559 } // namespace geometry
560 
561 #endif // DB0_POINT_LOCATOR_H
sec_vd_value_type _bin_diag
The diagonal length of the smallest bins.
virtual db0_point_locator & operator=(const point_locator &xother)
Assignment operator; disabled.
db0_point_locator & operator=(const db0_point_locator &xother)
Assignment operator; disabled.
The information stored in the search structure for each vertex.
An abstract point location query in domains with global coordinate dimension DC and local coordinate ...
void update_search_q(bin_coord_type xold_lb[], bin_coord_type xold_ub[])
Puts previous unsearched bins from the search region onto the search queue.
void initialize_search_q()
Puts all the bins from the search region onto the search queue.
block< sec_vd_value_type > _bin_size
The dimensions of the smallest bins.
A point in chart space.
Definition: chart_point.h:52
sec_vd_value_type _search_radius
The radius of a sphere centered on the query point that will be searched for vertices.
A section of a fiber bundle with a d-dimensional Euclidean vector space fiber.
Definition: sec_ed.h:47
std::queue< int > _search_q
The bins scheduled to be searched for the current query point.
block< sec_vd_value_type > _one_over_min_bin_size
Reciprocal of the dimensions of the smallest bins.
An index within the external ("client") scope of a given id space.
Definition: scoped_index.h:116
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
Definition: sheaf.h:52
db0_point_locator()
Default constructor; disabled.
int bin_coord_type
The type of the bin coordinates.
void print_bins(std::ostream &xos, const std::string &xmsg) const
Prints the contents of the bins on xos; intended for debugging.
singly_linked_list< vertex_type > vertex_list_type
The type of vertex list.
db0_point_locator(const db0_point_locator &xother)
Copy constructor; disabled.
double sec_vd_dof_type
The type of degree of freedom in the section space.
Definition: fiber_bundle.h:78
block< vertex_list_type > _bins
The search structure; a d-dimensional array of bins.
sec_vd_value_type max_bin_distance(const sec_vd_value_type xpt[], const bin_coord_type xbin_pos[]) const
The maximum distance from the query point xpt to any point in the bin with coordinates xbin_pos...
Namespace for geometry component of sheaf system.
Definition: field_vd.h:54
vd_value_type sec_vd_value_type
The type of component in the value of a section at a point.
Definition: fiber_bundle.h:73
int bin_id(const bin_coord_type xcoord[]) const
The id of the bin with bin coords xcoord.
Wrapper class for forward_list or slist depending on compiler. The class replicates the minimum subse...
An abstract point location query in domains with global coordinate dimension dc and local coordinate ...
Definition: point_locator.h:52