Skip to main content

Octree structure containing 3D triangular mesh model

Project description

Octree structure containing a 3D triangular mesh model. To be used for ray tracing / shadow casting.

Written in C++ for speed, but exposed to Python using Cython.

Latest PyPI version

Details

Pyoctree uses an adaptive structure, so it will automatically divide branches to ensure that there are no more than 200 objects per leaf.

Requirements

  • Python 2.7 or Python >= 3.5

Optional

  • vtk >= v6.2.0 or >= v7.0 (for outputting a vtk file for viewing octree structure in Paraview)

  • A C++ compiler for building the extension module from the provided cpp file (already cythonized). Suggested compilers are: - The Microsoft C++ Compiler for Python 2.7 if using Python 2 on Windows - Microsoft Visual C++ 2015 (14.0) if using Python 3 on Windows - gcc on Linux - Mingw32 on Windows or Linux

  • Cython >= v0.20 and a C++ compiler to build from source

Note that a compiler is not required if installing using the provided Python wheel.

Installation

Intersection testing uses parallel processing via OpenMP. To use more than a single processor, use the provided Python wheel or compile from source using a compiler that supports OpenMP. Then set value of environment variable OMP_NUM_THREADS to the number of desired processors.

Note that the compilers provided by the Anaconda Python distribution do not support OpenMP.

1. Building from source

To compile without OpenMP, open a command prompt, browse to the base directory containing the setup.py file and type:

python setup.py install

To compile with OpenMP, open a command prompt, browse to the base directory containing the setup.py file and type:

python setup.py install --openmp

2. Installation using Python wheel

Download the python wheel from releases i.e. pyoctree-0.2.10-cp36-cp36m-win_amd64.whl for Python 3.6 on Windows 64-bit. Then, open a command prompt, browse to the download directory and type:

pip install pyoctree-0.2.10-cp36-cp36m-win_amd64.whl

Note that Python wheels have been built with OpenMP.

Usage

1. Creating the octree representation of a 3D triangular mesh model

from pyoctree import pyoctree as ot
tree = ot.PyOctree(pointCoords,connectivity)

where:

  • pointCoords is a Nx3 numpy array of floats (dtype=float) representing the 3D coordinates of the mesh points

  • connectivity is a Nx3 numpy array of integers (dtype=np.int32) representing the point connectivity of each tri element in the mesh

2. Finding intersection between mesh object and ray

The octree can be used to quickly find intersections between the object and a ray. For example:

import numpy as np
startPoint = [0.0,0.0,0.0]
endPoint   = [0.0,0.0,1.0]
rayList    = np.array([[startPoint,endPoint]],dtype=np.float32)
intersectionFound  = tree.rayIntersection(rayList)

Examples

Some Jupyter notebooks are provided in the Examples directory on how to use pyoctree.

Help

If help is required, please create an issue on Github.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyoctree-0.2.10.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

pyoctree-0.2.10-cp36-cp36m-win_amd64.whl (2.4 MB view details)

Uploaded CPython 3.6m Windows x86-64

File details

Details for the file pyoctree-0.2.10.tar.gz.

File metadata

  • Download URL: pyoctree-0.2.10.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for pyoctree-0.2.10.tar.gz
Algorithm Hash digest
SHA256 d3654cdabe0b3bf418056f5c5fccf5618a69524a9602d332bdbb00bcd04cdbda
MD5 26aee0f20f472b032a56d00bb4f5c738
BLAKE2b-256 ffb90000bafc6e857d0ee771b6b064e0b5933f16ab486d6439fadb773c976719

See more details on using hashes here.

File details

Details for the file pyoctree-0.2.10-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: pyoctree-0.2.10-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.3

File hashes

Hashes for pyoctree-0.2.10-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 67ad5e7f709f5ba01d5268dd74db3d1758a47c761c46077ffe550a5debe925d4
MD5 2bcd54d7583c63c3f677fe7cc68ef704
BLAKE2b-256 4b878d457f93026861c0e1926152b9f01e0a7b096fc469a04583d2a91db31d2e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page