[geos-commits] r2479 - in trunk/source: headers/geos/geom
headers/geos/index/chain headers/geos/noding index/chain noding
svn_geos at osgeo.org
svn_geos at osgeo.org
Wed May 6 13:42:59 EDT 2009
Author: strk
Date: 2009-05-06 13:42:58 -0400 (Wed, 06 May 2009)
New Revision: 2479
Modified:
trunk/source/headers/geos/geom/Makefile.am
trunk/source/headers/geos/index/chain/MonotoneChain.h
trunk/source/headers/geos/index/chain/MonotoneChainOverlapAction.h
trunk/source/headers/geos/noding/MCIndexNoder.h
trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h
trunk/source/index/chain/MonotoneChain.cpp
trunk/source/index/chain/MonotoneChainOverlapAction.cpp
trunk/source/noding/MCIndexNoder.cpp
trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp
Log:
Cleanup MonotoneChainOverlapAction, reduce heap allocations. Cascade changes.
Modified: trunk/source/headers/geos/geom/Makefile.am
===================================================================
--- trunk/source/headers/geos/geom/Makefile.am 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/headers/geos/geom/Makefile.am 2009-05-06 17:42:58 UTC (rev 2479)
@@ -6,7 +6,9 @@
# Notes:
# GeometryComponentFilter.h needed by Polygonizer.h
-# LineSegment.h needed by buffer/OffsetCurveBuilder.h needed by BufferOp.h
+# LineSegment.h needed by buffer/OffsetCurveBuilder.h needed by BufferOp.h,
+# needed by index/chain/monotoneChainSelectAction.h by McPointInRing.h,
+# needed by index/chain/monotoneChainOverlapAction.h by McIndexNoder.h
# Location.h needed by PointLocator.h for inlines
geosdir = $(includedir)/geos/geom
Modified: trunk/source/headers/geos/index/chain/MonotoneChain.h
===================================================================
--- trunk/source/headers/geos/index/chain/MonotoneChain.h 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/headers/geos/index/chain/MonotoneChain.h 2009-05-06 17:42:58 UTC (rev 2479)
@@ -112,7 +112,7 @@
* Set given LineSegment with points of the segment starting
* at the given index.
*/
- void getLineSegment(unsigned int index, geom::LineSegment& ls) const;
+ void getLineSegment(size_t index, geom::LineSegment& ls) const;
/**
* Return the subsequence of coordinates forming this chain.
@@ -145,7 +145,8 @@
MonotoneChainSelectAction& mcs);
void computeOverlaps(size_t start0, size_t end0, MonotoneChain& mc,
- int start1, int end1, MonotoneChainOverlapAction& mco);
+ size_t start1, size_t end1,
+ MonotoneChainOverlapAction& mco);
/// Externally owned
const geom::CoordinateSequence& pts;
Modified: trunk/source/headers/geos/index/chain/MonotoneChainOverlapAction.h
===================================================================
--- trunk/source/headers/geos/index/chain/MonotoneChainOverlapAction.h 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/headers/geos/index/chain/MonotoneChainOverlapAction.h 2009-05-06 17:42:58 UTC (rev 2479)
@@ -20,13 +20,12 @@
#ifndef GEOS_IDX_CHAIN_MONOTONECHAINOVERLAPACTION_H
#define GEOS_IDX_CHAIN_MONOTONECHAINOVERLAPACTION_H
+#include <geos/geom/LineSegment.h>
+#include <geos/geom/Envelope.h>
+
// Forward declarations
namespace geos {
- namespace geom {
- class Envelope;
- class LineSegment;
- }
namespace index {
namespace chain {
class MonotoneChain;
@@ -46,38 +45,40 @@
protected:
- geom::LineSegment *overlapSeg1;
+ geom::LineSegment overlapSeg1;
- geom::LineSegment *overlapSeg2;
+ geom::LineSegment overlapSeg2;
public:
- MonotoneChainOverlapAction();
+ MonotoneChainOverlapAction() {};
- virtual ~MonotoneChainOverlapAction();
+ virtual ~MonotoneChainOverlapAction() {};
/**
* This function can be overridden if the original chains are needed
*
- * @param start1 the index of the start of the overlapping segment from mc1
- * @param start2 the index of the start of the overlapping segment from mc2
+ * @param start1 the index of the start of the overlapping segment
+ * from mc1
+ * @param start2 the index of the start of the overlapping segment
+ * from mc2
*/
- virtual void overlap(MonotoneChain *mc1, int start1,
- MonotoneChain *mc2, int start2);
+ virtual void overlap(MonotoneChain& mc1, size_t start1,
+ MonotoneChain& mc2, size_t start2);
/**
- * This is a convenience function which can be overridden to obtain the actual
- * line segments which overlap
+ * This is a convenience function which can be overridden to
+ * obtain the actual line segments which overlap
* @param seg1
* @param seg2
*/
- virtual void overlap(geom::LineSegment* /*newSeg1*/,
- geom::LineSegment* /*newSeg2*/)
+ virtual void overlap(const geom::LineSegment& /*seg1*/,
+ const geom::LineSegment& /*seg2*/)
{}
// these envelopes are used during the MonotoneChain search process
- geom::Envelope *tempEnv1;
- geom::Envelope *tempEnv2;
+ geom::Envelope tempEnv1;
+ geom::Envelope tempEnv2;
};
} // namespace geos::index::chain
Modified: trunk/source/headers/geos/noding/MCIndexNoder.h
===================================================================
--- trunk/source/headers/geos/noding/MCIndexNoder.h 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/headers/geos/noding/MCIndexNoder.h 2009-05-06 17:42:58 UTC (rev 2479)
@@ -95,18 +95,13 @@
public:
SegmentOverlapAction(SegmentIntersector& newSi)
:
+ index::chain::MonotoneChainOverlapAction(),
si(newSi)
{}
- void overlap(index::chain::MonotoneChain* mc1, int start1,
- index::chain::MonotoneChain* mc2, int start2);
+ void overlap(index::chain::MonotoneChain& mc1, size_t start1,
+ index::chain::MonotoneChain& mc2, size_t start2);
- void overlap(geom::LineSegment* s1, geom::LineSegment* s2)
- {
- UNREFERENCED_PARAMETER(s1);
- UNREFERENCED_PARAMETER(s2);
- assert(0);
- }
};
};
Modified: trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h
===================================================================
--- trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/headers/geos/noding/MCIndexSegmentSetMutualIntersector.h 2009-05-06 17:42:58 UTC (rev 2479)
@@ -78,10 +78,13 @@
public:
SegmentOverlapAction(SegmentIntersector & si)
- : si(si)
+ :
+ index::chain::MonotoneChainOverlapAction(),
+ si(si)
{}
- void overlap(index::chain::MonotoneChain* mc1, int start1, index::chain::MonotoneChain* mc2, int start2);
+ void overlap(index::chain::MonotoneChain& mc1, size_t start1,
+ index::chain::MonotoneChain& mc2, size_t start2);
};
private:
Modified: trunk/source/index/chain/MonotoneChain.cpp
===================================================================
--- trunk/source/index/chain/MonotoneChain.cpp 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/index/chain/MonotoneChain.cpp 2009-05-06 17:42:58 UTC (rev 2479)
@@ -61,7 +61,7 @@
}
void
-MonotoneChain::getLineSegment(unsigned int index, LineSegment& ls) const
+MonotoneChain::getLineSegment(size_t index, LineSegment& ls) const
{
ls.p0 = pts[index];
ls.p1 = pts[index+1];
@@ -127,14 +127,14 @@
void
MonotoneChain::computeOverlaps(size_t start0, size_t end0,
MonotoneChain& mc,
- int start1, int end1,
+ size_t start1, size_t end1,
MonotoneChainOverlapAction& mco)
{
//Debug.println("computeIntersectsForChain:"+p00+p01+p10+p11);
// terminating condition for the recursion
if (end0-start0==1 && end1-start1==1)
{
- mco.overlap(this, start0, &mc, start1);
+ mco.overlap(*this, start0, mc, start1);
return;
}
@@ -144,9 +144,9 @@
const Coordinate& p11 = mc.pts[end1];
// nothing to do if the envelopes of these chains don't overlap
- mco.tempEnv1->init(p00, p01);
- mco.tempEnv2->init(p10, p11);
- if (!mco.tempEnv1->intersects(mco.tempEnv2)) return;
+ mco.tempEnv1.init(p00, p01);
+ mco.tempEnv2.init(p10, p11);
+ if (!mco.tempEnv1.intersects(mco.tempEnv2)) return;
// the chains overlap,so split each in half and iterate (binary search)
size_t mid0=(start0+end0)/2;
Modified: trunk/source/index/chain/MonotoneChainOverlapAction.cpp
===================================================================
--- trunk/source/index/chain/MonotoneChainOverlapAction.cpp 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/index/chain/MonotoneChainOverlapAction.cpp 2009-05-06 17:42:58 UTC (rev 2479)
@@ -29,28 +29,12 @@
namespace index { // geos.index
namespace chain { // geos.index.chain
-MonotoneChainOverlapAction::MonotoneChainOverlapAction() {
- overlapSeg1=new geom::LineSegment();
- overlapSeg2=new geom::LineSegment();
- tempEnv1=new geom::Envelope();
- tempEnv2=new geom::Envelope();
-
-}
-
-MonotoneChainOverlapAction::~MonotoneChainOverlapAction() {
- delete overlapSeg1;
- delete overlapSeg2;
- delete tempEnv1;
- delete tempEnv2;
-}
-
-
void
-MonotoneChainOverlapAction::overlap(MonotoneChain *mc1, int start1,
- MonotoneChain *mc2, int start2)
+MonotoneChainOverlapAction::overlap(MonotoneChain& mc1, size_t start1,
+ MonotoneChain& mc2, size_t start2)
{
- mc1->getLineSegment(start1, *overlapSeg1);
- mc2->getLineSegment(start2, *overlapSeg2);
+ mc1.getLineSegment(start1, overlapSeg1);
+ mc2.getLineSegment(start2, overlapSeg2);
overlap(overlapSeg1, overlapSeg2);
}
Modified: trunk/source/noding/MCIndexNoder.cpp
===================================================================
--- trunk/source/noding/MCIndexNoder.cpp 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/noding/MCIndexNoder.cpp 2009-05-06 17:42:58 UTC (rev 2479)
@@ -136,16 +136,16 @@
}
void
-MCIndexNoder::SegmentOverlapAction::overlap(MonotoneChain* mc1, int start1,
- MonotoneChain* mc2, int start2)
+MCIndexNoder::SegmentOverlapAction::overlap(MonotoneChain& mc1, size_t start1,
+ MonotoneChain& mc2, size_t start2)
{
SegmentString* ss1 = const_cast<SegmentString*>(
- static_cast<const SegmentString *>(mc1->getContext())
+ static_cast<const SegmentString *>(mc1.getContext())
);
assert(ss1);
SegmentString* ss2 = const_cast<SegmentString*>(
- static_cast<const SegmentString *>(mc2->getContext())
+ static_cast<const SegmentString *>(mc2.getContext())
);
assert(ss2);
Modified: trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp
===================================================================
--- trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp 2009-05-06 17:14:27 UTC (rev 2478)
+++ trunk/source/noding/MCIndexSegmentSetMutualIntersector.cpp 2009-05-06 17:42:58 UTC (rev 2479)
@@ -150,10 +150,11 @@
void
-MCIndexSegmentSetMutualIntersector::SegmentOverlapAction::overlap( MonotoneChain * mc1, int start1, MonotoneChain * mc2, int start2)
+MCIndexSegmentSetMutualIntersector::SegmentOverlapAction::overlap(
+ MonotoneChain& mc1, size_t start1, MonotoneChain& mc2, size_t start2)
{
- SegmentString * ss1 = (SegmentString *)(mc1->getContext());
- SegmentString * ss2 = (SegmentString *)(mc2->getContext());
+ SegmentString * ss1 = (SegmentString *)(mc1.getContext());
+ SegmentString * ss2 = (SegmentString *)(mc2.getContext());
si.processIntersections(ss1, start1, ss2, start2);
}
More information about the geos-commits
mailing list