Commit 53d483fe authored by sumpfralle's avatar sumpfralle

trimesh models now use the kdtree by default:

 * fixes performance issue when using a support grid (previously a new (non-kdtree) trimesh model was created)
implemented a proper update-trigger for kdtree of trimesh model


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@479 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 30fa4082
Version 0.3.0 - UNRELEASED Version 0.3.0 - UNRELEASED
* improved performance of toolpath generation
* added a complete commandline interface * added a complete commandline interface
* added basic support for importing simple DXF contour files * added basic support for importing simple DXF contour files
* added support for engravings * added support for engravings
* integrated "help" links pointing to the wiki * integrated "help" links pointing to the wiki
* allow non-square profiles for the support grid * allow non-square profiles for the support grid
* improved OpenGL lightning (contributed by imyrek) * improved OpenGL lightning (contributed by imyrek)
* fixed performance issue when using a support grid
* fixed empty toolpath after transforming the model
* added minor fix for PushCutter * added minor fix for PushCutter
Version 0.2.5 - 2010-06-10 Version 0.2.5 - 2010-06-10
......
...@@ -179,13 +179,15 @@ class BaseModel(object): ...@@ -179,13 +179,15 @@ class BaseModel(object):
class Model(BaseModel): class Model(BaseModel):
def __init__(self): def __init__(self, use_kdtree=True):
super(Model, self).__init__() super(Model, self).__init__()
self._triangles = [] self._triangles = []
self._item_groups.append(self._triangles) self._item_groups.append(self._triangles)
self._export_function = pycam.Exporters.STLExporter.STLExporter self._export_function = pycam.Exporters.STLExporter.STLExporter
# marker for state of kdtree # marker for state of kdtree
self._kdtree_dirty = False self._kdtree_dirty = False
# enable/disable kdtree
self._use_kdtree = use_kdtree
def append(self, item): def append(self, item):
super(Model, self).append(item) super(Model, self).append(item)
...@@ -200,19 +202,21 @@ class Model(BaseModel): ...@@ -200,19 +202,21 @@ class Model(BaseModel):
self._update_kdtree() self._update_kdtree()
def _update_kdtree(self): def _update_kdtree(self):
if hasattr(self, "t_kdtree"): if self._use_kdtree:
self.t_kdtree = TriangleKdtree(self.triangles()) self._t_kdtree = TriangleKdtree(self.triangles())
# the kdtree is up-to-date again # the kdtree is up-to-date again
self._kdtree_dirty = False self._kdtree_dirty = False
def triangles(self, minx=-INFINITE,miny=-INFINITE,minz=-INFINITE,maxx=+INFINITE,maxy=+INFINITE,maxz=+INFINITE): def triangles(self, minx=-INFINITE, miny=-INFINITE, minz=-INFINITE,
if minx==-INFINITE and miny==-INFINITE and minz==-INFINITE and maxx==+INFINITE and maxy==+INFINITE and maxz==+INFINITE: maxx=+INFINITE, maxy=+INFINITE, maxz=+INFINITE):
if (minx == miny == minz == -INFINITE) \
and (maxx == maxy == maxz == +INFINITE):
return self._triangles return self._triangles
if hasattr(self, "t_kdtree"): if self._use_kdtree:
# update the kdtree, if new triangles were added meanwhile # update the kdtree, if new triangles were added meanwhile
if self._kdtree_dirty: if self._kdtree_dirty:
self._update_kdtree() self._update_kdtree()
return self.t_kdtree.Search(minx,maxx,miny,maxy) return self._t_kdtree.Search(minx, maxx, miny, maxy)
return self._triangles return self._triangles
......
...@@ -114,7 +114,7 @@ def ImportModel(filename, use_kdtree=True): ...@@ -114,7 +114,7 @@ def ImportModel(filename, use_kdtree=True):
if use_kdtree: if use_kdtree:
kdtree = PointKdtree([], 3, 1, epsilon) kdtree = PointKdtree([], 3, 1, epsilon)
model = Model() model = Model(use_kdtree)
t = None t = None
p1 = None p1 = None
...@@ -257,10 +257,6 @@ def ImportModel(filename, use_kdtree=True): ...@@ -257,10 +257,6 @@ def ImportModel(filename, use_kdtree=True):
if m: if m:
continue continue
if use_kdtree:
model.p_kdtree = kdtree
model.t_kdtree = TriangleKdtree(model.triangles())
log.info("Imported STL model: %d vertices, %d edges, %d triangles" \ log.info("Imported STL model: %d vertices, %d edges, %d triangles" \
% (vertices, edges, len(model.triangles()))) % (vertices, edges, len(model.triangles())))
vertices = 0 vertices = 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment