Commit 5aa03098 authored by oscar's avatar oscar

提交代码

parent 38c4dcf6
Pipeline #1030 failed with stages
#ifndef __JFXMAP_MAPINTERFACE_HPP_
#define __JFXMAP_MAPINTERFACE_HPP_
#include "MapApi.hpp"
namespace jf {
enum class LaneType {
NotInvestigated = 0, // 未调查
NormalLane = 1, // 普通车道
EnterLane = 2, // 入口车道
ExitLane = 3, // 出口车道
ConnectLane = 4, // 连接车道
EmergencyLane = 5, // 应急车道
StopLane = 6, // 停车道
EmergencyStopLane = 7, // 紧急停车道
AcceleratingLane = 8, // 加速车道
DeceleratingLane = 9, // 减速车道
HazardLane = 10, // 避险车道
JunctionLane = 11, // 路口车道
TollStationLane = 12, // 收费站车道
CheckpointLane = 13, // 检查站车道
UTurnLane = 14, // 掉头车道
BusLane = 15, // 公交车道
TidalLane = 16, // 潮汐(可变) 车道
LocomotiveLane = 17, // 机车车道
LocomotiveParkingArea = 18, // 机车停车区
HOVHighLoadLane = 19, // HOV 高承载车道
NonMotorizedLane = 30, // 非机动车道
Sidewalk = 40, // 人行道
Ohters = 99, // 其它车道
};
enum class EdgeCrossType {
NotInvestigated = 0, // 未调查
Unable = 1, // 无法跨越
BidirecAble = 2, // 双方向跨越
LeftAble = 3, // 向左跨越
RightAble = 4, // 向右跨越
};
class MapInterface {
public:
MapInterface(const std::string &strPrjPath, const std::string strCfgPath);
~MapInterface();
public:
bool GetMapData(const Point &ptInLoc, double dCarAngle, int &nOutLaneCnt, int &nOutLaneNum, LaneType &nOutLaneType, EdgeCrossType &nOutLeftEdgeCrossType, EdgeCrossType &nOutRightEdgeCrossType, int &nOutSpeedLimit, double &dOutLaneAngle,
Point &ptOutFoot);
bool GetMapData(const Point &ptInLoc, double dCarAngle, long &lOutRaodId, std::vector<long> &vctlOutPreRoadId, std::vector<long> &vctlOutNxtRoadId, int &nLaneCnt, int &nOutLaneNum, LaneType &nOutLaneType, EdgeCrossType &nOutLeftEdgeCrossType,
EdgeCrossType &nOutRightEdgeCrossType, int &nOutSpeedLimit, double &dOutLaneAngle, Point &ptOutFoot);
private:
MapLib m_mlMapLib;
};
} // namespace jf
#endif
\ No newline at end of file
#include "MapInterface.hpp"
#include <cmath>
#include <iostream>
#include <limits>
namespace jf {
MapInterface::MapInterface(const std::string &strPrjPath, const std::string strCfgPath) { m_mlMapLib.Init(strPrjPath, strCfgPath); }
MapInterface::~MapInterface() {}
bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, int &nOutLaneCnt, int &nOutLaneNum, LaneType &nOutLaneType, EdgeCrossType &nOutLeftEdgeCrossType, EdgeCrossType &nOutRightEdgeCrossType, int &nOutSpeedLimit, double &dOutLaneAngle,
Point &ptOutFoot) {
long lRoadId;
std::vector<long> vctlPreRoadId = {};
std::vector<long> vctlNxtRoadId = {};
return GetMapData(ptInLoc, dCarAngle, lRoadId, vctlPreRoadId, vctlNxtRoadId, nOutLaneCnt, nOutLaneNum, nOutLaneType, nOutLeftEdgeCrossType, nOutRightEdgeCrossType, nOutSpeedLimit, dOutLaneAngle, ptOutFoot);
}
bool MapInterface::GetMapData(const Point &ptInLoc, double dCarAngle, long &lOutRaodId, std::vector<long> &vctlOutPreRoadId, std::vector<long> &vctlOutNxtRoadId, int &nOutLaneCnt, int &nOutLaneNum, LaneType &nOutLaneType,
EdgeCrossType &nOutLeftEdgeCrossType, EdgeCrossType &nOutRightEdgeCrossType, int &nOutSpeedLimit, double &dOutLaneAngle, Point &ptOutFoot) {
std::vector<HdLinkId> vcthlLinkIds = {};
std::vector<HdLaneId> vcthlLaneIds = {};
// Locate lane failed
if (false == m_mlMapLib.GetLocateLanes(ptInLoc, vcthlLinkIds, vcthlLaneIds)) {
nOutLaneCnt = 0;
nOutLaneNum = 0;
nOutLaneType = LaneType::NotInvestigated;
nOutLeftEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = ptInLoc;
//std::cout << "MapInterface::GetMapData(), Locate lane failed." << std::endl;
return false;
}
int nIndex = 0;
double dMinAngleDiff = std::numeric_limits<double>::max();
auto func_GetAngleDiff = [](double dAngle1, double dAngle2) { return std::min(std::abs(dAngle1 - dAngle2), 360 - std::abs((dAngle1 - dAngle2))); };
for (int i = 0; i < vcthlLinkIds.size(); i++) {
const HdLinkId &hlLinkId = vcthlLinkIds[i];
const HdLaneId &hlLaneId = vcthlLaneIds[i];
double dAzimuth = 0;
if (vcthlLinkIds.size() == 1) {
nIndex = i;
} else {
if (true == m_mlMapLib.GetLaneAzimuth(hlLinkId, hlLaneId, ptInLoc, dAzimuth) || true == m_mlMapLib.GetLinkStartAngle(hlLinkId, dAzimuth)) {
double dAngleDiff = func_GetAngleDiff(dCarAngle, dAzimuth);
if (dMinAngleDiff >= dAngleDiff) {
dMinAngleDiff = dAngleDiff;
nIndex = i;
}
}
}
}
lOutRaodId = vcthlLinkIds[nIndex].lValue;
std::vector<HdLinkId> vctliPLinkIds = {};
std::vector<HdLinkId> vctliNLinkIds = {};
m_mlMapLib.GetLinkPreNxt(vcthlLinkIds[nIndex], vctliPLinkIds, vctliNLinkIds);
for (int i = 0; i < vctliPLinkIds.size(); ++i) {
vctlOutPreRoadId.push_back(vctliPLinkIds.at(i).lValue);
}
for (int i = 0; i < vctliNLinkIds.size(); ++i) {
vctlOutNxtRoadId.push_back(vctliNLinkIds.at(i).lValue);
}
if (false == m_mlMapLib.GetLaneCnt(vcthlLinkIds[nIndex], nOutLaneCnt)) {
nOutLaneCnt = 0;
nOutLaneNum = 0;
nOutLaneType = LaneType::NotInvestigated;
nOutLeftEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get lane count failed." << std::endl;
return false;
}
if (false == m_mlMapLib.GetLaneNum(vcthlLinkIds[nIndex], vcthlLaneIds[nIndex], nOutLaneNum)) {
nOutLaneNum = 0;
nOutLaneType = LaneType::NotInvestigated;
nOutLeftEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get lane num failed." << std::endl;
return false;
}
if (false == m_mlMapLib.GetLaneType(vcthlLinkIds[nIndex], nOutLaneNum, (int &)nOutLaneType)) {
nOutLaneType = LaneType::NotInvestigated;
nOutLeftEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get lane type failed." << std::endl;
return false;
}
if (false == m_mlMapLib.GetLaneEdgeCrossType(vcthlLinkIds[nIndex], nOutLaneNum, true, (int &)nOutLeftEdgeCrossType)) {
nOutLeftEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get left lane edge cross failed." << std::endl;
return false;
}
if (false == m_mlMapLib.GetLaneEdgeCrossType(vcthlLinkIds[nIndex], nOutLaneNum, false, (int &)nOutRightEdgeCrossType)) {
nOutRightEdgeCrossType = EdgeCrossType::NotInvestigated;
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get right lane cross failed." << std::endl;
return false;
}
if (false == m_mlMapLib.GetLinkSpeedLimit(vcthlLinkIds[nIndex], nOutSpeedLimit)) {
nOutSpeedLimit = 0;
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get link speed failed." << std::endl;
return false;
}
if (false == m_mlMapLib.GetLaneAzimuth(vcthlLinkIds[nIndex], vcthlLaneIds[nIndex], ptInLoc, dOutLaneAngle)) {
dOutLaneAngle = 0.0;
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get lane angle failed." << std::endl;
return false;
}
int nSeqNum = 0;
if (false == m_mlMapLib.GetLaneNum(vcthlLinkIds[nIndex], vcthlLaneIds[nIndex], nSeqNum)) {
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get lane num failed." << std::endl;
return false;
} else {
std::vector<std::vector<double>> vctvdGeoLink = {};
double dDistance = 0;
if (false == m_mlMapLib.GetLaneGeoLink(vcthlLinkIds[nIndex], nSeqNum, vctvdGeoLink)) {
ptOutFoot = {};
//std::cout << "MapInterface::GetMapData(), get lane geolink failed." << std::endl;
return false;
} else {
if (false == m_mlMapLib.GetPerpendicularFoot(ptInLoc, vctvdGeoLink, ptOutFoot, dDistance)) {
ptOutFoot = {};
std::cout << "MapInterface::GetMapData(), get lane foot point failed." << std::endl;
return false;
}
};
}
return true;
}
} // namespace jf
\ No newline at end of file
#pragma once
#include"string"
#include"unordered_map"
using namespace std;
namespace OpenDrive
{
class Connection
{
public:
Connection();
Connection& operator= (const Connection &conn);
Connection(const Connection &conn);
void SetID(const char* id);
const char* GetID() const;
void SetIncomingRoad(const char* incomingRoad);
const char* GetIncomingRoad() const;
void SetConnectingRoad(const char* incomingRoad);
const char* GetConnectingRoad() const;
void SetContactPoint(const char* contactPoint);
const char* GetContactPoint() const;
void SetLaneLinkFromTo(const char* laneLinkFrom, const char* laneLinkTo);
string GetLaneLinkFrom(const char* laneLinkTo) const;
string GetLaneLinkTo(const char* laneLinkFrom) const;
~Connection();
private:
string _id;
string _incomingRoad;
string _connectingRoad;
string _contactPoint;
unordered_map<string, string> *_laneLinkFromTo;
};
}
#pragma once
#include "vector"
#include"string"
#include"glm/glm.hpp"
using namespace std;
namespace OpenDrive
{
enum EnOpcode
{
ODR_OPCODE_NONE = 0,
ODR_OPCODE_HEADER,
ODR_OPCODE_ROAD_HEADER,
ODR_OPCODE_ROAD_LINK,
ODR_OPCODE_ROAD_TYPE,
ODR_OPCODE_GEO_HEADER,
ODR_OPCODE_GEO_LINE,
ODR_OPCODE_GEO_SPIRAL,
ODR_OPCODE_GEO_ARC,
ODR_OPCODE_Elevation,
ODR_OPCODE_LANE_SECTION, // 10
ODR_OPCODE_LANE,
ODR_OPCODE_LANE_LINK,
ODR_OPCODE_LANE_WIDTH,
ODR_OPCODE_LANE_MATERIAL,
ODR_OPCODE_LANE_VISIBILITY,
ODR_OPCODE_SIGNAL,
ODR_OPCODE_LANE_VALIDITY,
ODR_OPCODE_SIGNAL_DEPEND,
ODR_OPCODE_CONTROLLER,
ODR_OPCODE_CONTROL_ENTRY, // 20
ODR_OPCODE_JUNCTION_HEADER,
ODR_OPCODE_JUNCTION_LINK,
ODR_OPCODE_JUNCTION_PRIORITY,
ODR_OPCODE_OBJECT,
ODR_OPCODE_USER_DATA,
ODR_OPCODE_JUNCTION_LANE_LINK,
ODR_OPCODE_CROSSFALL,
ODR_OPCODE_JUNCTION_CONTROL,
ODR_OPCODE_LANE_ROAD_MARK,
ODR_OPCODE_PREDECESSOR, // 30
ODR_OPCODE_SUCCESSOR,
ODR_OPCODE_LANES,
ODR_OPCODE_LANES_LEFT,
ODR_OPCODE_LANES_CENTER,
ODR_OPCODE_LANES_RIGHT,
ODR_OPCODE_PLANVIEW,
ODR_OPCODE_ELEV_PROFILE,
ODR_OPCODE_LATERAL_PROFILE,
ODR_OPCODE_OBJECTS,
ODR_OPCODE_SIGNALS, // 40
ODR_OPCODE_OPENDRIVE,
ODR_OPCODE_SUPERElevation,
ODR_OPCODE_GEO_POLY,
ODR_OPCODE_LANE_SPEED,
ODR_OPCODE_LANE_ACCESS,
ODR_OPCODE_LANE_HEIGHT,
ODR_OPCODE_CORNER_INERTIAL,
ODR_OPCODE_CORNER_ROAD,
ODR_OPCODE_CORNER_RELATIVE,
ODR_OPCODE_TUNNEL, // 50
ODR_OPCODE_BRIDGE,
ODR_OPCODE_SIGNAL_REFERENCE,
ODR_OPCODE_OBJECT_OUTLINE,
ODR_OPCODE_SURFACE,
ODR_OPCODE_SURFACE_CRG,
ODR_OPCODE_LANE_OFFSET,
ODR_OPCODE_GENERIC_NODE,
ODR_OPCODE_CORNER_LOCAL,
ODR_OPCODE_REPEAT,
ODR_OPCODE_GEO_PARAM_POLY, // 60
ODR_OPCODE_LANE_BORDER,
ODR_OPCODE_ROAD_SPEED,
ODR_OPCODE_GEO_REFERENCE,
ODR_OPCODE_LATERAL_SHAPE,
ODR_OPCODE_JUNCTION_GROUP,
ODR_OPCODE_JUNCTION_REFERENCE,
ODR_OPCODE_ROAD_MARK_TYPE,
ODR_OPCODE_ROAD_MARK_LINE,
ODR_OPCODE_PARKING_SPACE,
ODR_OPCODE_PARKING_SPACE_MARKING,
ODR_OPCODE_NEIGHBOR,
ODR_OPCODE_TRAFFIC_OBJECT = 2000,
ODR_OPCODE_RAILROAD_SWITCH
};
// GEOMETRY TYPE
enum EnGeometryType {
ODR_GEO_TYPE_LINE = 0,
ODR_GEO_TYPE_SPIRAL,
ODR_GEO_TYPE_ARC,
ODR_GEO_TYPE_POLY3
};
// ROAD MARK
enum EnRoadMark {
ODR_ROAD_MARK_NONE = 0,
ODR_ROAD_MARK_SOLID,
ODR_ROAD_MARK_SOLID_BOLD,
ODR_ROAD_MARK_BROKEN,
ODR_ROAD_MARK_SOLID_DOUBLE,
ODR_ROAD_MARK_BROKEN_BOLD,
ODR_ROAD_MARK_SOLID_YELLOW,
ODR_ROAD_MARK_SOLID_DOUBLE_YELLOW
};
enum EnRoadMarkType {
ODR_ROAD_MARK_TYPE_NONE = 0,
ODR_ROAD_MARK_TYPE_SOLID,
ODR_ROAD_MARK_TYPE_BROKEN,
ODR_ROAD_MARK_TYPE_SOLID_SOLID,
ODR_ROAD_MARK_TYPE_SOLID_BROKEN,
ODR_ROAD_MARK_TYPE_BROKEN_SOLID,
ODR_ROAD_MARK_TYPE_CURB
};
enum EnRoadMarkWeight {
ODR_ROAD_MARK_WEIGHT_NONE = 0,
ODR_ROAD_MARK_WEIGHT_STANDARD,
ODR_ROAD_MARK_WEIGHT_BOLD
};
enum EnRoadMarkColor {
ODR_ROAD_MARK_COLOR_NONE = 0,
ODR_ROAD_MARK_COLOR_STANDARD,
ODR_ROAD_MARK_COLOR_YELLOW,
ODR_ROAD_MARK_COLOR_RED,
ODR_ROAD_MARK_COLOR_WHITE
};
// LANE TYPE
enum EnLaneType {
ODR_LANE_TYPE_NONE = 0,
ODR_LANE_TYPE_DRIVING,
ODR_LANE_TYPE_STOP,
ODR_LANE_TYPE_SHOULDER,
ODR_LANE_TYPE_BIKING,
ODR_LANE_TYPE_SIDEWALK,
ODR_LANE_TYPE_BORDER,
ODR_LANE_TYPE_RESTRICTED,
ODR_LANE_TYPE_PARKING,
ODR_LANE_TYPE_MWY_ENTRY,
ODR_LANE_TYPE_MWY_EXIT,
ODR_LANE_TYPE_SPECIAL1,
ODR_LANE_TYPE_SPECIAL2,
ODR_LANE_TYPE_SPECIAL3,
ODR_LANE_TYPE_SPECIAL4,
ODR_LANE_TYPE_DRIVING_ROADWORKS,
ODR_LANE_TYPE_TRAM,
ODR_LANE_TYPE_RAIL
};
struct OdrInfo
{
char* _roadID = NULL;
char* _sectionID = NULL;
char* _laneID = NULL;
double _s = -1.0;
double _t = -1.0;
double _curvature = 0.0;
};
struct Position
{
double _s = 0.0;
double _x = 0.0;
double _y = 0.0;
double _direction = 0.0;
double _Elevation = 0.0;
double _crossfall = 0.0;
};
struct RoadWidth
{
double _s = 0.0;
double _roadWith = 0.0;
};
struct TurningAttr
{
double _s = 0.0;
double _turnRad = 0.0;
};
struct NearestDistance
{
double _leftLaneDistance = 0.0;
double _rightLaneDistance = 0.0;
double _leftRoadDistance = 0.0;
double _rightRoadDistance = 0.0;
};
//roadMark
struct LaneMark
{
EnRoadMarkColor _color;
EnRoadMarkType _type;
EnRoadMarkWeight _weight;
double _sOffset;
};
struct NearestRoadMark
{
LaneMark *_leftRoadMark = NULL;
LaneMark *_rightRoadMark = NULL;
};
struct LanePostion
{
double _s = 0.0;
double _x = 0.0;
double _y = 0.0;
};
struct PosXY
{
double _x = 0.0;
double _y = 0.0;
double _z = 0.0;
};
struct RoadProperty
{
bool _bRight = true;
vector<int> _vecLaneID;
EnLaneType _laneType = ODR_LANE_TYPE_NONE;
};
struct GeoCoordinatePoint
{
double _s = 0.0;
double _x = 0.0;
double _y = 0.0;
double _z = 0.0;
double _hdg = 0.0;
};
struct RoadPolygon
{
vector<Position> _vecPos;
};
struct SignalPos
{
string _id = "";
double _s = 0.0;
double _t = 0.0;
double _zOFF = 0.0;
double _x = 0.0;//相对于车的x坐标;
double _y = 0.0;//相对于车的y坐标;
};
struct LaneRelation
{
char* _roadID = NULL;
char* _sectionID = NULL;
char* _laneID = NULL;
};
// LANE TYPE
enum RoadDrivingAttr {
ODR_ROAD_TYPE_NONE =0,
ODR_ROAD_TYPE_STraightLine,
ODR_ROAD_TYPE_UTurning,
ODR_ROAD_TYPE_LTurning,
ODR_ROAD_TYPE_RTurning
};
struct LaneGeoCoordinage
{
int indx = 0;
vector<GeoCoordinatePoint> vecGeoLane;
};
/////////////////////////////////////////////////////
///////////////////车道规划;
/////////////////////////////////////////////////////
//路径规划中待扩展道路节点的ID、总距离_length、路径点序列_roadSeq等属性
struct RoadNode
{
char * _id = NULL;
double _length = 0.0;
double searchlength = 0.0;
std::vector <char *> _roadSeq;
double _duration = 0;
};
//路径规划中_length为待扩展道路节点到起点的总距离,通过此属性对待扩展道路节点进行排序
struct compare
{
bool operator()(const RoadNode& a, const RoadNode& b) const
{
return a._length > b._length;
}
};
//车道节点
struct LaneNode
{
char * _id = NULL;
char * _lane = NULL;
char * _section = NULL;
double _x = 0.0;
double _y = 0.0;
};
//车道级规划中的搜索节点
struct SearchNode
{
char * _id = NULL;
char * _section = NULL;
char * _lane = NULL;
double _length = 0.0;
double _x = 0.0;
double _y = 0.0;
int _count = 0;
int _sectionnum = 0;
int _roadnum = 0;
vector<LaneNode> _laneseq;
};
struct cmp_road {
bool operator ()(SearchNode x, SearchNode y)
{
if (x._roadnum == y._roadnum)
{
return x._count > y._count;
}
else return x._roadnum < y._roadnum;
}
};
struct cmp_section {
bool operator ()(SearchNode x, SearchNode y)
{
if (x._sectionnum == y._sectionnum)
{
return x._count > y._count;
}
else return x._sectionnum < y._sectionnum;
}
};
struct EventPos
{
double x = 0.0;
double y = 0.0;
};
struct Pathpoint
{
double x = 0.0;
double y = 0.0;
double z = 0.0;
double pith = 0.0;
double roll = 0.0;
double yaw = 0.0;
};
}
#pragma once
namespace OpenDrive
{
class Elevation
{
public:
Elevation();
void SetAValue(const double & value);
const double GetAValue() const;
void SetBValue(const double & value);
const double GetBBValue() const;
void SetCValue(const double & value);
const double GetCCValue() const;
void SetDValue(const double & value);
const double GetDValue() const;
void SetSValue(const double & value);
const double GetSValue() const;
Elevation& operator=(const Elevation &elev);
Elevation(const Elevation &elev);
~Elevation();
private:
double _a = 0.0;
double _b = 0;
double _c = 0;
double _d = 0;
double _s = 0;
};
}
#pragma once
#include"vector"
#include"string"
#include <sstream>
#include <iostream>
#include <limits>
#include <locale>
#include <windows.h>
#include"string"
#include"DataDefines.h"
#include"Elevation.h"
#include"LaneOffset.h"
using namespace std;
namespace OpenDrive
{
void QuickSort(vector<int> &vecData);
void QuickSort(vector<float> &vecData);
void QuickSort(vector<glm::dvec3> &vecData);//快速排序;
void QuickSort(vector<int> &vecData, int flag);//flag 0, 从小到大,1,从大到小。
void QuickSort(vector<int> &vecData, vector<string> &vecLaneID);
void QuickSort(vector<double> &vecData, vector<string> &vecSection);
string DoubleToString(const double &value);
bool GetComClockWise(const glm::dvec2 &p0, const glm::dvec2 &p1, const glm::dvec2 &p2);
//bool GetComClockWise(const glm::dvec3 &p0, const glm::dvec3 &p1, const glm::dvec3 &p2);
double GetLengthFromTwoPoints(const glm::dvec2 &p0, const glm::dvec2 &p1);
string IntToString(const long int &value);
void CalElevation(vector<GeoCoordinatePoint> &vecGeoCoor, const vector<Elevation*> *vecEle);
void CalLaneOffset(vector<GeoCoordinatePoint> &vecGeoCoor, const vector<LaneOffset*> *vecEle);
void CalElevation(GeoCoordinatePoint &geoCoor, const vector<Elevation*> *vecEle);
void CalLaneOffset(GeoCoordinatePoint &geoCoor, const vector<LaneOffset*> *vecEle);
double stringToDouble(string num);
vector<string> split(const string& s, const string& sep);
glm::dvec2 CalJointBetween(const glm::dvec2 &p0, const double &t0, const glm::dvec2 &p1, const double &t1);
double GetDirectionRad(const glm::dvec2 &vline1);
//bool IsInSidePolygon(const glm::vec2 &point, const vector<glm::dvec2> &vecData);
string TCHAR2STRING(TCHAR* str);
}
#pragma once
#include"DataDefines.h"
#include"vector"
#include"odrSpiral.h"
#include"glm/glm.hpp"
#include <glm/gtc/matrix_transform.hpp>
#include"Function.h"
using namespace std;
namespace OpenDrive
{
class Geometry
{
public:
Geometry();
Geometry(const Geometry &geo);
Geometry & operator = (const Geometry &geo);
double GetLaneDistanceFromLine(const double & longitude, const double &latitude, const double &slen);
double GetLaneDistanceFromArc(const double & longitude, const double &latitude, const double &slen);
double GetLaneDistanceFromSpiral(const double & longitude, const double &latitude, const double &slen);
bool GetNearestInfoFromLine(const double & longitude, const double &latitude,double &distance, glm::dvec2 & vec);
bool GetNearestInfoFromArc(const double & longitude, const double &latitude, double &distance, glm::dvec2 & vec);
bool GetNearestInfoFromSprial(const double & longitude, const double &latitude, double &distance, glm::dvec2 & vec);
bool GetNearestInfoFromPoly3(const double & longitude, const double &latitude, double &distance, glm::dvec2 & vec);
bool IsNearestInfoFromLine(const double &x, const double &y, const double &distance);
bool IsNearestInfoFromArc(const double &x, const double &y, const double &distance);
bool IsNearestInfoFromSprial(const double &x, const double &y, const double &distance);
bool IsNearestInfoFromPoly3(const double &x, const double &y, const double &distance);
const glm::dvec2 GetRoadGeoCoordinateXYFromLine(const double &s, const double &t)const;
const glm::dvec2 GetRoadGeoCoordinateXYFromArc(const double &s, const double &t)const;
const glm::dvec2 GetRoadGeoCoordinateXYFromSpiral(const double &s, const double &t)const;
const glm::dvec2 GetRoadGeoCoordinateXYFromPloy3(const double &s, const double &t)const;
const glm::dvec3 GetRoadGeoCoordinateXYHdgFromLine(const double &s, const double &t)const;
const glm::dvec3 GetRoadGeoCoordinateXYHdgFromArc(const double &s, const double &t)const;
const glm::dvec3 GetRoadGeoCoordinateXYHdgFromSpiral(const double &s, const double &t)const;
const glm::dvec3 GetRoadGeoCoordinateXYHdgFromPloy3(const double &s, const double &t)const;
const bool GetRoadGeoCoordinateSTFromLine(const glm::dvec3 vec, glm::dvec2 &st, double &dis)const;
const bool GetRoadGeoCoordinateSTFromArc(const glm::dvec3 vec, glm::dvec2 &st, double &dis)const;
const bool GetRoadGeoCoordinateSTFromSpiral(const glm::dvec3 vec, glm::dvec2 &st, double &dis)const;
const bool GetRoadGeoCoordinateSTFrompPloy3(const glm::dvec3 vec, glm::dvec2 &st, double &dis)const;
vector<glm::dvec3> GetDataFromLine();
vector<glm::dvec3> GetDataFromArc();
vector<glm::dvec3> GetDataFromSpiral();
//bool GetComClockWise(const glm::dvec2 &p0, const glm::dvec2 &p1, const glm::dvec2 &p2);
const vector<Position> GetLanePosiontAndDircetionsFromLine(const double & initPosition, const double &lastPosition, double &position)const;
const vector<Position> GetLanePosiontAndDircetionsFromArc(const double & initPosition, const double &lastPosition, double &position)const;
const vector<Position> GetLanePosiontAndDircetionsFromSpiral(const double & initPosition, const double &lastPosition, double &position)const;
//const vector<Position> GetLanePosiontAndDircetionsFromPloy3(const double & initPosition, const double &lastPosition, double &position)const;
const vector<TurningAttr> GetLaneTurningAttributesFromLine(const double & initPosition, const double &lastPosition, double &position,const int &flag)const;
const vector<TurningAttr> GetLaneTurningAttributesFromArc(const double & initPosition, const double &lastPosition, double &position, const int &flag)const;
const vector<TurningAttr> GetLaneTurningAttributesFromSpiral(const double & initPosition, const double &lastPosition, double &position, const int &flag)const;
double GetCurvatureFromLine(const double &s);
double GetCurvatureFromArc(const double &s);
double GetCurvatureFromSprial(const double &s);
double GetCurvatureFromPoly3(const double &s);
const double GetRoadGeoCoordinateHdgFromLine(const double &s)const;
const double GetRoadGeoCoordinateHdgFromArc(const double &s)const;
const double GetRoadGeoCoordinateHdgFromSpiral(const double &s)const;
const double GetRoadGeoCoordinateHdgFromPloy3(const double &s)const;
//const vector<TurningAttr> GetLaneTurningAttributesFromPloy3(const double & initPosition, const double &lastPosition, double &position, const int &flag)const;
~Geometry();
public:
double _hdg;
double _length;
double _s;
double _x;
double _y;
EnGeometryType _flag;
double _curvStart;
double _curvEnd;
double _curvature;
double _a = 0.0;
double _b = 0.0;
double _c = 0.0;
double _d = 0.0;
};
}
#pragma once
#include"set"
using namespace std;
namespace OpenDrive
{
class Grid
{
public:
Grid();
Grid& operator= (const Grid &grid);
Grid(const Grid &grid);
void SetRoadID(const char* roadID);
set<string> GetRoadID();
~Grid();
private:
set<string> _vecRoad;
};
}
#pragma once
namespace OpenDrive
{
//<height sOffset = "0" inner = "0.2" outer = "0.2" / >
class Height
{
public:
Height();
Height& operator = (const Height &height);
Height(const Height &height);
void SetsOffset(const double &value);
const double GetsOffset() const;
void SetInner(const double &value);
const double GetInner() const;
void SetOuter(const double &value);
const double GetOuter() const;
~Height();
private:
double _sOffset;
double _inner;
double _outer;
};
}
#pragma once
#include"string"
#include"Connection.h"
#include"map"
#include"vector"
using namespace std;
namespace OpenDrive
{
class Junction
{
public:
Junction();
Junction(const Junction &junc);
Junction& operator =(const Junction &junc);
void SetID(const char* id);
const char* GetID() const;
void SetName(const char* name);
const char* GetName() const;
void PushbackConnection(Connection *conn);
const vector<Connection*> GetAllConnection() const;
const vector<string> GetConnectingRoad(const char* roadID) const;
~Junction();
private:
string _name;
string _id;
map<string, Connection*> *_mapConn;
};
}
#pragma once
#include"DataDefines.h"
#include"LaneLink.h"
#include"LaneWidth.h"
#include"LaneRoadMark.h"
#include"Speed.h"
#include"Height.h"
#include"Function.h"
#include"UserData.h"
namespace OpenDrive
{
class Lane
{
public:
Lane();
void SetID(const char *id);
void SetSectionID(const char*id);
const char* GetID() const;
void SetLevel(const char* level);
void SetType(const EnLaneType &type);
const EnLaneType GetType() const;
const char* GetTypeString() const;
void SetSpeed(Speed *speed);
const Speed* GetSpeed() const;
void SetHeight(Height *height);
const Height* GetHeight() const;
const LaneLink* GetLink() const;
void SetType(const char* type);
void SetLaneReferenceData(const vector<GeoCoordinatePoint>& vecLaneRefernceData);
void SetLaneBoundaryData(const vector<GeoCoordinatePoint>& vecLaneRefernceData);
const vector<GeoCoordinatePoint>* GetlaneBoundaryData() const;
void SetLaneWidth(LaneWidth *width);
const vector<LaneWidth>* GetLaneWidth() const;
void SetLink(LaneLink* link);
void SetRoadMark(LaneRoadMark *roadMark);
const LaneRoadMark* GetLaneRoadMark() const;
LaneWidth GetLaneWidthFromLane(const double &soff);
//LaneWidth GetFirstLaneWidthFromLane(const double &soff);
void ConstructPolygon();
Lane& operator= (const Lane &lane);
const string GetPreLaneID()const;
const string GetSucLaneID()const;
Lane(const Lane &lane);
void CalBoundaryData();
const double GetLaneSpeed() const;
const vector<GeoCoordinatePoint>* GetLaneRefernceData() const;
const vector<GeoCoordinatePoint>* GetLaneBoundaryData() const;
void SetUserData(UserData *userData);
const UserData* GetUserData() const;
~Lane();
private:
string _id;
double _s = 0.0;
Height *_height;
EnLaneType _type;
LaneLink *_link;
vector<LaneWidth> *_laneWidth;
LaneRoadMark *_roadMark;
UserData *_userData;
Speed *_speed;
//vector<GeoCoordinatePoint> *_laneReference;
vector<GeoCoordinatePoint> *_laneReferenceData;
vector<GeoCoordinatePoint> *_laneBoundaryData;
public:
string _level = "false";
};
}
#pragma once
#include"Lane.h"
#include"DataDefines.h"
#include"LaneLink.h"
#include"LaneWidth.h"
#include"LaneRoadMark.h"
#include"Speed.h"
#include"Function.h"
#include"string"
using namespace std;
namespace OpenDrive
{
class LaneBase
{
public:
LaneBase();
LaneBase(const Lane*lane);
LaneBase& operator= (const LaneBase &lane);
LaneBase(const LaneBase &lane);
const double GetLaneSpeed() const;
//const vector<LaneWidth>& GetLaneWidth() const;
void SetRoadID(const char* roadID);
void SetSectionID(const char* roadID);
~LaneBase();
public:
string _id;
string _RoadID;
string _SectionID;
PosXY _initP;
PosXY _termP;
double _length = 0.0;
EnLaneType _type;
Speed *_speed;
LaneRoadMark *_roadMark;
vector<LaneWidth> *_vecLaneWidth;
string _strMaterial = "";
string _strVisible = "";
string _strAccess = "";
string _strHeight = "";
string _strRule = "";
};
}
#pragma once
#include"string"
using namespace std;
namespace OpenDrive
{
class LaneLink
{
public:
LaneLink();
LaneLink(const LaneLink&link);
void SetPreID(const char* id);
void SetSucID(const char* id);
const string GetPreLaneID()const;
const string GetSucLaneID()const;
LaneLink& operator = (const LaneLink&link);
~LaneLink();
private:
string _preID ;
string _sucID;
//<predecessor id = "-2" / >
// <successor id = "-3" / >
};
}
#pragma once
namespace OpenDrive
{
class LaneOffset
{
public:
LaneOffset();
void SetAValue(const double & value);
const double GetAValue() const;
void SetBValue(const double & value);
const double GetBBValue() const;
void SetCValue(const double & value);
const double GetCCValue() const;
void SetDValue(const double & value);
const double GetDValue() const;
void SetSValue(const double & value);
const double GetSValue() const;
LaneOffset& operator=(const LaneOffset &elev);
LaneOffset(const LaneOffset &elev);
~LaneOffset();
private:
double _a = 0.0;
double _b = 0;
double _c = 0;
double _d = 0;
double _s = 0;
};
}
#pragma once
#include"DataDefines.h"
namespace OpenDrive
{
class LaneRoadMark
{
public:
LaneRoadMark();
void SetColor(const char* color);
const EnRoadMarkColor GetColor() const;
void SetType(const char* type);
const EnRoadMarkType GetType() const;
void SetWeight(const char* weight);
const EnRoadMarkWeight GetWeight() const;
void SetOffSet(const double & offset);
const double GetOffSet()const;
LaneRoadMark(const LaneRoadMark & roadMark);
LaneRoadMark& operator = (const LaneRoadMark & roadMark);
~LaneRoadMark();
private:
EnRoadMarkColor _color;
EnRoadMarkType _type;// = "broken"
EnRoadMarkWeight _weight;// = "standard"
double _sOffset;
};
}
#pragma once
#include"map"
#include"Lane.h"
#include"Polygon.h"
#include"Function.h"
using namespace std;
namespace OpenDrive
{
class LaneSection
{
public:
LaneSection();
LaneSection(const LaneSection &laneSection);
LaneSection & operator = (const LaneSection &laneSection);
void SetLaneSectionID();
void ConstructPolygon(const vector<glm::dvec3> &vecRoadData);
void SetID(const char *id);
void SetWidth(const double &left,const double &right);
void PushLane(Lane *lane);
const char* GetID() const;
const string GetLaneID(const char* sectionID, const double & s, const double &t, const double &distance) const;
const string GetLaneID(const char* sectionID, const double & longitude, const double &latitude, const double & x, const double & y, const double & hdg) const;
vector<Lane*> GetAllLane() const ;
Lane* GetLane(const char* laneID);
const string GetPreLaneID(const char* laneID)const;
const string GetSucLaneID(const char* laneID)const;
const vector<string> GetLeftLaneIDS(const char* laneID)const;
const vector<string> GetRightLaneIDS(const char* laneID)const;
const vector<string> GetAllDrivingLaneIDS() const;
const vector<string> GetAllLaneIDS() const;
bool IsInSideLaneSection(const double & longitude, const double &latitude);
//const vector<LaneWidth>* GetFirstLaneWith(const char* laneID);
const LaneWidth GetLaneWith(const char* laneID, double s);
const vector<RoadWidth> GetSectionWidthofRoad() const;
const NearestDistance GetNeartestRoadandLaneAttributes(const char* laneID, const double &s, const double &t) const;
const NearestRoadMark GetNeartestLaneRoadMark(const char* laneID) const;
void CalBoundaryData(const char* laneID);
const vector<GeoCoordinatePoint>* GetlaneBoundaryData(const char* laneID) const;
const double GetLaneSpeed(const char* laneID) const;
const vector<PosXY>* GetLeftLinePosFromLane(const char* laneID) const;
const vector<PosXY>* GetRightLinePosFromLane(const char* laneID) const;
GeoCoordinatePoint* GetLanePositionBySectionID(const char* laneID) const;
const char* GetLaneTypeString(const char* laneID) const;
~LaneSection();
private:
map<string, Lane*>* _mapLane;
vector<Polygon*> *_vecPlygon;
string _id;
double _s;
double _leftWidth;
double _rightWidth;
};
}
#pragma once
namespace OpenDrive
{
class LaneWidth
{
public:
LaneWidth();
void SetAValue(const double & value);
const double GetAValue() const;
void SetBValue(const double & value);
const double GetBBValue() const;
void SetCValue(const double & value);
const double GetCCValue() const;
void SetDValue(const double & value);
const double GetDValue() const;
void SetOffSetValue(const double & value);
const double GetOffSetValue() const;
LaneWidth& operator=(const LaneWidth &width);
LaneWidth(const LaneWidth &width);
~LaneWidth();
private:
double _a = 0.0;
double _b = 0;
double _c = 0;
double _d = 0;
double _sOffset = 0;
};
}
#pragma once
#include <math.h>
#include"glm/glm.hpp"
namespace OpenDrive
{
class NavinfoGISCoord
{
public:
static NavinfoGISCoord* GetInstance();
glm::dvec2 LatLonToUTM(const double &lon, const double &lat, const char* name);
glm::dvec2 XYToLatLonUTM(double x, double y, bool southhemi, const char* name);
glm::dvec2 XYToLatLonUTM(double x, double y, bool southhemi);
double UTMCentralMeridian(const double &zone);
glm::dvec2 MapLatLonToXY(const double &phi, const double &lambda, const double &lambda0);
glm::dvec2 MapXYToLatLon(double x, double y, double lambda0);
double ArcLengthOfMeridian(const double &phi);
double FootpointLatitude(double y);
//{
// double y_, alpha_, beta_, gamma_, delta_, epsilon_, n;
// double result;
// /* Precalculate n (Eq. 10.18) */
// n = (sm_a - sm_b) / (sm_a + sm_b);
// /* Precalculate alpha_ (Eq. 10.22) */
// /* (Same as alpha in Eq. 10.17) */
// alpha_ = ((sm_a + sm_b) / 2.0) * (1 + (pow(n, 2.0) / 4) + (pow(n, 4.0) / 64));
// /* Precalculate y_ (Eq. 10.23) */
// y_ = y / alpha_;
// /* Precalculate beta_ (Eq. 10.22) */
// beta_ = (3.0 * n / 2.0) + (-27.0 * pow(n, 3.0) / 32.0) + (269.0 * pow(n, 5.0) / 512.0);
// /* Precalculate gamma_ (Eq. 10.22) */
// gamma_ = (21.0 * pow(n, 2.0) / 16.0) + (-55.0 * pow(n, 4.0) / 32.0);
// /* Precalculate delta_ (Eq. 10.22) */
// delta_ = (151.0 * pow(n, 3.0) / 96.0) + (-417.0 * pow(n, 5.0) / 128.0);
// /* Precalculate epsilon_ (Eq. 10.22) */
// epsilon_ = (1097.0 * pow(n, 4.0) / 512.0);
// /* Now calculate the sum of the series (Eq. 10.21) */
// result = y_ + (beta_ * sin(2.0 * y_)) + (gamma_ * sin(4.0 * y_)) + (delta_ * sin(6.0 * y_)) + (epsilon_ * sin(8.0 * y_));
// return result;
//}
private:
NavinfoGISCoord();
~NavinfoGISCoord();
private:
const double pi = M_PI;
const double sm_a = 6378137.0;
const double sm_b = 6356752.3142;
const double TMScaleFactor = 1.0;
double _zone = 0.0;
private:
static NavinfoGISCoord *_instance;
};
}
#pragma once
#include"vector"
#include"glm/glm.hpp"
#include"DataDefines.h"
#include"function.h"
#include"RepeatObj.h"
using namespace std;
namespace OpenDrive
{
class Object
{
public:
Object();
Object(const Object & obj3d);
Object& operator =(const Object & obj);
void SetName(const char* name);
const char* GetName() const;
void SetType(const char* type);
const char* GetType() const;
void SetSValue(double &value);
const double GetSValue() const;
void SetTValue(double &value);
const double GetTValue() const;
void PushbackData(glm::dvec3 vec);
vector<glm::dvec3>* GetCoords();
void SetWidthValue(double &value);
const double GetWidthValue() const;
void SetHeightValue(double &value);
const double GetHeightValue() const;
//zOffset
void SetzOffsetValue(double &value);
const double GetzOffsetValue() const;
void SetRepeatObjValue(RepeatObj *repeatObj);
const RepeatObj * GetRepeatObjValue() const;
~Object();
private:
string _name;
string _type;
double _s;
double _t;
double _width;
double _height;
double _zOffset;
vector<glm::dvec3> *_vecCoords;
RepeatObj *_repeatObj;
//<repeat s = "2.73406954883456" length = "79.566455604047" distance = "15" tStart = "-13.3226013033395" tEnd = "-13.3226013033395" widthStart = "5.7990000000000004e+00" widthEnd = "5.7990000000000004e+00" heightStart = "6.6230000000000002e+00" heightEnd = "6.6230000000000002e+00" zOffsetStart = "-3.8850000000000007e-01" zOffsetEnd = "-3.8850000000000007e-01" / >
};
}
#pragma once
#include"Road.h"
#include"Junction.h"
#include"unordered_map"
#include"xml/tinyxml.h"
#include"xml/tinystr.h"
#include"glm/glm.hpp"
#include"DataDefines.h"
#include"Elevation.h"
#include"SignalReference.h"
#include"NavinfoGISCoord.h"
#include"LaneBase.h"
#include"RoadBase.h"
#include"stack"
#include"Grid.h"
#include<fstream>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
namespace OpenDrive
{
class _declspec(dllexport) OdrManager
{
public:
explicit OdrManager();
bool LoadFile(const char* name);
const vector<OdrInfo> GetOdrInfo(const double & longitude, const double &latitude) const;
const vector<OdrInfo> GetOdrInfoByXY(const double & x, const double &y) const;
bool GetSucRoadID(const char* roadID, char**&vecRoadID, int &nSize);
bool GetPreRoadID(const char* roadID, char**&vecRoadID, int &nSize);
bool GetPreLaneID(const char* roadID, const char* sectionID, const char* laneID, char**&vecLane, int &nSize);
bool GetSucLaneID(const char* roadID, const char* sectionID, const char* laneID, char**&vecLane, int &nSize);
bool GetPreLaneRelationID(const char* roadID, const char* sectionID, const char* laneID, LaneRelation*&vecLaneRelation, int &nSize);
bool GetSucLaneRelationID(const char* roadID, const char* sectionID, const char* laneID, LaneRelation*&vecLaneRelation, int &nSize);
bool GetLeftLaneIDS(const char* roadID, const char* sectionID, const char* laneID, char**&vecLane, int &nSize);
bool GetRightLaneIDS(const char* roadID, const char* sectionID, const char* laneID, char**&vecLane, int &nSize);
bool GetAllDrivingLaneIDS(const char* roadID, const char* sectionID, char**&vecLane, int &nSize);
bool GetAllSectionIDS(const char* roadID, char**&vecSection, int &nSize);
bool GetAllRoadIDS(char**&vecRoad, int &nSize);
bool GetSectionWidthofRoad(const char* roadID, const char* sectionID, RoadWidth*&vecRoaDWidth, int &nSize);
//const vector<RoadWidth> GetSectionWidthofRoad(const char* roadID, const char* sectionID) const;
bool GetLanePosiontAndDircetions(const char* roadID, const char* sectionID, const char* laneID, const double & longitude, const double &latitude, Position*& pos, int &nSize);
bool GetLanePosiontAndDircetionsByXY(const char* roadID, const char* sectionID, const char* laneID, const double &x, const double &y, Position*& pos, int &nSize);
bool GetLaneTurningAttributes(const char* roadID, const char* sectionID, const char* laneID, const double &headDir, TurningAttr*& turAtt, int &nSize);
NearestDistance* GetNeartestRoadandLaneAttributes(const double & longitude, const double &latitude);
NearestDistance* GetNeartestRoadandLaneAttributesByXY(const double & x, const double &y);
NearestRoadMark GetNeartestLaneRoadMark(const double & longitude, const double &latitude);
NearestRoadMark GetNeartestLaneRoadMarkByXY(const double &x, const double &y);
bool GetEdgePolygon(const double &longitude, const double &latitude, const double &radius, PosXY**& pos, int &nSize, int *&length);
bool GetEdgePolygonByXY(const double &x, const double &y, const double &radius, PosXY**& pos, int &nSize, int *&length);
//const RoadProperty GetLaneProperty(const vector<Position> &vecPosition) const;
bool GetEdgePolygon(const double &longitude, const double &latitude, const double &radius, PosXY*& pos, int &nSize);
bool GetEdgePolygonByXY(const double &x, const double &y, const double &radius, PosXY*& pos, int &nSize);
const double GetLaneSpeed(const char* roadID, const char* sectionID, const char* laneID) const; //m/s;
bool GetLightPos(const double &longitude, const double &latitude, SignalPos*&pos, int &nSize) ;
bool GetLightPosByXY(const double &x, const double &y, SignalPos*&pos, int &nSize) ;
bool GetStopLinePos(const double &longitude, const double &latitude, SignalPos*&pos, int &nSize) ;
bool GetStopLinePosByXY(const double &x, const double &y, SignalPos*&pos, int &nSize) ;
bool GetLeftLinePosFromLane(const char* roadID, const char* sectionID, const char* laneID, const double &longitude, const double &latitude, PosXY*& pos, int &nSize); //车道左边界的相对坐标;
bool GetLeftLinePosFromLaneByXY(const char* roadID, const char* sectionID, const char* laneID, const double &x, const double &y, PosXY*& pos, int &nSize); //车道左边界的相对坐标;
bool GetRightLinePosFromLane(const char* roadID, const char* sectionID, const char* laneID, const double &longitude, const double &latitude, PosXY*& pos, int &nSize);//车道右边界的相对坐标;
bool GetRightLinePosFromLaneByXY(const char* roadID, const char* sectionID, const char* laneID, const double &x, const double &y, PosXY*& pos, int &nSize);//车道右边界的相对坐标;
PosXY GetXYFromRoadID(const char* roadID, const double &s, const double &t);
PosXY GetSTFromRoadID(const char* roadID, const double &x, const double &y);
PosXY LatLonToUTM(const double &lon, const double &lat) const;
PosXY XYToLatLonUTM(const double &lon, const double &lat) const;
LaneBase* GetLaneBase(const char* roadID, const char* sectionID, const char* laneID);
RoadBase* GetRoadBase(const char* roadID);
RoadDrivingAttr GetRoadDriveTurningAttr(const char* roadID);
void PreRoadID(const char* roadID, const double &length, const double &dir, stack<string> &stkRoad);
bool GetLaneInfor(const double &longitude, const double &latitude, const double &dir, const double &length, const double &width, bool bRoad_Edge, PosXY**& pos, int &nArraySize, int *&nSize, const double& thresholdDegreeValue);
bool GetLaneInforByXY(const double &x, const double &y, const double &dir, const double &length , const double &width, bool bRoad_Edge, PosXY**& pos, int &nArraySize, int *&nSize, const double& thresholdDegreeValue);
void GetRoadLaneInfor(Road*road, vector<LaneGeoCoordinage> &vecGeo, const set<string> &setTerm, set<string> &hasRoad, const vector<glm::dvec2> &vecData);
/////////////////
/////路径规划;
/////////////////
bool GetRoadPathByXY(const double sx, const double sy, const double ex, const double ey, vector<char *> &path, double &path_length);
bool GetRoadPath(const double &startlongitude, const double &startlatitude, const double &endlongitude, const double &endlatitude, std::vector<char *> &path, double &path_length);
bool GetSigleLanePath(const SearchNode sourcenode, const vector<LaneNode>events, const LaneNode lanenode, SearchNode &searchnode);
bool GetLanePathByXY(const double sx, const double sy, const double ex, const double ey, const vector<EventPos>events, vector<LaneNode> &path, double &path_length);
bool GetLanePath(const double &startlongitude, const double &startlatitude, const double &endlongitude, const double &endlatitude, const vector<EventPos>events, vector<Pathpoint> &path, double &path_length);
const char* GetLaneTypeString(const char* roadID, const char* sectionID, const char* laneID) const;
double GetHeightZvalue(const double &longitude, const double &latitude);
double GetHeightZvalueByXY(const double &x, const double &y);
double GetHdg(const double &longitude, const double &latitude);
double GetHdgByXY(const double &longitude, const double &latitude);
~OdrManager();
private:
vector<vector<glm::dvec3>> GetPrePolygon(const double &s, Road* road);
vector<vector<glm::dvec3>> GetSucPolygon(Road* road, const double &len);
vector<vector<glm::dvec3>> GetPolygon(const double &s, Road* road, const double &length);
private:
unordered_map<string, Road*> *_mapRoad;
unordered_map<string, Junction*> *_mapJunction;
};
}
#pragma once
#include"string"
#include"vector"
#include"glm/glm.hpp"
using namespace std;
namespace OpenDrive
{
class Polygon
{
public:
Polygon();
Polygon(const int &strSID, const int & strLaneID);
Polygon(const Polygon &plygon);
Polygon &operator = (const Polygon &plygon);
void SetData(glm::vec2 value, int indx);
void SetSID(int inSID);
void SetLaneID(int inLaneID);
void CalCenter();
void CalLineCenter();
void CalTriangleCenter();
void CalDirection();
void CalLineDirection();
void CalTriangleDirection();
const glm::vec2 & GetCenter();
const glm::vec2 & GetDirection();
const int &GetSectionID();
const int &GetLaneID();
const bool &GetEnterIsInSideFlag();
const bool &GetExitIsInSideFlag();
bool BEnterIsInSide(const glm::vec2 &intiPoint);
bool BExitIsInSide(const glm::vec2 &termiPoint);
bool BIsInSideLine(const glm::vec2 &point);
bool BIsInSideTriangle(const glm::vec2 &point);
bool BIsLine();
bool BIsTriangle();
void SetbEnterValue(const bool &bValue);
void SetbExitValue(const bool &bValue);
bool IsInSidePolygon(const glm::vec2 &point);
~Polygon();
private:
int _strSID;
int _strLaneID;
bool _bEnter;
bool _bExit;
vector<glm::vec2> _vecData;
glm::vec2 _center;
glm::vec2 _direction;
public:
string _strEnter;
string _strExit;
string _strSectionName;
};
}
#pragma once
#include"vector"
#include"glm/glm.hpp"
#include"DataDefines.h"
#include"function.h"
using namespace std;
namespace OpenDrive
{
class RepeatObj
{
public:
RepeatObj();
RepeatObj(const RepeatObj & obj);
RepeatObj& operator =(const RepeatObj & obj);
~RepeatObj();
void SetDistanceValue(double &value);
const double GetDistanceValue() const;
void SetLengthValue(double &value);
const double GetLengthValue() const;
void SetWidthValue(double &value);
const double GetWidthValue() const;
void SetHeightValue(double &value);
const double GetHeightValue() const;
private:
double _distance = 0.0;
double _length;
double _width;
double _height;
};
}
#pragma once
#include "Lane.h"
#include "LaneSection.h"
#include"unordered_map"
#include"glm/glm.hpp"
#include <glm/gtc/matrix_transform.hpp>
#include"DataDefines.h"
#include"Geometry.h"
#include"RoadLink.h"
#include"Polygon.h"
#include"Function.h"
#include"Elevation.h"
#include"Signal.h"
#include"LaneOffset.h"
#include "Object.h"
#include <string>
#include <io.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include<ctype.h>
using namespace std;
namespace OpenDrive
{
//extern void QuickSort(vector<double> &vecData);
//extern string DoubleToString(const double &value);
//extern string IntToString(const long int &value);
class Road
{
public:
Road();
Road(const Road & obj3d);
Road& operator =(const Road & road);
void SetID(const char* id);
void SetName(const char* name);
void SetJunction(const char* junction);
void SetLength(const double &junction);
//double GetLength();
void SetLink(const RoadLink & link, const char* name);
const char* GetSucRoad() const;
const char* GetPreRoad() const;
void PushbackLaneSection(LaneSection *laneSection);
LaneSection* GetSection(const char* sectionID);
void PushbackData(Geometry *geo);
void PushElevation(Elevation *ele);
void PushLaneOffSet(LaneOffset *laneOffset);
void PushSignal(Signal *sigl);
void PushObject(Object *obj);
void ResizeData();
void ResizeLaneSection();
const char* GetID() const;
const double GetLength() const;
const char* GetName() const;
const glm::dvec3 GetInitPosXY() const;
const glm::dvec3 GetTermPosXY() const;
double GetHeightZvalue(const double &s, const double &t);
void ConstructPolygon(glm::dvec2 &max, glm::dvec2 &min);
bool IsInSideRoad(const double & longitude, const double &latitude);
//void GetRefernceData();
const string GetPreLaneID(const char* sectionID, const char* laneID) const;
const string GetSucLaneID(const char* sectionID, const char* laneID) const;
const string GetLaneSectionID(const double &s) const;
const string GetLaneID(const char* sectionID, const double & longitude, const double &latitude, const double &distance) const;
const string GetLaneID(const char* sectionID, const double & longitude, const double &latitude) const;
const vector<string> GetLeftLaneIDS(const char* sectionID, const char* laneID)const;
const vector<string> GetRightLaneIDS(const char* sectionID, const char* laneID)const;
const vector<string> GetAllDrivingLaneIDS(const char* sectionID) const;
const vector<string> GetAllSectionIDS() const;
const vector<RoadWidth> GetSectionWidthofRoad(const char* sectionID) const;
const vector<Position> GetLanePosiontAndDircetions(const char* sectionID, const char* laneID) const;
const vector<TurningAttr> GetLaneTurningAttributes(const char* sectionID, const char* laneID) const;
const NearestDistance GetNeartestRoadandLaneAttributes(const char* sectionID, const char* laneID, const double &s, const double &t) const;
const NearestRoadMark GetNeartestLaneRoadMark(const char* sectionID, const char* laneID) const;
OdrInfo GetNearest(const double & longitude, const double &latitude,double &distance);
bool IsNearestRoad(const double & x, const double &y, const double &distance);
vector<GeoCoordinatePoint> GetDataFromLine(const double &s, const double &sReal, const double &x, const double &y, const double &hdg, const double &length);
vector<GeoCoordinatePoint> GetDataFromArc(const double &s, const double &sReal, const double &x, const double &y, const double &hdg, const double &length, const double &curvature);
vector<GeoCoordinatePoint> GetDataFromSprial(const double &s, const double &sReal, const double &x0, const double &y0, const double &hdg, const double &length, const double &curvEnd, const double &curvStart, double &lastcurv);
vector<GeoCoordinatePoint> GetDataFromPoly3(const double &s, const double &sReal, const double &x, const double &y, const double &hdg, const double &length, const double &a, const double &b, const double &c, const double &d);
const glm::dvec2 GetRoadInitPos() const;
const double GetLaneSpeed(const char* sectionID, const char* laneID) const;
const vector<SignalPos>* GetLightPos() const;
const vector<SignalPos>* GetStopLinePos() const;
const glm::dvec2 GetRoadGeoCoordinateXY(const double &s, const double &t)const;
const glm::dvec3 GetRoadGeoCoordinateXYHdg(const double &s, const double &t)const;
const glm::dvec2 GetSTCoordinateFromRoad(const double &x, const double &y)const;
const vector<PosXY>* GetLeftLinePosFromLane(const char* sectionID, const char* laneID) const;
const vector<PosXY>* GetRightLinePosFromLane(const char* sectionID, const char* laneID) const;
string GetLastSection()const;
string GetPreSection(const char* sectionID)const;
string GetSucSection(const char* sectionID)const;
const bool IsFirstSection(const char* sectionID)const;
const bool IsLastSection(const char* sectionID)const;
RoadDrivingAttr GetRoadDriveTurningAttr();
vector<GeoCoordinatePoint>* GetLeftBoundartData();
vector<GeoCoordinatePoint>* GetRightBoundartData();
vector<GeoCoordinatePoint>* GetReferenceData();
vector<Object*>* GetObjectData();
void GenerateLaneShp();
void GenerateObjShp();
void GenerateSingalObjShp();
void part(string _str, vector<int> &_num, vector<char> &_op);
GeoCoordinatePoint* GetLanePositionBySectionID(const char* sectionID, const char* laneID) const;
string GetJunction();
const char* GetLaneTypeString(const char* sectionID, const char* laneID) const;
double GetHdg(const double &s);
double GetElevation(const double &s);
~Road();
private:
vector<LaneSection*> *_vecLanSections;
map<string, Signal*> *_mapSignals;
string _name;
string _id;
string _junction;
double _length;
vector<LaneOffset*> *_vecLaneOff;
vector<Geometry*> *_vecData;
vector<Elevation*> *_vecElev;
RoadLink *_preLink;
RoadLink *_sucLink;
vector<Polygon*> _vecPolygon;
vector<GeoCoordinatePoint> *_vecReferenceData;
vector<GeoCoordinatePoint> *_vecLeftBoundaryData; //_laneBoundaryData
vector<GeoCoordinatePoint> *_vecRightBoundaryData; //_laneBoundaryData
glm::dvec2 _midPoint;
glm::dvec2 _min;
glm::dvec2 _max;
vector<string> _sectionID;
vector<Object*>* _vecObjs;
public:
glm::dvec2 _initPoint;
glm::dvec2 _termPoint;
};
}
#pragma once
#include"map"
#include"glm/glm.hpp"
#include"DataDefines.h"
#include"RoadLink.h"
#include"Function.h"
#include"Signal.h"
#include"Road.h"
using namespace std;
namespace OpenDrive
{
class RoadBase
{
public:
RoadBase();
RoadBase(const Road* road);
RoadBase(const RoadBase & roadBase);
RoadBase& operator =(const RoadBase & roadBase);
~RoadBase();
public:
string _name;
string _id;
double _length;
PosXY _initP;
PosXY _termP;
};
}
#pragma once
#include"string"
using namespace std;
namespace OpenDrive
{
class RoadLink
{
public:
RoadLink();
RoadLink& operator = (const RoadLink &link);
RoadLink(const RoadLink &link);
void SetContactPoint(const char* contactPoint);
void SetElementId(const char* elementId);
void SetElementType(const char* elementType);
const char* GetContactPoint()const;
const char* GetElementId()const;
const char* GetElementType()const;
~RoadLink();
private:
string _contactPoint;
string _elementId; //= "19046"
string _elementType;// = "junction" / >
};
}
#pragma once
#include"string"
#include"vector"
#include"SignalReference.h"
using namespace std;
namespace OpenDrive
{
class Signal
{
public:
Signal();
Signal &operator = (const Signal &sigl);
Signal(const Signal &sigl);
void SetID(const char* id);
const char* GetID() const;
void SetName(const char* name);
const char* GetName() const;
void SetCoodinateS(const double& value);
const double GetCoodinateS() const;
void SetCoodinateT(const double& value);
const double GetCoodinateT() const;
void SetCoodinatezOffset(const double& value);
const double GetCoodinatezOffset() const;
void PushSignal(SignalReference *siglRef);
~Signal();
private:
double _s;
double _t;
string _id;
string _name;
double _zOffset;
vector<SignalReference*> *_vecSigRef;
};
}
#pragma once
#include"string"
using namespace std;
namespace OpenDrive
{
class SignalReference
{
public:
SignalReference();
SignalReference& operator=(const SignalReference &siglRef);
SignalReference (const SignalReference &siglRef);
void SetID(const char* id);
const char* GetID() const;
void SetCoodinateS(const double& value);
const double GetCoodinateS() const;
void SetCoodinateT(const double& value);
const double GetCoodinateT() const;
~SignalReference();
private:
double _s = 0.0;
double _t = 0.0;
string _id;
};
}
#pragma once
namespace OpenDrive
{
class Speed
{
public:
Speed();
Speed& operator = (const Speed &speed);
Speed(const Speed &speed);
void SetsOffset(const double &value);
const double GetsOffset() const;
void SetMax(const double &value);
const double GetMax() const;
~Speed();
private:
double _sOffset;
double _max;
};
}
#pragma once
#include"string"
using namespace std;
namespace OpenDrive
{
class UserData
{
public:
UserData();
UserData& operator = (const UserData &usData);
UserData(const UserData &usData);
void SetCode(const char* id);
const string GetCode() const;
void SetsOffset(const char* sOffset);
const string GetsOffset() const;
void SetLaneStyle(const char* laneStyle);
const string GetLaneStyle() const;
void SetMapping(const char* mapping);
const string GetMapping() const;
void SetPos(const char* pos);
const string GetPos() const;
void SetStyle(const char* style);
const string GetStyle() const;
void SetId(const char* id);
const string GetId() const;
~UserData();
private:
string _code;
string _sOffset;
string _laneStyle;
string _mapping;
string _pos;
string _style;
string _id;
};
}
file(GLOB ROOT_SOURCE *.cpp)
file(GLOB ROOT_INLINE *.inl)
file(GLOB ROOT_HEADER *.hpp)
file(GLOB ROOT_TEXT ../*.txt)
file(GLOB ROOT_MD ../*.md)
file(GLOB ROOT_NAT ../util/glm.natvis)
file(GLOB_RECURSE CORE_SOURCE ./detail/*.cpp)
file(GLOB_RECURSE CORE_INLINE ./detail/*.inl)
file(GLOB_RECURSE CORE_HEADER ./detail/*.hpp)
file(GLOB_RECURSE EXT_SOURCE ./ext/*.cpp)
file(GLOB_RECURSE EXT_INLINE ./ext/*.inl)
file(GLOB_RECURSE EXT_HEADER ./ext/*.hpp)
file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp)
file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl)
file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp)
file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
file(GLOB_RECURSE SIMD_SOURCE ./simd/*.cpp)
file(GLOB_RECURSE SIMD_INLINE ./simd/*.inl)
file(GLOB_RECURSE SIMD_HEADER ./simd/*.h)
source_group("Text Files" FILES ${ROOT_TEXT} ${ROOT_MD})
source_group("Core Files" FILES ${CORE_SOURCE})
source_group("Core Files" FILES ${CORE_INLINE})
source_group("Core Files" FILES ${CORE_HEADER})
source_group("EXT Files" FILES ${EXT_SOURCE})
source_group("EXT Files" FILES ${EXT_INLINE})
source_group("EXT Files" FILES ${EXT_HEADER})
source_group("GTC Files" FILES ${GTC_SOURCE})
source_group("GTC Files" FILES ${GTC_INLINE})
source_group("GTC Files" FILES ${GTC_HEADER})
source_group("GTX Files" FILES ${GTX_SOURCE})
source_group("GTX Files" FILES ${GTX_INLINE})
source_group("GTX Files" FILES ${GTX_HEADER})
source_group("SIMD Files" FILES ${SIMD_SOURCE})
source_group("SIMD Files" FILES ${SIMD_INLINE})
source_group("SIMD Files" FILES ${SIMD_HEADER})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
if(GLM_STATIC_LIBRARY_ENABLE OR GLM_DYNAMIC_LIBRARY_ENABLE)
if(GLM_STATIC_LIBRARY_ENABLE)
add_library(glm_static STATIC ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif(GLM_STATIC_LIBRARY_ENABLE)
if(GLM_DYNAMIC_LIBRARY_ENABLE)
add_library(glm_shared SHARED ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif(GLM_DYNAMIC_LIBRARY_ENABLE)
else(GLM_STATIC_LIBRARY_ENABLE OR GLM_DYNAMIC_LIBRARY_ENABLE)
add_executable(glm_dummy ${ROOT_TEXT} ${ROOT_MD} ${ROOT_NAT}
${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
${EXT_SOURCE} ${EXT_INLINE} ${EXT_HEADER}
${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
${SIMD_SOURCE} ${SIMD_INLINE} ${SIMD_HEADER})
endif(GLM_STATIC_LIBRARY_ENABLE OR GLM_DYNAMIC_LIBRARY_ENABLE)
This diff is collapsed.
This diff is collapsed.
/// @ref core
/// @file glm/detail/_fixes.hpp
#include <cmath>
//! Workaround for compatibility with other libraries
#ifdef max
#undef max
#endif
//! Workaround for compatibility with other libraries
#ifdef min
#undef min
#endif
//! Workaround for Android
#ifdef isnan
#undef isnan
#endif
//! Workaround for Android
#ifdef isinf
#undef isinf
#endif
//! Workaround for Chrone Native Client
#ifdef log2
#undef log2
#endif
/// @ref core
/// @file glm/detail/_noise.hpp
#pragma once
#include "../vec2.hpp"
#include "../vec3.hpp"
#include "../vec4.hpp"
#include "../common.hpp"
namespace glm{
namespace detail
{
template<typename T>
GLM_FUNC_QUALIFIER T mod289(T const& x)
{
return x - floor(x * (static_cast<T>(1.0) / static_cast<T>(289.0))) * static_cast<T>(289.0);
}
template<typename T>
GLM_FUNC_QUALIFIER T permute(T const& x)
{
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<2, T, Q> permute(vec<2, T, Q> const& x)
{
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<3, T, Q> permute(vec<3, T, Q> const& x)
{
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, T, Q> permute(vec<4, T, Q> const& x)
{
return mod289(((x * static_cast<T>(34)) + static_cast<T>(1)) * x);
}
template<typename T>
GLM_FUNC_QUALIFIER T taylorInvSqrt(T const& r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<2, T, Q> taylorInvSqrt(vec<2, T, Q> const& r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<3, T, Q> taylorInvSqrt(vec<3, T, Q> const& r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, T, Q> taylorInvSqrt(vec<4, T, Q> const& r)
{
return T(1.79284291400159) - T(0.85373472095314) * r;
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<2, T, Q> fade(vec<2, T, Q> const& t)
{
return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<3, T, Q> fade(vec<3, T, Q> const& t)
{
return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
}
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER vec<4, T, Q> fade(vec<4, T, Q> const& t)
{
return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
}
}//namespace detail
}//namespace glm
This diff is collapsed.
This diff is collapsed.
/// @ref core
/// @file glm/detail/_vectorize.hpp
#pragma once
#include "type_vec1.hpp"
#include "type_vec2.hpp"
#include "type_vec3.hpp"
#include "type_vec4.hpp"
namespace glm{
namespace detail
{
template<length_t L, typename R, typename T, qualifier Q>
struct functor1{};
template<typename R, typename T, qualifier Q>
struct functor1<1, R, T, Q>
{
GLM_FUNC_QUALIFIER static vec<1, R, Q> call(R (*Func) (T x), vec<1, T, Q> const& v)
{
return vec<1, R, Q>(Func(v.x));
}
};
template<typename R, typename T, qualifier Q>
struct functor1<2, R, T, Q>
{
GLM_FUNC_QUALIFIER static vec<2, R, Q> call(R (*Func) (T x), vec<2, T, Q> const& v)
{
return vec<2, R, Q>(Func(v.x), Func(v.y));
}
};
template<typename R, typename T, qualifier Q>
struct functor1<3, R, T, Q>
{
GLM_FUNC_QUALIFIER static vec<3, R, Q> call(R (*Func) (T x), vec<3, T, Q> const& v)
{
return vec<3, R, Q>(Func(v.x), Func(v.y), Func(v.z));
}
};
template<typename R, typename T, qualifier Q>
struct functor1<4, R, T, Q>
{
GLM_FUNC_QUALIFIER static vec<4, R, Q> call(R (*Func) (T x), vec<4, T, Q> const& v)
{
return vec<4, R, Q>(Func(v.x), Func(v.y), Func(v.z), Func(v.w));
}
};
template<length_t L, typename T, qualifier Q>
struct functor2{};
template<typename T, qualifier Q>
struct functor2<1, T, Q>
{
GLM_FUNC_QUALIFIER static vec<1, T, Q> call(T (*Func) (T x, T y), vec<1, T, Q> const& a, vec<1, T, Q> const& b)
{
return vec<1, T, Q>(Func(a.x, b.x));
}
};
template<typename T, qualifier Q>
struct functor2<2, T, Q>
{
GLM_FUNC_QUALIFIER static vec<2, T, Q> call(T (*Func) (T x, T y), vec<2, T, Q> const& a, vec<2, T, Q> const& b)
{
return vec<2, T, Q>(Func(a.x, b.x), Func(a.y, b.y));
}
};
template<typename T, qualifier Q>
struct functor2<3, T, Q>
{
GLM_FUNC_QUALIFIER static vec<3, T, Q> call(T (*Func) (T x, T y), vec<3, T, Q> const& a, vec<3, T, Q> const& b)
{
return vec<3, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z));
}
};
template<typename T, qualifier Q>
struct functor2<4, T, Q>
{
GLM_FUNC_QUALIFIER static vec<4, T, Q> call(T (*Func) (T x, T y), vec<4, T, Q> const& a, vec<4, T, Q> const& b)
{
return vec<4, T, Q>(Func(a.x, b.x), Func(a.y, b.y), Func(a.z, b.z), Func(a.w, b.w));
}
};
template<length_t L, typename T, qualifier Q>
struct functor2_vec_sca{};
template<typename T, qualifier Q>
struct functor2_vec_sca<1, T, Q>
{
GLM_FUNC_QUALIFIER static vec<1, T, Q> call(T (*Func) (T x, T y), vec<1, T, Q> const& a, T b)
{
return vec<1, T, Q>(Func(a.x, b));
}
};
template<typename T, qualifier Q>
struct functor2_vec_sca<2, T, Q>
{
GLM_FUNC_QUALIFIER static vec<2, T, Q> call(T (*Func) (T x, T y), vec<2, T, Q> const& a, T b)
{
return vec<2, T, Q>(Func(a.x, b), Func(a.y, b));
}
};
template<typename T, qualifier Q>
struct functor2_vec_sca<3, T, Q>
{
GLM_FUNC_QUALIFIER static vec<3, T, Q> call(T (*Func) (T x, T y), vec<3, T, Q> const& a, T b)
{
return vec<3, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b));
}
};
template<typename T, qualifier Q>
struct functor2_vec_sca<4, T, Q>
{
GLM_FUNC_QUALIFIER static vec<4, T, Q> call(T (*Func) (T x, T y), vec<4, T, Q> const& a, T b)
{
return vec<4, T, Q>(Func(a.x, b), Func(a.y, b), Func(a.z, b), Func(a.w, b));
}
};
}//namespace detail
}//namespace glm
#pragma once
#include "setup.hpp"
#include <cstring>
#include <limits>
namespace glm{
namespace detail
{
template <typename T, bool isFloat = std::numeric_limits<T>::is_iec559>
struct compute_equal
{
GLM_FUNC_QUALIFIER static bool call(T a, T b)
{
return a == b;
}
};
template <typename T>
struct compute_equal<T, true>
{
GLM_FUNC_QUALIFIER static bool call(T a, T b)
{
return std::memcmp(&a, &b, sizeof(T)) == 0;
}
};
}//namespace detail
}//namespace glm
/// @ref core
/// @file glm/core/dummy.cpp
///
/// GLM is a header only library. There is nothing to compile.
/// dummy.cpp exist only a wordaround for CMake file.
/*
#define GLM_MESSAGES
#include <glm/glm.hpp>
#include <glm/ext.hpp>
#include <limits>
struct material
{
glm::vec4 emission; // Ecm
glm::vec4 ambient; // Acm
glm::vec4 diffuse; // Dcm
glm::vec4 specular; // Scm
float shininess; // Srm
};
struct light
{
glm::vec4 ambient; // Acli
glm::vec4 diffuse; // Dcli
glm::vec4 specular; // Scli
glm::vec4 position; // Ppli
glm::vec4 halfVector; // Derived: Hi
glm::vec3 spotDirection; // Sdli
float spotExponent; // Srli
float spotCutoff; // Crli
// (range: [0.0,90.0], 180.0)
float spotCosCutoff; // Derived: cos(Crli)
// (range: [1.0,0.0],-1.0)
float constantAttenuation; // K0
float linearAttenuation; // K1
float quadraticAttenuation;// K2
};
// Sample 1
#include <glm/vec3.hpp>// glm::vec3
#include <glm/geometric.hpp>// glm::cross, glm::normalize
glm::vec3 computeNormal
(
glm::vec3 const& a,
glm::vec3 const& b,
glm::vec3 const& c
)
{
return glm::normalize(glm::cross(c - a, b - a));
}
typedef unsigned int GLuint;
#define GL_FALSE 0
void glUniformMatrix4fv(GLuint, int, int, float*){}
// Sample 2
#include <glm/vec3.hpp> // glm::vec3
#include <glm/vec4.hpp> // glm::vec4, glm::ivec4
#include <glm/mat4x4.hpp> // glm::mat4
#include <glm/gtc/matrix_transform.hpp> // glm::translate, glm::rotate, glm::scale, glm::perspective
#include <glm/gtc/type_ptr.hpp> // glm::value_ptr
void func(GLuint LocationMVP, float Translate, glm::vec2 const& Rotate)
{
glm::mat4 Projection = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 100.f);
glm::mat4 ViewTranslate = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -Translate));
glm::mat4 ViewRotateX = glm::rotate(ViewTranslate, Rotate.y, glm::vec3(-1.0f, 0.0f, 0.0f));
glm::mat4 View = glm::rotate(ViewRotateX, Rotate.x, glm::vec3(0.0f, 1.0f, 0.0f));
glm::mat4 Model = glm::scale(glm::mat4(1.0f), glm::vec3(0.5f));
glm::mat4 MVP = Projection * View * Model;
glUniformMatrix4fv(LocationMVP, 1, GL_FALSE, glm::value_ptr(MVP));
}
// Sample 3
#include <glm/vec2.hpp>// glm::vec2
#include <glm/packing.hpp>// glm::packUnorm2x16
#include <glm/integer.hpp>// glm::uint
#include <glm/gtc/type_precision.hpp>// glm::i8vec2, glm::i32vec2
std::size_t const VertexCount = 4;
// Float quad geometry
std::size_t const PositionSizeF32 = VertexCount * sizeof(glm::vec2);
glm::vec2 const PositionDataF32[VertexCount] =
{
glm::vec2(-1.0f,-1.0f),
glm::vec2( 1.0f,-1.0f),
glm::vec2( 1.0f, 1.0f),
glm::vec2(-1.0f, 1.0f)
};
// Half-float quad geometry
std::size_t const PositionSizeF16 = VertexCount * sizeof(glm::uint);
glm::uint const PositionDataF16[VertexCount] =
{
glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, -1.0f))),
glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, -1.0f))),
glm::uint(glm::packUnorm2x16(glm::vec2( 1.0f, 1.0f))),
glm::uint(glm::packUnorm2x16(glm::vec2(-1.0f, 1.0f)))
};
// 8 bits signed integer quad geometry
std::size_t const PositionSizeI8 = VertexCount * sizeof(glm::i8vec2);
glm::i8vec2 const PositionDataI8[VertexCount] =
{
glm::i8vec2(-1,-1),
glm::i8vec2( 1,-1),
glm::i8vec2( 1, 1),
glm::i8vec2(-1, 1)
};
// 32 bits signed integer quad geometry
std::size_t const PositionSizeI32 = VertexCount * sizeof(glm::i32vec2);
glm::i32vec2 const PositionDataI32[VertexCount] =
{
glm::i32vec2 (-1,-1),
glm::i32vec2 ( 1,-1),
glm::i32vec2 ( 1, 1),
glm::i32vec2 (-1, 1)
};
struct intersection
{
glm::vec4 position;
glm::vec3 normal;
};
*/
/*
// Sample 4
#include <glm/vec3.hpp>// glm::vec3
#include <glm/geometric.hpp>// glm::normalize, glm::dot, glm::reflect
#include <glm/exponential.hpp>// glm::pow
#include <glm/gtc/random.hpp>// glm::vecRand3
glm::vec3 lighting
(
intersection const& Intersection,
material const& Material,
light const& Light,
glm::vec3 const& View
)
{
glm::vec3 Color(0.0f);
glm::vec3 LightVertor(glm::normalize(
Light.position - Intersection.position +
glm::vecRand3(0.0f, Light.inaccuracy));
if(!shadow(Intersection.position, Light.position, LightVertor))
{
float Diffuse = glm::dot(Intersection.normal, LightVector);
if(Diffuse <= 0.0f)
return Color;
if(Material.isDiffuse())
Color += Light.color() * Material.diffuse * Diffuse;
if(Material.isSpecular())
{
glm::vec3 Reflect(glm::reflect(
glm::normalize(-LightVector),
glm::normalize(Intersection.normal)));
float Dot = glm::dot(Reflect, View);
float Base = Dot > 0.0f ? Dot : 0.0f;
float Specular = glm::pow(Base, Material.exponent);
Color += Material.specular * Specular;
}
}
return Color;
}
*/
int main()
{
/*
glm::vec1 o(1);
glm::vec2 a(1);
glm::vec3 b(1);
glm::vec4 c(1);
glm::quat q;
glm::dualquat p;
glm::mat4 m(1);
float a0 = normalizeDotA(a, a);
float b0 = normalizeDotB(b, b);
float c0 = normalizeDotC(c, c);
*/
return 0;
}
This diff is collapsed.
/// @ref core
/// @file glm/detail/func_common_simd.inl
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
#include "../simd/common.h"
#include <immintrin.h>
namespace glm{
namespace detail
{
template<qualifier Q>
struct compute_abs_vector<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
vec<4, float, Q> result;
result.data = glm_vec4_abs(v.data);
return result;
}
};
template<qualifier Q>
struct compute_abs_vector<4, int, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, int, Q> call(vec<4, int, Q> const& v)
{
vec<4, int, Q> result;
result.data = glm_ivec4_abs(v.data);
return result;
}
};
template<qualifier Q>
struct compute_floor<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
vec<4, float, Q> result;
result.data = glm_vec4_floor(v.data);
return result;
}
};
template<qualifier Q>
struct compute_ceil<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
vec<4, float, Q> result;
result.data = glm_vec4_ceil(v.data);
return result;
}
};
template<qualifier Q>
struct compute_fract<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
vec<4, float, Q> result;
result.data = glm_vec4_fract(v.data);
return result;
}
};
template<qualifier Q>
struct compute_round<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
vec<4, float, Q> result;
result.data = glm_vec4_round(v.data);
return result;
}
};
template<qualifier Q>
struct compute_mod<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& x, vec<4, float, Q> const& y)
{
vec<4, float, Q> result;
result.data = glm_vec4_mod(x.data, y.data);
return result;
}
};
template<qualifier Q>
struct compute_min_vector<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v1, vec<4, float, Q> const& v2)
{
vec<4, float, Q> result;
result.data = _mm_min_ps(v1.data, v2.data);
return result;
}
};
template<qualifier Q>
struct compute_min_vector<4, int32, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, int32, Q> call(vec<4, int32, Q> const& v1, vec<4, int32, Q> const& v2)
{
vec<4, int32, Q> result;
result.data = _mm_min_epi32(v1.data, v2.data);
return result;
}
};
template<qualifier Q>
struct compute_min_vector<4, uint32, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, int32, Q> call(vec<4, uint32, Q> const& v1, vec<4, uint32, Q> const& v2)
{
vec<4, uint32, Q> result;
result.data = _mm_min_epu32(v1.data, v2.data);
return result;
}
};
template<qualifier Q>
struct compute_max_vector<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v1, vec<4, float, Q> const& v2)
{
vec<4, float, Q> result;
result.data = _mm_max_ps(v1.data, v2.data);
return result;
}
};
template<qualifier Q>
struct compute_max_vector<4, int32, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, int32, Q> call(vec<4, int32, Q> const& v1, vec<4, int32, Q> const& v2)
{
vec<4, int32, Q> result;
result.data = _mm_max_epi32(v1.data, v2.data);
return result;
}
};
template<qualifier Q>
struct compute_max_vector<4, uint32, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, uint32, Q> call(vec<4, uint32, Q> const& v1, vec<4, uint32, Q> const& v2)
{
vec<4, uint32, Q> result;
result.data = _mm_max_epu32(v1.data, v2.data);
return result;
}
};
template<qualifier Q>
struct compute_clamp_vector<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& x, vec<4, float, Q> const& minVal, vec<4, float, Q> const& maxVal)
{
vec<4, float, Q> result;
result.data = _mm_min_ps(_mm_max_ps(x.data, minVal.data), maxVal.data);
return result;
}
};
template<qualifier Q>
struct compute_clamp_vector<4, int32, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, int32, Q> call(vec<4, int32, Q> const& x, vec<4, int32, Q> const& minVal, vec<4, int32, Q> const& maxVal)
{
vec<4, int32, Q> result;
result.data = _mm_min_epi32(_mm_max_epi32(x.data, minVal.data), maxVal.data);
return result;
}
};
template<qualifier Q>
struct compute_clamp_vector<4, uint32, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, uint32, Q> call(vec<4, uint32, Q> const& x, vec<4, uint32, Q> const& minVal, vec<4, uint32, Q> const& maxVal)
{
vec<4, uint32, Q> result;
result.data = _mm_min_epu32(_mm_max_epu32(x.data, minVal.data), maxVal.data);
return result;
}
};
template<qualifier Q>
struct compute_mix_vector<4, float, bool, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& x, vec<4, float, Q> const& y, vec<4, bool, Q> const& a)
{
__m128i const Load = _mm_set_epi32(-static_cast<int>(a.w), -static_cast<int>(a.z), -static_cast<int>(a.y), -static_cast<int>(a.x));
__m128 const Mask = _mm_castsi128_ps(Load);
vec<4, float, Q> Result;
# if 0 && GLM_ARCH & GLM_ARCH_AVX
Result.data = _mm_blendv_ps(x.data, y.data, Mask);
# else
Result.data = _mm_or_ps(_mm_and_ps(Mask, y.data), _mm_andnot_ps(Mask, x.data));
# endif
return Result;
}
};
/* FIXME
template<qualifier Q>
struct compute_step_vector<float, Q, tvec4>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& edge, vec<4, float, Q> const& x)
{
vec<4, float, Q> Result;
result.data = glm_vec4_step(edge.data, x.data);
return result;
}
};
*/
template<qualifier Q>
struct compute_smoothstep_vector<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& edge0, vec<4, float, Q> const& edge1, vec<4, float, Q> const& x)
{
vec<4, float, Q> Result;
Result.data = glm_vec4_smoothstep(edge0.data, edge1.data, x.data);
return Result;
}
};
}//namespace detail
}//namespace glm
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
This diff is collapsed.
/// @ref core
/// @file glm/detail/func_exponential_simd.inl
#include "../simd/exponential.h"
#if GLM_ARCH & GLM_ARCH_SSE2_BIT
namespace glm{
namespace detail
{
template<qualifier Q>
struct compute_sqrt<4, float, Q, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, Q> call(vec<4, float, Q> const& v)
{
vec<4, float, Q> Result;
Result.data = _mm_sqrt_ps(v.data);
return Result;
}
};
template<>
struct compute_sqrt<4, float, aligned_lowp, true>
{
GLM_FUNC_QUALIFIER static vec<4, float, aligned_lowp> call(vec<4, float, aligned_lowp> const& v)
{
vec<4, float, aligned_lowp> Result;
Result.data = glm_vec4_sqrt_lowp(v.data);
return Result;
}
};
}//namespace detail
}//namespace glm
#endif//GLM_ARCH & GLM_ARCH_SSE2_BIT
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/// @ref core
/// @file glm/detail/type_mat.inl
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment