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

Add python wrapper module #4

Open
wants to merge 4 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ install/
configs/
renders/
.*.swp
*~
__pycache__
6 changes: 3 additions & 3 deletions include/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ namespace pbnj {

void setBackgroundColor(unsigned char r, unsigned char g, unsigned char b);
void setBackgroundColor(std::vector<unsigned char> bgColor);
void setVolume(Volume *v);
void setIsosurface(Volume *v, std::vector<float> &isoValues);
void setCamera(Camera *c);
void setVolume(pbnj::Volume *v);
void setIsosurface(pbnj::Volume *v, std::vector<float> &isoValues);
void setCamera(pbnj::Camera *c);
void setSamples(unsigned int spp);

void render();
Expand Down
2 changes: 1 addition & 1 deletion include/TimeSeries.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace pbnj {
int x, int y, int z);
~TimeSeries();

Volume *getVolume(unsigned int index);
pbnj::Volume *getVolume(unsigned int index);
int getVolumeIndex(std::string filename);
unsigned int getLength();
void setMaxMemory(unsigned int gigabytes);
Expand Down
45 changes: 45 additions & 0 deletions pbnj.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
%module pbnj

%include <std_string.i>
%include <std_vector.i>

%{
#include "pbnj.h"
#include "Configuration.h"
#include "Camera.h"
#include "ConfigReader.h"
#include "DataFile.h"
#include "Renderer.h"
#include "TimeSeries.h"
#include "TransferFunction.h"
#include "Volume.h"

namespace pbnj {
void init(void) {
int argc;
const char *argv[1];
const std::string dummy = "dummy";

argc = 1;
argv[0] = dummy.c_str();

pbnj::pbnjInit(&argc, argv);
}
};

%}

namespace pbnj {

void init(void);

};

%include "include/Configuration.h"
%include "include/Camera.h"
%include "include/ConfigReader.h"
%include "include/DataFile.h"
%include "include/Renderer.h"
%include "include/TimeSeries.h"
%include "include/TransferFunction.h"
%include "include/Volume.h"
61 changes: 61 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env python
"""

"""

from distutils.core import setup, Extension
from os import environ


# Needed so that the extension can always find the modules, even if they aren't
# on your normal load path. e.g. /opt/embree/lib usually isn't in your
# ldconfig, so this hard codes /opt/embree/lib into your extension, so that it
# knows where to look for the libraries.
def patch_ld_run_path():
if 'LD_RUN_PATH' in environ is not None:
ld_run_path += environ['LD_RUN_PATH'] + ':'
else:
ld_run_path = ''

ld_run_path += ':'.join([
'/opt/embree/lib',
'/usr/local/lib',
'/usr/local/lib64',
])

environ['LD_RUN_PATH'] = ld_run_path


patch_ld_run_path()

_pbnj = Extension(
'_pbnj',
language='c++',
libraries=[
'pbnj',
],
sources=[
'pbnj_wrap.cxx',
],
)


setup(
name='pbnj',
version='0.0.1',
description='PBNJ',
author='Tanner Hobson',
author_email='[email protected]',
classifiers=[
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
],
python_requires='>=3.5',
entry_points={
},
ext_modules=[
_pbnj,
],
)
2 changes: 1 addition & 1 deletion src/DataFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void DataFile::loadFromFile(std::string filename, std::string var_name,
FILE *dataFile = fopen(filename.c_str(), "r");

if(dataFile == NULL) {
std::cerr << "Could not open file!" << std::endl;
std::cerr << "Could not open file! " << filename << std::endl;
}
else {
if(memmap) {
Expand Down