示例#1
0
 def transform_by_matrix(self, matrix, transformed_list=None, callback=None):
     from pycam.Geometry.PointUtils import ptransform_by_matrix
     if transformed_list is None:
         transformed_list = []
     # Prevent any kind of loops or double transformations (e.g. Points in
     # multiple containers (Line, Triangle, ...).
     # Use the 'id' builtin to prevent expensive object comparions.
     for item in next(self):
         if isinstance(item, TransformableContainer):
             item.transform_by_matrix(matrix, transformed_list, callback=callback)
         elif not id(item) in transformed_list:
             # Don't transmit the 'transformed_list' if the object is
             # not a TransformableContainer. It is not necessary and it
             # is hard to understand on the lowest level (e.g. Point).
             if isinstance(item, str):
                 theval = getattr(self, item)
                 if isinstance(theval, tuple):
                     setattr(self, item, ptransform_by_matrix(theval, matrix))
                 elif isinstance(theval, list):
                     setattr(self, item, [ptransform_by_matrix(x, matrix) for x in theval])
             elif isinstance(item, tuple):
                 _log.error("ERROR!! A tuple (Point, Vector) made it into base "
                            "transform_by_matrix without a back reference. "
                            "Point/Vector remains unchanged.")
             else:
                 item.transform_by_matrix(matrix, callback=callback)
         # run the callback - e.g. for a progress counter
         if callback and callback():
             # user requesteded abort
             break
     self.reset_cache()
示例#2
0
文件: Filters.py 项目: stevegt/pycam
 def filter_toolpath(self, toolpath):
     new_path = []
     for move_type, args in toolpath:
         if move_type in (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID):
             new_pos = ptransform_by_matrix(args, self.settings["matrix"])
             new_path.append((move_type, new_pos))
         else:
             new_path.append((move_type, args))
     return new_path
示例#3
0
 def filter_toolpath(self, toolpath):
     new_path = []
     for step in toolpath:
         if step.action in MOVES_LIST:
             new_pos = ptransform_by_matrix(step.position, self.settings["matrix"])
             new_path.append(ToolpathSteps.get_step_class_by_action(step.action)(new_pos))
         else:
             new_path.append(step)
     return new_path
示例#4
0
文件: Filters.py 项目: patyork/pycam
 def filter_toolpath(self, toolpath):
     new_path = []
     for move_type, args in toolpath:
         if move_type in (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID):
             new_pos = ptransform_by_matrix(args, self.settings["matrix"])
             new_path.append((move_type, new_pos))
         else:
             new_path.append((move_type, args))
     return new_path