1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
/**********************************************************************
* $Id: IntersectionAdder.cpp 1820 2006-09-06 16:54:23Z mloskot $
*
* GEOS - Geometry Engine Open Source
* http://geos.refractions.net
*
* Copyright (C) 2006 Refractions Research Inc.
*
* This is free software; you can redistribute and/or modify it under
* the terms of the GNU Lesser General Licence as published
* by the Free Software Foundation.
* See the COPYING file for more information.
*
**********************************************************************
*
* Last port: noding/IntersectionAdder.java rev. 1.4 (JTS-1.7)
*
**********************************************************************/
#include <geos/noding/IntersectionAdder.h>
#include <geos/noding/SegmentString.h>
#include <geos/algorithm/LineIntersector.h>
#include <geos/geom/Coordinate.h>
using namespace geos::geom;
namespace geos {
namespace noding { // geos.noding
/*private*/
bool
IntersectionAdder::isTrivialIntersection(const SegmentString* e0,
int segIndex0, const SegmentString* e1, int segIndex1)
{
if (e0 != e1) return false;
if (li.getIntersectionNum() != 1) return false;
if (isAdjacentSegments(segIndex0, segIndex1)) return true;
if (! e0->isClosed()) return false;
int maxSegIndex = e0->size() - 1;
if ( (segIndex0 == 0 && segIndex1 == maxSegIndex)
|| (segIndex1 == 0 && segIndex0 == maxSegIndex) )
{
return true;
}
return false;
}
/*public*/
void
IntersectionAdder::processIntersections(
SegmentString* e0, int segIndex0,
SegmentString* e1, int segIndex1)
{
// don't bother intersecting a segment with itself
if (e0 == e1 && segIndex0 == segIndex1) return;
numTests++;
const Coordinate& p00 = e0->getCoordinate(segIndex0);
const Coordinate& p01 = e0->getCoordinate(segIndex0 + 1);
const Coordinate& p10 = e1->getCoordinate(segIndex1);
const Coordinate& p11 = e1->getCoordinate(segIndex1 + 1);
li.computeIntersection(p00, p01, p10, p11);
//if (li.hasIntersection() && li.isProper()) Debug.println(li);
// No intersection, nothing to do
if (! li.hasIntersection()) return;
//intersectionFound = true;
numIntersections++;
if (li.isInteriorIntersection())
{
numInteriorIntersections++;
hasInterior=true;
}
// if the segments are adjacent they have at least
// one trivial intersection,
// the shared endpoint. Don't bother adding it if it
// is the only intersection.
if (! isTrivialIntersection(e0, segIndex0, e1, segIndex1))
{
hasIntersectionVar = true;
e0->addIntersections(&li, segIndex0, 0);
e1->addIntersections(&li, segIndex1, 1);
if (li.isProper()) {
numProperIntersections++;
//Debug.println(li.toString());
//Debug.println(li.getIntersection(0));
//properIntersectionPoint = (Coordinate) li.getIntersection(0).clone();
hasProper = true;
hasProperInterior = true;
}
}
}
} // namespace geos.noding
} // namespace geos
/**********************************************************************
* $Log$
* Revision 1.3 2006/03/15 09:51:12 strk
* streamlined headers usage
*
* Revision 1.2 2006/02/19 19:46:49 strk
* Packages <-> namespaces mapping for most GEOS internal code (uncomplete, but working). Dir-level libs for index/ subdirs.
*
* Revision 1.1 2006/02/16 08:19:07 strk
* Missed from last commit
*
**********************************************************************/
|