Metadata-Version: 2.1
Name: pyemblite
Version: 0.1.7
Summary: Python wrapper for Embree-3.
Author: Shane-J-Latham, Department of Materials Physics, ANU
License: Copyright (c) 2015, Anthony Scopatz
        All rights reserved.
        
        Redistribution and use in source and binary forms, with or without
        modification, are permitted provided that the following conditions are met:
        
        * Redistributions of source code must retain the above copyright notice, this
          list of conditions and the following disclaimer.
        
        * Redistributions in binary form must reproduce the above copyright notice,
          this list of conditions and the following disclaimer in the documentation
          and/or other materials provided with the distribution.
        
        THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
        AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
        DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
        FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
        SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
        CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
        OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
        OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
        
        
Project-URL: Homepage, https://github.com/AppliedMathematicsANU/pyemblite/
Project-URL: Repository, https://github.com/AppliedMathematicsANU/pyemblite/
Project-URL: Issues, https://github.com/AppliedMathematicsANU/pyemblite/issues
Keywords: embree,embree3,embree-3,ray-casting
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/x-rst
License-File: LICENSE.txt


===========
`pyemblite`
===========

.. start long description.
.. start badges.

.. image:: https://img.shields.io/pypi/v/pyemblite.svg
   :target: https://pypi.python.org/pypi/pyemblite/
   :alt: pyemblite python package
.. image:: https://github.com/AppliedMathematicsANU/pyemblite/actions/workflows/python-test.yml/badge.svg
   :target: https://github.com/AppliedMathematicsANU/pyemblite/actions/workflows/python-test.yml
   :alt: pyemblite python package
.. image:: https://github.com/AppliedMathematicsANU/pyemblite/actions/workflows/python-test-vcpkg.yml/badge.svg
   :target: https://github.com/AppliedMathematicsANU/pyemblite/actions/workflows/python-test-vcpkg.yml
   :alt: pyemblite python package
.. image:: https://img.shields.io/pypi/l/pyemblite.svg
   :target: https://pypi.python.org/pypi/pyemblite/
   :alt: BSD License
.. image:: https://img.shields.io/pypi/pyversions/pyemblite.svg
   :target: https://pypi.python.org/pypi/pyemblite/
   :alt: pyemblite python package

Python wrapper for Embree-3. Source code adapted from
`pyembree <https://github.com/scopatz/pyembree>`_ Embree-2 wrapper.

.. end long description.

Quick Start
===========

Example:


.. code-block:: python

   import numpy as np
   import trimesh
   from trimesh.primitives import Sphere
   from pyemblite.mesh_construction import TriangleMesh
   from pyemblite.rtcore_scene import EmbreeScene

   # Create Embree scene which holds meshes.
   scene = EmbreeScene()

   # Create a mesh using trimesh (https://github.com/mikedh/trimesh).
   tmesh = Sphere(radius=5.0, subdivisions=1)

   # Create Embree triangle mesh geometry
   emesh = TriangleMesh(scene, tmesh.vertices, tmesh.faces)

   # Commit the scene (builds spatial acceleration structures).
   scene.commit()

   # Generate ray origins and ray directions
   ray_orgs = (
       np.zeros((tmesh.vertices.shape[0], 3), dtype=np.float32)
       +
       tmesh.centroid
   ).astype(np.float32)
   ray_dirs = (tmesh.vertices - tmesh.centroid).astype(np.float32)
   ray_dirs /= np.linalg.norm(ray_dirs, axis=1)[np.newaxis, 1]

   # Query the index of the first face which gets hit by ray
   # (index of -1 indicates ray did not hit a face)
   primID = scene.run(ray_orgs, ray_dirs, query='INTERSECT')

   # Query the distance from the ray origin where face which gets hit by ray
   # Intersection points are ray_orgs + tfar * ray_dirs
   tfar = scene.run(ray_orgs, ray_dirs, query='DISTANCE')
   print(tfar)

   # Query all info, intersect_info is a dict with keys:
   # ['u', 'v', 'Ng', 'tfar', 'primID', 'geomID']
   intersect_info = scene.run(ray_orgs, ray_dirs, output=True)


Installation
============

Install from latest github source:

.. code-block:: console

   $ python -m pip install --user setuptools cython wheel numpy 'versioneer[toml]'
   $ python -m pip install --no-deps --no-build-isolation --user git+https://github.com/AppliedMathematicsANU/pyemblite.git#egg=pyemblite

or from source directory:

.. code-block:: console

   $ python -m pip install --user setuptools cython wheel numpy 'versioneer[toml]'
   $ git clone git@github.com:AppliedMathematicsANU/pyemblite.git
   $ cd pyemblite
   $ python -m pip install --no-deps --no-build-isolation --user .


If you're on windows, you can use `vcpkg <https://github.com/microsoft/vcpkg>`_ to
manage non-python dependencies (can also be used on Linux and MacOS):

.. code-block:: powershell

   PS > git clone https://github.com/microsoft/vcpkg
   PS > .\vcpkg\bootstrap-vcpkg.bat
   PS > $Env:VCPKG_ROOT=$(Resolve-Path ./vcpkg)
   PS > git clone git@github.com/AppliedMathematicsANU/pyemblite.git
   PS > cd pyemblite
   PS > python -m pip install --prefix=\path\to\install\root .


You also still need to have build tools installed (some kind of C/C++ compiler).
One way to achieve this is to install Visual Studio Build tools. Visual studio
build tools likely require the installation of visual studio community edition first.
This link should (hopefully) get you started:

 https://visualstudio.microsoft.com/downloads/


Requirements
============

Requires:

- python-3 version `>= 3.4`,
- `numpy <http://www.numpy.org/>`_ version `>= 1.7`,
- `embree <https://embree.github.io>`_ `>= 3.0 < 4.0` (`Latest release <https://github.com/embree/embree/releases/latest>`_)


Testing
=======

Run tests (unit-tests and doctest module docstring tests) using:

.. code-block:: console

   $ python -m pyemblite.test

or with *fail-fast* and *verbosity*:

.. code-block:: console

   $ python -m pyemblite.test -fv



Latest source code
==================

Source at github:

   https://github.com/AppliedMathematicsANU/pyemblite


License information
===================

See the file `LICENSE.txt <https://github.com/AppliedMathematicsANU/pyemblite/blob/dev/LICENSE.txt>`_
for terms & conditions, for usage and a DISCLAIMER OF ALL WARRANTIES.

