Пример #1
0
    def update_naming(self, make_shape):
        label = self.label
        shape = make_shape.Shape()

        input_shape = make_shape.Shape1()
        tool_shape = make_shape.Shape2()

        builder = TNaming.TNaming_Builder(label)
        builder.Generated(input_shape, shape)
        builder.Generated(tool_shape, shape)

        gen_label = label.FindChild(1)
        mod_label = label.FindChild(2)
        del_label = label.FindChild(3)

        gen_builder = TNaming.TNaming_Builder(gen_label)
        mod_builder = TNaming.TNaming_Builder(mod_label)
        del_builder = TNaming.TNaming_Builder(del_label)

        if make_shape.HasGenerated():
            for in_shape in [input_shape, tool_shape]:
                for face in Topo(in_shape).faces():
                    gen_shapes = make_shape.Generated(face)
                    itr = TopTools.TopTools_ListIteratorOfListOfShape(
                        gen_shapes)
                    while itr.More():
                        this = itr.Value()
                        gen_builder.Generated(face, this)
                        print "generated", face, this
                        itr.Next()

        if make_shape.HasModified():
            for face in Topo(input_shape).faces():
                mod_shapes = make_shape.Modified(face)
                itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes)
                while itr.More():
                    this = itr.Value()
                    mod_builder.Modify(face, this)
                    print "modified", face, this
                    itr.Next()

            for face in Topo(tool_shape).faces():
                mod_shapes = make_shape.Modified2(face)
                itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes)
                while itr.More():
                    this = itr.Value()
                    mod_builder.Modify(face, this)
                    print "modified2", face, this
                    itr.Next()

        if make_shape.HasDeleted():
            for face in Topo(input_shape).faces():
                if make_shape.IsDeleted(face):
                    del_builder.Delete(face)
            for face in Topo(tool_shape).faces():
                if make_shape.IsDeleted(face):
                    del_builder.Delete(face)
Пример #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 __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
Пример #4
0
def listFromTopToolsListOfShape(listOfShape):
    newList = []
    iterator = TopTools.TopTools_ListIteratorOfListOfShape(listOfShape)
    while iterator.More():
        newList.append(cast(iterator.Value()))
        iterator.Next()

    return newList
Пример #5
0
 def update_naming(self, make_shape):
     label = self.label
     shape = make_shape.Shape()
     
     input_shape = make_shape.Shape()
     
     builder = TNaming.TNaming_Builder(label)
     builder.Generated(input_shape, shape)
     
     #FindChild creates a new label, if one doesn't exist.
     #Label entry numbers are not necessarily incremental.
     #They are more like dictionary keys.
     gen_label = label.FindChild(1)
     mod_label = label.FindChild(2)
     del_label = label.FindChild(3)
     
     gen_builder = TNaming.TNaming_Builder(gen_label)
     mod_builder = TNaming.TNaming_Builder(mod_label)
     del_builder = TNaming.TNaming_Builder(del_label)
     
     topo = Topo(input_shape)
     
     for face in topo.faces():
         gen_shapes = make_shape.Generated(face)
         itr = TopTools.TopTools_ListIteratorOfListOfShape(gen_shapes)
         while itr.More():
             this = itr.Value()
             gen_builder.Generated(face, this)
             print "generated", face, this
             itr.Next()
                     
     for face in topo.faces():
         mod_shapes = make_shape.Modified(face)
         itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes)
         while itr.More():
             this = itr.Value()
             mod_builder.Modified(face, this)
             print "modified", face, this
             itr.Next()
                     
     for face in topo.faces():
         if make_shape.IsDeleted(face):
             del_builder.Delete(face)
Пример #6
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
Пример #7
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
Пример #8
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
Пример #9
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)
Пример #10
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
Пример #11
0
 def __init__(self):
     self.edges = TopTools.TopTools_HSequenceOfShape()