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.
Details
Pyoctree uses an adaptive structure, so it will automatically divide branches to ensure that there are no more than 200 objects per leaf.
Intersection testing uses parallel processing via OpenMP. To use more than a single processor, set value of environment variable OMP_NUM_THREADS to number of desired processors.
Requirements
Python 2.7 or Python >= 3.5
vtk >= v6.2.0 or >= v7.0 (optional, for outputting a vtk file for viewing octree structure in Paraview)
Cython >= v0.20 and a C++ compiler for building the extension module. Suggested compilers are:
The Microsoft C++ Compiler for Python 2.7 if using Python 2
Microsoft Visual C++ 2015 (14.0) if using Python 3
gcc on Linux
Mingw32 on Windows or Linux
Note that a compiler is not required if installing using the provided Python wheel.
Installation
1. Building from source
In a command prompt, browse to the base directory containing the setup.py file and type:
python setup.py install
2. Installation using Python wheel
Download the python wheel from releases i.e. pyoctree-0.2.0-cp27-cp27m-win_amd64.whl for Python 2.7 on Windows 64-bit. Then, open a command prompt, browse to the download directory and type:
pip install pyoctree-0.2.0-cp27-cp27m-win_amd64.whl
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
Built Distributions
File details
Details for the file pyoctree-0.2.0.tar.gz
.
File metadata
- Download URL: pyoctree-0.2.0.tar.gz
- Upload date:
- Size: 2.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e23779b816aa8cd0bf62cb040cd0e372355b44e233222b89ffa8b8e09b27c2d2 |
|
MD5 | 8e8ab75428b990200109bc383d54e71e |
|
BLAKE2b-256 | a3be3e092ed2bacc7cda6e345ab01703df2e1e0fd744e2a5152d08f1c29b065a |
Provenance
File details
Details for the file pyoctree-0.2.0-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: pyoctree-0.2.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 128.5 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79443368ef823954767f54db817f991e1996193a6b8110073f2f4bf5f4902e7f |
|
MD5 | 77c976d64b348663b1623e15e5b29909 |
|
BLAKE2b-256 | 2c78a23b355b50c4e4b6d67fee20f72b2dd201055c34011a2a4e0e0c326ce501 |
Provenance
File details
Details for the file pyoctree-0.2.0-cp27-cp27m-win_amd64.whl
.
File metadata
- Download URL: pyoctree-0.2.0-cp27-cp27m-win_amd64.whl
- Upload date:
- Size: 148.6 kB
- Tags: CPython 2.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9786365c4b4d52ad92d0ba80d3ca05dd83d85d9028c749c5003d23eef5c9bdfb |
|
MD5 | 31a4d71bd97b61d67fecfeef3f107550 |
|
BLAKE2b-256 | be34a8b3d0896e7cb5a8cbdfa767a3d589fe0051269fb54fdf2f76ed43e664c0 |