diff --git a/geo/dll/src/BoostPolygon.cpp b/geo/dll/src/BoostPolygon.cpp index a53764b7..dca7a5af 100644 --- a/geo/dll/src/BoostPolygon.cpp +++ b/geo/dll/src/BoostPolygon.cpp @@ -1417,6 +1417,7 @@ CommonOperGroup cogBC("box_connectivity", oper_policy::better_not_in_meta_script class AbstrBoxConnectivityOperator : public BinaryOperator { +protected: using ResultingDomainType = UInt32; AbstrBoxConnectivityOperator(const DataItemClass* polyAttrClass) @@ -1462,9 +1463,10 @@ class BoxConnectivityOperator : public AbstrBoxConnectivityOperator { using PointType = P; using ScalarType = scalar_of_t

; - using RectType = Range

; - using RectTypePtr = RectType*; + using RectType = Range; + using RectTypeCPtr = const RectType*; using Arg1Type = DataArray; + using SpatialIndexType = SpatialIndex; public: BoxConnectivityOperator() @@ -1481,7 +1483,9 @@ class BoxConnectivityOperator : public AbstrBoxConnectivityOperator lowerBoundData = {}; upperBoundData = {}; - auto spatialIndex = SpatialIndex(begin_ptr( rects ), end_ptr( rects )); + auto rects_begin = begin_ptr(rects); + auto rects_beyond = end_ptr(rects); + auto spatialIndex = SpatialIndexType(rects_begin, rects_beyond); // counting SizeT nrEdges = 0; @@ -1489,12 +1493,15 @@ class BoxConnectivityOperator : public AbstrBoxConnectivityOperator { SizeT index = &rect - begin_ptr(rects); for (auto iter = spatialIndex.begin(rect); iter; ++iter) - if (Intersects(*((*iter)->get_ptr()), rect)) + { + auto currRectPtr = (*iter)->get_ptr(); + if (IsIntersecting(*currRectPtr, rect)) { - SizeT index2 = (*iter)->get_ptr() - beginPtr(rects); + SizeT index2 = currRectPtr - rects_begin; if (index < index2) ++nrEdges; } + } } res->SetCount(ThrowingConvert(nrEdges)); DataWriteLock resF1Lock(resF1); @@ -1508,9 +1515,11 @@ class BoxConnectivityOperator : public AbstrBoxConnectivityOperator { SizeT index = &rect - begin_ptr(rects); for (auto iter = spatialIndex.begin(rect); iter; ++iter) - if (Intersects(*((*iter)->get_ptr()), rect)) + { + auto currRectPtr = (*iter)->get_ptr(); + if (IsIntersecting(*currRectPtr, rect)) { - SizeT index2 = (*iter)->get_ptr() - beginPtr(rects); + SizeT index2 = currRectPtr - rects_begin; if (index < index2) { assert(e < nrEdges); @@ -1519,6 +1528,7 @@ class BoxConnectivityOperator : public AbstrBoxConnectivityOperator ++e; } } + } } indexAssigner1.Store(); indexAssigner2.Store(); @@ -1675,6 +1685,7 @@ namespace tl_oper::inst_tuple_templ cgalOverlayOperators(grCGALOverlayPolygon); tl_oper::inst_tuple_templ polygonConnectivityOperators; + tl_oper::inst_tuple_templ boxConnectivityOperators; PolyOperatorGroupss simple("", PolygonFlags()); BpPolyOperatorGroupss bp_simple; diff --git a/rtc/dll/src/geo/SpatialIndex.h b/rtc/dll/src/geo/SpatialIndex.h index 92add0df..3d2e0610 100644 --- a/rtc/dll/src/geo/SpatialIndex.h +++ b/rtc/dll/src/geo/SpatialIndex.h @@ -11,6 +11,7 @@ #define __RTC_GEO_SPATIALINDEX_H #include "geo/Pair.h" +#include "geo/SequenceArray.h" #include "utl/IncrementalLock.h" template struct neighbour_iter; @@ -29,6 +30,13 @@ Point _FirstElem(const Point& p) return p; } +template +Range +RangeFromPtr(const Range* rect) +{ + return *rect; +} + template Range RangeFromPtr(typename sequence_traits::cseq_t::const_iterator point) @@ -149,14 +157,25 @@ struct PolyLeaf: LeafBase> extents_type m_Bounds; }; -template struct LeafTypeGetter; +template struct LeafTypeGetter +{ + using type = PolyLeaf; +}; + +template struct LeafTypeGetter +{ + using type = PointLeaf; +}; + -template struct LeafTypeGetter { typedef PointLeaf type; }; +/* +template struct LeafTypeGetter*> { typedef PolyLeaf*> type; }; template struct LeafTypeGetter*> { typedef PolyLeaf *> type; }; template struct LeafTypeGetter > { typedef PolyLeaf > type; }; template struct LeafTypeGetter > { typedef PolyLeaf > type; }; +*/ -template using LeafTypeGetter_t = LeafTypeGetter::type; +template using LeafTypeGetter_t = typename LeafTypeGetter::type; template @@ -362,7 +381,7 @@ struct SpatialIndex friend struct iterator; friend struct iterator; - SpatialIndex(ObjectPtr first, ObjectPtr last, SizeT maxNrFutureInserts) + SpatialIndex(ObjectPtr first, ObjectPtr last, SizeT maxNrFutureInserts = 0) { MG_CHECK(first != last || !maxNrFutureInserts); // future inserts must be within the current determinable boundingbox m_Leafs.reserve((last-first) + maxNrFutureInserts);