VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtOsgEarthBoundary.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2019 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 
11 #pragma once
12 
14 #include <osg/Node>
15 #include <osg/CoordinateSystemNode>
16 #include <osg/NodeVisitor>
17 
18 namespace makVrv
19 {
20 
26  {
27  public:
28 
31  class DT_DLL_VRVOSGEARTH VertexCollectionVisitor : public osg::NodeVisitor
32  {
33  public:
34 
38  VertexCollectionVisitor(bool geocentric = false, TraversalMode traversalMode = TRAVERSE_ALL_CHILDREN);
39 
41  virtual void reset();
42 
44  osg::Vec3dArray* getVertices() { return _vertices.get(); }
45 
47  void apply(osg::Node& node);
48 
50  void apply(osg::Transform& transform);
51 
53  void apply(osg::Geode& geode);
54 
56  inline void pushMatrix(osg::Matrix& matrix) { _matrixStack.push_back(matrix); }
57 
59  inline void popMatrix() { _matrixStack.pop_back(); }
60 
62  void applyDrawable(osg::Drawable* drawable);
63 
64  protected:
65 
66  typedef std::vector<osg::Matrix> MatrixStack;
67 
72 
73  void addVertex(osg::Vec3 vertex);
74  };
75 
78 
80  static void setTolerance(double meters);
81 
83  static double getTolerance() { return myTolerance; }
84 
86  static osg::Vec3dArray* getBoundary(osg::Node* modelNode, bool geocentric = true, bool convexHull = false);
87 
90  static osg::Vec3dArray* findHull(osg::Vec3dArray& points);
91 
95  static osg::Vec3dArray* findMeshBoundary(osg::Node* modelNode, bool geocentric = true);
96 
97  protected:
99  static osg::Vec3dArray* hullPresortPoints(osg::Vec3dArray& points);
100 
107  static inline float isLeft(osg::Vec3d P0, osg::Vec3d P1, osg::Vec3d P2)
108  {
109  return (P1.x() - P0.x())*(P2.y() - P0.y()) - (P2.x() - P0.x())*(P1.y() - P0.y());
110  }
111 
112  static double myTolerance;
113 
114  private:
118  DtOsgEarthBoundary &operator=(const DtOsgEarthBoundary&);
119  };
120 }
VertexCollectionVisitor.
Definition: DtOsgEarthBoundary.h:31
osg::Vec3dArray * getVertices()
Resets the visitor for next use.
Definition: DtOsgEarthBoundary.h:44
DtOsgEarthBoundary.
Definition: DtOsgEarthBoundary.h:25
#define DT_DLL_VRVOSGEARTH
Definition: vrvOsgEarth.h:21
void popMatrix()
Pops the matrix into matrix stack.
Definition: DtOsgEarthBoundary.h:59
bool _geocentric
Definition: DtOsgEarthBoundary.h:70
static float isLeft(osg::Vec3d P0, osg::Vec3d P1, osg::Vec3d P2)
Tests if a point is Left|On|Right of an infinite line Returns: &gt;0 for P2 left of the line through P0 ...
Definition: DtOsgEarthBoundary.h:107
MatrixStack _matrixStack
Definition: DtOsgEarthBoundary.h:69
std::vector< osg::Matrix > MatrixStack
Definition: DtOsgEarthBoundary.h:66
void pushMatrix(osg::Matrix &matrix)
Pushes the matrix into matrix stack.
Definition: DtOsgEarthBoundary.h:56
osg::ref_ptr< osg::EllipsoidModel > _ellipsoidModel
Definition: DtOsgEarthBoundary.h:71
static double myTolerance
Definition: DtOsgEarthBoundary.h:112
static double getTolerance()
Gets the tolerance when combining close verts. Default = 0.01.
Definition: DtOsgEarthBoundary.h:83
Contains DLL export macros.
osg::ref_ptr< osg::Vec3dArray > _vertices
Definition: DtOsgEarthBoundary.h:68

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)