Cpp autoformatter

This commit is contained in:
hodasemi 2019-01-24 15:38:18 +01:00
parent 87e032c473
commit 8a97a05969
18 changed files with 518 additions and 552 deletions

View file

@ -13,7 +13,6 @@
#include "LineSegment.h"
#include "Point.h"
/**
* Axis aligned bounding volume hierachy data structure.
*/
@ -33,11 +32,14 @@ public:
protected:
//storage of bounding box assosiated with aabb_node
Box bounds;
public:
AABBNode() {
AABBNode()
{
}
AABBNode(const Box& b): bounds(b) {
AABBNode(const Box &b) : bounds(b)
{
}
//returns the bounding box of the node
@ -48,12 +50,10 @@ public:
virtual int NumPrimitives() const = 0;
//this method must be implemented to return true for a leaf node and false for a non_lef node
virtual bool IsLeaf() const = 0;
//virtual destructor
virtual ~AABBNode() {}
};
///a class representing a leaf node of an aabb tree (non split node)
class AABBLeafNode : public AABBNode
@ -61,14 +61,12 @@ public:
//internal storage to the range (begin and end pointer) of the primitives associated with the current leaf node
PrimitiveIterator primitivesBegin, primitivesEnd;
public:
//construct a leaf node from
AABBLeafNode(const PrimitiveIterator &primitivesBegin,
const PrimitiveIterator &primitivesEnd,
const Box& b):
primitivesBegin(primitivesBegin),primitivesEnd(primitivesEnd), AABBNode(b)
const Box &b) : primitivesBegin(primitivesBegin), primitivesEnd(primitivesEnd), AABBNode(b)
{
}
@ -92,8 +90,6 @@ public:
{
return primitivesEnd;
}
};
///a class representing a split node of an aabb tree (non leaf node)
@ -101,6 +97,7 @@ public:
{
//child pointers
AABBNode *children[2];
public:
//default constructor
AABBSplitNode()
@ -157,7 +154,6 @@ public:
{
return Left()->NumPrimitives() + Right()->NumPrimitives();
}
};
private:
@ -172,7 +168,8 @@ private:
//constructor
SearchEntry(float sqrDistance, const AABBNode *node)
: sqrDistance(sqrDistance), node(node)
{ }
{
}
//search entry a < b means a.sqr_distance > b. sqr_distance
bool operator<(const SearchEntry &e) const
@ -191,11 +188,13 @@ private:
//default constructor
ResultEntry()
: sqrDistance(std::numeric_limits<float>::infinity()), prim(nullptr)
{ }
{
}
//constructor
ResultEntry(float sqrDistance, const Primitive *p)
: sqrDistance(sqrDistance), prim(p)
{ }
{
}
//result_entry are sorted by their sqr_distance using this less than operator
bool operator<(const ResultEntry &e) const
{
@ -214,7 +213,6 @@ private:
//a flag indicating if the tree is constructed
bool completed;
public:
//returns a pointer to the root node of the tree
AABBNode *Root()
@ -233,10 +231,8 @@ public:
//constructor of aabb tree
//default maximal tree depth is 20
//default minimal size of a node not to be further subdivided in the cnstruction process is two
AABBTree(int maxDepth=20, int minSize=2):
maxDepth(maxDepth),minSize(minSize),root(nullptr),completed(false)
AABBTree(int maxDepth = 20, int minSize = 2) : maxDepth(maxDepth), minSize(minSize), root(nullptr), completed(false)
{
}
//copy constructor
@ -380,7 +376,6 @@ public:
k_best.pop();
}
return result;
}
//closest k primitive computation
@ -421,9 +416,7 @@ public:
return sqrt(SqrDistance(p));
}
protected:
//helper function to copy a subtree
AABBNode *CopyTree(const primitive_list &other_primitives, AABBNode *node)
{
@ -453,8 +446,6 @@ protected:
return bounds;
}
//recursive tree construction initially called from method complete()
//build an aabb (sub)-tree over the range of primitives [begin,end),
//the current bounding box is given by bounds and the current tree depth is given by the parameter depth
@ -491,16 +482,13 @@ protected:
max_extent = e[2];
}
PrimitiveIterator mid = begin + (end - begin) / 2;
std::nth_element(begin,mid,end,[&axis](const Primitive& a, const Primitive& b)
{ return a.ReferencePoint()[axis] < b.ReferencePoint()[axis];});
std::nth_element(begin, mid, end, [&axis](const Primitive &a, const Primitive &b) { return a.ReferencePoint()[axis] < b.ReferencePoint()[axis]; });
Box lbounds = ComputeBounds(begin, mid);
Box rbounds = ComputeBounds(mid, end);
return new AABBSplitNode(Build(begin, mid, lbounds, depth + 1), Build(mid, end, rbounds, depth + 1), bounds);
}
};
@ -510,4 +498,3 @@ void BuildAABBTreeFromTriangles(const HEMesh& m, AABBTree<Triangle >& tree);
void BuildAABBTreeFromVertices(const HEMesh &m, AABBTree<Point> &tree);
//helper function to construct an aabb tree data structure from the edges of the halfedge mesh m
void BuildAABBTreeFromEdges(const HEMesh &m, AABBTree<LineSegment> &tree);

View file

@ -12,7 +12,6 @@ class Box
std::pair<Eigen::Vector3f, Eigen::Vector3f> bounds;
public:
//creates an empty box like the method Clear
Box();
@ -77,5 +76,4 @@ public:
//returns the euclidean distance between p and the box
float Distance(const Eigen::Vector3f &p) const;
};

View file

@ -47,6 +47,4 @@ public:
//returns a reference point which is on the line segment and is used to sort the primitive in the AABB tree construction
Eigen::Vector3f ReferencePoint() const;
};

View file

@ -6,7 +6,6 @@
#include "Box.h"
#include "util/OpenMeshUtils.h"
/*
a triangle primitive which can be used with the AABBTree and the HashGrid data structure
*/
@ -22,7 +21,6 @@ class Triangle
OpenMesh::FaceHandle h;
public:
//default constructor
Triangle();
//constructs a triangle using the vertex positions v0,v1 and v2
@ -43,6 +41,4 @@ public:
float Distance(const Eigen::Vector3f &p) const;
//returns a reference point which is on the triangle and is used to sort the primitive in the AABB tree construction
Eigen::Vector3f ReferencePoint() const;
};

View file

@ -24,10 +24,11 @@ public:
void drawContents();
private:
enum PrimitiveType
{
Vertex, Edge, Tri
Vertex,
Edge,
Tri
};
void SetupGUI();

View file

@ -6,7 +6,6 @@
#include "GridUtils.h"
#include <limits>
//creates an empty box like the method Clear
Box::Box()
{
@ -174,5 +173,3 @@ float Box::Distance(const Eigen::Vector3f& p) const
{
return sqrt(SqrDistance(p));
}

View file

@ -5,9 +5,9 @@
#include "GridTraverser.h"
#include "GridUtils.h"
GridTraverser::GridTraverser()
{ }
{
}
GridTraverser::GridTraverser(const Eigen::Vector3f &o, const Eigen::Vector3f &d, const Eigen::Vector3f cell_extents)
: orig(o), dir(d), cellExtents(cell_extents)
@ -59,5 +59,3 @@ Eigen::Vector3i GridTraverser::operator*()
{
return current;
}

View file

@ -5,7 +5,6 @@
#include "LineSegment.h"
#include "GridUtils.h"
//default constructor
LineSegment::LineSegment()
{
@ -86,10 +85,7 @@ bool LineSegment::Overlaps(const Box& b) const
if (!OverlapIntervals(-r, r, lb, ub))
return false;
return true;
}
//returns the point with smallest distance topoint p which lies on the line segment
@ -118,6 +114,3 @@ Eigen::Vector3f LineSegment::ReferencePoint() const
{
return 0.5f * (v0 + v1);
}

View file

@ -33,8 +33,7 @@ bool Point::Overlaps(const Box& b) const
{
Eigen::Vector3f lb = b.LowerBound();
Eigen::Vector3f ub = b.UpperBound();
return
(v0[0] >= lb[0] && v0[0] <= ub[0]&&
return (v0[0] >= lb[0] && v0[0] <= ub[0] &&
v0[1] >= lb[1] && v0[1] <= ub[1] &&
v0[2] >= lb[2] && v0[2] <= ub[2]);
}

View file

@ -6,7 +6,6 @@
#include "GridUtils.h"
#include <tuple>
//default constructor
Triangle::Triangle()
{
@ -33,7 +32,6 @@ Box Triangle::ComputeBounds() const
return b;
}
//returns true if the triangle overlaps the given box b
bool Triangle::Overlaps(const Box &b) const
{
@ -75,7 +73,6 @@ void Triangle::ClosestPointBarycentric(const Eigen::Vector3f& p, float& l0, floa
s = 0.f;
t = -e / c;
t = std::min(std::max(t, 0.0f), 1.0f);
}
}
else
@ -157,7 +154,6 @@ Eigen::Vector3f Triangle::ClosestPoint(const Eigen::Vector3f& p) const
float l0, l1, l2;
ClosestPointBarycentric(p, l0, l1, l2);
return l0 * v0 + l1 * v1 + l2 * v2;
}
//returns the squared distance between point p and the triangle
float Triangle::SqrDistance(const Eigen::Vector3f &p) const
@ -175,6 +171,3 @@ Eigen::Vector3f Triangle::ReferencePoint() const
{
return (v0 + v1 + v2) / 3.0f;
}

View file

@ -75,9 +75,12 @@ void Viewer::SetupGUI()
});
sldRaySteps->callback()(sldRaySteps->value());
chkRenderMesh = new nanogui::CheckBox(mainWindow, "Render Mesh"); chkRenderMesh->setChecked(true);
chkRenderGrid = new nanogui::CheckBox(mainWindow, "Render Non-Empty Grid Cells"); chkRenderGrid->setChecked(false);
chkRenderRay = new nanogui::CheckBox(mainWindow, "Render Ray"); chkRenderRay->setChecked(false);
chkRenderMesh = new nanogui::CheckBox(mainWindow, "Render Mesh");
chkRenderMesh->setChecked(true);
chkRenderGrid = new nanogui::CheckBox(mainWindow, "Render Non-Empty Grid Cells");
chkRenderGrid->setChecked(false);
chkRenderRay = new nanogui::CheckBox(mainWindow, "Render Ray");
chkRenderRay->setChecked(false);
shadingBtn = new nanogui::ComboBox(mainWindow, {"Smooth Shading", "Flat Shading"});
@ -200,10 +203,14 @@ void Viewer::AddBoxVertices(const Box & box, std::vector<Eigen::Vector4f>& posit
{
auto &lb = box.LowerBound();
auto &ub = box.UpperBound();
Eigen::Vector4f o; o << lb, 1.0f;
Eigen::Vector4f x; x << ub.x() - lb.x(), 0, 0, 0;
Eigen::Vector4f y; y << 0, ub.y() - lb.y(), 0, 0;
Eigen::Vector4f z; z << 0, 0, ub.z() - lb.z(), 0;
Eigen::Vector4f o;
o << lb, 1.0f;
Eigen::Vector4f x;
x << ub.x() - lb.x(), 0, 0, 0;
Eigen::Vector4f y;
y << 0, ub.y() - lb.y(), 0, 0;
Eigen::Vector4f z;
z << 0, 0, ub.z() - lb.z(), 0;
positions.push_back(o);
positions.push_back(o + x);
positions.push_back(o + x);

View file

@ -29,7 +29,6 @@ int main(int argc, char* argv[])
{
std::cerr << e.what() << std::endl;
}
}
nanogui::shutdown();