Esempio n. 1
0
    def addLines(self):

        origin = (0, 0, 0)
        ais_list = []

        for name, color, direction in zip(('X', 'Y', 'Z'), (RED, GREEN, BLUE),
                                          ((1, 0, 0), (0, 1, 0), (0, 0, 1))):
            line_placement = Geom_Line(
                gp_Ax1(gp_Pnt(*origin), gp_Dir(*direction)))
            line = AIS_Line(line_placement.GetHandle())
            line.SetColor(color)

            self.Helpers.addChild(ObjectTreeItem(name, ais=line))

            ais_list.append(line)

        self.sigObjectsAdded.emit(ais_list)
        self.tree.expandToDepth(1)
def line():
    # create a line
    p1 = gp_Pnt(2., 3., 4.)
    d1 = gp_Dir(4., 5., 6.)
    line1 = Geom_Line(p1, d1)

    ais_line1 = AIS_Line(line1.GetHandle())

    # if we need to edit color, we can simply use SetColor
    # ais_line1.SetColor(Quantity_NOC_RED)

    # but actually we need to edit more, not just color. Line width and style as well
    # To do that, we need to do use AIS_Drawer and apply it to ais_line1
    width = 1.0
    drawer = Prs3d_Drawer()
    ais_line1.SetAttributes(drawer.GetHandle())

    display.Context.Display(ais_line1.GetHandle(), False)
    # we can apply the same rule for other lines by just doing a for loop
    for i in range(1, 5):
        p2 = gp_Pnt(i, 2., 5.)
        d2 = gp_Dir(4*i, 6., 9.)
        line2 = Geom_Line(p2, d2)

        ais_line2 = AIS_Line(line2.GetHandle())
    
        width = float(i)
        drawer = ais_line2.Attributes().GetObject()
        # asp : first parameter color, second type, last width
        asp = Prs3d_LineAspect(9*i, i, width)
        drawer.SetLineAspect(asp.GetHandle())
        ais_line2.SetAttributes(drawer.GetHandle())

        display.Context.Display(ais_line2.GetHandle(), False)
    start_display()
Esempio n. 3
0
def reflect_axs2(beam, surf, axs=gp_Ax3(), indx=1):
    p0, v0 = beam.Location(), dir_to_vec(beam.Direction())
    h_surf = BRep_Tool.Surface(surf)
    ray = Geom_Line(gp_Lin(p0, vec_to_dir(v0)))
    if GeomAPI_IntCS(ray.GetHandle(), h_surf).NbPoints() == 0:
        return beam, beam, None
    elif GeomAPI_IntCS(ray.GetHandle(), h_surf).NbPoints() == 1:
        return beam, beam, None
    GeomAPI_IntCS(ray.GetHandle(), h_surf).IsDone()
    u, v, w = GeomAPI_IntCS(ray.GetHandle(), h_surf).Parameters(indx)
    p1, vx, vy = gp_Pnt(), gp_Vec(), gp_Vec()
    GeomLProp_SurfaceTool.D1(h_surf, u, v, p1, vx, vy)
    vz = vx.Crossed(vy)
    vx.Normalize()
    vy.Normalize()
    vz.Normalize()
    v1 = v0.Mirrored(gp_Ax2(p1, vec_to_dir(vz), vec_to_dir(vx)))
    norm_ax = gp_Ax3(p1, vec_to_dir(vz), vec_to_dir(vx))
    beam_ax = gp_Ax3(p1, vec_to_dir(v1), beam.XDirection().Reversed())
    return beam_ax, norm_ax, 1
Esempio n. 4
0
    def show_line(self, origin=(0, 0, 0), direction=(0, 0, 1)):

        line_placement = Geom_Line(gp_Ax1(gp_Pnt(*origin), gp_Dir(*direction)))
        line = AIS_Line(line_placement.GetHandle())
        self._display_ais(line)