30#ifndef LSST_SPHGEOM_PIXELFINDER_H_
31#define LSST_SPHGEOM_PIXELFINDER_H_
79 RegionType
const & region,
86 _maxRanges{maxRanges == 0 ? maxRanges - 1 : maxRanges}
100 Relationship r = detail::relate(pixel, pixel + NumVertices, *_region);
101 if ((r & DISJOINT) != 0) {
105 if ((r & WITHIN) != 0) {
108 _insert(index, level);
110 }
else if (level == _level) {
113 _insert(index, level);
117 static_cast<Derived *
>(
this)->subdivide(pixel, index, level);
122 RegionType
const * _region;
124 int const _desiredLevel;
125 size_t const _maxRanges;
127 void _insert(uint64_t index,
int level) {
128 int shift = 2 * (_desiredLevel - level);
129 _ranges->
insert(index << shift, (index + 1) << shift);
130 while (_ranges->size() > _maxRanges) {
141 _ranges->complement();
143 _ranges->simplify(shift);
145 _ranges->complement();
155 template <
typename,
bool>
class Finder,
160 if (
auto circle =
dynamic_cast<Circle const *
>(&r)) {
161 Finder<Circle, InteriorOnly> find(s, *circle, level, maxRanges);
163 }
else if (
auto ellipse =
dynamic_cast<Ellipse const *
>(&r)) {
164 Finder<Circle, InteriorOnly> find(
165 s, ellipse->getBoundingCircle(), level, maxRanges);
167 }
else if (
auto box =
dynamic_cast<Box
const *
>(&r)) {
168 Finder<Box, InteriorOnly> find(s, *box, level, maxRanges);
170 }
else if (
auto polygon =
dynamic_cast<ConvexPolygon
const *
>(&r)) {
171 Finder<ConvexPolygon, InteriorOnly> find(
172 s, *polygon, level, maxRanges);
174 }
else if (
auto union_region =
dynamic_cast<UnionRegion
const *
>(&r)) {
176 for (std::size_t i = 0; i < union_region->nOperands(); ++ i) {
177 Region
const ®ion = union_region->getOperand(i);
178 auto rs = findPixels<Finder, InteriorOnly>(region, maxRanges, level, universe);
181 }
else if (
auto intersection_region =
dynamic_cast<IntersectionRegion
const *
>(&r)) {
184 for (std::size_t i = 0; i < intersection_region->nOperands(); ++ i) {
185 Region
const ®ion = intersection_region->getOperand(i);
186 auto rs = findPixels<Finder, InteriorOnly>(region, maxRanges, level, universe);
190 throw std::runtime_error(std::string(
"PixelFinder: Unsupported type ") +
typeid(r).name());
This file declares classes for representing compound regions on the unit sphere.
This file contains the meat of the ConvexPolygon implementation.
This file provides a type for representing integer sets.
Definition RangeSet.h:106
RangeSet intersection(RangeSet const &s) const
intersection returns the intersection of this set and s.
Definition RangeSet.cc:142
RangeSet join(RangeSet const &s) const
join returns the union of this set and s.
Definition RangeSet.cc:152
void insert(std::uint64_t u)
Definition RangeSet.h:292
Definition UnitVector3d.h:62
std::bitset< 3 > Relationship
Relationship describes how two sets are related.
Definition Relationship.h:42