![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /******************************************************************************* 00002 ** Copyright (c) 2011 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *******************************************************************************/ 00005 00006 #pragma once 00007 00008 #include "gdb/rangeNetSegMet.h" 00009 #include "gdb/vecNetwrk.h" 00010 #include "gdb/netwrkSeg.h" 00011 #include "gdb/specification.h" 00012 #include <deque> 00013 00014 namespace BHAVE 00015 { 00016 typedef void (*DtProcessBoundingPolygonCallbackFcn)(std::deque<DtPoint> points, void* usr); 00017 00021 struct DtSegmentStruct 00022 { 00023 DtPoint leftOffset; 00024 DtPoint rightOffset; 00025 double halfWidth; 00026 unsigned int segmentId; 00027 unsigned int firstNodeId; 00028 unsigned int secondNodeId; 00029 const DtNetworkSegment* vectorSegment; 00030 00031 DtPoint leftFirstBP; 00032 DtPoint rightFirstBP; 00033 DtPoint leftSecondBP; 00034 DtPoint rightSecondBP; 00035 00036 DtPoint leftEnd; 00037 DtPoint rightEnd; 00038 00039 DtSegmentStruct(const DtNetworkSegment* seg) 00040 { 00041 vectorSegment = seg; 00042 leftEnd = vectorSegment->endpoint0(); 00043 rightEnd = vectorSegment->endpoint1(); 00044 } 00045 00046 DtPoint endPoint(int zeroOrOne) const 00047 { 00048 if (zeroOrOne) 00049 { 00050 return rightEnd; 00051 } 00052 else 00053 { 00054 return leftEnd; 00055 } 00056 } 00057 }; 00058 00062 struct DtSegmentNodeStruct 00063 { 00064 public: 00065 DtPoint location; 00066 std::map<unsigned int,int> segmentEnds; 00067 unsigned int nodeId; 00068 std::deque<DtPoint> boundingPoints; 00069 00070 DtSegmentNodeStruct(const DtPoint& point) 00071 { 00072 location = point; 00073 } 00074 00075 bool operator< (const DtSegmentNodeStruct& right) const 00076 { 00077 if (location.x() != right.location.x()) 00078 { 00079 return (location.x() < right.location.x()); 00080 } 00081 if (location.y() != right.location.y()) 00082 { 00083 return (location.y() < right.location.y()); 00084 } 00085 if (location.z() != right.location.z()) 00086 { 00087 return (location.z() < right.location.z()); 00088 } 00089 return false; 00090 } 00091 00092 bool operator==(const DtSegmentNodeStruct& other) const 00093 { 00094 return (location == other.location); 00095 } 00096 00097 bool operator!=(const DtSegmentNodeStruct& other) const 00098 { 00099 return (location == other.location); 00100 } 00101 }; 00102 00103 class DtVectorNetworkConverter 00104 { 00105 public: 00113 DtVectorNetworkConverter(const DtVectorNetwork* network, bool isGeocentric = false); 00114 virtual ~DtVectorNetworkConverter(); 00115 00121 virtual void init(const DtPoint& center, double distance = 0.0); 00122 00130 virtual bool processAllBoundingPolygons(DtProcessBoundingPolygonCallbackFcn func, void* usr) const; 00131 00132 00133 protected: 00134 00135 virtual bool isValidBoundingPolygon(const std::deque<DtPoint>& points) const; 00136 00152 // 00155 virtual bool calcSegmentPoints(DtSegmentStruct& segment); 00156 00163 virtual bool calcSlopeOfLine(const DtPoint& startPoint, const DtPoint& endPoint, double& slope) const; 00164 00172 // 00180 // 00181 // 00188 virtual bool calcIntersectionOfTwoArbSegs(const DtPoint& segOneA, const DtPoint& segOneB, 00189 const DtPoint& segTwoA, const DtPoint& segTwoB, DtPoint& result) const; 00190 00194 // 00199 // 00202 // 00206 virtual void calcEndNodePoints(DtSegmentNodeStruct& node, unsigned int segmentId, int segmentEnd); 00207 00216 // 00224 // 00230 virtual void calcTopNodePoints(DtSegmentNodeStruct& node, unsigned int segmentOneId, 00231 int segmentOneEnd, unsigned int segmentTwoId, int segmentTwoEnd); 00232 00240 virtual void generateNodesAndSegments(DtRangeNetworkSegmentMetric* metric); 00241 00245 virtual void calcNodeBoundingPoints(); 00246 00253 // 00263 // 00264 virtual bool calcOrthoOffset(const DtPoint& startPoint, const DtPoint& endPoint, double distance, 00265 DtPoint& leftOffset, DtPoint& rightOffset) const; 00266 00272 // 00276 // 00277 virtual bool findPointOnLine(const DtPoint& startPoint, 00278 const DtPoint& endPoint, DtPoint& result, double distance) const; 00279 00285 virtual bool addSegment(const DtNetworkSegment* seg); 00286 00294 virtual unsigned int addNode(const DtPoint& point, unsigned int segmentId, int endpoint); 00295 00300 // 00305 // 00306 // 00311 virtual double determineAngle(const DtPoint& centerPoint, const DtPoint& point, bool degrees = false) const; 00312 00313 const DtVectorNetwork* myNetwork; 00314 DtRangeNetworkSegmentMetric* myMetric; 00315 00317 std::map<DtSegmentNodeStruct, unsigned int> myNodeHistory; 00318 std::deque<DtSegmentNodeStruct> myNodes; 00319 std::deque<DtSegmentStruct> mySegments; 00320 00321 double myMinZ; 00322 double myMaxZ; 00323 00324 bool myIsGeocentric; 00325 }; 00326 00327 00328 }