Example #1
0
 def snapToExtOrtho(self,last,constrain,eline):
     "returns an ortho X extension snap location"
     if self.isEnabled("extension") and self.isEnabled("ortho"):
         if constrain and last and self.constraintAxis and self.extLine:
             tmpEdge1 = Part.Line(last,last.add(self.constraintAxis)).toShape()
             tmpEdge2 = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape()
             # get the intersection points
             pt = fcgeo.findIntersection(tmpEdge1,tmpEdge2,True,True)
             if pt:
                 return [pt[0],'ortho',pt[0]]
         if eline:
             try:
                 tmpEdge2 = Part.Line(self.extLine.p1(),self.extLine.p2()).toShape()
                 # get the intersection points
                 pt = fcgeo.findIntersection(eline,tmpEdge2,True,True)
                 if pt:
                     return [pt[0],'ortho',pt[0]]
             except:
                 return None
     return None
Example #2
0
 def snapToElines(self,e1,e2):
     "returns a snap location at the infinite intersection of the given edges"
     snaps = []
     if self.isEnabled("intersection") and self.isEnabled("extension"):
         if e1 and e2:
             # get the intersection points
             pts = fcgeo.findIntersection(e1,e2,True,True)
             if pts:
                 for p in pts:
                     snaps.append([p,'intersection',p])
     return snaps
Example #3
0
 def getAxisPoints(self, obj):
     "returns the gridpoints of linked axes"
     from draftlibs import fcgeo
     pts = []
     if len(obj.Axes) == 1:
         for e in obj.Axes[0].Shape.Edges:
             pts.append(e.Vertexes[0].Point)
     elif len(obj.Axes) >= 2:
         set1 = obj.Axes[0].Shape.Edges
         set2 = obj.Axes[1].Shape.Edges
         for e1 in set1:
             for e2 in set2:
                 pts.extend(fcgeo.findIntersection(e1, e2))
     return pts
Example #4
0
 def getAxisPoints(self,obj):
     "returns the gridpoints of linked axes"
     from draftlibs import fcgeo
     pts = []
     if len(obj.Axes) == 1:
         for e in obj.Axes[0].Shape.Edges:
             pts.append(e.Vertexes[0].Point)
     elif len(obj.Axes) >= 2:
         set1 = obj.Axes[0].Shape.Edges
         set2 = obj.Axes[1].Shape.Edges
         for e1 in set1:
             for e2 in set2: 
                 pts.extend(fcgeo.findIntersection(e1,e2))
     return pts
Example #5
0
 def snapToOrtho(self,shape,last,constrain):
     "returns a list of ortho snap locations"
     snaps = []
     if self.isEnabled("ortho"):
         if constrain:
             if isinstance(shape,Part.Edge):
                 if last:
                     if isinstance(shape.Curve,Part.Line):
                         if self.constraintAxis:
                             tmpEdge = Part.Line(last,last.add(self.constraintAxis)).toShape()
                             # get the intersection points
                             pt = fcgeo.findIntersection(tmpEdge,shape,True,True)
                             if pt:
                                 for p in pt:
                                     snaps.append([p,'ortho',p])
     return snaps
Example #6
0
    def zOverlaps(self,face1,face2):
        "Checks if face1 overlaps face2 in Z direction"
        face1 = self.flattenFace(face1)
        face2 = self.flattenFace(face2)
        
        # first we check if one of the verts is inside the other face
        for v in face1[0].Vertexes:
            if self.isInside(v,face2):
                return True

        # even so, faces can still overlap if their edges cross each other
        for e1 in face1[0].Edges:
            for e2 in face2[0].Edges:
                if fcgeo.findIntersection(e1,e2):
                    return True
        return False
Example #7
0
 def snapToIntersection(self,shape):
     "returns a list of intersection snap locations"
     snaps = []
     if self.isEnabled("intersection"):
         # get the stored objects to calculate intersections
         if self.lastObj[0]:
             obj = FreeCAD.ActiveDocument.getObject(self.lastObj[0])
             if obj:
                 if obj.isDerivedFrom("Part::Feature"):
                     if (not self.maxEdges) or (len(obj.Shape.Edges) <= self.maxEdges):
                         for e in obj.Shape.Edges:
                             # get the intersection points
                             pt = fcgeo.findIntersection(e,shape)
                             if pt:
                                 for p in pt:
                                     snaps.append([p,'intersection',p])
     return snaps
Example #8
0
    def zOverlaps(self, face1, face2):
        "Checks if face1 overlaps face2 in Z direction"

        face1 = self.flattenFace(face1)
        face2 = self.flattenFace(face2)

        # first we check if one of the verts is inside the other face
        for v in face1.Vertexes:
            if self.isInside(v, face2):
                return True

        # even so, faces can still overlap if their edges cross each other
        for e1 in face1.Edges:
            for e2 in face2.Edges:
                if fcgeo.findIntersection(e1, e2):
                    return True

        return False