Esempio n. 1
0
    def next(self):
        if self.index == self.number_of_vertices:
            raise StopIteration

        vert = self.vertsA[self.index]
        closest = self.closest_point(vert)
        edges_a = self.tp_A.edges_from_vertex(vert)
        edges_b = self.tp_B.edges_from_vertex(closest)
        a1, a2 = Edge(edges_a.next()), Edge(edges_a.next())
        b1, b2 = Edge(edges_b.next()), Edge(edges_b.next())
        mpA = a1.mid_point()
        self.index += 1

        if mpA.Distance(b1.mid_point()) < mpA.Distance(b2.mid_point()):
            return iter([a1, a2]), iter([b1, b2])
        else:
            return iter([a1, a2]), iter([b2, b1])
Esempio n. 2
0
 def intersect_curve(self, crv):
     '''
     intersect the face with a curve
     @param crv:
     '''
     if not isinstance(crv, Edge):
         crv = Edge(crv)
     bics = BRepIntCurveSurface_Inter()
     bics.Init(self.face, crv.crv)
     # state, u,v,w
     while bics.More():
         uvw = [bics.U(). bics.V(), bics.W()]
         return uvw, bics.Point(), bics.Face(), bics.Transition()
Esempio n. 3
0
    def next(self):
        if self.index == self.number_of_vertices:
            raise StopIteration

        vert = self.vertsA[self.index]
        closest = self.closest_point(vert)
        edges_a = self.tp_A.edges_from_vertex(vert)
        edges_b = self.tp_B.edges_from_vertex(closest)
        a1, a2 = Edge(edges_a.next()), Edge(edges_a.next())
        b1, b2 = Edge(edges_b.next()), Edge(edges_b.next())
        mpA = a1.mid_point()
        self.index += 1

        if mpA.Distance(b1.mid_point()) < mpA.Distance(b2.mid_point()):
            return iter([a1, a2]), iter([b1, b2])
        else:
            return iter([a1, a2]), iter([b2, b1])
Esempio n. 4
0
class TestEdge_Line(unittest.TestCase):
    '''
    this test case would be much better if the methods would run on a number of test cases
    [ line, arc, closed polygon, bspline with lots of points... stuff like that... ]
    so for the moment its mostly about asserting the KBE API makes sense...
    '''
    line = make_line(gp_Pnt(), gp_Pnt(1, 0, 0))
    edg = Edge(line)

    def test_domain(self):
        domain = self.edg.domain()
        self.assertEqual((0.0, 1.0), domain)

    def test_param2pnt(self):
        pnt = self.edg.parameter_to_point(0.0)
        self.assertEqual(pnt.Coord(), (0, 0, 0))

    def test_pnt2param(self):
        param, pnt = self.edg.project_pnt_on_edge(gp_Pnt())
        self.assertEqual(param, 0.)
        self.assertEqual(gp_Pnt().IsEqual(pnt, 0.000001), 1)

    def test_length(self):
        _len = self.edg.length()
        self.assertEqual(_len, 1.)

    def test_divide_by_n_pnts(self):
        pnts = self.edg.divide_by_number_of_points(4)
        xx = [round(i[0], 2) for i in pnts]
        self.assertEqual(xx,
                         [0.0, 0.33000000000000002, 0.67000000000000004, 1.0])

    def test_trim(self):
        pnts = self.edg.divide_by_number_of_points(4)
        param1, param2 = pnts[1][0], pnts[2][0]
        trimmed = self.edg.trim(param1, param2)
        self.assertEqual(trimmed.domain(),
                         (0.33333333333333331, 0.66666666666666663))

    def test_first_last_vertex(self):
        # TODO: should return KBE.Vertex, now just a TopoDS_Vertex
        v1 = self.edg.first_vertex()
        v2 = self.edg.last_vertex()

    def test_periodic_rational_closed(self):
        self.assertEqual(self.edg.is_periodic(), 0)
        self.assertEqual(self.edg.is_rational(), 0)
        self.assertEqual(self.edg.is_closed(), 0)
Esempio n. 5
0
 def Edges(self):
     return [Edge(i) for i in Topo(self.topo).edges()]
Esempio n. 6
0
 def Edges(self):
     return [
         Edge(i)
         for i in WireExplorer(self.topo.wires().next()).ordered_edges()
     ]