Merge branch 'master' of https://git.frank-ebner.de/FHWS/Indoor
This commit is contained in:
115
data/File.h
Normal file
115
data/File.h
Normal file
@@ -0,0 +1,115 @@
|
||||
#ifndef FS_FILE_H
|
||||
#define FS_FILE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
|
||||
|
||||
#if __cplusplus > 201103L
|
||||
|
||||
// use new cross-platform std::experimental stuff
|
||||
#include <experimental/filesystem>
|
||||
|
||||
namespace FS {
|
||||
|
||||
class File {
|
||||
|
||||
std::experimental::filesystem::path path;
|
||||
|
||||
public:
|
||||
|
||||
File(const std::string& fileOrFolder) : path(fileOrFolder) {
|
||||
|
||||
}
|
||||
|
||||
bool exists() const {
|
||||
return std::experimental::filesystem::exists(path);
|
||||
}
|
||||
|
||||
std::vector<File> listFiles() const {
|
||||
std::vector<File> res;
|
||||
for (std::experimental::filesystem::directory_entry entry : std::experimental::filesystem::directory_iterator(path)) {
|
||||
const std::string abs = entry.path().string();
|
||||
res.push_back(File(abs));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string getPath() const {
|
||||
return path.string();
|
||||
}
|
||||
|
||||
std::string getFilename() const {
|
||||
return path.filename().string();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// use linux-only fallback
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace FS {
|
||||
|
||||
class File {
|
||||
|
||||
std::string path;
|
||||
|
||||
public:
|
||||
|
||||
File(const std::string& fileOrFolder) : path(fileOrFolder) {
|
||||
|
||||
}
|
||||
|
||||
bool exists() const {
|
||||
struct stat st;
|
||||
int res = stat(path.c_str(), &st );
|
||||
return res == 0;
|
||||
}
|
||||
|
||||
/** list of all files/folders within the current folder */
|
||||
std::vector<File> listFiles() const {
|
||||
|
||||
std::vector<File> res;
|
||||
|
||||
DIR* dir;
|
||||
|
||||
dir = opendir(path.c_str());
|
||||
if (!dir) {throw Exception("failed to open folder " + path);}
|
||||
|
||||
// fetch all entries
|
||||
while(true) {
|
||||
dirent* entry = readdir(dir);
|
||||
if (!entry) {break;}
|
||||
const std::string abs = path + "/" + entry->d_name;
|
||||
res.push_back(File(abs));
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
}
|
||||
|
||||
const std::string& getPath() const {
|
||||
return path;
|
||||
}
|
||||
|
||||
const std::string getFilename() const {
|
||||
const size_t lastSlash = path.find_last_of("/");
|
||||
if (std::string::npos == lastSlash) {return path;}
|
||||
std::string name = path.substr(lastSlash+1);
|
||||
return name;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // FS_FILE_H
|
||||
@@ -136,6 +136,14 @@ public:
|
||||
|
||||
}
|
||||
|
||||
/** perform some sanity checks */
|
||||
bool isValid() const {
|
||||
if (p1 == p2) {return false;}
|
||||
if (p1 == p3) {return false;}
|
||||
if (p2 == p3) {return false;}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
int rayIntersectsTriangle(float *p, float *d,
|
||||
float *v0, float *v1, float *v2) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../../Grid.h"
|
||||
#include "../../../math/DrawList.h"
|
||||
#include "modules/WalkModule.h"
|
||||
#include "../../../math/Distributions.h"
|
||||
#include "../../../math/distribution/Normal.h"
|
||||
#include "../../../math/Stats.h"
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "WalkModule.h"
|
||||
|
||||
#include "../../../../geo/Heading.h"
|
||||
#include "../../../../math/Distributions.h"
|
||||
#include "../../../../math/distribution/Normal.h"
|
||||
|
||||
#include "../../../../sensors/activity/ActivityButterPressure.h"
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "WalkStateHeading.h"
|
||||
|
||||
#include "../../../../geo/Heading.h"
|
||||
#include "../../../../math/Distributions.h"
|
||||
#include "../../../../math/distribution/Normal.h"
|
||||
|
||||
#include "../../../../Assertions.h"
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include "../../../../nav/dijkstra/Dijkstra.h"
|
||||
#include "../../../../nav/dijkstra/DijkstraPath.h"
|
||||
|
||||
#include "../../../../math/Distributions.h"
|
||||
#include "../../../../math/distribution/Normal.h"
|
||||
#include "../../../../Assertions.h"
|
||||
|
||||
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
#include "WalkStateHeading.h"
|
||||
|
||||
#include "../../../../geo/Heading.h"
|
||||
#include "../../../../math/Distributions.h"
|
||||
|
||||
#include "../../../../math/distribution/Normal.h"
|
||||
#include "../../../../math/distribution/LUT.h"
|
||||
#include "../../../../math/distribution/VonMises.h"
|
||||
|
||||
/** keep the state's heading */
|
||||
template <typename Node, typename WalkState, typename Control> class WalkModuleHeadingControl : public WalkModule<Node, WalkState> {
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
#include "WiFiProbability.h"
|
||||
#include "model/WiFiModel.h"
|
||||
#include "../../math/Distributions.h"
|
||||
#include "../../math/distribution/Normal.h"
|
||||
#include "../../math/distribution/Region.h"
|
||||
#include "../../math/distribution/Exponential.h"
|
||||
#include "VAPGrouper.h"
|
||||
#include "../../floorplan/v2/Floorplan.h"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "../../math/Distributions.h"
|
||||
#include "../../math/distribution/Normal.h"
|
||||
#include "../../data/Timestamp.h"
|
||||
|
||||
#include "WiFiGridNode.h"
|
||||
|
||||
@@ -339,6 +339,13 @@ namespace Ray3D {
|
||||
|
||||
const std::string& name = foo->file;
|
||||
Obstacle3D obs = OBJPool::get().getObject(name);
|
||||
|
||||
// perform sanity checks
|
||||
if (!obs.isValid()) {
|
||||
throw std::runtime_error("invalid obstacle-data detected");
|
||||
}
|
||||
|
||||
// apply scaling/rotation/translation
|
||||
obs = obs.scaled(foo->scale);
|
||||
obs = obs.rotated_deg( Point3(foo->rot.x, foo->rot.y, foo->rot.z) );
|
||||
obs = obs.translated(foo->pos + Point3(0,0,fpos.z1));
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
// LINUX ONLY
|
||||
//#include <dirent.h>
|
||||
//#include <stdio.h>
|
||||
#include <experimental/filesystem>
|
||||
#include "../../../data/File.h"
|
||||
|
||||
|
||||
#include "../../../misc/Debug.h"
|
||||
|
||||
@@ -83,17 +84,17 @@ namespace Ray3D {
|
||||
/** scan the given folder for all *.obj files */
|
||||
void scanFolder(const std::string& folder) {
|
||||
|
||||
std::experimental::filesystem::path d(folder);
|
||||
if (!std::experimental::filesystem::exists(d)) {
|
||||
FS::File d(folder);
|
||||
if (!d.exists()) {
|
||||
throw Exception("OBJPool: folder not found: " + folder);
|
||||
}
|
||||
|
||||
for (std::experimental::filesystem::directory_entry entry : std::experimental::filesystem::directory_iterator(d)) {
|
||||
const std::string absFile = entry.path().string();
|
||||
if (endsWith(absFile, ".obj")) {
|
||||
std::string name = entry.path().filename().string();
|
||||
for (const FS::File& f : d.listFiles()) {
|
||||
std::string name = f.getFilename();
|
||||
if (endsWith(name, ".obj")) {
|
||||
//std::string name = entry.path().filename().string();
|
||||
name = name.substr(0, name.length() - 4); // without extension
|
||||
load(absFile, name);
|
||||
load(f.getPath(), name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -89,6 +89,14 @@ namespace Ray3D {
|
||||
return res;
|
||||
}
|
||||
|
||||
/** perform sanity checks */
|
||||
bool isValid() const {
|
||||
for (const Triangle3& t : triangles) {
|
||||
if (!t.isValid()) {return false;}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user