AnyCAD在医疗中的应用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | void addPoint(List< float > buffer, Vector3 pt) { buffer.Add(( float )pt.X); buffer.Add(( float )pt.Y); buffer.Add(( float )pt.Z); } void ComputeMinMax(Vector3 a, Vector3 b, Vector3 c, Vector3 minPt, Vector3 maxPt) { minPt.X = Math.Min(Math.Min(a.X, b.X), c.X); minPt.Y = Math.Min(Math.Min(a.Y, b.Y), c.Y); minPt.Z = Math.Min(Math.Min(a.Z, b.Z), c.Z); maxPt.X = Math.Max(Math.Max(a.X, b.X), c.X); maxPt.Y = Math.Max(Math.Max(a.Y, b.Y), c.Y); maxPt.Z = Math.Max(Math.Max(a.Z, b.Z), c.Z); } private void faceToolStripMenuItem1_Click( object sender, EventArgs e) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "TEXT (*.txt)|*.txt|All Files(*.*)|*.*" ; if (DialogResult.OK != dlg.ShowDialog()) return ; String vertexFileName = dlg.FileName; if (DialogResult.OK != dlg.ShowDialog()) return ; String faceFileName = dlg.FileName; List<Vector3> points = new List<Vector3>(); StreamReader sr = new StreamReader(vertexFileName, Encoding.Default); String line; while ((line = sr.ReadLine()) != null ) { String[] items = line.Split( '\t' ); if (items.Length == 3) { Vector3 pt = new Vector3(); pt.X = float .Parse(items[0]); pt.Y = float .Parse(items[1]); pt.Z = float .Parse(items[2]); points.Add(pt); } } List< uint > faces = new List< uint >(); faces.Add(0); faces.Add(1); faces.Add(2); Random num = new Random(); List<FaceStyle> faceStyles = new List<FaceStyle>(); FaceStyle fs1 = new FaceStyle(); fs1.SetColor(num.Next(0, 255), num.Next(0, 255), num.Next(0, 255)); faceStyles.Add(fs1); FaceStyle fs2 = new FaceStyle(); fs2.SetColor(num.Next(0, 255), num.Next(0, 255), num.Next(0, 255)); faceStyles.Add(fs2); FaceStyle fs3 = new FaceStyle(); fs3.SetColor(num.Next(0, 255), num.Next(0, 255), num.Next(0, 255)); faceStyles.Add(fs3); FaceStyle fs4 = new FaceStyle(); fs4.SetColor(num.Next(0, 255), num.Next(0, 255), num.Next(0, 255)); faceStyles.Add(fs4); FaceStyle fs5 = new FaceStyle(); fs5.SetColor(num.Next(0, 255), num.Next(0, 255), num.Next(0, 255)); faceStyles.Add(fs5); FaceStyle fs6 = new FaceStyle(); fs6.SetColor(num.Next(0, 255), num.Next(0, 255), num.Next(0, 255)); faceStyles.Add(fs6); ElementId id = new ElementId(); sr = new StreamReader(faceFileName, Encoding.Default); while ((line = sr.ReadLine()) != null ) { String[] items = line.Split( '\t' ); if (items.Length == 3) { int a = int .Parse(items[0]) - 1; int b = int .Parse(items[1]) - 1; int c = int .Parse(items[2]) - 1; List< float > positions = new List< float >(); addPoint(positions, points[a]); addPoint(positions, points[b]); addPoint(positions, points[c]); Vector3 normal = (points[b] - points[a]).CrossProduct(points[c] - points[a]); normal.Normalize(); List< float > normals = new List< float >(); addPoint(normals, normal); addPoint(normals, normal); addPoint(normals, normal); AABox bbox = new AABox(); ComputeMinMax(points[a], points[b], points[c], bbox.MinPt, bbox.MaxPt); var entity = GlobalInstance.TopoShapeConvert.CreateFaceEntity(positions.ToArray(), faces.ToArray(), normals.ToArray(), null , bbox); EntitySceneNode node = new EntitySceneNode(); node.SetEntity(entity); node.SetId(++id); node.SetFaceStyle(faceStyles[num.Next(0, 5)]); renderView.ShowSceneNode(node); } } } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY