23template<
typename ItemType,
typename BoundsTraits>
24class TemplateSTRNode {
26 using BoundsType =
typename BoundsTraits::BoundsType;
32 const TemplateSTRNode* childrenEnd;
34 explicit Body (ItemType&& p_item) : item(std::forward<ItemType>(p_item)) {}
36 explicit Body (
const ItemType& p_item) : item(p_item) {}
38 explicit Body (
const TemplateSTRNode<ItemType, BoundsTraits>* p_childrenEnd) : childrenEnd(p_childrenEnd) {}
42 const TemplateSTRNode* children;
47 data.item.~ItemType();
51 TemplateSTRNode(ItemType&& p_item,
const BoundsType& env) :
53 data(std::forward<ItemType>(p_item)),
57 TemplateSTRNode(
const ItemType& p_item,
const BoundsType& env) :
63 TemplateSTRNode(
const TemplateSTRNode* begin,
const TemplateSTRNode* end) :
64 bounds(boundsFromChildren(begin, end)),
69 const TemplateSTRNode* beginChildren()
const {
73 const TemplateSTRNode* endChildren()
const {
74 return data.childrenEnd;
77 bool isDeleted()
const {
78 return children ==
this;
82 return children ==
nullptr || children ==
this;
85 bool isComposite()
const {
89 bool boundsIntersect(
const BoundsType& queryBounds)
const {
90 return BoundsTraits::intersects(getBounds(), queryBounds);
93 double getSize()
const {
94 return BoundsTraits::size(getBounds());
97 static BoundsType boundsFromChildren(
const TemplateSTRNode* from,
const TemplateSTRNode* to) {
98 BoundsType bnds = from->getBounds();
100 for (
auto *child = from + 1; child < to; ++child) {
101 BoundsTraits::expandToInclude(bnds, child->getBounds());
107 BoundsType boundsFromChildren()
const {
108 return boundsFromChildren(children, data.childrenEnd);
111 const BoundsType& getBounds()
const {
115 std::size_t getNumNodes()
const
118 return isDeleted() ? 0 : 1;
121 std::size_t count = 1;
122 for (
const auto* child = beginChildren(); child != endChildren(); ++child) {
123 count += child->getNumNodes();
129 std::size_t getNumLeafNodes()
const
132 return isDeleted() ? 0 : 1;
135 std::size_t count = 0;
136 for (
const auto* child = beginChildren(); child != endChildren(); ++child) {
137 count += child->getNumNodes();
142 const ItemType& getItem()
const {
143 assert(!isDeleted());
Basic namespace for all GEOS functionalities.
Definition geos.h:39