VR-Forces 4.1 Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
include
geometry
polygonUtilities.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2005 MAK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
/******************************************************************************
6
** $RCSfile: polygonUtilities.h,v $ $Revision: 1.8 $ $State: Exp $
7
******************************************************************************/
8
#ifndef polygonUtilities_H_
9
#define polygonUtilities_H_
10
11
//
12
// \file polygonUtilities.h
13
// \brief Contains utility functions for interacting with/on DtGeometricPolygons.
14
//
15
#include "
geometry/geometryDefines.h
"
16
#include <vlutil/vlConfig.h>
17
#include <vector>
18
19
class
DtPoint
;
20
class
DtCircle
;
21
class
DtPolygon2D
;
22
class
DtChord
;
23
class
DtExtent
;
24
25
26
// Determines if the specified point is inside the specified polygon by performing
27
// and edge crossings test, originally presented by Eric Haines in Graphics Gems IV.
28
//
29
// \return A boolean indicating whether or not the pointToTest is inside the polygon
30
// or not.
31
//
32
// \note This function will work with concave polygons, as opposed to the pointInPolygonXy
33
// function below, \see DtPointInPolygonXy, which is more efficient but only works
34
// with convex polygons.
35
DT_DLL_geometry
bool
DtCrossingsTest
(
const
DtPolygon2D
& polygon,
const
DtPoint
& pointToTest);
36
37
38
// Determines if the specified point is inside the specified polygon in the XY plane.
39
// Does this by creating and edge between the point and each vertex of the polygon
40
// and testing the angle between that edge and the edges of the polygon to see if
41
// the edge is interior to the polygon. If this is true for all possible point-vertex
42
// edges, then the point is inside the polygon.
43
//
44
// \return A boolean indicating whether or not the pointToTest is inside the polygon
45
// or not.
46
//
47
// \note It is most likely better to use the above function as it isn't always less
48
// efficient and is better behaved when the input is not completely clean (convex, etc.)
49
DT_DLL_geometry
bool
DtPointInPolygonInXy
(
const
DtPolygon2D
& polygon,
const
DtPoint
& pointToTest);
50
51
52
// Determines if the specified polygon and edge intersect, in the boolean sense.
53
// \return A boolean specifying whether or not any piece of the edge, or the entire
54
// edge, is inside the polygon.
55
// \note This function also handles the case where the polygon is concave.
56
DT_DLL_geometry
bool
DtIntersectsInXy
(
const
DtPolygon2D
& polygon,
const
DtChord
& chord);
57
58
59
// Determines if the specified polygon and edge intersect, in the boolean sense,
60
// and returns through the specified input container, all the pieces of the edge
61
// that are inside the polygon. In the majority of cases, and always with convex
62
// polygons, the container should have one edge. However, when the polygon is
63
// concave, it might have several as the chord is "clipped" in several places by
64
// the polygon. If the chord is completely contained in the polygon, the function
65
// returns true and the container will hold a copy of hte specified chord.
66
//
67
// \return A boolean specifying whether or not any piece of the edge, or the entire
68
// edge, is inside the polygon.
69
// \note This function also handles the case where the polygon is concave.
70
DT_DLL_geometry
bool
DtGetIntersectionInXy
(
const
DtPolygon2D
& polygon,
const
DtChord
& chord,
71
std::vector<DtChord>& chordPolyIntersection);
72
73
74
// Determines if the specified polygons intersect, in the boolean sense.
75
// \return A boolean indicating whether or not there is \b any overlap of the two
76
// polygons in the XY plane.
77
//
78
// \note This means that if either polygon completely contains the other, they are considered
79
// to intersect.
80
DT_DLL_geometry
bool
DtIntersectsInXy
(
const
DtPolygon2D
& polygon1,
const
DtPolygon2D
& polygon2);
81
82
83
// Determines if the specified chord intersects any of the \b edges of the specified
84
// polygon, in the XY plane.
85
//
86
// \return A boolean indicating whether or not the chord intersects any of the
87
// edges of the specified polygon.
88
//
89
// \note This will \b return false if the chord is completely contained inside
90
// the polygon.
91
DT_DLL_geometry
bool
DtEdgesIntersectInXy
(
const
DtPolygon2D
& polygon,
const
DtChord
& chord);
92
93
94
DT_DLL_geometry
bool
DtPolygonContains
(
const
DtPolygon2D
& polygon1,
const
DtPolygon2D
& polygon2);
95
96
//bool DtIntersectsInXy(const DtCircle& circle, const DtPolygon2D& polygon);
97
//
98
//
99
//bool DtBoundsInXy(const DtPolygon2D& boundingPolygon, const DtPolygon2D& polygonToTest);
100
//
101
//bool DtBoundsInXy(const DtCircle& boundingCircle, const DtPolygon2D& polygonToTest);
102
103
104
#endif
105
Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)