1 /**********************************************************************
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
6 * Copyright (C) 2006 Refractions Research Inc.
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
13 **********************************************************************
15 * Last port: noding/IntersectionFinderAdder.java rev. 1.5 (JTS-1.9)
17 **********************************************************************/
21 #include <geos/noding/IntersectionFinderAdder.h>
22 #include <geos/noding/SegmentString.h>
23 #include <geos/noding/NodedSegmentString.h>
24 #include <geos/algorithm/LineIntersector.h>
25 #include <geos/geom/Coordinate.h>
27 using namespace geos::geom
;
30 namespace noding
{ // geos.noding
33 IntersectionFinderAdder::processIntersections(
34 SegmentString
* e0
, int segIndex0
,
35 SegmentString
* e1
, int segIndex1
)
37 // don't bother intersecting a segment with itself
38 if (e0
== e1
&& segIndex0
== segIndex1
) return;
40 const Coordinate
& p00
= e0
->getCoordinate(segIndex0
);
41 const Coordinate
& p01
= e0
->getCoordinate(segIndex0
+ 1);
42 const Coordinate
& p10
= e1
->getCoordinate(segIndex1
);
43 const Coordinate
& p11
= e1
->getCoordinate(segIndex1
+ 1);
45 li
.computeIntersection(p00
, p01
, p10
, p11
);
46 //if (li.hasIntersection() && li.isProper()) Debug.println(li);
48 if (li
.hasIntersection())
50 if (li
.isInteriorIntersection())
52 for (int intIndex
=0, n
=li
.getIntersectionNum(); intIndex
<n
; intIndex
++)
54 interiorIntersections
.push_back(li
.getIntersection(intIndex
));
57 NodedSegmentString
* ee0
= dynamic_cast<NodedSegmentString
*>(e0
);
58 NodedSegmentString
* ee1
= dynamic_cast<NodedSegmentString
*>(e1
);
60 ee0
->addIntersections(&li
, segIndex0
, 0);
61 ee1
->addIntersections(&li
, segIndex1
, 1);
66 } // namespace geos.noding
69 /**********************************************************************
71 * Revision 1.3 2006/03/15 09:51:12 strk
72 * streamlined headers usage
74 * Revision 1.2 2006/02/19 19:46:49 strk
75 * Packages <-> namespaces mapping for most GEOS internal code (uncomplete, but working). Dir-level libs for index/ subdirs.
77 * Revision 1.1 2006/02/14 13:28:26 strk
78 * New SnapRounding code ported from JTS-1.7 (not complete yet).
79 * Buffer op optimized by using new snaprounding code.
80 * Leaks fixed in XMLTester.
82 **********************************************************************/