Exemple #1
0
    def easyTest(self):
        """
            this function is usefoul for short test
            as soon it works copy the code into featureTest
        """
        pass
        newDoc = self.__pyCadApplication.newDocument()
        intPoint = Point(2.0, 2.0)

        # a = {'SEGMENT_0': intPoint, 'SEGMENT_1': Point(10.0, 0.0)}
        s1 = Segment(intPoint, Point(10.0, 0.0))
        # s1 = Segment(a)
        s2 = Segment(intPoint, Point(0.0, 10.0))

        ent1 = newDoc.saveEntity(s1)
        ent2 = newDoc.saveEntity(s2)

        cObject = self.__pyCadApplication.getCommand("CHAMFER")
        keys = cObject.keys()
        cObject[keys[0]] = ent1
        cObject[keys[1]] = ent2
        cObject[keys[2]] = 2
        cObject[keys[3]] = 2
        cObject[keys[4]] = None
        cObject[keys[5]] = None
        cObject.applyCommand()
Exemple #2
0
 def mag(self):
     """
         Get the versor
     """
     _a = self.absAng
     p1 = Point(0, 0)
     p2 = Point(math.cos(_a), math.sin(_a))
     return Vector(p1, p2)
Exemple #3
0
def CreateModifieEntity(kr):
    """
        test for create and modifie an entity
    """
    ent = createSegment(kr)
    celement = {'POINT_1': Point(100, 100), 'POINT_2': Point(200, 200)}
    ent.setConstructionElement(celement)
    kr.saveEntity(ent)
Exemple #4
0
def testSingleSegment(kernel):
    """
        create a single segment
    """
    _p1 = Point(10, 10)
    _p2 = Point(10, 20)
    _s = Segment(_p1, _p2)
    kernel.saveEntity(_s)
def segment_circle():
    print("++ segment_circle ++")
    p1 = Point(0, 0)
    arg = {"ARC_0": p1, "ARC_1": 5, "ARC_2": 0, "ARC_3": 6.2831}
    arc = Arc(arg)
    p2 = Point(0, 0)
    p3 = Point(-1, 0)
    arg = {"CLINE_0": p2, "CLINE_1": p3}
    seg1 = CLine(arg)
    print(find_intersections(arc, seg1))
    print("-- segment_circle --")
def segment_ellipse():
    print("++ segment_ellipse ++")
    p1 = Point(0, 0)
    arg = {"ELLIPSE_0": p1, "ELLIPSE_1": 300, "ELLIPSE_2": 100}
    eli = Ellipse(arg)
    p2 = Point(0, 0)
    p3 = Point(-1, 0)
    arg = {"CLINE_0": p2, "CLINE_1": p3}
    seg1 = CLine(arg)
    print(find_intersections(eli, seg1))
    print("-- segment_ellipse --")
Exemple #7
0
 def newSegment(self):
     """
         create a new segment
     """
     try:
         val = (input("-->Get First Point x,y :"))
         p1 = Point(val[0], val[1])
         val = (input("-->Get Second Point x,y :"))
         p2 = Point(val[0], val[1])
         _s = Segment(p1, p2)
         self.__kr.saveEntity(_s)
     except:
         print("---->Error on point creation !!")
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 --")
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 --")
def testSympyCline():
    print("++ Sympy CLine ++")
    p1 = Point(0, 1)
    p2 = Point(10, 20)
    arg = {"CLINE_0": p1, "CLINE_1": p2}
    seg = CLine(arg)
    symSeg = seg.getSympy()
    print(symSeg)
    p3 = Point(30, 40)
    arg1 = {"CLINE_0": p1, "CLINE_1": p3}
    seg1 = CLine(arg1)
    seg1.setFromSympy(symSeg)
    print("CLine ", seg1)
    print("-- Sympy CLine --")
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 --")
Exemple #12
0
def testMultiSegments(kernel, nSegments):
    """
        create a single segment
    """
    startTime = time.clock()
    kernel.startMassiveCreation()
    for i in range(nSegments):
        _p1 = Point(10, i)
        _p2 = Point(10, i)
        _s = Segment(_p1, _p2)
        kernel.saveEntity(_s)
    kernel.performCommit()
    endTime = time.clock() - startTime
    print("Create n: %s entity in : %ss" % (str(nSegments), str(endTime)))
Exemple #13
0
 def getRandomPoint(self):
     """
         get a random point
     """
     x = random() * 1000
     y = random() * 1000
     return Point(x, y)
Exemple #14
0
def findSegmentExtendedIntersectionPoint(obja, objb):
    """
        xtend the segment intersection on a cline intersection
        Return a [Point,Point,..]
    """
    return [
        Point(x, y) for x, y in findSegmentExtendedIntersection(obja, objb)
    ]
Exemple #15
0
 def testGeoChamfer(self):
     self.outputMsg("Test Chamfer")
     p1 = Point(0.0, 0.0)
     p2 = Point(10.0, 0.0)
     p3 = Point(0.0, 10.0)
     s1 = Segment(p1, p2)
     s2 = Segment(p1, p3)
     cmf = Chamfer(s1, s2, 2.0, 2.0)
     cl = cmf.getLength()
     self.outputMsg("Chamfer Lengh %s" % str(cl))
     s1, s2, s3 = cmf.getReletedComponent()
     if s3:
         for p in s3.getEndpoints():
             x, y = p.getCoords()
             self.outputMsg("P1 Cords %s, %s" % (str(x), str(y)))
     else:
         self.outputMsg("Chamfer segment in None")
def testSympyEllipse():
    print("++ Sympy Ellipse ++")
    p1 = Point(0, 1)
    arg = {"ELLIPSE_0": p1, "ELLIPSE_1": 100, "ELLIPSE_2": 50}
    eli = Ellipse(arg)
    sympEli = eli.getSympy()
    print("sympEllipse", sympEli)
    sympEli1 = geoSympy.Ellipse(geoSympy.Point(10, 10), 300, 200)
    eli.setFromSympy(sympEli1)
    print("Pythonca Ellipse ", eli)
    print("-- Sympy Ellipse --")
def testSympyCircle():
    print("++ Sympy Arc ++")
    p1 = Point(0, 1)
    arg = {"ARC_0": p1, "ARC_1": 5, "ARC_2": 0, "ARC_3": 6.2831}
    arc = Arc(arg)
    sympCircle = arc.getSympy()
    print("sympCircle", sympCircle)
    sympCircel = geoSympy.Circle(geoSympy.Point(10, 10), 10)
    arc.setFromSympy(sympCircel)
    print("Pythonca Arc ", arc)
    print("-- Sympy Arc --")
Exemple #18
0
def testSinglePoint(kernel):
    """
        test single point operation
    """
    startTime = time.clock()
    print("Create a single point")
    basePoint = Point(10, 1)
    print("singlePoint ", type(basePoint))
    kernel.saveEntity(basePoint)
    endTime = time.clock() - startTime
    print("Time for saving  a single point   %ss" % str(endTime))
Exemple #19
0
 def map(self, pPro):
     """
         Get a vector for the mapping point
     """
     p0 = Point(0, 0)
     vProj = Vector(p0, pPro)
     ang = self.ang(vProj)
     vProjNorm = vProj.norm
     projectionUnitDistance = vProjNorm * math.cos(ang)
     vSelfMag = self.mag()
     vSelfMag.mult(projectionUnitDistance)
     return vSelfMag
Exemple #20
0
 def imputPoint(self, msg):
     """
         ask at the user to imput a point 
     """
     msg = msg + " x,y "
     value = self.inputMsg(msg)
     if value:
         coords = value.split(',')
         x = float(coords[0])
         y = float(coords[1])
         return Point(x, y)
     return None
Exemple #21
0
def testMultiPoints(kernel, nPoint):
    """
        test the point operatoin
    """
    startTime = time.clock()
    kernel.startMassiveCreation()
    for i in range(nPoint):
        basePoint = Point(10, i)
        kernel.saveEntity(basePoint)
    kernel.performCommit()
    endTime = time.clock() - startTime
    print("Create n: %s entity in : %ss" % (str(nPoint), str(endTime)))
Exemple #22
0
    def testChamferCommand(self):
        """
            this function is usefoul for short test
            as soon it works copy the code into featureTest
        """
        newDoc = self.__pyCadApplication.newDocument()
        intPoint = Point(0.0, 0.0)

        s1 = Segment(intPoint, Point(10.0, 0.0))
        s2 = Segment(intPoint, Point(0.0, 10.0))

        ent1 = newDoc.saveEntity(s1)
        ent2 = newDoc.saveEntity(s2)

        cObject = self.__pyCadApplication.getCommand("CHAMFER")
        keys = cObject.keys()
        cObject[keys[0]] = ent1
        cObject[keys[1]] = ent2
        cObject[keys[2]] = 2
        cObject[keys[3]] = 2
        cObject[keys[4]] = None
        cObject[keys[5]] = None
        cObject.applyCommand()
Exemple #23
0
    def newArc(self):
        """
            Create a new arc
        """
        radius = input("-->Insert the radius :")
        val = input("-->insert The center position x,y:")
        xy = val.split(',')
        if len(xy) == 2:
            center = Point(xy[0], xy[1])
        else:
            #print("Errore valore incorretto inserire un valore 10,20 in questo formato")
            print("Incorrectly entered value, please use the format 10,20")
            return

        start_angle = input("-->insert startAngle [Empty in case of circle]:")
        if start_angle:
            end_angle = input("-->insert The end Angle :")
        else:
            start_angle = end_angle = 0
        arc = Arc(center, float(radius), float(start_angle), float(end_angle))
        self.__kr.saveEntity(arc)
Exemple #24
0
 def point(self):
     """
           Return The Point 
     """
     return Point(self.X, self.Y)