Пример #1
0
    def __init__(self):
        log.debug("Creating New Slice...")
        self.path = ""

        #actually these are Wires
        self.fillWires = TopTools.TopTools_HSequenceOfShape()
        self.fillEdges = TopTools.TopTools_HSequenceOfShape()
        #self.boundaryWires = [];
        self.zLevel = 0
        self.zHeight = 0
        self.layerNo = 0
        self.sliceHeight = 0
        self.faces = TopTools.TopTools_HSequenceOfShape()
        self.fillWidth = None
        self.hatchDir = None
        self.checkSum = None
Пример #2
0
def makeWiresFromOffsetShape(shape):
    "get all the wires from the offset shape"
    resultWires = TopTools.TopTools_HSequenceOfShape()
    if shape.ShapeType() == TopAbs.TopAbs_WIRE:
        #log.info( "offset result is a wire" );
        wire = topoDS.Wire(shape)
        #resultWires.append(wire);
        resultWires.Append(wire)
    elif shape.ShapeType() == TopAbs.TopAbs_COMPOUND:
        #log.info( "offset result is a compound");

        bb = TopExp.TopExp_Explorer()
        bb.Init(shape, TopAbs.TopAbs_WIRE)
        while bb.More():
            w = topoDS.Wire(bb.Current())

            #resultWires.append(w);
            resultWires.Append(w)
            #
            #debugShape(w);
            bb.Next()

        bb.ReInit()

    return resultWires
Пример #3
0
def loopWire2(w):
    edges = TopTools.TopTools_HSequenceOfShape()
    topexp = TopExp.TopExp_Explorer()
    topexp.Init(w, TopAbs.TopAbs_EDGE)

    while topexp.More():
        #currentEdge = Wrappers.cast();
        edges.Append(topexp.Current())
        topexp.Next()
    return edges
Пример #4
0
    def edgesAsSequence(self):
        "returns edge list as a sequence"
        wireExp = BRepTools.BRepTools_WireExplorer(self.wire)
        resultWires = TopTools.TopTools_HSequenceOfShape()

        while wireExp.More():
            e = wireExp.Current()
            resultWires.Append(e)
            wireExp.Next()

        return resultWires
Пример #5
0
    def getWires(self):

        wireSeq = TopTools.TopTools_HSequenceOfShape()
        #use of this method detailed by Roman Here:
        #http://www.opencascade.org/org/forum/thread_15635/?forum=3
        #this really should work but it doensnt, and its not clear why at all.
        ShapeAnalysis.ShapeAnalysis_FreeBounds().ConnectEdgesToWires(
            self.edges.GetHandle(), 0.0001, False, wireSeq.GetHandle())

        l = listFromHSequenceOfShape(wireSeq)
        print "Merged %d edges into %d wires" % (self.edges.Length(),
                                                 wireSeq.Length())
        return l
Пример #6
0
    def computeLayerPath(self, slice):
        "computes paths for a single layer"

        pe = PathExport.ShapeDraw(True, 0.001)
        path = []

        allShapes = TopTools.TopTools_HSequenceOfShape()
        Wrappers.extendhSeq(allShapes, slice.fillWires)
        Wrappers.extendhSeq(allShapes, slice.fillEdges)
        for move in pe.follow(allShapes):
            moveType = move.__class__.__name__
            if moveType == "LinearMove":
                path.append(self.linearMove(move))
            elif moveType == "ArcMove":
                path.append(self.arcMove(move))
            else:
                raise ValueError, "Unknown Move Type!"

        return "\n".join(path)
Пример #7
0
def checkMinimumDistanceForOffset(offset, resolution):
    "PERFORMANCE INTENSIVE!!!!"
    "check an offset shape to make sure that it does not overlap too closely"
    "this consists of making sure that none of the wires are too close to each other"
    "and that no individual wires have edges too close together"
    log.info("Checking this offset for minimum distances")

    te = TopExp.TopExp_Explorer()
    resultWires = TopTools.TopTools_HSequenceOfShape()
    te.Init(offset, TopAbs.TopAbs_WIRE)

    allPoints = []
    while te.More():
        w = ts.Wire(te.Current())
        wr = Wire(w)
        resultWires.Append(w)
        allPoints.extend(pointsFromWire(w, resolution * 3))
        #for p in wr.discretePoints(resolution/2):
        #	debugShape(make_vertex(p));
        #	allPoints.append(p);
        te.Next()
    te.ReInit()

    log.info("There are %d wires, and %d points" %
             (resultWires.Length(), len(allPoints)))

    #cool trick here: list all permutations of these points
    "this is where we could probably really improve this algorithm"
    for (p1, p2) in list(itertools.combinations(allPoints, 2)):
        d = p1.Distance(p2)
        if d < resolution:
            log.warn("Distance %0.5f is less than expected value" % d)
            return False
        #else:
        #log.info("Computed distance = %0.5f" % d );

    return True
Пример #8
0
 def __init__(self):
     self.edges = TopTools.TopTools_HSequenceOfShape()