Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

SnapOverlayOp.h

00001 /**********************************************************************
00002  * $Id$
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 rev 1.4 (JTS-1.10)
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 // Forward declarations
00029 namespace geos {
00030         namespace geom {
00031                 class Geometry;
00032         }
00033 }
00034 
00035 namespace geos {
00036 namespace operation { // geos::operation
00037 namespace overlay { // geos::operation::overlay
00038 namespace snap { // geos::operation::overlay::snap
00039 
00051 class GEOS_DLL SnapOverlayOp
00052 {
00053 
00054 public:
00055 
00056         static std::auto_ptr<geom::Geometry>
00057         overlayOp(const geom::Geometry& g0, const geom::Geometry& g1,
00058                   OverlayOp::OpCode opCode)
00059         {
00060                 SnapOverlayOp op(g0, g1);
00061                 return op.getResultGeometry(opCode);
00062         }
00063 
00064         static std::auto_ptr<geom::Geometry>
00065         intersection(const geom::Geometry& g0, const geom::Geometry& g1)
00066         {
00067                 return overlayOp(g0, g1, OverlayOp::opINTERSECTION);
00068         }
00069 
00070         static std::auto_ptr<geom::Geometry>
00071         Union(const geom::Geometry& g0, const geom::Geometry& g1)
00072         {
00073                 return overlayOp(g0, g1, OverlayOp::opUNION);
00074         }
00075 
00076         static std::auto_ptr<geom::Geometry>
00077         difference(const geom::Geometry& g0, const geom::Geometry& g1)
00078         {
00079                 return overlayOp(g0, g1, OverlayOp::opDIFFERENCE);
00080         }
00081 
00082         static std::auto_ptr<geom::Geometry>
00083         symDifference(const geom::Geometry& g0, const geom::Geometry& g1)
00084         {
00085                 return overlayOp(g0, g1, OverlayOp::opSYMDIFFERENCE);
00086         }
00087 
00088         SnapOverlayOp(const geom::Geometry& g1, const geom::Geometry& g2)
00089                 :
00090                 geom0(g1),
00091                 geom1(g2)
00092         {
00093                 computeSnapTolerance();
00094         }
00095 
00096         
00097         typedef std::auto_ptr<geom::Geometry> GeomPtr;
00098 
00099         GeomPtr getResultGeometry(OverlayOp::OpCode opCode);
00100 
00101 private:
00102 
00103         void computeSnapTolerance();
00104 
00105         typedef std::pair<GeomPtr, GeomPtr> GeomPtrPair;
00106 
00107         void snap(GeomPtrPair& ret);
00108 
00109         void removeCommonBits(const geom::Geometry& geom0,
00110                               const geom::Geometry& geom1, GeomPtrPair& ret);
00111 
00112         // re-adds common bits to the given geom
00113         void prepareResult(geom::Geometry& geom);
00114 
00115 
00116         const geom::Geometry& geom0;
00117         const geom::Geometry& geom1;
00118 
00119         double snapTolerance;
00120 
00121         std::auto_ptr<precision::CommonBitsRemover> cbr;
00122 };
00123  
00124 
00125 } // namespace geos::operation::overlay::snap
00126 } // namespace geos::operation::overlay
00127 } // namespace geos::operation
00128 } // namespace geos
00129 
00130 #endif // ndef GEOS_OP_OVERLAY_SNAP_SNAPOVERLAYOP_H
00131 
00132 /**********************************************************************
00133  * $Log$
00134  **********************************************************************/
00135 

Generated on Thu Jun 11 06:17:02 2009 for GEOS by  doxygen 1.4.4