21 #ifndef DB0_POINT_LOCATOR_IMPL_H 22 #define DB0_POINT_LOCATOR_IMPL_H 24 #ifndef SHEAF_DLL_SPEC_H 25 #include "SheafSystem/sheaf_dll_spec.h" 28 #ifndef DB0_POINT_LOCATOR_H 29 #include "SheafSystem/db0_point_locator.h" 32 #ifndef ASSERT_CONTRACT_H 33 #include "SheafSystem/assert_contract.h" 37 #include "SheafSystem/block.h" 40 #ifndef CHART_POINT_3D_H 41 #include "SheafSystem/chart_point_3d.h" 44 #ifndef ERROR_MESSAGE_H 45 #include "SheafSystem/error_message.h" 48 #ifndef PREORDER_ITERATOR_H 49 #include "SheafSystem/preorder_iterator.h" 52 #ifndef SEC_AT1_SPACE_H 53 #include "SheafSystem/sec_at1_space.h" 57 #include "SheafSystem/sec_ed.h" 60 #ifndef SEC_REP_DESCRIPTOR_H 61 #include "SheafSystem/sec_rep_descriptor.h" 64 #ifndef SECTION_SPACE_SCHEMA_POSET_H 65 #include "SheafSystem/section_space_schema_poset.h" 69 #include "SheafSystem/std_cmath.h" 73 #include "SheafSystem/std_iomanip.h" 77 #include "SheafSystem/std_limits.h" 101 require(xcoords.
schema().
df() == DC);
102 require(xcoords.
schema().
rep().
name() ==
"vertex_vertex_constant");
103 require(xbin_ub.
ct() >= DC);
104 require_for_all(i, 0, xbin_ub.
ct(), xbin_ub[i] > 0);
117 for(
int i=0; i<DC; i++)
141 require(xcoords.
schema().
rep().
name() ==
"vertex_vertex_constant");
142 require(xavg_occupancy > 0);
159 / static_cast<double>(DC)));
163 lbin_ub = (lbin_ub > 1) ? lbin_ub : 1;
166 for(
int i=0; i<DC; i++)
212 ensure_for_all(i, 0,
dc(), result[i] > 0);
254 for(
int i=0; result && (i<
_bins.ct()); ++i)
256 result =
_bins[i].empty();
280 for(
int i=0; i<DC; i++)
283 #ifdef DIAGNOSTIC_OUTPUT 284 cout <<
"xpt: " << xpt[i] << endl;
291 #ifdef DIAGNOSTIC_OUTPUT 293 int lprecision = cout.precision();
294 cout <<
"tmp: " << scientific << setprecision(15) << ltmp;
295 cout.unsetf(ios_base::floatfield);
296 cout << setprecision(lprecision);
297 cout <<
" result: " << xresult[i] << endl;
320 for(
int i=0; i<
_bins.ct(); ++i)
350 #ifdef DIAGNOSTIC_OUTPUT 353 for(
int i=0; i<DC; i++)
361 for(
int i=0; i<DC; i++)
368 #ifdef DIAGNOSTIC_OUTPUT 370 cout <<
"bin_size: ";
371 for(
int i=0; i<DC; i++)
381 for(
int i=0; i<DC; i++)
387 #ifdef DIAGNOSTIC_OUTPUT 388 cout <<
"one_over_bin_size: ";
389 for(
int i=0; i<DC; i++)
399 for(
int i=0; i<DC; i++)
404 _bins.reserve(lbin_ct);
405 _bins.set_ct(lbin_ct);
431 for(
int i=0; i<DC; ++i)
439 else if(lpt_coord >=
_bin_ub[i])
445 xbin_pos[i] = lpt_coord;
449 #ifdef DIAGNOSTIC_OUTPUT 455 ensure_for_all(i, 0, DC, (0 <= xbin_pos[i]) && (xbin_pos[i] <
_bin_ub[i]));
468 #ifdef DIAGNOSTIC_OUTPUT 469 cout << endl << endl;
470 post_information_message(
"entering initialize_search_region");
483 #ifdef DIAGNOSTIC_OUTPUT 511 #ifdef DIAGNOSTIC_OUTPUT 513 post_information_message(
"leaving initialize_search_region");
514 cout << endl << endl;
526 #ifdef DIAGNOSTIC_OUTPUT 527 post_information_message(
"Entering expand_search_region.");
539 for(
int c=0; c<DC; ++c)
569 #ifdef DIAGNOSTIC_OUTPUT 571 post_information_message(
"Leavinging expand_search_region.");
592 for(
int i=0; i<DC; ++i)
602 #ifdef DIAGNOSTIC_OUTPUT 614 for(
int i=0; i<DC; ++i)
619 #ifdef DIAGNOSTIC_OUTPUT 627 for(
int i=0; i<DC; ++i)
639 #ifdef DIAGNOSTIC_OUTPUT 677 for(
int i=0; i<DC; ++i)
683 #ifdef DIAGNOSTIC_OUTPUT 684 cout <<
"vertex= " << setw(4) << xvertex_entry.disc_id
685 <<
" branch= " << setw(4) << xvertex_entry.branch_id
686 <<
" distance squared= " << result << endl;
691 ensure(result >= 0.0);
717 #ifdef DIAGNOSTIC_OUTPUT 719 cout <<
"searching bin= " << setw(4) << i << endl;
749 typename vertex_list_type::const_iterator iter;
751 for(iter = lvertex_list.
begin(); iter != lvertex_list.
end(); ++iter)
757 if(lvertex_dist_sq < xclosest_dist_sq)
762 xclosest_dist_sq = lvertex_dist_sq;
765 #ifdef DIAGNOSTIC_OUTPUT 767 cout <<
"vertex= " << iter->disc_id <<
" is closest" << endl;
793 xos << endl << xmsg << endl;
795 xos <<
"_bins.ub()= " <<
_bins.ub()
796 <<
" _bins.ct()= " <<
_bins.ct()
799 for(
int i=0; i<
_bins.ct(); ++i)
801 cout <<
"bin: " << setw(4) << i <<
" vertices: " << endl;
805 for(
typename vertex_list_type::const_iterator lv_itr = lverts.
begin();
806 lv_itr != lverts.
end();
809 cout << setw(6) << lv_itr->disc_id
810 << setw(6) << lv_itr->branch_id;
812 for(
int lc=0; lc<DC; ++lc)
814 cout << setw(16) << lv_itr->coords[lc];
841 xos << endl << xmsg << endl;
850 xos << setw(6) << ltmp.front();
868 const std::string& xmsg)
const 879 for(
int i=0; i<DC; ++i)
881 cout << setw(12) << xvalue[i];
898 const std::string& xmsg)
const 909 for(
int i=0; i<DC; ++i)
911 cout << setw(6) << xcoords[i];
938 invariance(
coordinates().schema().rep().name() ==
"vertex_vertex_constant");
963 #ifdef DIAGNOSTIC_OUTPUT 965 print_bins(cout,
"Before initializing bins:");
987 lvertex_entry.disc_id =
994 lindex >> lvertex_entry.disc_id;
996 lvertex_entry.branch_id = lbranch_id;
1000 lbranch.
get_fiber(ldisc_id, lvertex_entry.coords,
1010 int lbin_id =
bin_id(lrel_pos);
1012 _bins[lbin_id].push_front(lvertex_entry);
1024 #ifdef DIAGNOSTIC_OUTPUT 1026 print_bins(cout,
"After initializing bins:");
1044 require(xvalue != 0);
1045 require(xvalue_ub >=
dc());
1046 require(xresult.
db() >=
db());
1047 require(
coordinates().schema().discretization_ct() > 0);
1091 #ifdef DIAGNOSTIC_OUTPUT 1093 cout <<
" chart pt: " << xresult << endl;
1112 require(xvalue != 0);
1113 require(xvalue_ub >=
dc());
1125 ensure_for_all(i, 0, xresult.
ct(), xresult[i].is_valid());
1140 require(xvalue != 0);
1141 require(xvalue_ub >=
dc());
1146 define_old_variable(
int old_xresult_ct = xresult.
ct());
1156 ensure(xresult.
ct() == old_xresult_ct + 1);
1157 ensure_for_all(i, old_xresult_ct, xresult.
ct(),
1159 ensure_for_all(i, old_xresult_ct, xresult.
ct(), xresult[i].second.is_valid());
1174 #endif // DB0_POINT_LOCATOR_IMPL_H sec_vd_value_type _bin_diag
The diagonal length of the smallest bins.
SHEAF_DLL_SPEC void sqrt(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute sqrt of x0 (sqrt(x0)) (pre-allocated version).
void truncate()
Makes this the next member of the subset which is not less than old this, i.e. the depth-first descen...
void print_value(std::ostream &xos, const sec_vd_value_type xvalue[], const std::string &xmsg) const
Prints xvlaue on xos; intended for debugging.
virtual void update_bins()
Updates the bin parameters.
section_space_schema_poset * host() const
The poset which this is a handle to a component of.
virtual bool invariant() const
Class invariant.
size_type ct() const
The number of items currently in use.
void print_queue(std::ostream &xos, const std::string &xmsg) const
Prints the contents of the search queue on xos; intended for debugging.
sec_ed & coordinates() const
The coordinate section this inverts.
The information stored in the search structure for each vertex.
bool state_is_read_accessible() const
True if this is attached and if the state is accessible for read or access control is disabled...
void get_fiber(pod_index_type xdisc_id, vd_lite &xfiber) const
Sets xfiber to the fiber referred to by discretization id xdisc_id.
virtual void clear()
Clear the search structure of all bounding boxes.
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.
virtual int db() const =0
The dimension of this chart.
void initialize_search_q()
Puts all the bins from the search region onto the search queue.
void find_closest_bin(const bin_coord_type xpt_pos[], bin_coord_type xbin_pos[])
Set xbin_pos the bin closest to xpt_pos.
void find_closest_vertex(const sec_vd_value_type *xvalue, sec_vd_value_type &xclosest_dist_sq, chart_point &xresult)
Sets xresult.chart() to the vertex in _bins that is both closest to the point with value xvalue and c...
block< sec_vd_value_type > _bin_size
The dimensions of the smallest bins.
void reserve(index_type xub)
Makes ub() at least xub; if new storage is allocated, it is uninitialized.
point_locator()
Default constructor.
bin_coord_type _search_region_ub[DC]
The upper bound of the search region.
void put_chart_id(pod_index_type xchart)
Sets chart_id() to xchart_id.
sec_vd_value_type vertex_distance_sq(const sec_vd_value_type xglobal_coords[], const vertex_type &xvertex_entry)
The squared distance from the point with coordinates xglobal_coords to the vertex associated with xve...
void update_domain()
Initializes the domain bounds and dimension.
host_type * host() const
The poset this is a member of.
const scoped_index & index() const
The index of the component state this handle is attached to.
std::string name() const
A name for this.
virtual void branch_points_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, block< branch_point_pair > &xresult)
Finds one chart point in each branch at which coordinates() has value xvalue and appends them to xres...
virtual void all_points_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, block< chart_point_3d > &xresult)
Finds all chart points at which coordinates() has value xvalue; for sections over db = 0 base spaces...
iterator begin()
Returns an iterator to the first element of the container.
bool is_empty() const
True if the search structure contains no vertices.
bool is_valid() const
True if this ia a valid point in a chart.
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.
std::queue< int > _search_q
The bins scheduled to be searched for the current query point.
void invalidate()
Makes this invalid.
void relative_position(const sec_vd_value_type xpt[], bin_coord_type xresult[]) const
The position of xpt relative to the lower bound in integer coordinates.
const bool NOT_STRICT
Iteration strictness control.
const bool DOWN
Iteration directions.
block< sec_vd_value_type > _lb
The lower bound of the domain.
block< sec_vd_value_type > _one_over_min_bin_size
Reciprocal of the dimensions of the smallest bins.
void set_ct(size_type xct)
Sets ct() == xct.
An index within the external ("client") scope of a given id space.
unsigned long size_type
An unsigned integral type used to represent sizes and capacities.
virtual bool contains_member(pod_index_type xmbr_hub_id, bool xauto_access=true) const
True if some version of this poset contains poset member with hub id xmbr_hub_id. ...
db0_point_locator()
Default constructor; disabled.
int discretization_ct() const
The number of members in the intersection of the discretization subposet and the down set of the base...
bin_coord_type _search_region_lb[DC]
The lower bound of the search region.
void compute_search_region(const sec_vd_value_type xvalue[])
Compute the intersection of the domain with the search box enclosing the search sphere.
int bin_coord_type
The type of the bin coordinates.
SHEAF_DLL_SPEC void max(const vd &x0, vd_value_type &xresult, bool xauto_access)
Maximum component of x0, pre-allocated version.
iterator end()
Returns an iterator to the element following the last element of the container.
SHEAF_DLL_SPEC void log(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute log of x0 (log(x0)) (pre-allocated version).
A section of a fiber bundle with a d-dimensional vector space fiber.
const block< sec_vd_value_type > & bin_size() const
The dimensions of the smallest bins.
bool is_done() const
True if iteration finished.
void detach_from_state()
Detaches field from state it is currently attached to.
virtual ~db0_point_locator()
Destructor.
void print_bins(std::ostream &xos, const std::string &xmsg) const
Prints the contents of the bins on xos; intended for debugging.
int db() const
The intrinsic dimension of the domain; the dimension of the local coordinates.
virtual void point_at_value(const sec_vd_value_type *xvalue, size_type xvalue_ub, chart_point &xresult)
Finds a chart point at which coordinates() has value xvalue; for sections over db = 0 base spaces...
SHEAF_DLL_SPEC void floor(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute floor of x0 (floor(x0)) (pre-allocated version).
void find_closest_vertex_in_bin(int xbin_id, const sec_vd_value_type *xvalue, chart_point &xresult, sec_vd_value_type &xclosest_dist)
Sets xresult.chart() to the vertex, if any in bin xbin_id that is both.
const index_space_handle & discretization_id_space() const
The id space for the discretization members in the down set of the base space of this (const version)...
virtual section_space_schema_member & schema()
The restricted schema for this (mutable version).
int_type pod_index_type
The plain old data index type.
int dc() const
The spatial dimension of the domain; the dimension of the global coordinates.
block< sec_vd_value_type > _ub
The upper bound of the domain.
block< size_type > _bin_ub
The upper bound for the bin index.
int df() const
The dimension of the fiber space component.
void initialize_search_region(const sec_vd_value_type xvalue[])
Initialize the search radius and the search region.
void attach_to_state(const namespace_poset *xns, const poset_path &xpath, bool xauto_access=true)
Attach to the state specified by path xpath in the namespace xns.
const block< size_type > & bin_ub() const
The upper bound for the bin index.
SHEAF_DLL_SPEC void exp(const sec_at0 &x0, sec_at0 &xresult, bool xauto_access)
Compute exp of x0 (exp(x0)) (pre-allocated version).
virtual void update()
Updates the search structure to the current values of coordinates().
double sec_vd_dof_type
The type of degree of freedom in the section space.
void expand_search_region(const sec_vd_value_type xvalue[])
Increase the search radius and expand the search region to match.
sec_rep_descriptor & rep()
The representation for section spaces on this schema (mutable version).
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.
void print_coords(std::ostream &xos, const bin_coord_type xcoords[], const std::string &xmsg) const
Prints xcoords on xos; intended for debugging.
vd_value_type sec_vd_value_type
The type of component in the value of a section at a point.
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 ...
base_space_poset & base_space()
The base space for section spaces on this schema.
virtual const scoped_index & member_id(bool xauto_access) const
An id in the member hub id space; intended for copying to initialize ids to the member id space...
const scoped_index & index() const
The index of the current member of the iteration.