VR-Forces 4.0.4 Class Documentation
include/geometry/polygonUtilities.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 2005 MAK Technologies, Inc.
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 /******************************************************************************
00006 ** $RCSfile: polygonUtilities.h,v $ $Revision: 1.8 $ $State: Exp $
00007 ******************************************************************************/
00008 #ifndef polygonUtilities_H_
00009 #define polygonUtilities_H_
00010 
00011 //
00012 // \file polygonUtilities.h
00013 // \brief Contains utility functions for interacting with/on DtGeometricPolygons.
00014 //
00015 #include "geometry/geometryDefines.h"
00016 #include <vlutil/vlConfig.h>
00017 #include <vector>
00018 
00019 class DtPoint;
00020 class DtCircle;
00021 class DtPolygon2D;
00022 class DtChord;
00023 class DtExtent;
00024 
00025 
00026 // Determines if the specified point is inside the specified polygon by performing 
00027 // and edge crossings test, originally presented by Eric Haines in Graphics Gems IV.
00028 //
00029 // \return A boolean indicating whether or not the pointToTest is inside the polygon
00030 // or not.  
00031 //
00032 // \note This function will work with concave polygons, as opposed to the pointInPolygonXy
00033 // function below, \see DtPointInPolygonXy, which is more efficient but only works 
00034 // with convex polygons.
00035 DT_DLL_geometry bool DtCrossingsTest(const DtPolygon2D& polygon, const DtPoint& pointToTest);
00036 
00037 
00038 // Determines if the specified point is inside the specified polygon in the XY plane.
00039 // Does this by creating and edge between the point and each vertex of the polygon
00040 // and testing the angle between that edge and the edges of the polygon to see if
00041 // the edge is interior to the polygon.  If this is true for all possible point-vertex
00042 // edges, then the point is inside the polygon.
00043 //
00044 // \return A boolean indicating whether or not the pointToTest is inside the polygon
00045 // or not.  
00046 //
00047 // \note It is most likely better to use the above function as it isn't always less
00048 // efficient and is better behaved when the input is not completely clean (convex, etc.)
00049 DT_DLL_geometry bool DtPointInPolygonInXy(const DtPolygon2D& polygon, const DtPoint& pointToTest);
00050 
00051 
00052 // Determines if the specified polygon and edge intersect, in the boolean sense.
00053 // \return A boolean specifying whether or not any piece of the edge, or the entire
00054 // edge, is inside the polygon.  
00055 // \note This function also handles the case where the polygon is concave.
00056 DT_DLL_geometry bool DtIntersectsInXy(const DtPolygon2D& polygon, const DtChord& chord);
00057 
00058 
00059 // Determines if the specified polygon and edge intersect, in the boolean sense, 
00060 // and returns through the specified input container, all the pieces of the edge
00061 // that are inside the polygon.  In the majority of cases, and always with convex
00062 // polygons, the container should have one edge.  However, when the polygon is 
00063 // concave, it might have several as the chord is "clipped" in several places by
00064 // the polygon.  If the chord is completely contained in the polygon, the function
00065 // returns true and the container will hold a copy of hte specified chord.
00066 //
00067 // \return A boolean specifying whether or not any piece of the edge, or the entire
00068 // edge, is inside the polygon.  
00069 // \note This function also handles the case where the polygon is concave.
00070 DT_DLL_geometry bool DtGetIntersectionInXy(const DtPolygon2D& polygon, const DtChord& chord, 
00071                            std::vector<DtChord>& chordPolyIntersection);
00072 
00073 
00074 // Determines if the specified polygons intersect, in the boolean sense.  
00075 // \return A boolean indicating whether or not there is \b any overlap of the two
00076 // polygons in the XY plane.  
00077 //
00078 // \note This means that if either polygon completely contains the other, they are considered
00079 // to intersect.  
00080 DT_DLL_geometry bool DtIntersectsInXy(const DtPolygon2D& polygon1, const DtPolygon2D& polygon2);
00081 
00082 
00083 // Determines if the specified chord intersects any of the \b edges of the specified
00084 // polygon, in the XY plane.
00085 //
00086 // \return A boolean indicating whether or not the chord intersects any of the
00087 // edges of the specified polygon. 
00088 //
00089 // \note This will \b return false if the chord is completely contained inside
00090 // the polygon.
00091 DT_DLL_geometry bool DtEdgesIntersectInXy(const DtPolygon2D& polygon, const DtChord& chord);
00092 
00093 
00094 DT_DLL_geometry bool DtPolygonContains(const DtPolygon2D& polygon1, const DtPolygon2D& polygon2);
00095 
00096 //bool DtIntersectsInXy(const DtCircle& circle, const DtPolygon2D& polygon);
00097 //
00098 //
00099 //bool DtBoundsInXy(const DtPolygon2D& boundingPolygon, const DtPolygon2D& polygonToTest);
00100 //
00101 //bool DtBoundsInXy(const DtCircle& boundingCircle, const DtPolygon2D& polygonToTest);
00102 
00103 
00104 #endif
00105 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)