GEOS  3.3.3
MCIndexSegmentSetMutualIntersector.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.refractions.net
5  *
6  * Copyright (C) 2006 Refractions Research Inc.
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU Lesser General Public Licence as published
10  * by the Free Software Foundation.
11  * See the COPYING file for more information.
12  *
13  *
14  **********************************************************************
15  *
16  * Last port: noding/MCIndexSegmentSetMutualIntersector.java r388 (JTS-1.12)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
21 #define GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
22 
23 #include <geos/noding/SegmentSetMutualIntersector.h> // inherited
24 #include <geos/index/chain/MonotoneChainOverlapAction.h> // inherited
25 
26 namespace geos {
27  namespace index {
28  class SpatialIndex;
29 
30  namespace chain {
31  class MonotoneChain;
32  }
33  namespace strtree {
34  //class STRtree;
35  }
36  }
37  namespace noding {
38  class SegmentString;
39  class SegmentIntersector;
40  }
41 }
42 
43 //using namespace geos::index::strtree;
44 
45 namespace geos {
46 namespace noding { // geos::noding
47 
55 {
56 public:
57 
59 
61 
62  /* Returns a reference to a vector of MonotoneChain objects owned
63  * by this class and destroyed on next call to ::process.
64  * Copy them if you need them alive for longer.
65  */
66  std::vector<index::chain::MonotoneChain *>& getMonotoneChains()
67  {
68  return monoChains;
69  }
70 
71  index::SpatialIndex* getIndex()
72  {
73  return index;
74  }
75 
76  void setBaseSegments(SegmentString::ConstVect* segStrings);
77 
78  // NOTE: re-populates the MonotoneChain vector with newly created chains
79  void process(SegmentString::ConstVect* segStrings);
80 
81  class SegmentOverlapAction : public index::chain::MonotoneChainOverlapAction
82  {
83  private:
84  SegmentIntersector & si;
85 
86  // Declare type as noncopyable
87  SegmentOverlapAction(const SegmentOverlapAction& other);
88  SegmentOverlapAction& operator=(const SegmentOverlapAction& rhs);
89 
90  public:
91  SegmentOverlapAction(SegmentIntersector & si) :
93  {}
94 
95  void overlap(index::chain::MonotoneChain& mc1, std::size_t start1,
96  index::chain::MonotoneChain& mc2, std::size_t start2);
97  };
98 
99 private:
100 
101  typedef std::vector<index::chain::MonotoneChain *> MonoChains;
102  MonoChains monoChains;
103 
104  /*
105  * The {@link SpatialIndex} used should be something that supports
106  * envelope (range) queries efficiently (such as a {@link Quadtree}
107  * or {@link STRtree}.
108  */
109  index::SpatialIndex * index;
110  int indexCounter;
111  int processCounter;
112  // statistics
113  int nOverlaps;
114 
115  /* memory management helper, holds MonotoneChain objects used
116  * in the SpatialIndex. It's cleared when the SpatialIndex is
117  */
118  MonoChains chainStore;
119 
120  void addToIndex( SegmentString * segStr);
121 
122  void intersectChains();
123 
124  void addToMonoChains( SegmentString * segStr);
125 
126 };
127 
128 } // namespace geos::noding
129 } // namespace geos
130 
131 #endif // GEOS_NODING_MCINDEXSEGMENTSETMUTUALINTERSECTOR_H
132 /**********************************************************************
133  * $Log$
134  **********************************************************************/
135