-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from master-csmi/docker
Docker
- Loading branch information
Showing
23 changed files
with
277 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "Vegetation", | ||
"image": "2024m1vegetation:latest" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM ubuntu:24.04 | ||
|
||
# Copy project files | ||
COPY . /vegetation | ||
WORKDIR /vegetation | ||
|
||
# Set the timezone to Europe/Paris | ||
ENV TZ=Europe/Paris | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y \ | ||
wget \ | ||
build-essential \ | ||
cmake \ | ||
git \ | ||
libmpfr-dev \ | ||
libboost-dev \ | ||
libcurl4-openssl-dev \ | ||
python3-pip \ | ||
libcgal-dev \ | ||
libfmt-dev \ | ||
libspdlog-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
{ | ||
"A": { | ||
"latitude": 48.578702, | ||
"longitude": 7.739103 | ||
}, | ||
"B": { | ||
"latitude": 48.587756, | ||
"longitude": 7.756632 | ||
} | ||
} | ||
"A": { | ||
"latitude": 48.5858, | ||
"longitude": 7.7541 | ||
}, | ||
"B": { | ||
"latitude": 48.5802, | ||
"longitude": 7.7429 | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#ifndef MESH_HPP | ||
#define MESH_HPP | ||
|
||
#include "tree.hpp" | ||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h> | ||
#include <CGAL/IO/polygon_soup_io.h> | ||
#include <CGAL/Polygon_mesh_processing/bbox.h> | ||
#include <CGAL/Real_timer.h> | ||
#include <CGAL/Surface_mesh.h> | ||
#include <CGAL/alpha_wrap_3.h> | ||
#include <array> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
|
||
using K = CGAL::Exact_predicates_inexact_constructions_kernel; | ||
using Point_3 = K::Point_3; | ||
using Mesh = CGAL::Surface_mesh<Point_3>; | ||
|
||
class TreeMesh { | ||
public: | ||
void wrap_tree(const Tree &t) { | ||
std::string filePath = "../data/tree/"; | ||
std::string season = t.getSeason(); | ||
std::string species = t.getSpecies(); | ||
|
||
if (season == "spring" || season == "summer") { | ||
filePath += "leafy/"; | ||
} else { | ||
filePath += "leafless/"; | ||
} | ||
|
||
// if (species == "Acer pseudoplatanus") { | ||
// filePath += "arbre1.off"; | ||
// } | ||
// ... | ||
filePath += "arbre1.stl"; | ||
filename = "arbre1.stl"; | ||
|
||
double relative_alpha; | ||
double relative_offset = 600; | ||
|
||
switch (M_lod) { | ||
case 0: | ||
relative_alpha = 0.1; | ||
break; | ||
case 1: | ||
relative_alpha = 20; | ||
break; | ||
case 2: | ||
relative_alpha = 100; | ||
break; | ||
default: | ||
break; | ||
} | ||
|
||
CGAL::data_file_path(filePath); | ||
std::vector<Point_3> points; | ||
std::vector<std::array<int, 3>> faces; | ||
std::vector<std::array<int, 3>> edges; | ||
CGAL::Bbox_3 bbox; | ||
|
||
if (!CGAL::IO::read_polygon_soup(filePath, points, faces) || | ||
faces.empty()) { | ||
std::cerr << "Invalid input." << std::endl; | ||
exit(1); | ||
} | ||
|
||
for (const Point_3 &p : points) | ||
bbox += p.bbox(); | ||
const double diag_length = | ||
std::sqrt(CGAL::square(bbox.xmax() - bbox.xmin()) + | ||
CGAL::square(bbox.ymax() - bbox.ymin()) + | ||
CGAL::square(bbox.zmax() - bbox.zmin())); | ||
|
||
const double alpha = diag_length / relative_alpha; | ||
const double offset = diag_length / relative_offset; | ||
|
||
// scale the points depending on the tree object | ||
|
||
// for (auto &point : points) { | ||
// point = Point_3(point.x(), point.y(), point.z()); | ||
// } | ||
|
||
CGAL::Real_timer ti; | ||
ti.start(); | ||
|
||
CGAL::alpha_wrap_3(points, faces, alpha, offset, M_wrap); | ||
|
||
ti.stop(); | ||
|
||
// std::cout << "Result: " << num_vertices(M_wrap) << " vertices, " | ||
// << num_faces(M_wrap) << " faces" << std::endl; | ||
// std::cout << "Took " << ti.time() << " s." << std::endl; | ||
} | ||
|
||
void setLod(int lod) { M_lod = lod; } | ||
|
||
std::string getFilename() const { return filename; } | ||
int getLod() const { return M_lod; } | ||
Mesh getWrap() const { return M_wrap; } | ||
|
||
void dumpMesh(const Tree &t) const { | ||
|
||
std::string output_dir = "../temp/"; | ||
|
||
std::string input_name = std::string(filename); | ||
input_name = input_name.substr(input_name.find_last_of("/") + 1, | ||
input_name.length() - 1); | ||
input_name = input_name.substr(0, input_name.find_last_of(".")); | ||
|
||
std::string output_name = | ||
output_dir + input_name + "_" + | ||
std::to_string(static_cast<int>(M_lod)) + "_" + | ||
std::to_string(static_cast<int>(t.getX())) + "_" + | ||
std::to_string(static_cast<int>(t.getY())) + ".stl"; | ||
// std::cout << "Writing to " << output_name << std::endl; | ||
CGAL::IO::write_polygon_mesh(output_name, M_wrap, | ||
CGAL::parameters::stream_precision(17)); | ||
} | ||
|
||
private: | ||
int M_lod; | ||
Mesh M_wrap; | ||
std::string filename; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": 0.6, | ||
"generator": "Overpass API 0.7.62.1 084b4234", | ||
"osm3s": { | ||
"timestamp_osm_base": "2024-04-16T08:36:06Z", | ||
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL." | ||
}, | ||
"elements": [ | ||
|
||
|
||
|
||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.