VR-Vantage API Documentation
DtIntersector.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2008 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtIntersector.h,v $ $Revision: 1.9 $ $State: Exp $
7 ******************************************************************************/
8 
13 
14 #pragma once
15 #include <vrvCore/vrvCore.h>
16 #include <vrvCore/DtUniqueID.h>
18 #include <boost/unordered_map.hpp>
19 #include <vector>
20 
21 namespace makVrv
22 {
23  class DtDe;
24  class DtChannel;
25 
29  {
30  public:
31  // For this purpose, a triangle is described as 9 doubles; x0, y0, z0,
32  // x1, x2, etc...
33  typedef std::vector<double> DtIntersectTriangle;
34 
35  public:
38 
40  DtIntersectorResult( double x, double y, double z,
41  double normalX, double normalY, double normalZ, const DtUniqueID& id);
42 
45 
47  DtIntersectorResult& operator=( const DtIntersectorResult& orig );
48 
50  bool operator==(const DtIntersectorResult&) const;
51 
53  bool operator!=(const DtIntersectorResult& rhs) const
54  {
55  return !(*this == rhs);
56  }
57 
58  public:
59 
61  double x;
62 
64  double y;
65 
67  double z;
68 
71  double normalX;
72 
75  double normalY;
76 
79  double normalZ;
80 
83 
86  };
87 
92  {
93  public:
94 
98  {
99  AllNodes = 0,
100  PickableNodes = 1,
101  SupportNodes = 2,
102  NodesThatReceivesShadows = 4,
103  NodesThatCastsShadows = 8
104  };
105 
107  typedef std::vector<DtIntersectorResult> DtIntersections;
108 
110  DtIntersector( DtDe& de );
111 
113  virtual ~DtIntersector();
114 
129  virtual bool findNearestIntersectionToPoint(double x, double y, double z,
130  double vx, double vy, double vz, DtIntersectorResult& intersection,
131  IntersectProperties properties = AllNodes,
132  std::vector<DtElementID>* ignoreList = 0, bool returnTriangle = false,
133  double maxIsectorLength = -1., bool useHighLod = false ) = 0;
134 
142  virtual bool findAllIntersectionsThroughPoint( double x, double y, double z,
143  double vx, double vy, double vz, DtIntersections& intersections,
144  IntersectProperties properties = AllNodes,
145  std::vector<DtElementID>* ignoreList = 0, bool sort = true,
146  bool useHighLod = false ) = 0;
147 
154  virtual bool findFirstIntersectWithLineSegment(
155  double x, double y, double z, double end_x, double end_y, double end_z,
156  DtIntersectorResult& intersection,
157  IntersectProperties properties=AllNodes,
158  std::vector<DtElementID>* ignoreList=0,
159  bool useHighLod = false) = 0;
160 
167  virtual bool findAllIntersectWithLineSegment(
168  double x, double y, double z, double end_x, double end_y, double end_z,
169  DtIntersections& intersections,
170  IntersectProperties properties=AllNodes,
171  std::vector<DtElementID>* ignoreList=0, bool sort=true,
172  bool useHighLod = false ) = 0;
173 
179  virtual bool pick( DtChannel& channel, double mx, double my,
180  DtIntersectorResult& intersection,
181  IntersectProperties properties=AllNodes,
182  std::vector<DtElementID>* ignoreList=0) = 0;
183 
188  virtual bool pickAll( DtChannel* channel, double mx, double my,
189  DtIntersections& intersections,
190  IntersectProperties properties=AllNodes,
191  std::vector<DtElementID>* ignoreList=0) = 0;
192 
193  protected:
195 
198  struct CachedPick
199  {
201  : simTime(0.0)
202  , channel(0)
203  , mx(0)
204  , my(0)
205  , properties(DtIntersector::AllNodes)
206  , ignoreList(0)
207  {
208  }
209 
210  bool operator==(const CachedPick& b)
211  {
212  return simTime == b.simTime &&
213  channel == b.channel &&
214  mx == b.mx &&
215  my == b.my &&
216  properties == b.properties &&
217  ignoreList == b.ignoreList;
218  }
219 
220  double simTime;
222  double mx;
223  double my;
225  std::vector<DtElementID>* ignoreList;
226  };
227 
231 
232  };
233 
237  {
238  public:
239 
242  static DtIntersectorManager& instance(DtDe& de);
243 
245  static void registerInstance(DtDe& de, DtIntersectorManager* anInstance);
246 
248  DtIntersector& modelSetIntersector(int modelSet);
249 
250  protected:
252 
253  protected:
254  typedef boost::unordered_map<int, DtIntersector*> IntersectorMap;
257  };
258 
262  {
263  public:
264 
267  static DtIntersectorCreator& instance(DtDe& de);
268 
270  static void registerInstance(DtDe& de, DtIntersectorCreator* anInstance);
271 
273  virtual DtIntersector* create( DtDe& de, int modelSet ) = 0;
274  };
275 }


Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)