How to use the pyntcloud.structures.base.Structure function in pyntcloud

To help you get started, we’ve selected a few pyntcloud examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github daavoo / pyntcloud / pyntcloud / structures / base.py View on Github external
def __setitem__(self, key, val):
        if not issubclass(val.__class__, Structure):
            raise TypeError("{} must be base.Structure subclass".format(key))

        # TODO better structure.id check
        if key.startswith("V"):
            self.n_voxelgrids += 1
        elif key.startswith("K"):
            self.n_kdtrees += 1
        elif key.startswith("D"):
            self.n_delaunays += 1
        elif key.startswith("CH"):
            self.n_convex_hulls += 1
        else:
            raise ValueError("{} is not a valid structure.id".format(key))
        super().__setitem__(key, val)
github daavoo / pyntcloud / pyntcloud / structures / delanuay.py View on Github external
import pandas as pd
from scipy.spatial import Delaunay
from itertools import combinations

from .base import Structure


class Delaunay3D(Delaunay, Structure):

    def __init__(self, points,
                 furthest_site=False,
                 incremental=False,
                 qhull_options=None):
        Structure.__init__(self, points)
        self._furthest_site = furthest_site
        self._incremental = incremental
        self._qhull_options = qhull_options

    def compute(self):
        """ABC API"""
        self.id = "D({},{})".format(self._furthest_site, self._qhull_options)
        Delaunay.__init__(self,
                          self._points,
                          self._furthest_site,
github daavoo / pyntcloud / pyntcloud / structures / convex_hull.py View on Github external
import pandas as pd
from scipy.spatial import ConvexHull as scipy_ConvexHull


from .base import Structure


class ConvexHull(scipy_ConvexHull, Structure):

    def __init__(self, points,
                 incremental=False,
                 qhull_options=None):
        Structure.__init__(self, points=points)
        self._incremental = incremental
        self._qhull_options = qhull_options

    def compute(self):
        """ABC API"""
        self.id = "CH({})".format(self._qhull_options)
        scipy_ConvexHull.__init__(self,
                                  self._points,
                                  self._incremental,
                                  self._qhull_options)
github daavoo / pyntcloud / pyntcloud / structures / kdtree.py View on Github external
from scipy.spatial import cKDTree

from .base import Structure


class KDTree(cKDTree, Structure):

    def __init__(self, *, points, leafsize=16, compact_nodes=False, balanced_tree=False):
        Structure.__init__(self, points=points)
        self._leafsize = leafsize
        self._compact_nodes = compact_nodes
        self._balanced_tree = balanced_tree

    def compute(self):
        self.id = "K({},{},{})".format(self._leafsize, self._compact_nodes, self._balanced_tree)
        cKDTree.__init__(
            self,
            self._points,
            leafsize=self._leafsize,
            compact_nodes=self._compact_nodes,
            balanced_tree=self._balanced_tree)
github daavoo / pyntcloud / pyntcloud / structures / voxelgrid.py View on Github external
is_matplotlib_avaliable = False

from scipy.spatial import cKDTree

from .base import Structure
from ..plot import plot_voxelgrid
from ..utils.array import cartesian

try:
    from ..utils.numba import groupby_max, groupby_count, groupby_sum
    is_numba_avaliable = True
except ImportError:
    is_numba_avaliable = False


class VoxelGrid(Structure):

    def __init__(self, *, points, n_x=1, n_y=1, n_z=1, size_x=None, size_y=None, size_z=None, regular_bounding_box=True):
        """Grid of voxels with support for different build methods.

        Parameters
        ----------
        cloud: (N, 3) numpy.array
        n_x, n_y, n_z :  int, optional
            Default: 1
            The number of segments in which each axis will be divided.
            Ignored if corresponding size_x, size_y or size_z is not None.
        size_x, size_y, size_z : float, optional
            Default: None
            The desired voxel size along each axis.
            If not None, the corresponding n_x, n_y or n_z will be ignored.
        regular_bounding_box : bool, optional