Esempio n. 1
0
 def __init__(self, x=0, y=0, z=0, **kwargs):
     if isinstance(x, TopoDS_Shape):
         pnt = BRep_Tool.Pnt_(x)
         x, y, z = pnt.X(), pnt.Y(), pnt.Z()
     elif isinstance(x, gp_Pnt):
         x, y, z = pnt.X(), pnt.Y(), pnt.Z()
     super().__init__(x=x, y=y, z=z, **kwargs)
Esempio n. 2
0
 def point(self):
     """
     :return: A point at vertex location.
     :rtype: afem.geometry.entities.Point
     """
     gp_pnt = BRep_Tool.Pnt_(self.object)
     return Point(gp_pnt.X(), gp_pnt.Y(), gp_pnt.Z())
Esempio n. 3
0
def coerce_direction(arg):
    if isinstance(arg, TopoDS_Shape):
        arg = BRep_Tool.Pnt_(arg)
    if hasattr(arg, 'XYZ'):  # copy from gp_Pnt2d, gp_Vec2d, gp_Dir2d, etc..
        return Direction(arg.X(), arg.Y(), arg.Z())
    if isinstance(arg, Direction):
        return arg
    if isinstance(arg, dict):
        return Direction(**arg)
    return Direction(*arg)
Esempio n. 4
0
def coerce_point(arg):
    if isinstance(arg, TopoDS_Shape):
        arg = BRep_Tool.Pnt_(arg)
    if hasattr(arg, 'XYZ'):  # copy from gp_Pnt, gp_Vec, gp_Dir, etc..
        return Point(arg.X(), arg.Y(), arg.Z())
    if isinstance(arg, Point):
        return arg
    if isinstance(arg, dict):
        return Point(**arg)
    return Point(*arg)
Esempio n. 5
0
    def pnt_of_vertex(vertex):
        """
        Get the underlying point of the vertex.

        :param OCCT.TopoDS.TopoDS_Vertex vertex: The vertex.

        :return: The point.
        :rtype: OCCT.gp.gp_Pnt
        """
        return BRep_Tool.Pnt_(vertex)
Esempio n. 6
0
 def make_plane(self, v1, v2):
     d = self.declaration
     p1 = BRep_Tool.Pnt_(v1)
     p2 = BRep_Tool.Pnt_(v2)
     p3 = (d.direction + p2).proxy
     return GC_MakePlane(p1, p2, p3).Value().Pln()