Commit e7995bc1 authored by sumpfralle's avatar sumpfralle

r699@erker: lars | 2010-02-21 16:34:10 +0100

 simplified some cutter code
 moved "Dimension" to the base of PathGenerator


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@151 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 07aaaa83
......@@ -695,7 +695,7 @@ class ProjectGui:
direction = self.settings.get("path_direction")
# Due to some weirdness the height of the drill must be bigger than the object's size.
# Otherwise some collisions are not detected.
cutter_height = 2 * (self.settings.get("maxz") - self.settings.get("minz"))
cutter_height = 4 * max((self.settings.get("maxz") - self.settings.get("minz")), (self.model.maxz - self.model.minz))
if cuttername == "SphericalCutter":
self.cutter = pycam.Cutters.SphericalCutter(radius, height=cutter_height)
elif cuttername == "CylindricalCutter":
......@@ -746,7 +746,7 @@ class ProjectGui:
self.option = pycam.PathProcessors.ContourCutter()
else:
self.option = None
self.pathgenerator = pycam.PathGenerators.PushCutter(self.cutter, self.model, self.option);
self.pathgenerator = pycam.PathGenerators.PushCutter(self.cutter, self.model, self.option, physics=self.physics);
if pathprocessor == "ContourCutter":
dx = x_shift
else:
......
......@@ -191,13 +191,8 @@ def generate_physics(settings, cutter, physics=None):
physics = ode_objects.PhysicalWorld()
physics.reset()
physics.add_mesh((0, 0, 0), settings.get("model").triangles())
#radius = settings.get("tool_radius")
# weird: the normal length of the drill causes the detection to fail at high points of the object
#height = 2 * (settings.get("maxz") - settings.get("minz"))
#physics.set_drill(ode_objects.ShapeCylinder(radius, height), (settings.get("minx"), settings.get("miny"), settings.get("maxz")))
#physics.set_drill(ode_objects.ShapeCylinder(radius, height), (0, 0, height/2.0))
shape_info = cutter.get_shape("ODE", settings.get("material_allowance"))
physics.set_drill(shape_info[0], shape_info[2])
shape_info = cutter.get_shape("ODE", additional_distance=settings.get("material_allowance"))
physics.set_drill(shape_info[0], (0.0, 0.0, 0.0))
return physics
def is_ode_available():
......
......@@ -2,35 +2,8 @@ from pycam.PathProcessors import *
from pycam.Geometry import *
from pycam.Geometry.utils import *
from pycam.Geometry.intersection import intersect_lines
import pycam.PathGenerators
class Dimension:
def __init__(self, start, end):
self.start = float(start)
self.end = float(end)
self._min = float(min(start, end))
self._max = float(max(start, end))
self.downward = start > end
self.value = 0.0
def check_bounds(self, value=None, tolerance=None):
if value is None:
value = self.value
if tolerance is None:
return (value >= self._min) and (value <= self._max)
else:
return (value > self._min - tolerance) and (value < self._max + tolerance)
def shift(self, distance):
if self.downward:
self.value -= distance
else:
self.value += distance
def set(self, value):
self.value = float(value)
def get(self):
return self.value
class DropCutter:
......@@ -49,9 +22,9 @@ class DropCutter:
else:
pa = PathAccumulator()
dim_x = Dimension(minx, maxx)
dim_y = Dimension(miny, maxy)
dim_height = Dimension(z1, z0)
dim_x = pycam.PathGenerators.Dimension(minx, maxx)
dim_y = pycam.PathGenerators.Dimension(miny, maxy)
dim_height = pycam.PathGenerators.Dimension(z1, z0)
dims = [None, None, None]
# map the scales according to the order of direction
if direction == 0:
......
list = ["DropCutter", "PushCutter"]
list = ["DropCutter", "PushCutter", "Dimension"]
__all__ = list
from DropCutter import DropCutter
from PushCutter import PushCutter
class Dimension:
def __init__(self, start, end):
self.start = float(start)
self.end = float(end)
self._min = float(min(start, end))
self._max = float(max(start, end))
self.downward = start > end
self.value = 0.0
def check_bounds(self, value=None, tolerance=None):
if value is None:
value = self.value
if tolerance is None:
return (value >= self._min) and (value <= self._max)
else:
return (value > self._min - tolerance) and (value < self._max + tolerance)
def shift(self, distance):
if self.downward:
self.value -= distance
else:
self.value += distance
def set(self, value):
self.value = float(value)
def get(self):
return self.value
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