OpenSceneGraph 3.6.5
PolytopeIntersector
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGUTIL_POLYTOPEINTERSECTOR
15#define OSGUTIL_POLYTOPEINTERSECTOR 1
16
18
19namespace osgUtil
20{
21
25{
26 public:
27
30
33
38 PolytopeIntersector(CoordinateFrame cf, double xMin, double yMin, double xMax, double yMax);
39
42
44 const osg::Polytope& getPolytope() const { return _polytope;}
45
46
48
50 {
56
57 bool operator < (const Intersection& rhs) const
58 {
59 if (distance < rhs.distance) return true;
60 if (rhs.distance < distance) return false;
61 if (primitiveIndex < rhs.primitiveIndex) return true;
62 if (rhs.primitiveIndex < primitiveIndex) return false;
63 if (nodePath < rhs.nodePath) return true;
64 if (rhs.nodePath < nodePath ) return false;
65 return (drawable < rhs.drawable);
66 }
67
69
70 double distance;
71 double maxDistance;
78 unsigned int primitiveIndex;
79 };
80
81 typedef std::set<Intersection> Intersections;
82
83 inline void insertIntersection(const Intersection& intersection) { getIntersections().insert(intersection); }
84
85 inline Intersections& getIntersections() { return _parent ? _parent->_intersections : _intersections; }
86
87 inline Intersection getFirstIntersection() { Intersections& intersections = getIntersections(); return intersections.empty() ? Intersection() : *(intersections.begin()); }
88
89
91 enum {
93 LINE_PRIMITIVES = (1<<1),
96 };
97
99 void setPrimitiveMask(unsigned int mask) { _primitiveMask = mask; }
100
102 unsigned int getPrimitiveMask() const { return _primitiveMask; }
103
109 inline void setReferencePlane(const osg::Plane& plane) { _referencePlane = plane; }
110
111 inline const osg::Plane& getReferencePlane() const { return _referencePlane; }
112
113#ifdef OSG_USE_DEPRECATED_API
114 enum {
115 DimZero = POINT_PRIMITIVES,
116 DimOne = LINE_PRIMITIVES,
117 DimTwo = TRIANGLE_PRIMITIVES,
118 AllDims = ALL_PRIMITIVES
119 };
120
122 inline void setDimensionMask(unsigned int mask) { setPrimitiveMask(mask); }
123
125 inline unsigned int getDimensionMask() const { return getPrimitiveMask(); }
126#endif
127
128public:
129
131
132 virtual bool enter(const osg::Node& node);
133
134 virtual void leave();
135
137
138 virtual void reset();
139
140 virtual bool containsIntersections() { return !getIntersections().empty(); }
141
142 protected:
143
145
147
148 unsigned int _primitiveMask;
150
152
153};
154
155}
156
157#endif
158
std::vector< Node * > NodePath
A vector of Nodes pointers which is used to describe the path from a root node to a descendant.
Definition Node:47
The osgUtil library provides general purpose utility classes such as update, cull and draw traverses,...
Definition NodeVisitor:25
Pure virtual base class for drawable geometry.
Definition Drawable:89
Base class for all internal nodes in the scene graph.
Definition Node:72
A plane class.
Definition Plane:34
Vec3d Vec3_type
Definition Plane:46
A Polytope class for representing convex clipping volumes made up of a set of planes.
Definition Polytope:26
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
CoordinateFrame
Definition IntersectionVisitor:38
Intersector(CoordinateFrame cf=MODEL, IntersectionLimit il=NO_LIMIT)
Definition IntersectionVisitor:53
IntersectionVisitor is used to testing for intersections with the scene, traversing the scene using g...
Definition IntersectionVisitor:152
osg::Plane _referencePlane
plane to use for sorting intersections
Definition PolytopeIntersector:149
@ TRIANGLE_PRIMITIVES
check for lines
Definition PolytopeIntersector:94
@ LINE_PRIMITIVES
check for points
Definition PolytopeIntersector:93
@ POINT_PRIMITIVES
Definition PolytopeIntersector:92
@ ALL_PRIMITIVES
check for triangles and other primitives like quad, polygons that can be decomposed into triangles
Definition PolytopeIntersector:95
PolytopeIntersector(CoordinateFrame cf, double xMin, double yMin, double xMax, double yMax)
Convenience constructor for supporting picking in WINDOW, or PROJECTION coordinates In WINDOW coordin...
virtual bool enter(const osg::Node &node)
std::set< Intersection > Intersections
Definition PolytopeIntersector:81
void setPrimitiveMask(unsigned int mask)
Set which Primitives should be tested for intersections.
Definition PolytopeIntersector:99
PolytopeIntersector(const osg::Polytope &polytope)
Construct a PolytopeIntersector using specified polytope in MODEL coordinates.
unsigned int _primitiveMask
mask which dimensions should be checked
Definition PolytopeIntersector:148
osg::Plane::Vec3_type Vec3_type
Definition PolytopeIntersector:47
void setReferencePlane(const osg::Plane &plane)
set the plane used to sort the intersections.
Definition PolytopeIntersector:109
unsigned int getPrimitiveMask() const
Get which Primitives should be tested for intersections.
Definition PolytopeIntersector:102
const osg::Polytope & getPolytope() const
Get the const Polytope used by the intersector.
Definition PolytopeIntersector:44
Intersection getFirstIntersection()
Definition PolytopeIntersector:87
Intersections _intersections
Definition PolytopeIntersector:151
const osg::Plane & getReferencePlane() const
Definition PolytopeIntersector:111
PolytopeIntersector * _parent
Definition PolytopeIntersector:144
osg::Polytope _polytope
Definition PolytopeIntersector:146
virtual bool containsIntersections()
Definition PolytopeIntersector:140
void insertIntersection(const Intersection &intersection)
Definition PolytopeIntersector:83
PolytopeIntersector(CoordinateFrame cf, const osg::Polytope &polytope)
Construct a PolytopeIntersector using specified polytope in specified coordinate frame.
virtual void intersect(osgUtil::IntersectionVisitor &iv, osg::Drawable *drawable)
osg::Polytope & getPolytope()
Get the Polytope used by the intersector.
Definition PolytopeIntersector:41
Intersections & getIntersections()
Definition PolytopeIntersector:85
virtual Intersector * clone(osgUtil::IntersectionVisitor &iv)
Definition PolytopeIntersector:50
Vec3_type localIntersectionPoint
center of all intersection points
Definition PolytopeIntersector:75
osg::ref_ptr< osg::RefMatrix > matrix
Definition PolytopeIntersector:74
unsigned int numIntersectionPoints
Definition PolytopeIntersector:76
@ MaxNumIntesectionPoints
Definition PolytopeIntersector:68
unsigned int primitiveIndex
primitive index
Definition PolytopeIntersector:78
double distance
distance from reference plane
Definition PolytopeIntersector:70
Vec3_type intersectionPoints[MaxNumIntesectionPoints]
Definition PolytopeIntersector:77
osg::NodePath nodePath
Definition PolytopeIntersector:72
double maxDistance
maximum distance of intersection points from reference plane
Definition PolytopeIntersector:71
osg::ref_ptr< osg::Drawable > drawable
Definition PolytopeIntersector:73
Intersection()
Definition PolytopeIntersector:51
#define OSGUTIL_EXPORT
Definition Export:40

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.