Exemplo n.º 1
0
 def Write_GCode(self, PostPro):
     """
     Writes the GCODE for a Break.
     @param PostPro: The PostProcessor instance to be used
     @return: Returns the string to be written to file.
     """
     oldZ = PostPro.ze
     oldFeed = PostPro.feed
     if self.height <= oldZ:
         return (LineGeo.Write_GCode(self, PostPro))
     else:
         return (PostPro.chg_feed_rate(self.zfeed) +
                 PostPro.lin_pol_z(self.height) +
                 PostPro.chg_feed_rate(self.xyfeed) +
                 LineGeo.Write_GCode(self, PostPro) +
                 PostPro.chg_feed_rate(self.zfeed) +
                 PostPro.lin_pol_z(oldZ) + PostPro.chg_feed_rate(oldFeed))
Exemplo n.º 2
0
    def Read(self, caller):
        """
        This function does read the geometry.
        @param caller: The instance which is calling the function
        """
        # Assign short name
        lp = caller.line_pairs
        e = lp.index_code(0, caller.start + 1)

        # Assign layer
        s = lp.index_code(8, caller.start + 1)
        self.Layer_Nr = caller.Get_Layer_Nr(lp.line_pair[s].value)

        # X Value
        sl = lp.index_code(10, s + 1)
        x0 = float(lp.line_pair[sl].value)

        # Y Value
        s = lp.index_code(20, sl + 1)
        y0 = float(lp.line_pair[s].value)

        # X Value 2
        s = lp.index_code(11, sl + 1)
        x1 = float(lp.line_pair[s].value)

        # Y Value 2
        s = lp.index_code(21, s + 1)
        y1 = float(lp.line_pair[s].value)

        # Searching for an extrusion direction
        s_nxt_xt = lp.index_code(230, s + 1, e)
        # If there is a extrusion direction given flip around x-Axis
        if s_nxt_xt is not None:
            extrusion_dir = float(lp.line_pair[s_nxt_xt].value)
            logger.debug(
                self.tr('Found extrusion direction: %s') % extrusion_dir)
            if extrusion_dir == -1:
                x0 = -x0
                x1 = -x1

        Ps = Point(x0, y0)
        Pe = Point(x1, y1)

        # Anhängen der LineGeo Klasse für die Geometrie
        # Annexes to LineGeo class for geometry ???
        self.geo.append(LineGeo(Ps=Ps, Pe=Pe))

        # Länge entspricht der Länge des Kreises
        # Length corresponding to the length (circumference?) of the circle
        self.length = self.geo[-1].length

        # Neuen Startwert für die nächste Geometrie zurückgeben
        # New starting value for the next geometry
        caller.start = s
Exemplo n.º 3
0
    def compress_lines(self, Curve):
        """
        compress_lines()
        """
        NewCurve = []
        Pts = []
        for geo in Curve:
            NewCurve.append(geo)
            anz = len(NewCurve)
            if anz >= 2:
                # Wenn Geo eine Linie ist anh�ngen und �berpr�fen
                if isinstance(NewCurve[-2], LineGeo) and isinstance(
                        NewCurve[-1], LineGeo):
                    Pts.append(geo.Pe)
                    JointLine = LineGeo(NewCurve[-2].Ps, NewCurve[-1].Pe)

                    # �berpr�fung der Abweichung
                    res = []
                    for Point in Pts:
                        res.append(JointLine.distance_l_p(Point))
                    # print res

                    # Wenn die Abweichung OK ist Vorheriges anh�ngen
                    if max(res) < self.epsilon:
                        anz = len(NewCurve)
                        del NewCurve[anz - 2:anz]
                        NewCurve.append(JointLine)
                        points = [geo.Pe]
                    # Wenn nicht nicht anh�ngen und Pts zur�cksetzen
                    else:
                        Pts = [geo.Pe]

                # Wenn es eines eine andere Geometrie als eine Linie ist
                else:
                    Pts = []

        return NewCurve
Exemplo n.º 4
0
 def breakLineGeo(self, lineGeo):
     """
     Try to break passed lineGeo with any of the shapes on a break layers.
     Will break lineGeos recursively.
     @return: The list of geometries after breaking (lineGeo itself if no breaking happened)
     """
     newGeos = Geos([])
     for breakLayer in self.breakLayers:
         for breakShape in breakLayer.shapes.not_disabled_iter():
             intersections = self.intersectLineGeometry(lineGeo, breakShape)
             if len(intersections) == 2:
                 (near,
                  far) = self.classifyIntersections(lineGeo, intersections)
                 logger.debug("Line %s broken from (%f, %f) to (%f, %f)" %
                              (lineGeo.to_short_string(), near.x, near.y,
                               far.x, far.y))
                 newGeos.extend(self.breakLineGeo(LineGeo(lineGeo.Ps,
                                                          near)))
                 newGeos.append(
                     BreakGeo(near, far, breakShape.axis3_mill_depth,
                              breakShape.f_g1_plane, breakShape.f_g1_depth))
                 newGeos.extend(self.breakLineGeo(LineGeo(far, lineGeo.Pe)))
                 return newGeos
     return [lineGeo]
Exemplo n.º 5
0
    def Read(self, caller):
        """
        Read()
        """
        # Assign short name
        lp = caller.line_pairs
        e = lp.index_both(0, "SEQEND", caller.start + 1) + 1

        # Assign layer
        s = lp.index_code(8, caller.start + 1)
        self.Layer_Nr = caller.Get_Layer_Nr(lp.line_pair[s].value)

        # Ps=None for the first point
        Ps = None

        # Polyline flag
        s_temp = lp.index_code(70, s + 1, e)
        if s_temp is None:
            PolyLineFlag = 0
        else:
            PolyLineFlag = int(lp.line_pair[s_temp].value)
            s = s_temp

        # print("PolylineFlag: %i" %PolyLineFlag)

        while 1:  # and s is not None:
            s = lp.index_both(0, "VERTEX", s + 1, e)
            if s == None:
                break

            # X Value
            s = lp.index_code(10, s + 1, e)
            x = float(lp.line_pair[s].value)

            # Y Value
            s = lp.index_code(20, s + 1, e)
            y = float(lp.line_pair[s].value)
            Pe = Point(x, y)

            # Bulge
            bulge = 0

            e_vertex = lp.index_both(0, "VERTEX", s + 1, e)
            if e_vertex is None:
                e_vertex = e

            s_temp = lp.index_code(42, s + 1, e_vertex)
            # print('stemp: %s, e: %s, next 10: %s' %(s_temp,e,lp.index_both(0,"VERTEX",s+1,e)))
            if s_temp is not None:
                bulge = float(lp.line_pair[s_temp].value)
                s = s_temp

            # Vertex flag (bit-coded); default is 0; 1 = Closed; 128 = Plinegen
            s_temp = lp.index_code(70, s + 1, e_vertex)
            if s_temp is None:
                VertexFlag = 0
            else:
                VertexFlag = int(lp.line_pair[s_temp].value)
                s = s_temp

            # print("Vertex Flag: %i" %PolyLineFlag)

            # Assign the geometries for the Polyline
            if VertexFlag != 16:
                if Ps is not None:
                    if next_bulge == 0:
                        self.geo.append(LineGeo(Ps=Ps, Pe=Pe))
                    else:
                        # self.geo.append(LineGeo(Ps=Ps,Pe=Pe))
                        # print bulge
                        self.geo.append(self.bulge2arc(Ps, Pe, next_bulge))

                    # L�nge drauf rechnen wenns eine Geometrie ist
                    # Wenns Ldnge count on it is a geometry ???
                    self.length += self.geo[-1].length

                # Der Bulge wird immer f�r den und den n�chsten Punkt angegeben
                # The bulge is always given for the next point
                next_bulge = bulge
                Ps = Pe

        # It is a closed polyline
        if PolyLineFlag == 1 and len(self.geo) > 0:
            # print("sollten �bereinstimmen: %s, %s" %(Ps,Pe))
            if next_bulge == 0:
                self.geo.append(LineGeo(Ps=Ps, Pe=self.geo[0].Ps))
            else:
                self.geo.append(self.bulge2arc(Ps, self.geo[0].Ps, next_bulge))
            # L�nge drauf rechnen wenns eine Geometrie ist
            # Wenns Ldnge count on it is a geometry ???
            self.length += self.geo[-1].length

        # Neuen Startwert f�r die n�chste Geometrie zur�ckgeben
        # New starting value for the next geometry
        caller.start = e
Exemplo n.º 6
0
    def __init__(self, Ps, Pe, height, xyfeed, zfeed):
        LineGeo.__init__(self, Ps, Pe)

        self.height = height
        self.xyfeed = xyfeed
        self.zfeed = zfeed
Exemplo n.º 7
0
    def __init__(self, Ps=Point(), tan_a=0.0, Pb=Point, tan_b=0.0, min_r=1e-6):
        """
        Std. method to initialise the class.
        @param Ps: Start Point for the Biarc
        @param tan_a: Tangent of the Start Point
        @param Pb: End Point of the Biarc
        @param tan_b: Tangent of the End Point
        @param min_r: The minimum radius of a arc section.
        """
        min_len = 1e-12  # Min Abstand f�r doppelten Punkt / Minimum clearance for double point
        min_alpha = 1e-4  # Winkel ab welchem Gerade angenommen wird inr rad / Angle for which it is assumed straight inr rad
        max_r = 5e3  # Max Radius ab welchem Gerade angenommen wird (5m) / Max radius is assumed from which line (5m)
        min_r = min_r  # Min Radius ab welchem nichts gemacht wird / Min radius beyond which nothing is done

        self.Ps = Ps
        self.tan_a = tan_a
        self.Pb = Pb
        self.tan_b = tan_b
        self.l = 0.0
        self.shape = None
        self.geos = []
        self.k = 0.0

        # Errechnen der Winkel, L�nge und Shape
        # Calculate the angle, length and shape
        norm_angle, self.l = self.calc_normal(self.Ps, self.Pb)

        alpha, beta, self.theta, self.shape = self.calc_diff_angles(
            norm_angle, self.tan_a, self.tan_b, min_alpha)

        if self.l < min_len:
            self.shape = "Zero"

        elif self.shape == "LineGeo":
            # Erstellen der Geometrie
            # Create the geometry
            self.geos.append(LineGeo(self.Ps, self.Pb))
        else:
            # Berechnen der Radien, Mittelpunkte, Zwichenpunkt
            # Calculate the radii, midpoints Zwichenpunkt
            r1, r2 = self.calc_r1_r2(self.l, alpha, beta, self.theta)

            if abs(r1) > max_r or abs(r2) > max_r:
                # Erstellen der Geometrie
                # Create the geometry
                self.shape = "LineGeo"
                self.geos.append(LineGeo(self.Ps, self.Pb))
                return

#             elif abs(r1) < min_r or abs(r2) < min_r:
#                 self.shape = "Zero"
#                 return

            O1, O2, k = self.calc_O1_O2_k(r1, r2, self.tan_a, self.theta)

            # Berechnen der Start und End- Angles f�r das drucken
            # Calculate the start and end angles for the print
            s_ang1, e_ang1 = self.calc_s_e_ang(self.Ps, O1, k)
            s_ang2, e_ang2 = self.calc_s_e_ang(k, O2, self.Pb)

            # Berechnen der Richtung und der Extend
            # Calculate the direction and extent
            dir_ang1 = (tan_a - s_ang1) % (-2 * pi)
            dir_ang1 -= ceil(dir_ang1 / pi) * (2 * pi)

            dir_ang2 = (tan_b - e_ang2) % (-2 * pi)
            dir_ang2 -= ceil(dir_ang2 / pi) * (2 * pi)

            # Erstellen der Geometrien
            # Create the geometries
            self.geos.append(
                ArcGeo(Ps=self.Ps,
                       Pe=k,
                       O=O1,
                       r=r1,
                       s_ang=s_ang1,
                       e_ang=e_ang1,
                       direction=dir_ang1))
            self.geos.append(
                ArcGeo(Ps=k,
                       Pe=self.Pb,
                       O=O2,
                       r=r2,
                       s_ang=s_ang2,
                       e_ang=e_ang2,
                       direction=dir_ang2))
Exemplo n.º 8
0
    def Read(self, caller):
        """
        Read()
        """
        Old_Point = Point(0, 0)

        # Assign short name
        lp = caller.line_pairs
        e = lp.index_code(0, caller.start + 1)

        # Assign layer
        s = lp.index_code(8, caller.start + 1)
        self.Layer_Nr = caller.Get_Layer_Nr(lp.line_pair[s].value)

        # Ps=None for the first point
        Ps = None

        # Number of vertices
        s = lp.index_code(90, s + 1, e)
        NoOfVert = int(lp.line_pair[s].value)

        # Polyline flag (bit-coded); default is 0; 1 = Closed; 128 = Plinegen
        s = lp.index_code(70, s + 1, e)
        LWPLClosed = int(lp.line_pair[s].value)
        # print LWPLClosed

        s = lp.index_code(10, s + 1, e)
        while 1:
            # X Value
            if s is None:
                break
            x = float(lp.line_pair[s].value)

            # Y Value
            s = lp.index_code(20, s + 1, e)
            y = float(lp.line_pair[s].value)
            Pe = Point(x=x, y=y)

            # Bulge
            bulge = 0

            s_nxt_x = lp.index_code(10, s + 1, e)
            e_nxt_b = s_nxt_x

            # Wenn am Ende dann Suche bis zum Ende
            # If in the end the search until the end ???
            if e_nxt_b is None:
                e_nxt_b = e

            s_bulge = lp.index_code(42, s + 1, e_nxt_b)

            #logger.debug('stemp: %s, e: %s, next 10: %s' %(s_bulge,e,lp.index_code(10,s+1,e)))
            if s_bulge is not None:
                bulge = float(lp.line_pair[s_bulge].value)
                s_nxt_x = s_nxt_x

            # Take the next X value as the starting value
            s = s_nxt_x

            # Assign the geometries for the Polyline
            if Ps is not None:
                if bulge == 0:
                    self.geo.append(LineGeo(Ps=Ps, Pe=Pe))
                else:
                    # self.geo.append(LineGeo(Ps=Ps,Pe=Pe))
                    # print bulge
                    self.geo.append(self.bulge2arc(Ps, Pe, bulge))

                # L�nge drauf rechnen wenns eine Geometrie ist
                # Wenns Ldnge count on it is a geometry ???
                self.length += self.geo[-1].length

            # The bulge is always given for the next point
            next_bulge = bulge
            Ps = Pe

        if LWPLClosed == 1 or LWPLClosed == 129:
            #logger.debug("sollten �bereinstimmen: %s, %s" %(Ps,Pe))
            #logger.debug(self.geo)
            if next_bulge and len(self.geo) > 0:
                self.geo.append(self.bulge2arc(Ps, self.geo[0].Ps, next_bulge))
                self.length += self.geo[-1].length
            elif len(self.geo) > 0:
                self.geo.append(LineGeo(Ps=Ps, Pe=self.geo[0].Ps))
                self.length += self.geo[-1].length
            else:
                pass

        # New starting value for the next geometry
        caller.start = e
Exemplo n.º 9
0
    def make_start_moves(self):
        """
        This function called to create the start move. It will
        be generated based on the given values for start and angle.
        """
        self.geos = Geos([])

        if g.config.machine_type == 'drag_knife':
            self.make_swivelknife_move()
            return

        # Get the start rad. and the length of the line segment at begin.
        start_rad = self.shape.parentLayer.start_radius

        # Get tool radius based on tool diameter.
        tool_rad = self.shape.parentLayer.getToolRadius()

        # Calculate the starting point with and without compensation.
        start = self.start
        angle = self.angle

        if self.shape.cut_cor == 40:
            self.append(RapidPos(start))

        elif self.shape.cut_cor != 40 and not g.config.vars.Cutter_Compensation[
                "done_by_machine"]:

            toolwidth = self.shape.parentLayer.getToolRadius()
            offtype = "in" if self.shape.cut_cor == 42 else "out"
            offshape = offShapeClass(parent=self.shape,
                                     offset=toolwidth,
                                     offtype=offtype)

            if len(offshape.rawoff) > 0:
                start, angle = offshape.rawoff[0].get_start_end_points(
                    True, True)

                self.append(RapidPos(start))
                self.geos += offshape.rawoff

        # Cutting Compensation Left
        elif self.shape.cut_cor == 41:
            # Center of the Starting Radius.
            Oein = start.get_arc_point(angle + pi / 2, start_rad + tool_rad)
            # Start Point of the Radius
            Ps_ein = Oein.get_arc_point(angle + pi, start_rad + tool_rad)
            # Start Point of the straight line segment at begin.
            Pg_ein = Ps_ein.get_arc_point(angle + pi / 2, start_rad)

            # Get the dive point for the starting contour and append it.
            start_ein = Pg_ein.get_arc_point(angle, tool_rad)
            self.append(RapidPos(start_ein))

            # generate the Start Line and append it including the compensation.
            start_line = LineGeo(start_ein, Ps_ein)
            self.append(start_line)

            # generate the start rad. and append it.
            start_rad = ArcGeo(Ps=Ps_ein,
                               Pe=start,
                               O=Oein,
                               r=start_rad + tool_rad,
                               direction=1)
            self.append(start_rad)

        # Cutting Compensation Right
        elif self.shape.cut_cor == 42:
            # Center of the Starting Radius.
            Oein = start.get_arc_point(angle - pi / 2, start_rad + tool_rad)
            # Start Point of the Radius
            Ps_ein = Oein.get_arc_point(angle + pi, start_rad + tool_rad)
            # Start Point of the straight line segment at begin.
            Pg_ein = Ps_ein.get_arc_point(angle - pi / 2, start_rad)

            # Get the dive point for the starting contour and append it.
            start_ein = Pg_ein.get_arc_point(angle, tool_rad)
            self.append(RapidPos(start_ein))

            # generate the Start Line and append it including the compensation.
            start_line = LineGeo(start_ein, Ps_ein)
            self.append(start_line)

            # generate the start rad. and append it.
            start_rad = ArcGeo(Ps=Ps_ein,
                               Pe=start,
                               O=Oein,
                               r=start_rad + tool_rad,
                               direction=0)
            self.append(start_rad)