Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] some refactoring (needs salvaging) #86

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ os:

dist: trusty
addons:
sources:
- llvm-toolchain-trusty-7 # clang-7
apt:
packages:
- clang-7
- libglew-dev
- libglm-dev
- xorg-dev
Expand Down
8 changes: 0 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ set(SOURCES
src/Algo2DEntropy.cc
src/Algo2DFourColors.cc
src/Algo2DGrayscale.cc
src/Algo3DCubeFull.cc
src/Algo3DCubeContiBnW.cc
src/Algo3DCubeContiRainbow.cc
src/Algo3DCubeContiFrebet.cc
src/Algo3DSphereFull.cc
src/Algo3DSphereContiBnW.cc
src/Algo3DSphereContiRainbow.cc
src/Algo3DSphereContiFrebet.cc

src/GlfwManager.cc

Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM debian
WORKDIR /app
COPY . $PWD
RUN set -x \
&& apt update \
&& apt install -y \
x11-apps \
libglew-dev libglm-dev libglfw3-dev pkg-config \
libc++-dev clang cmake
RUN set -x \
&& ./configure \
&& cd build \
&& make -j7
ENV DISPLAY :0
ENTRYPOINT ["/app/build/voidstar"]
10 changes: 10 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM debian
RUN set -x \
&& apt update \
&& apt install -y \
x11-apps \
libglew-dev libglm-dev libglfw3-dev pkg-config \
libc++-dev clang cmake
ENV DISPLAY :0
WORKDIR /app
ENTRYPOINT ["/bin/sh", "-c", "set -x && ./configure && cd build && make -j7 && ./voidstar ./voidstar ../data/*"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ The actual file being represented below [is data/BigPictureBG.tga](http://www.do

## Installing

### docker

Known to work with
* ubuntu 18.10 + docker 18.09.0

```
docker build -t void .
./contained.sh
```

### on MacOS

1. Download one of the `osx` files of [the latest release](https://github.com/fenollp/voidstar/releases/latest)
Expand Down
17 changes: 17 additions & 0 deletions docker-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

#$ docker build -f Dockerfile.dev -t voiddev .

# https://stackoverflow.com/a/25168483/1418165

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

docker run --rm -it \
-v $XSOCK:$XSOCK \
-v $XAUTH:$XAUTH \
-v /dev/input \
-v "$PWD":/app \
-e XAUTHORITY=$XAUTH \
voiddev
15 changes: 15 additions & 0 deletions docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# https://stackoverflow.com/a/25168483/1418165

XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
xauth nlist :0 | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -

docker run --rm -it \
-v $XSOCK:$XSOCK \
-v $XAUTH:$XAUTH \
-v /dev/input \
-e XAUTHORITY=$XAUTH \
void \
/app/build/voidstar
26 changes: 0 additions & 26 deletions src/Algo3DCubeContiBnW.cc

This file was deleted.

28 changes: 0 additions & 28 deletions src/Algo3DCubeContiFrebet.cc

This file was deleted.

26 changes: 0 additions & 26 deletions src/Algo3DCubeContiRainbow.cc

This file was deleted.

16 changes: 0 additions & 16 deletions src/Algo3DCubeFull.cc

This file was deleted.

26 changes: 0 additions & 26 deletions src/Algo3DSphereContiBnW.cc

This file was deleted.

32 changes: 0 additions & 32 deletions src/Algo3DSphereContiFrebet.cc

This file was deleted.

26 changes: 0 additions & 26 deletions src/Algo3DSphereContiRainbow.cc

This file was deleted.

16 changes: 0 additions & 16 deletions src/Algo3DSphereFull.cc

This file was deleted.

22 changes: 6 additions & 16 deletions src/Algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
#include <Algo2DEntropy.hh>
#include <Algo2DFourColors.hh>
#include <Algo2DGrayscale.hh>
#include <Algo3DCubeFull.hh>
#include <Algo3DCubeContiBnW.hh>
#include <Algo3DCubeContiRainbow.hh>
#include <Algo3DCubeContiFrebet.hh>
#include <Algo3DSphereFull.hh>
#include <Algo3DSphereContiBnW.hh>
#include <Algo3DSphereContiRainbow.hh>
#include <Algo3DSphereContiFrebet.hh>
#include <XYZRGB.hh>
#include <RΘΦ.hh>
#include <ΡΦZ.hh>

void
Algorithm::use(std::shared_ptr<Loader> loader, std::shared_ptr<DataRange> range) {
Expand Down Expand Up @@ -57,12 +52,7 @@ const std::map<const std::string, AlgorithmFactoryFunc> algorithms = {
{"entropy", []() { return std::make_shared<Algo2DEntropy>(); }},
{"4col", []() { return std::make_shared<Algo2DFourColors>(); }},
{"gray", []() { return std::make_shared<Algo2DGrayscale>(); }},
{"cube", []() { return std::make_shared<Algo3DCubeFull>(); }},
{"contibnw", []() { return std::make_shared<Algo3DCubeContiBnW>(); }},
{"contirb", []() { return std::make_shared<Algo3DCubeContiRainbow>(); }},
{"conti", []() { return std::make_shared<Algo3DCubeContiFrebet>(); }},
{"sphere", []() { return std::make_shared<Algo3DSphereFull>(); }},
{"sphere_bnw", []() { return std::make_shared<Algo3DSphereContiBnW>(); }},
{"sphere_rb", []() { return std::make_shared<Algo3DSphereContiRainbow>(); }},
{"sphere_frebet", []() { return std::make_shared<Algo3DSphereContiFrebet>(); }},
{"cube", []() { return std::make_shared<XYZRGB>(); }},
{"sphere", []() { return std::make_shared<RΘΦ>(); }},
{"cylinder", []() { return std::make_shared<ΡΦZ>(); }},
};
36 changes: 21 additions & 15 deletions src/Manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,6 @@
#include <Manager.hh>
#include <GlfwManager.hh>

void
Manager::loadScene(std::shared_ptr<Scene> scene) {
// XXX delete scene prior to creating a new one
if (scene_) {
std::cout << "deleting scene" << std::endl;
}
scene_ = scene;
scene->init(args_);
}

void
Manager::loadFile(const std::string& filename) {
args_->paths.push_back(filename);
Expand All @@ -37,13 +27,29 @@ Manager::loadFile(size_t index) {
auto range = DataRange::create(args_->range_begin, args_->range_end);

if (scene_) {
auto algo = scene_->algorithm();
algo->use(loader, range);
scene_->algorithm()->use(loader, range);
scene_->reload();
} else {
auto algo = createAlgorithm(args_->algo);
return true;
}

auto uglyhack_algo = createAlgorithm(args_->algo);
if (auto algo = std::dynamic_pointer_cast<Algo3D>(uglyhack_algo)) {
algo->use(loader, range);
if (scene_) {
std::cout << "deleting 3D scene" << std::endl;
}
scene_ = Scene::with_algo(args_, algo);
scene_->init(args_);
return true;
}

if (auto algo = std::dynamic_pointer_cast<Algo2D>(uglyhack_algo)) {
algo->use(loader, range);
loadScene(Scene::with_algo(args_, algo));
if (scene_) {
std::cout << "deleting 2D scene" << std::endl;
}
scene_ = Scene::with_algo(args_, algo);
scene_->init(args_);
}
return true;
}
Expand Down
Loading