Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
akaszynski committed May 31, 2017
0 parents commit 585f8e4
Show file tree
Hide file tree
Showing 110 changed files with 31,673 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Compiled source #
###################
*.pyc
*.pyd
*.so
*.o

# Cython generated files #
#pymeshfix/cython/_meshfix.cpp

# OS generated files #
######################
.fuse_hidden*
*~

# Pip generated folders #
#########################
*.egg-info/
build/
dist/
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

Empty file added MANIFEST.in
Empty file.
7 changes: 7 additions & 0 deletions NOTES
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
To upload to sphinx
$ python setup.py build_sphinx
$ python setup.py upload_sphinx

To upload to pypi
python setup.py register -r pypi
python setup.py sdist upload -r pypi
143 changes: 143 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
vtkInterface Overview
=====================

vtkInterface is a VTK helper module that takes a different approach on interfacing with VTK through numpy and direct array access. This module also simplifies mesh creation and plotting by adding functionality to existing VTK objects.

This moudle is suited creating engineering plots for presentations and research papers as well as being a supporting module for other mesh dependent python modules.


Installation
------------

If you have a working copy of VTK, installation is simply::

pip install vtkInterface
You can also visit `PyPi <http://pypi.python.org/pypi/vtkInterface>`_ or `GitHub <https://github.com/akaszynski/vtkInterface>`_ to download the source.

See the :ref:`install_ref` for more details.


Quick Examples
--------------

Loading and Plotting a Mesh from File
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Loading a mesh is trivial::

import vtkInterface
mesh = vtkInterface.LoadMesh('airplane.ply')
mesh.Plot(color='orange')
.. image:: airplane.png

In fact, the code to generate the previous screenshot was created with::

mesh.Plot(screenshot='airplane.png', color='orange')

The points and faces from the mesh are directly accessible as a numpy array::
print mesh.GetNumpyPoints()
#[[ 896.99401855 48.76010132 82.26560211]
# [ 906.59301758 48.76010132 80.74520111]
# [ 907.53900146 55.49020004 83.65809631]
# ...,
# [ 806.66497803 627.36297607 5.11482 ]
# [ 806.66497803 654.43200684 7.51997995]
# [ 806.66497803 681.5369873 9.48744011]]
print mesh.GetNumpyFaces()
#[[ 0 1 2]
# [ 0 2 3]
# [ 4 5 1]
# ...,
# [1324 1333 1323]
# [1325 1216 1334]
# [1325 1334 1324]]
Creating a Structured Surface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This example creates a simple surface grid and plots the resulting grid and its curvature::

import vtkInterface

# Make data
import numpy as np
X = np.arange(-10, 10, 0.25)
Y = np.arange(-10, 10, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
# Create and plot structured grid
sgrid = vtkInterface.GenStructSurf(X, Y, Z)
sgrid.Plot()
# Plot mean curvature as well
surf.PlotCurvature()

.. image:: curvature.png

Generating a structured grid is a one liner in this module, and the points from the resulting surface are also a numpy array::

surf.GetNumpyPoints()
#[[-10. -10. 0.99998766]
# [ -9.75 -10. 0.98546793]
# [ -9.5 -10. 0.9413954 ]
# ...,
# [ 9.25 9.75 0.76645876]
# [ 9.5 9.75 0.86571785]
# [ 9.75 9.75 0.93985707]]


Creating a GIF Movie
~~~~~~~~~~~~~~~~~~~~

This example shows the versatility of the plotting object by generating a moving gif::
import vtkInterface
import numpy as np
# Make data
X = np.arange(-10, 10, 0.25)
Y = np.arange(-10, 10, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)
# Create and structured surface
sgrid = vtkInterface.GenStructSurf(X, Y, Z)
# Make deep copy of points
pts = sgrid.GetNumpyPoints(deep=True)
# Start a plotter object and set the scalars to the Z height
plobj = vtkInterface.PlotClass()
plobj.AddMesh(sgrid, scalars=Z.ravel())
plobj.Plot(autoclose=False)
# Open a gif
plobj.OpenGif('wave.gif')
# Update Z and write a frame for each updated position
nframe = 15
for phase in np.linspace(0, 2*np.pi, nframe + 1)[:nframe]:
Z = np.sin(R + phase)
pts[:, -1] = Z.ravel()
plobj.UpdateCoordinates(pts)
plobj.UpdateScalars(Z.ravel())
plobj.WriteFrame()
# Close movie and delete object
plobj.Close()
del plobj

.. image:: wave.gif

6 changes: 6 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
__version__ = '0.1'

from vtkInterface.plotting import *
from vtkInterface.utilities import *
from vtkInterface.colors import *

156 changes: 156 additions & 0 deletions conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# -*- coding: utf-8 -*-
#
# vtkInterface documentation build configuration file, created by
# sphinx-quickstart on Tue May 30 20:21:38 2017.
#
# This file is execfile()d with the current directory set to its
# containing dir.
#
# Note that not all possible configuration values are present in this
# autogenerated file.
#
# All configuration values have a default; values that are commented out
# serve to show the default.

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = []

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'vtkInterface'
copyright = u'2017, Alex Kaszynski'
author = u'Alex Kaszynski'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'0.1'
# The full version, including alpha/beta/rc tags.
release = u'0.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'vtkInterfacedoc'


# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'vtkInterface.tex', u'vtkInterface Documentation',
u'Alex Kaszynski', 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'vtkinterface', u'vtkInterface Documentation',
[author], 1)
]


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'vtkInterface', u'vtkInterface Documentation',
author, 'vtkInterface', 'One line description of project.',
'Miscellaneous'),
]



Binary file added docs/AntsAndPlane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = vtkInterface
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Binary file added docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file added docs/_build/doctrees/examples.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/index.doctree
Binary file not shown.
Binary file added docs/_build/doctrees/installation.doctree
Binary file not shown.
4 changes: 4 additions & 0 deletions docs/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config:
tags:
Binary file added docs/_build/html/_images/AntsAndPlane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_build/html/_images/airplane.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_build/html/_images/beam.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_build/html/_images/beam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_build/html/_images/beam_wireframe.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_build/html/_images/curvature.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_build/html/_images/wave.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 585f8e4

Please sign in to comment.