def points_from_intersection(): ''' @param display: ''' plane = gp_Pln(gp_Ax3(gp_XOY())) minor_radius, major_radius = 5., 8. ellips = gp_Elips(gp_YOZ(), major_radius, minor_radius) intersection = IntAna_IntConicQuad(ellips, plane, precision_Angular(), precision_Confusion()) a_plane = GC_MakePlane(plane).Value() a_surface = Geom_RectangularTrimmedSurface(a_plane, -8., 8., -12., 12., True, True) display.DisplayShape(a_surface, update=True) anEllips = GC_MakeEllipse(ellips).Value() display.DisplayShape(anEllips) if intersection.IsDone(): nb_results = intersection.NbPoints() if nb_results > 0: for i in range(1, nb_results + 1): P = intersection.Point(i) pstring = "P%i" % i display.DisplayShape(P) display.DisplayMessage(P, pstring)
def points_from_intersection(event=None): ''' @param display: ''' plane = gp_Pln(gp_Ax3(gp_XOY())) minor_radius, major_radius = 5., 8. ellips = gp_Elips(gp_YOZ(), major_radius, minor_radius) intersection = IntAna_IntConicQuad(ellips, plane, precision_Angular(), precision_Confusion()) a_plane = GC_MakePlane(plane).Value() a_surface = Geom_RectangularTrimmedSurface(a_plane, - 8., 8., - 12., 12., True, True) display.DisplayShape(a_surface, update=True) anEllips = GC_MakeEllipse(ellips).Value() display.DisplayShape(anEllips) if intersection.IsDone(): nb_results = intersection.NbPoints() if nb_results > 0: for i in range(1, nb_results + 1): P = intersection.Point(i) pstring = "P%i" % i display.DisplayShape(P) display.DisplayMessage(P, pstring)
def reflect(p0, v0, ax): ray = gp_Lin(p0, vec_to_dir(v0)) intersection = IntAna_IntConicQuad(ray, gp_Pln(ax), precision_Angular(), precision_Confusion()) p1 = intersection.Point(1) vx, vy = gp_Vec(1, 0, 0), gp_Vec(0, 1, 0) handle = Geom_Plane(ax) handle.D1(0.5, 0.5, gp_Pnt(), vx, vy) vz = vx.Crossed(vy) v1 = v0.Mirrored(gp_Ax2(p1, vec_to_dir(vz))) return p1, v1
def draft_angle(event=None): S = BRepPrimAPI_MakeBox(200., 300., 150.).Shape() adraft = BRepOffsetAPI_DraftAngle(S) topExp = TopExp_Explorer() topExp.Init(S, TopAbs_FACE) while topExp.More(): face = topods_Face(topExp.Current()) surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(face)).GetObject() dirf = surf.Pln().Axis().Direction() ddd = gp_Dir(0, 0, 1) if dirf.IsNormal(ddd, precision_Angular()): adraft.Add(face, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY()))) topExp.Next() adraft.Build() display.DisplayShape(adraft.Shape(), update=True)