Ejemplo n.º 1
0
def getEntityEntity(sympyEntity):
    """
        convert sympy object into PyCAD object
    """
    if isinstance(sympyEntity, geoSympy.Circle):
        arg = {
            "ARC_0": Point(0.0, 0.0),
            "ARC_1": 1,
            "ARC_2": None,
            "ARC_3": None
        }
        arc = Arc(arg)
        arc.setFromSympy(sympyEntity)
        return arc
    elif isinstance(sympyEntity, geoSympy.Point):
        p = Point(0.0, 0.0)
        p.setFromSympy(sympyEntity)
        return p
    elif isinstance(sympyEntity, geoSympy.Segment):
        segArg = {"SEGMENT_0": Point(0.0, 0.0), "SEGMENT_1": Point(1.0, 1.0)}
        seg = Segment(segArg)
        seg.setFromSympy(sympyEntity)
        return seg
    elif isinstance(sympyEntity, geoSympy.Ellipse):
        arg = {
            "ELLIPSE_0": Point(0.0, 0.0),
            "ELLIPSE_1": 1.0,
            "ELLIPSE_2": 2.0
        }
        e = Ellipse(arg)
        e.setFromSympy(sympyEntity)
        return e
    else:
        raise "not supported entity"
Ejemplo n.º 2
0
    def getEntsToSave(self):
        """
            get the chamfer segments
        """
        id0, p0 = self.value[0]
        id1, p1 = self.value[1]
        objEnt = []
        ent1 = self.document.getEntity(id0)
        ent2 = self.document.getEntity(id1)

        cel1 = ent1.getConstructionElements()
        seg1 = Segment(cel1)

        cel2 = ent2.getConstructionElements()
        seg2 = Segment(cel2)
        arg = {
            "OBJECTJOINT_0": seg1,
            "OBJECTJOINT_1": seg2,
            "OBJECTJOINT_2": p0,
            "OBJECTJOINT_3": p1,
            "OBJECTJOINT_5": self.value[2],
        }

        cmf = Bisector(arg)
        bisectorSegment = cmf.getReletedComponent()
        objEnt.append(bisectorSegment)
        return objEnt
Ejemplo n.º 3
0
def updateSegment(objSegment, objPoint, objInterPoint):
    """
            Return a segment with trimed to the intersection point
        """
    from Kernel.GeoEntity.segment import Segment
    from Kernel.GeoEntity.point import Point
    from Kernel.GeoUtil.geolib import Vector

    objProjection = objSegment.getProjection(objPoint)
    _p1, _p2 = objSegment.getEndpoints()
    if not (_p1 == objInterPoint or _p2 == objInterPoint):
        pickIntVect = Vector(objInterPoint, objProjection).mag()
        p1IntVect = Vector(objInterPoint, _p1).mag()
        if (pickIntVect == p1IntVect):
            arg = {"SEGMENT_0": _p1, "SEGMENT_1": objInterPoint}
            return Segment(arg)
        p2IntVect = Vector(objInterPoint, _p2).mag()
        if (pickIntVect == p2IntVect):
            arg = {"SEGMENT_0": objInterPoint, "SEGMENT_1": _p2}
            return Segment(arg)
    ldist = objProjection.dist(_p1)
    if ldist > objProjection.dist(_p2):
        arg = {"SEGMENT_0": _p1, "SEGMENT_1": objInterPoint}
        return Segment(arg)
    else:
        arg = {"SEGMENT_0": objInterPoint, "SEGMENT_1": _p2}
        return Segment(arg)
Ejemplo n.º 4
0
def getEntityEntity(sympyEntity):
    """
        convert sympy object into PyCAD object
    """
    if isinstance(sympyEntity, geoSympy.Circle):
        arg={"ARC_0":Point(0.0, 0.0), 
             "ARC_1":1, 
             "ARC_2":None, 
             "ARC_3":None
             }    
        arc=Arc(arg)
        arc.setFromSympy(sympyEntity)
        return arc
    elif isinstance(sympyEntity, geoSympy.Point):
        p=Point(0.0, 0.0)
        p.setFromSympy(sympyEntity)
        return p
    elif isinstance(sympyEntity, geoSympy.Segment):
        segArg={"SEGMENT_0":Point(0.0, 0.0), "SEGMENT_1":Point(1.0, 1.0)}
        seg=Segment(segArg)
        seg.setFromSympy(sympyEntity)
        return seg
    elif isinstance(sympyEntity, geoSympy.Ellipse):
        arg={"ELLIPSE_0":Point(0.0, 0.0), "ELLIPSE_1":1.0, "ELLIPSE_2":2.0}
        e=Ellipse(arg)
        e.setFromSympy(sympyEntity)
        return e
    else:
        raise "not supported entity"
def segment_segmet():
    print "++ segment_segmet ++"
    p1 = Point(0, 0)
    p2 = Point(0, 1)
    arg = {"SEGMENT_0": p1, "SEGMENT_1": p2}
    seg1 = Segment(arg)
    p3 = Point(0, 0)
    p4 = Point(-1, 0)
    arg = {"SEGMENT_0": p3, "SEGMENT_1": p4}
    seg2 = Segment(arg)

    print find_intersections(seg1, seg2)
    print "-- segment_segmet --"
Ejemplo n.º 6
0
def testSympySegment():
    print "++ Sympy Segment ++"
    p1=Point(0, 1)
    p2=Point(10, 20)
    arg={"SEGMENT_0":p1, "SEGMENT_1":p2}
    seg=Segment(arg)
    symSeg=seg.getSympy()
    print symSeg
    p3=Point(30, 40)
    arg1={"SEGMENT_0":p1, "SEGMENT_1":p3}
    seg1=Segment(arg1)
    seg1.setFromSympy(symSeg)
    print "Segment ", seg1
    print "-- Sympy Segment --"
Ejemplo n.º 7
0
 def createLine(self, x1, y1, x2, y2, c):
     """
       Create the line into the current drawing
     """
     args = {"SEGMENT_0": Point(x1, y1), "SEGMENT_1": Point(x2, y2)}
     _seg = Segment(args)
     self.__kernel.saveEntity(_seg)
 def getEntsToSave(self):
     """
         get all the segment of the rectangle
     """
     objEnt = []
     p1 = self.value[0]
     p2 = self.value[1]
     x1, y1 = p1.getCoords()
     x2, y2 = p2.getCoords()
     p3 = Point(x1, y2)
     p4 = Point(x2, y1)
     segArg = {"SEGMENT_0": p1, "SEGMENT_1": p4}
     objEnt.append(Segment(segArg))
     segArg = {"SEGMENT_0": p4, "SEGMENT_1": p2}
     objEnt.append(Segment(segArg))
     segArg = {"SEGMENT_0": p2, "SEGMENT_1": p3}
     objEnt.append(Segment(segArg))
     segArg = {"SEGMENT_0": p3, "SEGMENT_1": p1}
     objEnt.append(Segment(segArg))
     return objEnt
def segment_cline():
    print "++ segment_cline ++"
    p1 = Point(0, 0)
    p2 = Point(0, 1)
    arg = {"CLINE_0": p1, "CLINE_1": p2}
    seg1 = CLine(arg)
    p3 = Point(0, 0)
    p4 = Point(-1, 0)
    arg = {"SEGMENT_0": p3, "SEGMENT_1": p4}
    seg2 = Segment(arg)

    print find_intersections(seg1, seg2)
    print "-- segment_cline --"
Ejemplo n.º 10
0
    def getEntsToSave(self):
        """
            get the chamfer segments
        """
        id0, p0 = self.value[0]
        id1, p1 = self.value[1]

        objEnt = []
        ent1 = self.document.getEntity(id0)
        ent2 = self.document.getEntity(id1)

        cel1 = ent1.getConstructionElements()
        seg1 = Segment(cel1)

        cel2 = ent2.getConstructionElements()
        seg2 = Segment(cel2)
        arg = {
            "OBJECTJOINT_0": seg1,
            "OBJECTJOINT_1": seg2,
            "OBJECTJOINT_2": p0,
            "OBJECTJOINT_3": p1,
            "OBJECTJOINT_4": self.value[2],
            "OBJECTJOINT_5": self.value[3],
            "OBJECTJOINT_6": self.value[4]
        }

        cmf = Chamfer(arg)
        seg1Mod, seg2Mod, chamferSegment = cmf.getReletedComponent()

        _cElements1, entityType = self.document._getCelements(seg1Mod)
        _cElements2, entityType = self.document._getCelements(seg2Mod)

        ent1.setConstructionElements(_cElements1)
        ent2.setConstructionElements(_cElements2)

        objEnt.append(ent1)
        objEnt.append(ent2)
        objEnt.append(chamferSegment)
        return objEnt
Ejemplo n.º 11
0
 def getEntsToSave(self):
     """
         return a list of segment
     """
     objEnt = []
     self.CalculatePoint()
     if len(self.__xpts):
         # find starting point ...
         _p0 = Point(self.__xpts[0], self.__ypts[0])
         # make segments for all the points ...
         _p1 = _p0
         for _i in range(1, self.side):
             _x = self.__xpts[_i]
             _y = self.__ypts[_i]
             _pi = Point(_x, _y)
             segArg = {"SEGMENT_0": _p1, "SEGMENT_1": _pi}
             objEnt.append(Segment(segArg))
             _p1 = _pi
         # now add closing segment ...
         segArg = {"SEGMENT_0": _p1, "SEGMENT_1": _p0}
         objEnt.append(Segment(segArg))
     return objEnt
Ejemplo n.º 12
0
 def getSegments(self):
     """
         return an array of segments that identifie the polyline
         used for intersection porpouse
     """
     tempPoint=None
     exitArray=[]
     for p in self.points():
         if tempPoint:
             constr={"SEGMENT_0":tempPoint, "SEGMENT_1":p}
             exitArray.append(Segment(constr))
         tempPoint=p
     else:
         return exitArray
     return []
def testSympySegment():
    print "++ Sympy Segment ++"
    p1 = Point(0, 1)
    p2 = Point(10, 20)
    arg = {"SEGMENT_0": p1, "SEGMENT_1": p2}
    seg = Segment(arg)
    symSeg = seg.getSympy()
    print symSeg
    p3 = Point(30, 40)
    arg1 = {"SEGMENT_0": p1, "SEGMENT_1": p3}
    seg1 = Segment(arg1)
    seg1.setFromSympy(symSeg)
    print "Segment ", seg1
    print "-- Sympy Segment --"
Ejemplo n.º 14
0
 def applyCommand(self):
     if len(self.value)!=2:
         raise PyCadWrongImputData("Wrong number of imput parameter")
     segArg={"SEGMENT_0":self.value[0], "SEGMENT_1":self.value[1]}
     seg=Segment(segArg)
     self.document.saveEntity(seg)