GEOS
3.3.7
|
00001 /********************************************************************** 00002 * $Id: SnapOverlayOp.h 3538 2011-12-09 10:44:54Z strk $ 00003 * 00004 * GEOS - Geometry Engine Open Source 00005 * http://geos.refractions.net 00006 * 00007 * Copyright (C) 2009 Sandro Santilli <strk@keybit.net> 00008 * 00009 * This is free software; you can redistribute and/or modify it under 00010 * the terms of the GNU Lesser General Public Licence as published 00011 * by the Free Software Foundation. 00012 * See the COPYING file for more information. 00013 * 00014 *********************************************************************** 00015 * 00016 * Last port: operation/overlay/snap/SnapOverlayOp.java r320 (JTS-1.12) 00017 * 00018 **********************************************************************/ 00019 00020 #ifndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H 00021 #define GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H 00022 00023 #include <geos/operation/overlay/OverlayOp.h> // for enums 00024 #include <geos/precision/CommonBitsRemover.h> // for dtor visibility by auto_ptr 00025 00026 #include <memory> // for auto_ptr 00027 00028 #ifdef _MSC_VER 00029 #pragma warning(push) 00030 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class 00031 #endif 00032 00033 // Forward declarations 00034 namespace geos { 00035 namespace geom { 00036 class Geometry; 00037 struct GeomPtrPair; 00038 } 00039 } 00040 00041 namespace geos { 00042 namespace operation { // geos::operation 00043 namespace overlay { // geos::operation::overlay 00044 namespace snap { // geos::operation::overlay::snap 00045 00057 class GEOS_DLL SnapOverlayOp 00058 { 00059 00060 public: 00061 00062 static std::auto_ptr<geom::Geometry> 00063 overlayOp(const geom::Geometry& g0, const geom::Geometry& g1, 00064 OverlayOp::OpCode opCode) 00065 { 00066 SnapOverlayOp op(g0, g1); 00067 return op.getResultGeometry(opCode); 00068 } 00069 00070 static std::auto_ptr<geom::Geometry> 00071 intersection(const geom::Geometry& g0, const geom::Geometry& g1) 00072 { 00073 return overlayOp(g0, g1, OverlayOp::opINTERSECTION); 00074 } 00075 00076 static std::auto_ptr<geom::Geometry> 00077 Union(const geom::Geometry& g0, const geom::Geometry& g1) 00078 { 00079 return overlayOp(g0, g1, OverlayOp::opUNION); 00080 } 00081 00082 static std::auto_ptr<geom::Geometry> 00083 difference(const geom::Geometry& g0, const geom::Geometry& g1) 00084 { 00085 return overlayOp(g0, g1, OverlayOp::opDIFFERENCE); 00086 } 00087 00088 static std::auto_ptr<geom::Geometry> 00089 symDifference(const geom::Geometry& g0, const geom::Geometry& g1) 00090 { 00091 return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE); 00092 } 00093 00094 SnapOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2) 00095 : 00096 geom0(g1), 00097 geom1(g2) 00098 { 00099 computeSnapTolerance(); 00100 } 00101 00102 00103 typedef std::auto_ptr<geom::Geometry> GeomPtr; 00104 00105 GeomPtr getResultGeometry(OverlayOp::OpCode opCode); 00106 00107 private: 00108 00109 void computeSnapTolerance(); 00110 00111 void snap(geom::GeomPtrPair& ret); 00112 00113 void removeCommonBits(const geom::Geometry& geom0, 00114 const geom::Geometry& geom1, 00115 geom::GeomPtrPair& ret); 00116 00117 // re-adds common bits to the given geom 00118 void prepareResult(geom::Geometry& geom); 00119 00120 00121 const geom::Geometry& geom0; 00122 const geom::Geometry& geom1; 00123 00124 double snapTolerance; 00125 00126 std::auto_ptr<precision::CommonBitsRemover> cbr; 00127 00128 // Declare type as noncopyable 00129 SnapOverlayOp(const SnapOverlayOp& other); 00130 SnapOverlayOp& operator=(const SnapOverlayOp& rhs); 00131 }; 00132 00133 } // namespace geos::operation::overlay::snap 00134 } // namespace geos::operation::overlay 00135 } // namespace geos::operation 00136 } // namespace geos 00137 00138 #ifdef _MSC_VER 00139 #pragma warning(pop) 00140 #endif 00141 00142 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H 00143 00144 /********************************************************************** 00145 * $Log$ 00146 **********************************************************************/ 00147