Skip to content

liblaf.melon.proximity ¤

Classes:

  • NearestAlgorithm –
  • NearestAlgorithmPrepared –
  • NearestPoint –
  • NearestPointOnSurface –
  • NearestPointOnSurfacePrepared –
  • NearestPointOnSurfaceResult –
  • NearestPointPrepared –
  • NearestPointResult –
  • NearestResult –

Functions:

  • nearest –
  • nearest_point_on_surface –

NearestAlgorithm ¤

Bases: ABC


              flowchart TD
              liblaf.melon.proximity.NearestAlgorithm[NearestAlgorithm]

              

              click liblaf.melon.proximity.NearestAlgorithm href "" "liblaf.melon.proximity.NearestAlgorithm"
            

Methods:

  • prepare –

prepare abstractmethod ¤

prepare(source: Any) -> NearestAlgorithmPrepared
Source code in src/liblaf/melon/proximity/_abc.py
22
23
@abc.abstractmethod
def prepare(self, source: Any) -> NearestAlgorithmPrepared: ...

NearestAlgorithmPrepared ¤

Bases: ABC


              flowchart TD
              liblaf.melon.proximity.NearestAlgorithmPrepared[NearestAlgorithmPrepared]

              

              click liblaf.melon.proximity.NearestAlgorithmPrepared href "" "liblaf.melon.proximity.NearestAlgorithmPrepared"
            

Methods:

  • query –

query abstractmethod ¤

query(query: Any) -> NearestResult
Source code in src/liblaf/melon/proximity/_abc.py
17
18
@abc.abstractmethod
def query(self, query: Any) -> NearestResult: ...

NearestPoint ¤

Bases: NearestAlgorithm


              flowchart TD
              liblaf.melon.proximity.NearestPoint[NearestPoint]
              liblaf.melon.proximity._abc.NearestAlgorithm[NearestAlgorithm]

                              liblaf.melon.proximity._abc.NearestAlgorithm --> liblaf.melon.proximity.NearestPoint
                


              click liblaf.melon.proximity.NearestPoint href "" "liblaf.melon.proximity.NearestPoint"
              click liblaf.melon.proximity._abc.NearestAlgorithm href "" "liblaf.melon.proximity._abc.NearestAlgorithm"
            

Parameters:

  • distance_threshold ¤

    (float, default: 0.1 ) –
  • ignore_orientation ¤

    (bool, default: True ) –
  • max_k ¤

    (int, default: 32 ) –
  • normal_threshold ¤

    (float, default: -inf ) –
  • workers ¤

    (int, default: -1 ) –

Methods:

  • prepare –

Attributes:

  • distance_threshold (float) –
  • ignore_orientation (bool) –
  • max_k (int) –
  • normal_threshold (float) –
  • workers (int) –

distance_threshold class-attribute instance-attribute ¤

distance_threshold: float = 0.1

ignore_orientation class-attribute instance-attribute ¤

ignore_orientation: bool = True

max_k class-attribute instance-attribute ¤

max_k: int = 32

normal_threshold class-attribute instance-attribute ¤

normal_threshold: float = field(
    default=-inf, validator=le(1.0)
)

workers class-attribute instance-attribute ¤

workers: int = -1

prepare ¤

prepare(source: Any) -> NearestPointPrepared
Source code in src/liblaf/melon/proximity/_nearest_point.py
110
111
112
113
114
115
116
117
118
119
120
121
122
123
@override
def prepare(self, source: Any) -> NearestPointPrepared:
    need_normals: bool = self.normal_threshold > -1.0
    source: pv.PointSet = io.as_pointset(source, point_normals=need_normals)
    tree: scipy.spatial.KDTree = scipy.spatial.KDTree(source.points)
    return NearestPointPrepared(
        source=source,
        tree=tree,
        distance_threshold=self.distance_threshold,
        max_k=self.max_k,
        normal_threshold=self.normal_threshold,
        ignore_orientation=self.ignore_orientation,
        workers=self.workers,
    )

NearestPointOnSurface ¤

Bases: NearestAlgorithm


              flowchart TD
              liblaf.melon.proximity.NearestPointOnSurface[NearestPointOnSurface]
              liblaf.melon.proximity._abc.NearestAlgorithm[NearestAlgorithm]

                              liblaf.melon.proximity._abc.NearestAlgorithm --> liblaf.melon.proximity.NearestPointOnSurface
                


              click liblaf.melon.proximity.NearestPointOnSurface href "" "liblaf.melon.proximity.NearestPointOnSurface"
              click liblaf.melon.proximity._abc.NearestAlgorithm href "" "liblaf.melon.proximity._abc.NearestAlgorithm"
            

Parameters:

  • distance_threshold ¤

    (float, default: 0.1 ) –
  • ignore_orientation ¤

    (bool, default: False ) –
  • normal_threshold ¤

    (float | None, default: 0.8 ) –

Methods:

  • prepare –

Attributes:

  • distance_threshold (float) –
  • ignore_orientation (bool) –
  • normal_threshold (float | None) –

distance_threshold class-attribute instance-attribute ¤

distance_threshold: float = 0.1

ignore_orientation class-attribute instance-attribute ¤

ignore_orientation: bool = False

normal_threshold class-attribute instance-attribute ¤

normal_threshold: float | None = field(
    default=0.8, validator=optional([ge(-1.0), le(1.0)])
)

prepare ¤

prepare(source: Any) -> NearestPointOnSurfacePrepared
Source code in src/liblaf/melon/proximity/_nearest_point_on_surface.py
113
114
115
116
117
118
119
120
121
@override
def prepare(self, source: Any) -> NearestPointOnSurfacePrepared:
    return NearestPointOnSurfacePrepared(
        source=io.as_warp_mesh(source),
        source_pv=io.as_polydata(source),
        distance_threshold=self.distance_threshold,
        ignore_orientation=self.ignore_orientation,
        normal_threshold=self.normal_threshold,
    )

NearestPointOnSurfacePrepared ¤

Bases: NearestAlgorithmPrepared


              flowchart TD
              liblaf.melon.proximity.NearestPointOnSurfacePrepared[NearestPointOnSurfacePrepared]
              liblaf.melon.proximity._abc.NearestAlgorithmPrepared[NearestAlgorithmPrepared]

                              liblaf.melon.proximity._abc.NearestAlgorithmPrepared --> liblaf.melon.proximity.NearestPointOnSurfacePrepared
                


              click liblaf.melon.proximity.NearestPointOnSurfacePrepared href "" "liblaf.melon.proximity.NearestPointOnSurfacePrepared"
              click liblaf.melon.proximity._abc.NearestAlgorithmPrepared href "" "liblaf.melon.proximity._abc.NearestAlgorithmPrepared"
            

Parameters:

  • source_pv ¤

    (PolyData) –
  • source ¤

    (Mesh) –
  • distance_threshold ¤

    (float) –
  • ignore_orientation ¤

    (bool) –
  • normal_threshold ¤

    (float | None) –

Methods:

  • query –

Attributes:

  • distance_threshold (float) –
  • face_normals (Float[ndarray, 'M 3']) –
  • ignore_orientation (bool) –
  • length (float) –
  • normal_threshold (float | None) –
  • source (Mesh) –
  • source_pv (PolyData) –

distance_threshold instance-attribute ¤

distance_threshold: float

face_normals property ¤

face_normals: Float[ndarray, 'M 3']

ignore_orientation instance-attribute ¤

ignore_orientation: bool

length property ¤

length: float

normal_threshold instance-attribute ¤

normal_threshold: float | None

source instance-attribute ¤

source: Mesh

source_pv instance-attribute ¤

source_pv: PolyData

query ¤

query(query: Any) -> NearestPointOnSurfaceResult
Source code in src/liblaf/melon/proximity/_nearest_point_on_surface.py
37
38
39
40
41
@override
def query(self, query: Any) -> NearestPointOnSurfaceResult:
    if self.normal_threshold is None:
        return self._query_without_normal_threshold(query)
    return self._query_with_normal_threshold(query)

NearestPointOnSurfaceResult ¤

Bases: NearestResult


              flowchart TD
              liblaf.melon.proximity.NearestPointOnSurfaceResult[NearestPointOnSurfaceResult]
              liblaf.melon.proximity._abc.NearestResult[NearestResult]

                              liblaf.melon.proximity._abc.NearestResult --> liblaf.melon.proximity.NearestPointOnSurfaceResult
                


              click liblaf.melon.proximity.NearestPointOnSurfaceResult href "" "liblaf.melon.proximity.NearestPointOnSurfaceResult"
              click liblaf.melon.proximity._abc.NearestResult href "" "liblaf.melon.proximity._abc.NearestResult"
            

Parameters:

  • distance ¤

    (Float[ndarray, Q]) –
  • missing ¤

    (Bool[ndarray, Q]) –
  • nearest ¤

    (Float[ndarray, 'Q 3']) –
  • barycentric ¤

    (Float[ndarray, 'N 3']) –
  • triangle_id ¤

    (Integer[ndarray, N]) –

Attributes:

  • barycentric (Float[ndarray, 'N 3']) –
  • distance (Float[ndarray, ' Q']) –
  • missing (Bool[ndarray, ' Q']) –
  • nearest (Float[ndarray, 'Q 3']) –
  • triangle_id (Integer[ndarray, ' N']) –

barycentric instance-attribute ¤

barycentric: Float[ndarray, 'N 3']

distance instance-attribute ¤

distance: Float[ndarray, ' Q']

missing instance-attribute ¤

missing: Bool[ndarray, ' Q']

nearest instance-attribute ¤

nearest: Float[ndarray, 'Q 3']

triangle_id instance-attribute ¤

triangle_id: Integer[ndarray, ' N']

NearestPointPrepared ¤

Bases: NearestAlgorithmPrepared


              flowchart TD
              liblaf.melon.proximity.NearestPointPrepared[NearestPointPrepared]
              liblaf.melon.proximity._abc.NearestAlgorithmPrepared[NearestAlgorithmPrepared]

                              liblaf.melon.proximity._abc.NearestAlgorithmPrepared --> liblaf.melon.proximity.NearestPointPrepared
                


              click liblaf.melon.proximity.NearestPointPrepared href "" "liblaf.melon.proximity.NearestPointPrepared"
              click liblaf.melon.proximity._abc.NearestAlgorithmPrepared href "" "liblaf.melon.proximity._abc.NearestAlgorithmPrepared"
            

Parameters:

Methods:

  • query –

Attributes:

  • distance_threshold (float) –
  • ignore_orientation (bool) –
  • max_k (int) –
  • normal_threshold (float) –
  • source (PointSet) –
  • tree (KDTree) –
  • workers (int) –

distance_threshold instance-attribute ¤

distance_threshold: float

ignore_orientation instance-attribute ¤

ignore_orientation: bool

max_k instance-attribute ¤

max_k: int

normal_threshold instance-attribute ¤

normal_threshold: float

source instance-attribute ¤

source: PointSet

tree instance-attribute ¤

tree: KDTree

workers instance-attribute ¤

workers: int

query ¤

query(query: Any) -> NearestPointResult
Source code in src/liblaf/melon/proximity/_nearest_point.py
30
31
32
33
34
@override
def query(self, query: Any) -> NearestPointResult:
    if self.normal_threshold <= -1.0:
        return self._nearest_vertex(query)
    return self._nearest_vertex_with_normal_threshold(query)

NearestPointResult ¤

Bases: NearestResult


              flowchart TD
              liblaf.melon.proximity.NearestPointResult[NearestPointResult]
              liblaf.melon.proximity._abc.NearestResult[NearestResult]

                              liblaf.melon.proximity._abc.NearestResult --> liblaf.melon.proximity.NearestPointResult
                


              click liblaf.melon.proximity.NearestPointResult href "" "liblaf.melon.proximity.NearestPointResult"
              click liblaf.melon.proximity._abc.NearestResult href "" "liblaf.melon.proximity._abc.NearestResult"
            

Parameters:

  • distance ¤

    (Float[ndarray, Q]) –
  • missing ¤

    (Bool[ndarray, Q]) –
  • nearest ¤

    (Float[ndarray, 'Q 3']) –
  • vertex_id ¤

    (Integer[ndarray, N]) –

Attributes:

  • distance (Float[ndarray, ' Q']) –
  • missing (Bool[ndarray, ' Q']) –
  • nearest (Float[ndarray, 'Q 3']) –
  • vertex_id (Integer[ndarray, ' N']) –

distance instance-attribute ¤

distance: Float[ndarray, ' Q']

missing instance-attribute ¤

missing: Bool[ndarray, ' Q']

nearest instance-attribute ¤

nearest: Float[ndarray, 'Q 3']

vertex_id instance-attribute ¤

vertex_id: Integer[ndarray, ' N']

NearestResult ¤

Parameters:

  • distance ¤

    (Float[ndarray, Q]) –
  • missing ¤

    (Bool[ndarray, Q]) –
  • nearest ¤

    (Float[ndarray, 'Q 3']) –

Attributes:

  • distance (Float[ndarray, ' Q']) –
  • missing (Bool[ndarray, ' Q']) –
  • nearest (Float[ndarray, 'Q 3']) –

distance instance-attribute ¤

distance: Float[ndarray, ' Q']

missing instance-attribute ¤

missing: Bool[ndarray, ' Q']

nearest instance-attribute ¤

nearest: Float[ndarray, 'Q 3']

nearest ¤

nearest(
    source: Any,
    query: Any,
    algo: NearestPoint | None = None,
) -> NearestPointResult
nearest(
    source: Any, query: Any, algo: NearestPointOnSurface
) -> NearestPointOnSurfaceResult
nearest(
    source: Any, query: Any, algo: NearestAlgorithm
) -> NearestResult
Source code in src/liblaf/melon/proximity/_nearest.py
21
22
23
24
25
26
27
def nearest(
    source: Any, query: Any, algo: NearestAlgorithm | None = None
) -> NearestResult:
    if algo is None:
        algo = NearestPoint()
    prepared: NearestAlgorithmPrepared = algo.prepare(source)
    return prepared.query(query)

nearest_point_on_surface ¤

nearest_point_on_surface(
    source: Any,
    target: Any,
    *,
    distance_threshold: float = 0.1,
    ignore_orientation: bool = True,
    normal_threshold: float | None = 0.8,
) -> NearestPointOnSurfaceResult
Source code in src/liblaf/melon/proximity/_nearest_point_on_surface.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
def nearest_point_on_surface(
    source: Any,
    target: Any,
    *,
    distance_threshold: float = 0.1,
    ignore_orientation: bool = True,
    normal_threshold: float | None = 0.8,
) -> NearestPointOnSurfaceResult:
    algorithm = NearestPointOnSurface(
        distance_threshold=distance_threshold,
        ignore_orientation=ignore_orientation,
        normal_threshold=normal_threshold,
    )
    prepared: NearestPointOnSurfacePrepared = algorithm.prepare(source)
    return prepared.query(target)