Skip to content

Commit

Permalink
Merge pull request #456 from 3dgeo-heidelberg/devel-aux
Browse files Browse the repository at this point in the history
Devel aux
  • Loading branch information
han16nah authored Jun 5, 2024
2 parents e576163 + 6c06b23 commit 1fff9a6
Show file tree
Hide file tree
Showing 46 changed files with 1,496 additions and 547,180 deletions.
193 changes: 100 additions & 93 deletions example_notebooks/1-tls_arbaro.ipynb

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions example_notebooks/10-uls_toyblocks_livox.ipynb

Large diffs are not rendered by default.

64 changes: 15 additions & 49 deletions example_notebooks/11-als_toyblock_multi_scanner_livox.ipynb

Large diffs are not rendered by default.

1,593 changes: 31 additions & 1,562 deletions example_notebooks/12-multi_scanner_puck.ipynb

Large diffs are not rendered by default.

547 changes: 9 additions & 538 deletions example_notebooks/13-interpolated_trajectory.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions example_notebooks/14-urban_mls_dynamic.ipynb

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions example_notebooks/15-tls_tree_dynamic.ipynb

Large diffs are not rendered by default.

1,129 changes: 11 additions & 1,118 deletions example_notebooks/2-mls_wheat.ipynb

Large diffs are not rendered by default.

1,061 changes: 20 additions & 1,041 deletions example_notebooks/3-mls_toyblocks.ipynb

Large diffs are not rendered by default.

54 changes: 10 additions & 44 deletions example_notebooks/4-uls_toyblocks_surveyscene.ipynb

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions example_notebooks/5_als_hd_demo.ipynb

Large diffs are not rendered by default.

64 changes: 15 additions & 49 deletions example_notebooks/6-als_hd_height_above_ground.ipynb

Large diffs are not rendered by default.

74 changes: 21 additions & 53 deletions example_notebooks/7-tls_sphere_xyzloader.ipynb

Large diffs are not rendered by default.

70 changes: 19 additions & 51 deletions example_notebooks/8-als_uls_detailed_voxel.ipynb

Large diffs are not rendered by default.

26 changes: 7 additions & 19 deletions example_notebooks/9-tls_livox_demo.ipynb

Large diffs are not rendered by default.

256 changes: 65 additions & 191 deletions example_notebooks/A-arboretum_notebook.ipynb

Large diffs are not rendered by default.

1,279 changes: 22 additions & 1,257 deletions example_notebooks/I-getting-started.ipynb

Large diffs are not rendered by default.

2,406 changes: 21 additions & 2,385 deletions example_notebooks/II-the-survey.ipynb

Large diffs are not rendered by default.

194,584 changes: 14 additions & 194,570 deletions example_notebooks/III-pyhelios_sim_and_vis.ipynb

Large diffs are not rendered by default.

343,993 changes: 39 additions & 343,954 deletions example_notebooks/IV-live_trajectory_plot.ipynb

Large diffs are not rendered by default.

Binary file added example_notebooks/images/VZ400_technical_data.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pytests/test_demo_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_xyzVoxels_tls_pyh():

def eval_xyzVoxels_tls(dirname):
assert (dirname / 'leg000_points.las').exists()
assert abs((dirname / 'leg000_points.las').stat().st_size - 50_340_807) < MAX_DIFFERENCE_BYTES
assert abs((dirname / 'leg000_points.las').stat().st_size - 19_352_123) < MAX_DIFFERENCE_BYTES
# clean up
if DELETE_FILES_AFTER:
shutil.rmtree(dirname)
Expand Down Expand Up @@ -450,7 +450,7 @@ def test_dyn_exe():

def eval_dyn(dirname):
assert (dirname / 'leg000_points.laz').exists()
assert abs((dirname / 'leg000_points.laz').stat().st_size - 4_174_789) < MAX_DIFFERENCE_BYTES
assert abs((dirname / 'leg000_points.laz').stat().st_size - 2_642_291) < MAX_DIFFERENCE_BYTES
# clean up
if DELETE_FILES_AFTER:
shutil.rmtree(dirname)
2 changes: 1 addition & 1 deletion pytests/test_pyhelios.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_create_survey():
output = simB.join()
meas, traj = pyhelios.outputToNumpy(output)
# check length of output
assert meas.shape == (34317, 17)
assert meas.shape == (9926, 17)
assert traj.shape == (6670, 7)
# compare individual points
np.testing.assert_allclose(meas[100, :3], np.array([83.32, -66.44204, 0.03114649]))
Expand Down
7 changes: 5 additions & 2 deletions python/pyhelios/simulation_builder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .pyheliostools_exception import PyHeliosToolsException
from .simulation_build import SimulationBuild
from collections import namedtuple
from collections.abc import Iterable
from math import isnan
import os
import time
Expand Down Expand Up @@ -66,6 +67,8 @@ class SimulationBuilder:
# --- CONSTRUCTOR --- #
# --------------------- #
def __init__(self, surveyPath, assetsDir, outputDir):
if not isinstance(assetsDir, Iterable) or isinstance(assetsDir, str):
assetsDir = [assetsDir]
# Add default values for asset directories
assetsDir = assetsDir + [os.getcwd(), str(resources.files("pyhelios")), str(resources.files("pyhelios") / "data")]

Expand Down Expand Up @@ -127,8 +130,6 @@ def build(self):
build.sim.finalOutput = self.finalOutput
build.sim.legacyEnergyModel = self.legacyEnergyModel
build.sim.exportToFile = self.exportToFile
if self.callback is not None:
build.sim.setCallback(self.callback)
for rotateFilter in self.rotateFilters:
build.sim.addRotateFilter(
rotateFilter.q0,
Expand Down Expand Up @@ -157,6 +158,8 @@ def build(self):
self.fullwaveNoise,
self.platformNoiseDisabled
)
if self.callback is not None:
build.sim.setCallback(self.callback)

end = time.perf_counter()
print(
Expand Down
2 changes: 2 additions & 0 deletions src/assetloading/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ target_sources(
"geometryfilter/RotateFilter.cpp"
"geometryfilter/GeoTiffFileLoader.cpp"
"geometryfilter/DetailedVoxelLoader.cpp"
"geometryfilter/DenseVoxelGrid.cpp"
"geometryfilter/SparseVoxelGrid.cpp"
"geometryfilter/WavefrontObj.cpp"
"geometryfilter/XYZPointCloudFileLoader.cpp"
"geometryfilter/AbstractGeometryFilter.cpp"
Expand Down
2 changes: 1 addition & 1 deletion src/assetloading/XmlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ std::map<std::string, ObjectT> XmlUtils::createParamsFromXml(
result.insert(std::pair<std::string, std::string>(key, valueString));
} else {

if (type == "boolean") {
if (type == "boolean" || type == "bool") {
bool b = valueString == "true";
result.insert(std::pair<std::string, bool>(key, b));
} else if (type == "double") {
Expand Down
135 changes: 135 additions & 0 deletions src/assetloading/geometryfilter/DenseVoxelGrid.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#include <assetloading/geometryfilter/DenseVoxelGrid.h>

// *** CONSTRUCTION / DESTRUCTION *** //
// ************************************ //
DenseVoxelGrid::DenseVoxelGrid(size_t const maxNVoxels) :
IVoxelGrid(maxNVoxels)
{
voxels = new VoxelGridCell[maxNVoxels];
}


// *** VOXEL GRID INTERFACE *** //
// ****************************** //
void DenseVoxelGrid::release(){
if(voxels != nullptr){
delete[] voxels;
voxels = nullptr;
}
}


bool DenseVoxelGrid::hasVoxel(size_t const key){
return voxels[key].voxel != nullptr;
}

Voxel* DenseVoxelGrid::getVoxel(size_t const key){
return voxels[key].voxel;
}

Voxel * DenseVoxelGrid::setVoxel(
size_t const key,
double const x, double const y, double const z,
double halfVoxelSize
){
VoxelGridCell &vgc = voxels[key];
vgc.voxel = new Voxel(x, y, z, halfVoxelSize);
return vgc.voxel;
}

void DenseVoxelGrid::deleteVoxel(size_t const key){
Voxel *voxel = voxels[key].voxel;
if(voxel == nullptr) return;
delete voxel;
voxels[key].voxel = nullptr;
}

Mat<double> * DenseVoxelGrid::getMatrix(size_t const key) const {
return voxels[key].matrix;
}

Mat<double> & DenseVoxelGrid::getMatrixRef(size_t const key) const {
return *voxels[key].matrix;
}

Mat<double> const & DenseVoxelGrid::getMatrixConstRef(size_t const key) const {
return *voxels[key].matrix;
}

void DenseVoxelGrid::setMatrix(size_t const key, Mat<double> *mat){
VoxelGridCell &vgc = voxels[key];
if(vgc.matrix != nullptr) deleteMatrix(key);
vgc.matrix = mat;
}

void DenseVoxelGrid::setNextMatrixCol(
size_t const key,
double const x, double const y, double const z
) {
VoxelGridCell &vgc = voxels[key];
size_t const startIdx = vgc.cursor*3;
(*vgc.matrix)[startIdx] = x;
(*vgc.matrix)[startIdx+1] = y;
(*vgc.matrix)[startIdx+2] = z;
++vgc.cursor;
}

void DenseVoxelGrid::deleteMatrix(size_t const key){
delete voxels[key].matrix;
voxels[key].matrix = nullptr;
}
void DenseVoxelGrid::deleteMatrices(){
for(size_t i = 0 ; i < maxNVoxels ; ++i) deleteMatrix(i);
}


size_t DenseVoxelGrid::getCursor(size_t const key) const{
return voxels[key].cursor;
}

void DenseVoxelGrid::setCursor(size_t const key, size_t const cursor) {
voxels[key].cursor = cursor;
}

void DenseVoxelGrid::incrementCursor(size_t const key){
++voxels[key].cursor;
}

double DenseVoxelGrid::getClosestPointDistance(size_t const key) const {
return voxels[key].closestPointDistance;
}
void DenseVoxelGrid::setClosestPointDistance(
size_t const key, double const distance
) {
voxels[key].closestPointDistance = distance;
}


// *** WHILE INTERFACE *** //
// *************************** //
void DenseVoxelGrid::whileLoopStart(){
for(
whileLoopIter = 0 ;
whileLoopIter < maxNVoxels && voxels[whileLoopIter].voxel == nullptr;
++whileLoopIter
);
}

bool DenseVoxelGrid::whileLoopHasNext(){
return whileLoopIter < maxNVoxels;
}

Voxel * DenseVoxelGrid::whileLoopNext(size_t *key){
// Obtain current voxel
Voxel *voxel = voxels[whileLoopIter].voxel;
// Obtain the matrix, if requested
if(key != nullptr) *key = whileLoopIter;
// Iterate to find next voxel, if any, and update whileLoopIter
for(
++whileLoopIter;
whileLoopIter < maxNVoxels && voxels[whileLoopIter].voxel == nullptr;
++whileLoopIter
);
// Return current voxel
return voxel;
}
141 changes: 141 additions & 0 deletions src/assetloading/geometryfilter/DenseVoxelGrid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
#pragma once

#include <assetloading/geometryfilter/IVoxelGrid.h>

/**
* @author Alberto M. Esmoris Pena
* @version 1.0
*
* @brief Dense voxel grid implementation of IVoxelGrid. It uses the indices
* of an array to represent the (key, value) pairs as (index, voxel).
*
* @see IVoxelGrid
*/
class DenseVoxelGrid : public IVoxelGrid {
protected:
// *** ATTRIBUTES *** //
// ********************** //
/**
* @brief Array of voxels.
* @see VoxelGridCell
* @see Voxel
*/
VoxelGridCell *voxels;
/**
* @brief Used internally to track the current iteration of the while loop.
*/
size_t whileLoopIter;

public:
// *** CONSTRUCTION / DESTRUCTION *** //
// ************************************ //
/**
* @brief Constructor for a dense voxel grid.
* @see IVoxelGrid::IVoxelGrid
*/
DenseVoxelGrid(size_t const maxNVoxels);
virtual ~DenseVoxelGrid() {release();}

// *** VOXEL GRID INTERFACE *** //
// ****************************** //
/**
* @see IVoxelGrid::release
*/
void release() override;


/**
* @see IVoxelGrid::hasVoxel
*/
bool hasVoxel(size_t const key) override;
/**
* @see IVoxelGrid::getVoxel
*/
Voxel* getVoxel(size_t const key) override;
/**
* @see IVoxelGrid::setVoxel
*/
Voxel * setVoxel(
size_t const key,
double const x, double const y, double const z,
double halfVoxelSize
) override;
/**
* @see IVoxelGrid::deleteVoxel
*/
void deleteVoxel(size_t const key) override;


/**
* @see IVoxelGrid::getMatrix
*/
Mat<double> * getMatrix(size_t const key) const override;
/**
* @see IVoxelGrid::getMatrixRef
*/
Mat<double> & getMatrixRef(size_t const key) const override;
/**
* @see IVoxelGrid::getMatrixConstRef
*/
Mat<double> const & getMatrixConstRef(size_t const key) const override;
/**
* @see IVoxelGrid::setMatrix
*/
void setMatrix(size_t const key, Mat<double> *mat) override;
/**
* @see IVoxelGrid::setNextMatrixCol
*/
void setNextMatrixCol(
size_t const key,
double const x, double const y, double const z
) override;
/**
* @see IVoxelGrid::deleteMatrix
*/
void deleteMatrix(size_t const key) override;
/**
* @see IVoxelGrid::deleteMatrices
*/
void deleteMatrices() override;


/**
* @see IVoxelGrid::getCursor
*/
size_t getCursor(size_t const key) const override;
/**
* @see IVoxelGrid::setCursor
*/
void setCursor(size_t const key, size_t const cursor) override;
/**
* @see IVoxelGrid::incrementCursor
*/
void incrementCursor(size_t const key) override;

/**
* @see IVoxelGird::getClosestPointDistance
*/
double getClosestPointDistance(size_t const key) const override;
/**
* @see IVoxelGrid::setClosestPointDistance
*/
void setClosestPointDistance(
size_t const key, double const distance
) override;


// *** WHILE INTERFACE *** //
// *************************** //
/**
* @see IVoxelGrid::whileLoopStart
*/
void whileLoopStart() override;
/**
* @see IVoxelGrid::whileLoopHasNext
*/
bool whileLoopHasNext() override;
/**
* @see IVoxelGrid::whileLoopNext
*/
Voxel * whileLoopNext(size_t *key=nullptr) override;
};
5 changes: 3 additions & 2 deletions src/assetloading/geometryfilter/DetailedVoxelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ void DetailedVoxelLoader::loadDv(
}
// Prepare default material
Material mat;
mat.isGround = false;
// Legacy default material for vegetation studies commented below
/*mat.isGround = false;
mat.useVertexColors = true;
mat.reflectance = 0.5;
mat.specularity = 0.5;
Expand All @@ -78,7 +79,7 @@ void DetailedVoxelLoader::loadDv(
mat.kd[2] = 0.5; mat.kd[3] = 0.5;
mat.ks[0] = 0.5; mat.ks[1] = 0.5;
mat.ks[2] = 0.5; mat.ks[3] = 0.5;
mat.spectra = "wood";
mat.spectra = "wood";*/

// Parse detailed voxels
VoxelFileParser vfp;
Expand Down
Loading

0 comments on commit 1fff9a6

Please sign in to comment.