private void textToolStripMenuItem_Click(object sender, EventArgs e) { { TextNode text = new TextNode(); text.SetPosition(new Vector3(200, 200, 200)); text.SetText("AnyCAD .Net SDK Pro"); text.SetTextColor(new ColorValue(1, 0, 0, 1)); renderView.SceneManager.AddNode(text); } { TextNode text = new TextNode(); text.SetPosition(new Vector3(10, 50, 0)); text.SetText("AnyCAD .Net SDK Pro 2D"); text.SetTextColor(new ColorValue(0, 1, 0, 1)); renderView.SceneManager.AddNode2d(text); } renderView.RequestDraw(); }
private void surfaceToolStripMenuItem_Click(object sender, EventArgs e) { LineStyle lineStyle = new LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.RED); Vector3List points = new Vector3List(); points.Add(new Vector3(0, 0, 0)); points.Add(new Vector3(50, 0, 0)); points.Add(new Vector3(100, 0, 0)); points.Add(new Vector3(0, 50, 0)); points.Add(new Vector3(50, 50, 5)); points.Add(new Vector3(100, 50, -5)); points.Add(new Vector3(0, 150, 5)); points.Add(new Vector3(50, 150, -5)); points.Add(new Vector3(100, 150, 0)); TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3); renderView.ShowGeometry(face, ++shapeId); GeomeSurface surface = new GeomeSurface(); surface.Initialize(face); float ufirst = surface.FirstUParameter(); float uLarst = surface.LastUParameter(); float vfirst = surface.FirstVParameter(); float vLast = surface.LastVParameter(); float ustep = (uLarst - ufirst) * 0.1f; float vstep = (vLast - vfirst) * 0.1f; for (float ii = ufirst; ii <= uLarst; ii += ustep) { for (float jj = vfirst; jj <= vLast; jj += vstep) { Vector3List data = surface.D1(ii, jj); Vector3 pos = data.Get(0); Vector3 dirU = data.Get(1); Vector3 dirV = data.Get(2); Vector3 dir = dirV.CrossProduct(dirU); dir.Normalize(); { TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir * 10.0f); SceneNode node = renderView.ShowGeometry(line, ++shapeId); node.SetLineStyle(lineStyle); } } } TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(face); float area = property.SurfaceArea(); TextNode text = new TextNode(); text.SetText(String.Format("Surface Area: {0}", area)); text.SetPosition(new Vector3(100, 100, 0)); renderView.SceneManager.ClearNodes2d(); renderView.SceneManager.AddNode2d(text); renderView.RequestDraw(); }
private void curveToolStripMenuItem_Click(object sender, EventArgs e) { renderView.View3d.SetStandardView(3); LineStyle lineStyle = new LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.BLUE); LineStyle lineStyle2 = new LineStyle(); lineStyle2.SetLineWidth(0.5f); lineStyle2.SetColor(ColorValue.GREEN); TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z); renderView.ShowGeometry(arc, ++shapeId); { GeomeCurve curve = new GeomeCurve(); curve.Initialize(arc); float paramStart = curve.FirstParameter(); float paramEnd = curve.LastParameter(); float step = (paramEnd - paramStart) * 0.1f; for (float uu = paramStart; uu <= paramEnd; uu += step) { Vector3 dir = curve.DN(uu, 1); Vector3 pos = curve.Value(uu); // 切线 { TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir); SceneNode node = renderView.ShowGeometry(line, ++shapeId); node.SetLineStyle(lineStyle); } // 法线 { Vector3 dirN = dir.CrossProduct(Vector3.UNIT_Z); TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dirN); SceneNode node = renderView.ShowGeometry(line, ++shapeId); node.SetLineStyle(lineStyle2); } } } TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(arc); float len = property.EdgeLength(); TextNode text = new TextNode(); text.SetText(String.Format("Arc Length: {0}", len)); text.SetPosition(new Vector3(100, 100, 0)); renderView.SceneManager.ClearNodes2d(); renderView.SceneManager.AddNode2d(text); renderView.RequestDraw(); }
private void planeAngleToolStripMenuItem_Click(object sender, EventArgs e) { // plane Vector3 planeDir = Vector3.UNIT_Z; TopoShape plane1 = GlobalInstance.BrepTools.MakePlaneFace(Vector3.ZERO, planeDir, -100, 100, -100, 100); { GeomSurface gs = new GeomSurface(); gs.Initialize(plane1); List<Vector3> rst = gs.D1(gs.FirstUParameter(), gs.FirstVParameter()); Vector3 dir2 = rst[1].CrossProduct(rst[2]); MessageBox.Show(dir2.ToString()); } Vector3 normal = new Vector3(0,1,1); normal.Normalize(); TopoShape plane2 = GlobalInstance.BrepTools.MakePlaneFace(Vector3.ZERO, normal, -100, 100, -100, 100); renderView.ShowGeometry(plane1, ++shapeId); renderView.ShowGeometry(plane2, ++shapeId); LineStyle style = new LineStyle(); style.SetColor(ColorValue.GREEN); // witness Vector3 end1 = new Vector3(0, 0, 100); LineNode line1 = new LineNode(); line1.Set(Vector3.ZERO, end1); line1.SetLineStyle(style); renderView.ShowSceneNode(line1); Vector3 end2 = normal * 100; LineNode line2 = new LineNode(); line2.Set(Vector3.ZERO, end2); line2.SetLineStyle(style); renderView.ShowSceneNode(line2); // angle float angle = normal.AngleBetween(planeDir); Vector3 dir = normal.CrossProduct(planeDir); dir.Normalize(); TopoShape arc = GlobalInstance.BrepTools.MakeArc(end2, end1, Vector3.ZERO, dir); SceneNode arcNode = renderView.ShowGeometry(arc, ++shapeId); arcNode.SetLineStyle(style); // text TextNode text = new TextNode(); text.SetText(angle.ToString()); Vector3 pos = end2 + end1; pos = pos * 0.5f; text.SetPosition(pos); renderView.ShowSceneNode(text); renderView.RequestDraw(); }
private void surfaceToolStripMenuItem_Click(object sender, EventArgs e) { Platform.LineStyle lineStyle = new Platform.LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.RED); var points = new System.Collections.Generic.List<Vector3>(); points.Add(new Vector3(0, 0, 0)); points.Add(new Vector3(50, 0, 0)); points.Add(new Vector3(100, 0, 0)); points.Add(new Vector3(0, 50, 0)); points.Add(new Vector3(50, 50, 5)); points.Add(new Vector3(100, 50, -5)); points.Add(new Vector3(0, 150, 5)); points.Add(new Vector3(50, 150, -5)); points.Add(new Vector3(100, 150, 0)); TopoShape face = GlobalInstance.BrepTools.MakeSurfaceFromPoints(points, 3, 3); renderView.ShowGeometry(face, 101); GeomSurface surface = new GeomSurface(); surface.Initialize(face); float ufirst = surface.FirstUParameter(); float uLarst = surface.LastUParameter(); float vfirst = surface.FirstVParameter(); float vLast = surface.LastVParameter(); float ustep = (uLarst - ufirst) * 0.1f; float vstep = (vLast - vfirst) * 0.1f; for(float ii=ufirst; ii<=uLarst; ii+= ustep) for (float jj = vfirst; jj <= vLast; jj += vstep) { var data = surface.D1(ii, jj); Vector3 pos = data[0]; Vector3 dirU = data[1]; Vector3 dirV = data[2]; Vector3 dir = dirV.CrossProduct(dirU); dir.Normalize(); { Platform.TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir*10.0f); Platform.SceneNode node = renderView.ShowGeometry(line, 101); node.SetLineStyle(lineStyle); } } TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(face); float area = property.SurfaceArea(); TextNode text = new TextNode(); text.SetText(String.Format("Surface Area: {0}", area)); text.SetPosition(new Vector3(100, 100, 0)); renderView.SceneManager.ClearNodes2d(); renderView.SceneManager.AddNode2d(text); renderView.RequestDraw(); }
private void curveToolStripMenuItem_Click(object sender, EventArgs e) { renderView.SetStandardView(EnumStandardView.SV_Top); Platform.LineStyle lineStyle = new Platform.LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.BLUE); Platform.LineStyle lineStyle2 = new Platform.LineStyle(); lineStyle2.SetLineWidth(0.5f); lineStyle2.SetColor(ColorValue.GREEN); Platform.TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z); renderView.ShowGeometry(arc, 100); { GeomCurve curve = new GeomCurve(); curve.Initialize(arc); float paramStart = curve.FirstParameter(); float paramEnd = curve.LastParameter(); float step = (paramEnd - paramStart) * 0.1f; for (float uu = paramStart; uu <= paramEnd; uu += step) { Vector3 dir = curve.DN(uu, 1); Vector3 pos = curve.Value(uu); // 切线 { Platform.TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir); Platform.SceneNode node = renderView.ShowGeometry(line, 101); node.SetLineStyle(lineStyle); } // 法线 { Vector3 dirN = dir.CrossProduct(Vector3.UNIT_Z); Platform.TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dirN); Platform.SceneNode node = renderView.ShowGeometry(line, 101); node.SetLineStyle(lineStyle2); } } } TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(arc); float len = property.EdgeLength(); TextNode text = new TextNode(); text.SetText(String.Format("Arc Length: {0}", len)); text.SetPosition(new Vector3(100, 100, 0)); renderView.SceneManager.ClearNodes2d(); renderView.SceneManager.AddNode2d(text); renderView.RequestDraw(); }
private void textToolStripMenuItem_Click(object sender, EventArgs e) { { GlobalInstance.FontManager.SetDefaultFont("FangSong (TrueType)"); TextNode text = new TextNode(); text.SetPosition(new Vector3(200, 200, 200)); text.SetText("AnyCAD .Net SDK Pro 专业版"); text.SetTextColor(new ColorValue(1, 0, 0, 1)); renderView.SceneManager.AddNode(text); } { TextNode text = new TextNode(); text.SetPosition(new Vector3(10, 50, 0)); text.SetText("AnyCAD .Net SDK Pro 2D"); text.SetTextColor(new ColorValue(0, 1, 0, 1)); renderView.SceneManager.AddNode2d(text); } renderView.RequestDraw(); }