pint, pointellipse, center, Gdir, normal, 'ellipse1', extra=extra1) seghb = vm.LineSegment3D(segbh.points[1], segbh.points[0]) center2 = center + vm.Point3D([i * h for i in normal.vector]) pointellipse2 = center2 + Gradius * Gdir pint2 = pint + vm.Point3D([i * h for i in normal.vector]) extra2 = extra1 + vm.Point3D([i * h for i in normal.vector]) ellipse2 = vm.ArcEllipse3D(pointellipse2, pint2, pointellipse2, center2, Gdir, normal, 'ellipse2', extra=extra2) edges = [segbh, ellipse1, seghb, ellipse2] points = segbh.points + ellipse1.points + seghb.points + ellipse2.points contours = [vm.Contour3D(edges)] EllipseFace = vm.BSplineFace3D(contours, bsplinextru, points) shell = vm.Shell3D([EllipseFace]) m = vm.VolumeModel([shell]) m.babylonjs()
segbh2 = volmdlr.LineSegment2D(center2d2, center2d2 + volmdlr.Point2D((0,h2))) #### Minus Pt2D because of Step adaptation circlestart2 = volmdlr.LineSegment2D(segbh2.points[1], segbh2.points[1]+volmdlr.Point2D((2*math.pi,0))) #You can change 2*pi by an other angle seghb2 = volmdlr.LineSegment2D(circlestart2.points[1],circlestart2.points[1]-segbh2.points[1]) circlend2 = volmdlr.LineSegment2D(seghb2.points[1],segbh2.points[0]) edges2 = [segbh2, circlestart2, seghb2, circlend2] points2 = edges2[0].points contours2 = [volmdlr.Contour2D(edges2)] cyl1 = volmdlr.CylindricalFace3D(contours, cylsurface1, points) cyl2 = volmdlr.CylindricalFace3D(contours2, cylsurface2, points2) pts1, tangle1 = cyl1.triangulation(resolution=12) pts2, tangle2 = cyl2.triangulation(resolution=12) p1, p2 = cyl1.minimum_distance_points_cyl(cyl2) print(p1.point_distance(p2)) fig = plt.figure() ax = fig.add_subplot(111, projection='3d') [pt.MPLPlot(ax=ax) for pt in pts1] [pt.MPLPlot(ax=ax) for pt in pts2] p1.MPLPlot(ax=ax, color='r') p2.MPLPlot(ax=ax, color='b') shell = volmdlr.Shell3D([cyl1,cyl2]) vol = volmdlr.VolumeModel([shell, p1, p2]) vol.babylonjs_from_script() # m = volmdlr.VolumeModel([shell]) # m.babylonjs()
(angle_cyl / 3, 0))) circlend2 = volmdlr.LineSegment2D(seghb2.points[1], segbh2.points[0]) edges2 = [segbh2, circlestart2, seghb2, circlend2] points2 = edges2[0].points contours2 = [volmdlr.Contour2D(edges2)] toroidalface1 = volmdlr.ToroidalFace3D(contours2d, toresurface1, points) cyl2 = volmdlr.CylindricalFace3D(contours2, cylsurface2, points2) pts1, tangle1 = toroidalface1.triangulation(resolution=10) pts2, tangle2 = cyl2.triangulation(resolution=12) distance, p1, p2 = toroidalface1.minimum_distance(cyl2, return_points=True) print(distance) # fig = plt.figure() # ax = fig.add_subplot(111, projection='3d') # [pt.MPLPlot(ax=ax) for pt in pts1] # [pt.MPLPlot(ax=ax) for pt in pts2] # p1.MPLPlot(ax=ax, color='r') # p2.MPLPlot(ax=ax, color='b') # toroidalface1.start.MPLPlot(ax=ax, color='m') # toroidalface2.start.MPLPlot(ax=ax, color='g') # LS = volmdlr.LineSegment3D(p1, p2) shell = volmdlr.Shell3D([toroidalface1, cyl2]) vol = volmdlr.VolumeModel([shell, p1, p2]) vol.babylonjs_from_script() # m = volmdlr.VolumeModel([shell]) # m.babylonjs()
edges_2 = [seg1_2, seg2_2, seg3_2, seg4_2] contours2d_2 = [volmdlr.Contour2D(edges_2)] points_2 = [theta2, phi2] toroidalface1 = volmdlr.ToroidalFace3D(contours2d, toresurface1, points) toroidalface2 = volmdlr.ToroidalFace3D(contours2d_2, toresurface2, points_2) pts1, tangle1 = toroidalface1.triangulation(resolution=10) pts2, tangle2 = toroidalface2.triangulation(resolution=10) p1, p2 = toroidalface1.minimum_distance_points_tore(toroidalface2) print('p1, p2', p1, p2) print(p1.point_distance(p2)) # fig = plt.figure() # ax = fig.add_subplot(111, projection='3d') # [pt.MPLPlot(ax=ax) for pt in pts1] # [pt.MPLPlot(ax=ax) for pt in pts2] # p1.MPLPlot(ax=ax, color='r') # p2.MPLPlot(ax=ax, color='b') # toroidalface1.start.MPLPlot(ax=ax, color='m') # toroidalface2.start.MPLPlot(ax=ax, color='g') # LS = volmdlr.LineSegment3D(p1, p2) shell = volmdlr.Shell3D([toroidalface1, toroidalface2]) vol = volmdlr.VolumeModel([shell, p1, p2]) vol.babylonjs_from_script() # m = volmdlr.VolumeModel([shell]) # m.babylonjs()
center = vm.Point3D([0, 0, 0]) #Choose the coordinate of the center normal1 = vm.Vector3D([0, 0, 1]) #Choose the normal of the generative normal1.Normalize() #Normalize the normal if it is not the case vec1 = normal1.deterministic_unit_normal_vector() frame = vm.Frame3D(center, vec1, normal1.Cross(vec1), normal1) #Frame in the center of the generative arc3D toroidalsurface3d = vm.ToroidalSurface3D(frame, r1, r2) theta = 4 * math.pi / 3 #Tore's length phi = 2 * math.pi #angle of circle offset_theta = math.pi / 4 #Theta's offset if you want to turn it with normal's reference offset_phi = math.pi #Idem but with circle's normal #You have to create a cutting pattern in 2D pt1, pt2, pt3, pt4 = vm.Point2D((offset_theta, offset_phi)), vm.Point2D( (offset_theta, offset_phi + phi)), vm.Point2D( (offset_theta + theta, offset_phi + phi)), vm.Point2D( (offset_theta + theta, offset_phi)) seg1, seg2, seg3, seg4 = vm.LineSegment2D(pt1, pt2), vm.LineSegment2D( pt2, pt3), vm.LineSegment2D(pt3, pt4), vm.LineSegment2D(pt4, pt1) edges = [seg1, seg2, seg3, seg4] contours2d = [vm.Contour2D(edges)] points = [theta, phi] toroidalface = vm.ToroidalFace3D(contours2d, toroidalsurface3d, points) shell = vm.Shell3D([toroidalface]) m = vm.VolumeModel([shell]) m.babylonjs(debug=True)
#c1 = volmdlr.Contour2D([outer_profile]) #c2 = volmdlr.Contour2D([inner_profile]) # f, a = outer_profile.MPLPlot() # c2.MPLPlot(a) profile = primitives3D.ExtrudedProfile(volmdlr.O3D, volmdlr.Y3D, volmdlr.Z3D, outer_profile, [c2], volmdlr.X3D * 0.1, name='extrusion') dmin, p1, p2 = cyl1.minimum_distance(profile.faces[0], return_points=True) face_min = profile.faces[0] # print('dmin', dmin) for face in profile.faces[1:]: dtest, ptest1, ptest2 = cyl1.minimum_distance(face, return_points=True) # print('dtest', dtest) if dtest < dmin: p1, p2 = ptest1, ptest2 dmin = dtest face_min = face # print('>>>>>>>>> distance minimale', dmin) shell = volmdlr.Shell3D([cyl1]) vol = volmdlr.VolumeModel([shell, profile, p1, p2]) vol.babylonjs_from_script() # m = volmdlr.VolumeModel([shell, profile]) # m.babylonjs()
circles = [] delta_angle = 2*math.pi/number_holes inner_circle = volmdlr.Circle2D(volmdlr.O2D, 0.04) first_circle = volmdlr.Circle2D(volmdlr.Point2D((0, 0.05)), 0.005) circles = [inner_circle, first_circle] for i in range(1, number_holes): circles.append(first_circle.Rotation(volmdlr.O2D, i*delta_angle)) xn, yn, zn = random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100 xc, yc, zc = random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100, random.randrange(posmin, posmax, 1)/100 n = volmdlr.Vector3D([xn,yn,zn]) n.Normalize() c = volmdlr.Point3D((xc,yc,zc)) #Plane to place your PlaneFace3D plane = volmdlr.Plane3D.from_normal(c, n) #To do a PlaneFace3D, you need to use contours2D #The first is always the basis, the others are used to cut the basis contours = [volmdlr.Contour2D([outer_circle]), volmdlr.Contour2D([circles[0]]), volmdlr.Contour2D([circles[1]]), volmdlr.Contour2D([circles[2]]), volmdlr.Contour2D([circles[3]]),volmdlr.Contour2D([circles[4]]), volmdlr.Contour2D([circles[5]])] planeface = volmdlr.PlaneFace3D(contours, plane) shell = volmdlr.Shell3D([planeface]) m = volmdlr.VolumeModel([shell]) m.babylonjs()