Skip to main content

pyoctree

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 Number of PyPI downloads

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.2-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.2-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.

Metadata

Release files for pyoctree 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyoctree 0.2.2
File Size Uploaded
pyoctree-0.2.2.tar.gz 2.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for pyoctree 0.2.2
File Interpreter ABI Platform
pyoctree-0.2.2-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
pyoctree-0.2.2-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details

Total release size: 6.8 MB

Release files / pyoctree-0.2.2.tar.gz

Download URL pyoctree-0.2.2.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
f5ab9727fd40d37609306bedfbb78600709fb70a003cb7a8cd83fddbcbfe40d6
BLAKE2b-256 checksum
How to use checksums
62cfcde6b411521b51523b60b91f3da28bccb8a47e0253e061c8679ba9bec666
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyoctree-0.2.2-cp36-cp36m-win_amd64.whl

Download URL pyoctree-0.2.2-cp36-cp36m-win_amd64.whl
Size 2.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
f56d28ce95e69c13ae03e9e19ca00c804fecdbccebfca15e84133e609f3a7fbb
BLAKE2b-256 checksum
How to use checksums
a88c878c135d3be8f57d5bd665ec0b786b52916e67d63cbcbc64bd97a2d79573
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / pyoctree-0.2.2-cp27-cp27m-win_amd64.whl

Download URL pyoctree-0.2.2-cp27-cp27m-win_amd64.whl
Size 2.3 MB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
10977db20c2ed76b162eddea2b08041ef250d72a7056d53545c987ab475f4115
BLAKE2b-256 checksum
How to use checksums
edb0f48db0403201e6e144a89ddd2ef7cf150683d6f20d426767870f22092fa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.2.10

2 release files

0.2.4

3 release files

This release

0.2.2 This release

3 release files

0.2.1

3 release files

0.2.0

3 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page