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

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.2.tar.gz (2.2 MB view details)

Uploaded Source

Built Distributions

pyoctree-0.2.2-cp36-cp36m-win_amd64.whl (2.3 MB view details)

Uploaded CPython 3.6mWindows x86-64

pyoctree-0.2.2-cp27-cp27m-win_amd64.whl (2.3 MB view details)

Uploaded CPython 2.7mWindows x86-64

File details

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

File metadata

  • Download URL: pyoctree-0.2.2.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyoctree-0.2.2.tar.gz
Algorithm Hash digest
SHA256 f5ab9727fd40d37609306bedfbb78600709fb70a003cb7a8cd83fddbcbfe40d6
MD5 d620e19a9f1ddab513bc0a085add0cd2
BLAKE2b-256 62cfcde6b411521b51523b60b91f3da28bccb8a47e0253e061c8679ba9bec666

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyoctree-0.2.2-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f56d28ce95e69c13ae03e9e19ca00c804fecdbccebfca15e84133e609f3a7fbb
MD5 5472fdcdace59f52e72d5cbedd9d3467
BLAKE2b-256 a88c878c135d3be8f57d5bd665ec0b786b52916e67d63cbcbc64bd97a2d79573

See more details on using hashes here.

File details

Details for the file pyoctree-0.2.2-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for pyoctree-0.2.2-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 10977db20c2ed76b162eddea2b08041ef250d72a7056d53545c987ab475f4115
MD5 22cde45f4c2adc9f0d26e6f8fdf6e562
BLAKE2b-256 edb0f48db0403201e6e144a89ddd2ef7cf150683d6f20d426767870f22092fa4

See more details on using hashes here.

Supported by

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