Example #1
0
 def __init__(self, triangles, cutoff=3, cutoff_distance=1.0):
     nodes = []
     for t in triangles:
         n = Node()
         n.triangle = t
         n.bound = []
         n.bound.append(min(t.p1.x, t.p2.x, t.p3.x))
         n.bound.append(max(t.p1.x, t.p2.x, t.p3.x))
         n.bound.append(min(t.p1.y, t.p2.y, t.p3.y))
         n.bound.append(max(t.p1.y, t.p2.y, t.p3.y))
         nodes.append(n)
     super(TriangleKdtree, self).__init__(nodes, cutoff, cutoff_distance)
Example #2
0
 def point(self, x, y, z):
     if self._n:
         n = self._n
         n.bound = (x, y, z)
     else:
         n = Node(None, (x, y, z))
     (nn, dist) = self.nearest_neighbor(n, self.dist)
     if nn and (dist < self.tolerance):
         self._n = n
         return nn.obj
     else:
         n.obj = (x, y, z)
         self._n = None
         self.insert(n)
         return n.obj
Example #3
0
 def Point(self, x, y, z):
     if self._n:
         n = self._n
         n.bound = (x, y, z)
     else:
         n = Node(None, (x, y, z))
     (nn, dist) = self.nearest_neighbor(n, self.dist)
     if nn and (dist < self.tolerance):
         self._n = n
         return nn.obj
     else:
         n.obj = (x, y, z)
         self._n = None
         self.insert(n)
         return n.obj
Example #4
0
 def __init__(self, points=None, cutoff=5, cutoff_distance=0.5,
         tolerance=epsilon):
     if points is None:
         points = []
     self._n = None
     self.tolerance = tolerance
     nodes = []
     for p in points:
         n = Node()
         n.point = p
         n.bound = []
         n.bound.append(p.x)
         n.bound.append(p.y)
         n.bound.append(p.z)
         nodes.append(n)
     kdtree.__init__(self, nodes, cutoff, cutoff_distance)
Example #5
0
 def __init__(self, triangles, cutoff=3, cutoff_distance=1.0):
     nodes = []
     for t in triangles:
         n = Node(t, (min(t.p1[0], t.p2[0], t.p3[0]),
                      max(t.p1[0], t.p2[0], t.p3[0]),
                      min(t.p1[1], t.p2[1], t.p3[1]),
                      max(t.p1[1], t.p2[1], t.p3[1])))
         nodes.append(n)
     super().__init__(nodes, cutoff, cutoff_distance)
Example #6
0
 def Point(self, x, y, z):
     #return Point(x,y,z)
     if self._n:
         n = self._n
     else:
         n = Node()
     n.bound = []
     n.bound.append(x)
     n.bound.append(y)
     n.bound.append(z)
     (nn, dist) = self.nearest_neighbor(n, self.dist)
     if nn and (dist < self.tolerance):
         self._n = n
         return nn.p
     else:
         n.p = Point(x, y, z)
         self._n = None
         self.insert(n)
         return n.p
Example #7
0
 def Point(self, x, y, z):
     #return Point(x,y,z)
     if self._n:
         n = self._n
     else:
         n = Node()
     n.bound = []
     n.bound.append(x)
     n.bound.append(y)
     n.bound.append(z)
     (nn, dist) = self.nearest_neighbor(n, self.dist)
     if nn and (dist < self.tolerance):
         self._n = n
         return nn.p
     else:
         n.p = Point(x, y, z)
         self._n = None
         self.insert(n)
         return n.p
Example #8
0
 def __init__(self,
              points=None,
              cutoff=5,
              cutoff_distance=0.5,
              tolerance=epsilon):
     if points is None:
         points = []
     self._n = None
     self.tolerance = tolerance
     nodes = []
     for p in points:
         n = Node()
         n.point = p
         n.bound = []
         n.bound.append(p.x)
         n.bound.append(p.y)
         n.bound.append(p.z)
         nodes.append(n)
     kdtree.__init__(self, nodes, cutoff, cutoff_distance)
Example #9
0
 def __init__(self,
              points=None,
              cutoff=5,
              cutoff_distance=0.5,
              tolerance=epsilon):
     if points is None:
         points = []
     self._n = None
     self.tolerance = tolerance
     nodes = []
     for p in points:
         n = Node(p, p)
         nodes.append(n)
     Kdtree.__init__(self, nodes, cutoff, cutoff_distance)