Commit 5c349899 authored by sumpfralle's avatar sumpfralle

added a plane to the properties of a ContourModel


git-svn-id: https://pycam.svn.sourceforge.net/svnroot/pycam/trunk@641 bbaffbd6-741e-11dd-a85d-61de82d9cad9
parent 980006e7
...@@ -222,7 +222,7 @@ class Model(BaseModel): ...@@ -222,7 +222,7 @@ class Model(BaseModel):
collision_line = Line(collision_line.p2, collision_line.p1) collision_line = Line(collision_line.p2, collision_line.p1)
collision_lines.append(collision_line) collision_lines.append(collision_line)
# combine these lines into polygons # combine these lines into polygons
contour = ContourModel() contour = ContourModel(plane=plane)
for line in collision_lines: for line in collision_lines:
contour.append(line) contour.append(line)
log.debug("Waterline: %f - %d - %s" % (plane.p.z, log.debug("Waterline: %f - %d - %s" % (plane.p.z,
...@@ -237,20 +237,28 @@ class Model(BaseModel): ...@@ -237,20 +237,28 @@ class Model(BaseModel):
#super(Model, self).to_OpenGL() #super(Model, self).to_OpenGL()
z_diff = (self.maxz - self.minz) / (num_of_levels - 1) z_diff = (self.maxz - self.minz) / (num_of_levels - 1)
z_levels = [self.minz + z_diff * i for i in range(num_of_levels)] z_levels = [self.minz + z_diff * i for i in range(num_of_levels)]
projection_plane = Plane(Point(0, 0, 0), Vector(0, 0, 1))
for z_level in z_levels: for z_level in z_levels:
polygons = self.get_waterline_polygons(Plane(Point(0, 0, z_level), waterline_plane = Plane(Point(0, 0, z_level), Vector(0, 0, 1))
Vector(0, 0, 1))) polygons = self.get_waterline_polygons(waterline_plane)
for polygon in polygons: for polygon in polygons:
polygon.to_OpenGL() polygon.get_plane_projection(projection_plane).to_OpenGL()
class ContourModel(BaseModel): class ContourModel(BaseModel):
def __init__(self): def __init__(self, plane=None):
super(ContourModel, self).__init__() super(ContourModel, self).__init__()
self.name = "contourmodel%d" % self.id self.name = "contourmodel%d" % self.id
if plane is None:
# the default plane points upwards along the z axis
plane = Plane(Point(0, 0, 0), Point(0, 0, 1))
self._plane = plane
self._line_groups = [] self._line_groups = []
self._item_groups.append(self._line_groups) self._item_groups.append(self._line_groups)
# there is always just one plane
self._plane_groups = [self._plane]
self._item_groups.append(self._plane_groups)
self._cached_offset_models = {} self._cached_offset_models = {}
def reset_cache(self): def reset_cache(self):
...@@ -299,7 +307,7 @@ class ContourModel(BaseModel): ...@@ -299,7 +307,7 @@ class ContourModel(BaseModel):
break break
else: else:
# add a single line as part of a new group # add a single line as part of a new group
new_line_group = Polygon() new_line_group = Polygon(plane=self._plane)
new_line_group.append(item) new_line_group.append(item)
self._line_groups.append(new_line_group) self._line_groups.append(new_line_group)
elif isinstance(item, Polygon): elif isinstance(item, Polygon):
...@@ -329,7 +337,7 @@ class ContourModel(BaseModel): ...@@ -329,7 +337,7 @@ class ContourModel(BaseModel):
if not new_groups is None: if not new_groups is None:
new_line_groups.extend(new_groups) new_line_groups.extend(new_groups)
if len(new_line_groups) > 0: if len(new_line_groups) > 0:
result = ContourModel() result = ContourModel(plane=self.plane)
for group in new_line_groups: for group in new_line_groups:
result.append(group) result.append(group)
return result return result
...@@ -352,7 +360,7 @@ class ContourModel(BaseModel): ...@@ -352,7 +360,7 @@ class ContourModel(BaseModel):
# use a cached offset model if it exists # use a cached offset model if it exists
if offset in self._cached_offset_models: if offset in self._cached_offset_models:
return self._cached_offset_models[offset] return self._cached_offset_models[offset]
result = ContourModel() result = ContourModel(plane=self.plane)
for group in self._line_groups: for group in self._line_groups:
new_groups = group.get_offset_polygons(offset) new_groups = group.get_offset_polygons(offset)
if not new_groups is None: if not new_groups is None:
......
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