Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sevec committed Jun 22, 2020
0 parents commit d133428
Show file tree
Hide file tree
Showing 20 changed files with 2,630 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Assert.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

#include <cassert>

#define ASSERT(x, ...) assert(x)
79 changes: 79 additions & 0 deletions Box.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#pragma once

#include "Vector.hpp"

namespace Pvl {

template <typename T, int Dim>
class BoundingBox {
Vector<T, Dim> lower_;
Vector<T, Dim> upper_;

public:
BoundingBox()
: lower_(std::numeric_limits<T>::max())
, upper_(std::numeric_limits<T>::lowest()) {}

BoundingBox(const Vector<T, Dim>& lower, const Vector<T, Dim>& upper)
: lower_(lower)
, upper_(upper) {}

Vector<T, Dim>& lower() {
return lower_;
}

const Vector<T, Dim>& lower() const {
return lower_;
}

Vector<T, Dim>& upper() {
return upper_;
}

const Vector<T, Dim>& upper() const {
return upper_;
}

Vector<T, Dim> size() const {
return upper_ - lower_;
}

Vector<T, Dim> center() const {
return T(0.5) * (upper_ + lower_);
}


bool contains(const Vector<T, Dim>& p) const {
for (int i = 0; i < Dim; ++i) {
if (p[i] < lower_[i] || p[i] > upper_[i]) {
return false;
}
}
return true;
}

void extend(const Vector<T, Dim>& p) {
lower_ = min(lower_, p);
upper_ = max(upper_, p);
}
};

/// \brief Splits the box along given coordinate.
///
/// The splitting plane must pass through the box.
template <typename T, int Dim>
std::pair<BoundingBox<T, Dim>, BoundingBox<T, Dim>> splitBox(const BoundingBox<T, Dim>& box,
const int dim,
const T x) {
/*ASSERT(isValid());*/
ASSERT(dim < Dim);
ASSERT(x >= box.lower()[dim] && x <= box.upper()[dim]);
BoundingBox<T, Dim> b1 = box;
BoundingBox<T, Dim> b2 = box;
b1.lower()[dim] = x;
b2.upper()[dim] = x;
return std::make_pair(b1, b2);
}


} // namespace Pvl
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
cmake_minimum_required(VERSION 3.5)

project(pvl LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(TBB REQUIRED tbb)

add_executable(pvl
main.cpp
Utils.hpp
Assert.hpp
Math.hpp
Vector.hpp
Matrix.hpp
Svd.hpp
Box.hpp
KdTree.h KdTree.inl.h
PlyWriter.hpp PlyReader.hpp
Cloud.hpp
Kernels.hpp
TriangleMesh.hpp
MeshUtils.hpp
Range.hpp
Graph.hpp Graph.inl.hpp
UniformGrid.hpp
OctreeGrid.hpp
MarchingCubes.hpp MarchingCubes.cpp
)

target_link_libraries(pvl PRIVATE tbb)
3 changes: 3 additions & 0 deletions Cloud.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

namespace Pvl {}
Loading

0 comments on commit d133428

Please sign in to comment.