# HG changeset patch # User Radek Brich # Date 1469547696 -7200 # Node ID 3b3257a410fe2d69c2d01cd6c31bf938fe433fe4 # Parent de3e9ea18f56311064562ec9c21888f0ea0d025e Updated to compile: - KdTree+Octree: max_depth changed to static const (this should be configured at compile time) - wget tool replaced by curl, which is now more widespread - added CMakeLists (to eventually replace SCons) - various fixes diff -r de3e9ea18f56 -r 3b3257a410fe CMakeLists.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CMakeLists.txt Tue Jul 26 17:41:36 2016 +0200 @@ -0,0 +1,11 @@ +# This is still incomplete, use SCons for now. + +cmake_minimum_required(VERSION 3.0) +project(pyrit) + +file(GLOB SOURCES + src/*.cc + include/*.h) + +add_library(pyrit STATIC ${SOURCES}) +target_include_directories(pyrit PRIVATE include) diff -r de3e9ea18f56 -r 3b3257a410fe README --- a/README Mon Sep 08 20:14:24 2014 +0200 +++ b/README Tue Jul 26 17:41:36 2016 +0200 @@ -37,11 +37,7 @@ Stanford models, type 'scons download-models', which will download and extract the archives to appropriate location. -The download script uses 'tar' and 'wget' utilities. - -For Windows, these are available here: -http://gnuwin32.sourceforge.net/packages/wget.htm -http://gnuwin32.sourceforge.net/packages/libarchive.htm +The download script uses 'tar' and 'curl' utilities. Pthreads diff -r de3e9ea18f56 -r 3b3257a410fe include/kdtree.h --- a/include/kdtree.h Mon Sep 08 20:14:24 2014 +0200 +++ b/include/kdtree.h Tue Jul 26 17:41:36 2016 +0200 @@ -84,19 +84,15 @@ */ class KdTree: public Container { + static const int MAX_DEPTH; MemoryPool mempool; KdNode *root; - const int max_depth; bool built; void recursive_build(KdNode *node, const BBox &bbox, int maxdepth); void recursive_load(istream &st, KdNode *node); public: - /** default constructor, maximum depth is set to 32 */ - KdTree(): Container(), mempool(64), root(NULL), max_depth(32), built(false) {}; - - /** constructor which allows to se maximum tree depth (cannot be changed later) */ - KdTree(int maxdepth): Container(), mempool(64), root(NULL), max_depth(maxdepth), built(false) {}; + KdTree(): Container(), mempool(64), root(NULL), built(false) {}; ~KdTree() { if (root) delete root; }; /** add shape pointer to the container */ diff -r de3e9ea18f56 -r 3b3257a410fe include/octree.h --- a/include/octree.h Mon Sep 08 20:14:24 2014 +0200 +++ b/include/octree.h Tue Jul 26 17:41:36 2016 +0200 @@ -73,18 +73,13 @@ */ class Octree: public Container { + static const int MAX_DEPTH; OctreeNode *root; - const int max_depth; bool built; public: - /** default constructor, - * maximum depth of tree is set to 10 */ - Octree() : Container(), root(NULL), max_depth(10), built(false) {}; + Octree() : Container(), root(NULL), built(false) {}; + ~Octree() { if (root) delete root; }; - /** constructor - * @param[in] maxdepth maximum depth of the tree */ - Octree(int maxdepth) : Container(), root(NULL), max_depth(maxdepth), built(false) {}; - ~Octree() { if (root) delete root; }; void addShape(const Shape* aShape) { Container::addShape(aShape); built = false; }; const Shape *nearest_intersection(const Shape *origin_shape, const Ray &ray, Float &nearest_distance); diff -r de3e9ea18f56 -r 3b3257a410fe include/quaternion.h --- a/include/quaternion.h Mon Sep 08 20:14:24 2014 +0200 +++ b/include/quaternion.h Tue Jul 26 17:41:36 2016 +0200 @@ -26,7 +26,7 @@ */ #ifndef QUATERNION_H -#define QUATER_H +#define QUATERNION_H /** * quaternion class @@ -64,7 +64,7 @@ }; Float mag() const { - return sqrtf(mag()); + return sqrtf(mag2()); }; friend Quaternion operator*(const Quaternion &q1, const Quaternion &q2) { diff -r de3e9ea18f56 -r 3b3257a410fe models/download-stanford --- a/models/download-stanford Mon Sep 08 20:14:24 2014 +0200 +++ b/models/download-stanford Tue Jul 26 17:41:36 2016 +0200 @@ -3,19 +3,19 @@ mkdir -p "$1" cd "$1" -wget http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz +curl -O 'http://graphics.stanford.edu/pub/3Dscanrep/bunny.tar.gz' tar xzf bunny.tar.gz rm bunny.tar.gz rm -rf bunny/data mv bunny/reconstruction/* bunny rmdir bunny/reconstruction -wget http://graphics.stanford.edu/pub/3Dscanrep/happy/happy_recon.tar.gz +curl -O 'http://graphics.stanford.edu/pub/3Dscanrep/happy/happy_recon.tar.gz' tar xzf happy_recon.tar.gz rm happy_recon.tar.gz mv happy_recon happy -wget http://graphics.stanford.edu/pub/3Dscanrep/dragon/dragon_recon.tar.gz +curl -O 'http://graphics.stanford.edu/pub/3Dscanrep/dragon/dragon_recon.tar.gz' tar xzf dragon_recon.tar.gz rm dragon_recon.tar.gz mv dragon_recon dragon diff -r de3e9ea18f56 -r 3b3257a410fe src/kdtree.cc --- a/src/kdtree.cc Mon Sep 08 20:14:24 2014 +0200 +++ b/src/kdtree.cc Tue Jul 26 17:41:36 2016 +0200 @@ -66,6 +66,8 @@ delete getShapes(); } +const int KdTree::MAX_DEPTH = 32; + // kd-tree recursive build algorithm, inspired by PBRT (www.pbrt.org) void KdTree::recursive_build(KdNode *node, const BBox &bounds, int maxdepth) { @@ -199,7 +201,7 @@ ShapeList::iterator shape; for (shape = shapes.begin(); shape != shapes.end(); shape++) root->addShape(*shape); - recursive_build(root, bbox, max_depth); + recursive_build(root, bbox, MAX_DEPTH); built = true; } @@ -221,12 +223,7 @@ KdNode *farchild, *node; node = root; -#ifdef MSVC - // MSVC wants constant expression here... hope it won't overflow :) - StackElem stack[64]; -#else - StackElem stack[max_depth]; -#endif + StackElem stack[MAX_DEPTH]; int entry = 0, exit = 1; stack[entry].t = a; @@ -296,7 +293,7 @@ exit++; if (exit == entry) exit++; - assert(exit < max_depth); + assert(exit < MAX_DEPTH); stack[exit].prev = tmp; stack[exit].t = t; @@ -367,12 +364,7 @@ KdNode *farchild, *node; node = root; -#ifdef MSVC - // MSVC wants constant expression here... hope it won't overflow :) - StackElem4 stack[64]; -#else - StackElem4 stack[max_depth]; -#endif + StackElem4 stack[MAX_DEPTH]; int entry = 0, exit = 1; stack[entry].t = a; @@ -476,7 +468,7 @@ exit++; if (exit == entry) exit++; - assert(exit < max_depth); + assert(exit < MAX_DEPTH); stack[exit].prev = tmp; stack[exit].t = t; diff -r de3e9ea18f56 -r 3b3257a410fe src/octree.cc --- a/src/octree.cc Mon Sep 08 20:14:24 2014 +0200 +++ b/src/octree.cc Tue Jul 26 17:41:36 2016 +0200 @@ -26,6 +26,8 @@ #include "octree.h" +const int Octree::MAX_DEPTH = 10; + OctreeNode::~OctreeNode() { if (isLeaf()) @@ -101,7 +103,7 @@ ShapeList::iterator shape; for (shape = shapes.begin(); shape != shapes.end(); shape++) root->addShape(*shape); - root->subdivide(bbox, max_depth); + root->subdivide(bbox, MAX_DEPTH); built = true; } @@ -155,12 +157,7 @@ if (!built) return Container::nearest_intersection(origin_shape, ray, nearest_distance); -#ifdef MSVC - // MSVC wants constant expression here... hope it won't overflow :) - OctreeTravState st[20]; -#else - OctreeTravState st[max_depth+1]; -#endif + OctreeTravState st[MAX_DEPTH+1]; OctreeTravState *st_cur = st; # define node st_cur->node diff -r de3e9ea18f56 -r 3b3257a410fe src/pixmap.cc --- a/src/pixmap.cc Mon Sep 08 20:14:24 2014 +0200 +++ b/src/pixmap.cc Tue Jul 26 17:41:36 2016 +0200 @@ -31,6 +31,7 @@ #ifdef HAVE_PNG # include +# include #endif unsigned char *Pixmap::getCharData() const diff -r de3e9ea18f56 -r 3b3257a410fe tools/cpuflags.c --- a/tools/cpuflags.c Mon Sep 08 20:14:24 2014 +0200 +++ b/tools/cpuflags.c Tue Jul 26 17:41:36 2016 +0200 @@ -81,7 +81,7 @@ /* cpuid, from kernel source ( linux/include/asm-i386/processor.h ) */ -inline void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx) +void cpuid(int op, int *eax, int *ebx, int *ecx, int *edx) { __asm__("cpuid" : "=a" (*eax), "=b" (*ebx), "=c" (*ecx), "=d" (*edx) : "a" (op)); }