def get_tool_from_settings(tool_settings, height=None): """ get the tool specified by the relevant settings The settings must include: - "shape": one of "SphericalCutter", "CylindricalCutter" and "ToroidalCutter" - "radius": the tool radius The following settings are optional or shape specific: - "torus_radius": necessary for ToroidalCutter @type tool_settings: dict @value tool_settings: contains the attributes of the tool @type height: float @value height: the height of the tool @rtype: BaseCutter | basestring @return: a tool object or an error string """ cuttername = tool_settings["shape"] radius = tool_settings["tool_radius"] if cuttername == "SphericalCutter": return SphericalCutter(radius, height=height) elif cuttername == "CylindricalCutter": return CylindricalCutter(radius, height=height) elif cuttername == "ToroidalCutter": toroid = tool_settings["torus_radius"] return ToroidalCutter(radius, toroid, height=height) else: return "Invalid cutter shape: '%s' is not known" % str(cuttername)
from pycam.Gui.Visualization import Visualization from pycam.Simulation.ZBuffer import ZBuffer from pycam.Importers.TestModel import TestModel from pycam.Geometry.Point import Point from pycam.Cutters.SphericalCutter import SphericalCutter model = TestModel() zbuffer = ZBuffer(-5, +5, 150, -5, +5, 150, 1, 5) # zbuffer.add_wave() # zbuffer.add_triangle(Triangle(Point(-4, 0, 0), Point(3, 5, 2), Point(4, -3, 4))) c = SphericalCutter(0.25) p = Point(-5, -5, 2) c.moveto(p) zbuffer.add_triangles(model.triangles()) # zbuffer.add_cutter(c) def DrawScene(): size = 1 # axes GL.glBegin(GL.GL_LINES) GL.glColor3f(1, 0, 0) GL.glVertex3f(0, 0, 0)
from pycam.Importers.TestModel import TestModel from pycam.Geometry.Triangle import Triangle from pycam.Geometry.Point import Point from pycam.Cutters.SphericalCutter import SphericalCutter from OpenGL.GL import * model = TestModel() zbuffer = ZBuffer(-5,+5,150, -5,+5,150, 1,5) #zbuffer.add_wave() #zbuffer.add_triangle(Triangle(Point(-4,0,0),Point(3,5,2),Point(4,-3,4))) c = SphericalCutter(0.25) p = Point(-5,-5,2) c.moveto(p) zbuffer.add_triangles(model.triangles()) #zbuffer.add_cutter(c) def DrawScene(): size=1 # axes glBegin(GL_LINES) glColor3f(1,0,0) glVertex3f(0,0,0)
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with PyCAM. If not, see <http://www.gnu.org/licenses/>. """ from pycam.Geometry import Line, Path, Point, Triangle from pycam.Cutters.SphericalCutter import SphericalCutter from pycam.Gui.Visualization import ShowTestScene if __name__ == "__main__": if False: cutter = SphericalCutter(1, Point(-10, 0.5, 0)) edge = Line(Point(0, 0, -10), Point(0, 0, 10)) dir = Point(1, 0, 0) print("cutter=", cutter) print("edge=", edge) print("dir=", dir) (cl, ccp, cp, d) = cutter.intersect_sphere_line(dir, edge) print("cp=", cp) print("ccp=", ccp) print("d=", d) print("cl=", cl) exit() if False: cutter = SphericalCutter(1, Point(-10, 0, 0)) edge = Line(Point(0, -5, 1), Point(3, +5, 1))
from pycam.Geometry.utils import INFINITE from pycam.Cutters.SphericalCutter import SphericalCutter from pycam.Cutters.CylindricalCutter import CylindricalCutter from pycam.Cutters.ToroidalCutter import ToroidalCutter from pycam.Gui.Visualization import ShowTestScene from pycam.Importers import STLImporter from pycam.PathGenerators.PushCutter import PushCutter from pycam.PathProcessors import SimpleCutter if __name__ == "__main__": for c in [ SphericalCutter(0.1, Point(0, 0, 7)), CylindricalCutter(1, Point(0, 0, 7)), ToroidalCutter(1, 0.25, Point(0, 0, 7)) ]: print("c=", c) # model = TestModel() # model = STLImporter.ImportModel("Samples/STL/Box0.stl") # model = STLImporter.ImportModel("Samples/STL/Box1.stl") model = STLImporter.ImportModel("Samples/STL/Box0+1.stl") # model = Model() # model.append(Triangle(Point(0, 0, 0), Point(0, 5, 4), Point(0, -5, 4))) # model.append(Triangle(Point(2, 0, 0), Point(2, -5, 4), Point(2, 5, 4))) if True: lines = 20
def _drop(self, radius, triangle): return SphericalCutter(radius, location=(0, 0, 0)).drop(triangle)