Esempio n. 1
0
    def display_vector(self, origin, direction):
        r"""Display a vector starting at origin and going in direction

        Parameters
        ----------
        origin : tuple(float)
            The origin coordinates (x, y, z) of the vector to display
        direction : tuple(float)
            The direction coordinates (x, y, z) of the vector to display

        """
        xo, yo, zo = origin
        xd, yd, zd = direction
        end = (xo + xd, yo + xd, zo + zd)
        xe, ye, ze = end

        # self.glarea.d3d.DisplayVector(gp_Vec(xd, yd, zd), gp_Pnt(xo, yo, zo))

        presentation = Prs3d_Presentation(self.glarea.occ_context.MainPrsMgr().
                                          GetObject().StructureManager())
        arrow = Prs3d_Arrow()
        arrow.Draw(presentation.GetHandle(), gp_Pnt(xe, ye, ze),
                   gp_Dir(gp_Vec(xd, yd, zd)), _math.radians(20),
                   gp_Vec(xd, yd, zd).Magnitude() / 4.)
        presentation.Display()

        e1 = BRepBuilderAPI_MakeEdge(gp_Pnt(xo, yo, zo), gp_Pnt(xe, ye, ze)).\
            Edge()
        self.display(e1, line_width=4)
Esempio n. 2
0
    def DisplayVector(self, vec, pnt, update=False):
        """displays a vector as an arrow"""
        if self._inited:
            aStructure = Graphic3d_Structure(self._struc_mgr)

            pnt_as_vec = gp_Vec(pnt.X(), pnt.Y(), pnt.Z())
            start = pnt_as_vec + vec
            pnt_start = gp_Pnt(start.X(), start.Y(), start.Z())

            Prs3d_Arrow.Draw(aStructure, pnt_start, gp_Dir(vec),
                             math.radians(20), vec.Magnitude())
            aStructure.Display()
            # it would be more coherent if a AIS_InteractiveObject
            # would be returned
            if update:
                self.Repaint()
            return aStructure