public override bool Run(FeatureContext context) { TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 2, 200)); { SceneNode node = context.ShowGeometry(box); FaceStyle fs = new FaceStyle(); fs.SetColor(new ColorValue(0.5f, 0.5f, 1.0f, 0.5f)); fs.SetTransparent(true); node.SetFaceStyle(fs); } context.RequestDraw(); OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "Texture File (*.jpg;*.png)|*.jpg;*png||"; if (DialogResult.OK == dlg.ShowDialog()) { SceneNode node2 = context.ShowGeometry(box); node2.SetTransform(GlobalInstance.MatrixBuilder.MakeTranslate(new Vector3(0, 50, 0))); FaceStyle fs2 = new FaceStyle(); Texture tex = new Texture(); tex.SetName(dlg.SafeFileName); tex.SetFilePath(new Path(dlg.FileName)); fs2.SetTexture(0, tex); node2.SetFaceStyle(fs2); } return(true); }
public override bool Run(FeatureContext context) { // build two surfaces TopoShape arc = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, 100, 0, 135, Vector3.UNIT_Z); TopoShape cir = GlobalInstance.BrepTools.MakeCircle(new Vector3(-200, 0, 0), 50, Vector3.UNIT_X); TopoShape surf1 = GlobalInstance.BrepTools.Extrude(arc, 100, Vector3.UNIT_Z); TopoShape surf2 = GlobalInstance.BrepTools.Extrude(cir, 400, Vector3.UNIT_X); SceneNode n1 = context.ShowGeometry(surf1); { FaceStyle fs1 = new FaceStyle(); fs1.SetColor(new ColorValue(0, 0, 0.5f, 0.5f)); fs1.SetTransparent(true); n1.SetFaceStyle(fs1); } SceneNode n2 = context.ShowGeometry(surf2); { FaceStyle fs2 = new FaceStyle(); fs2.SetColor(new ColorValue(0, 0.5f, 0.5f, 0.5f)); fs2.SetTransparent(true); n2.SetFaceStyle(fs2); } // compute section wire TopoShape wire = GlobalInstance.BrepTools.SurfaceSection(surf1, surf2); SceneNode sectionNode = context.ShowGeometry(wire); LineStyle lineStyle = new LineStyle(); lineStyle.SetLineWidth(4); lineStyle.SetColor(ColorValue.RED); sectionNode.SetLineStyle(lineStyle); return(true); }
public override bool Run(FeatureContext context) { LineStyle lineStyle = new LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.RED); var points = new 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); context.ShowGeometry(face); GeomSurface surface = new GeomSurface(); surface.Initialize(face); double ufirst = surface.FirstUParameter(); double uLarst = surface.LastUParameter(); double vfirst = surface.FirstVParameter(); double vLast = surface.LastVParameter(); double ustep = (uLarst - ufirst) * 0.1; double vstep = (vLast - vfirst) * 0.1; for (double ii = ufirst; ii <= uLarst; ii += ustep) { for (double 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(); { TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dir * 0.01f); SceneNode node = context.ShowGeometry(line); node.SetLineStyle(lineStyle); } } } return(true); }
public override bool Run(FeatureContext context) { TopoShape oCircle1 = GlobalInstance.BrepTools.MakeCircle(Vector3.ZERO, 20, Vector3.UNIT_Z); TopoShape Pipe01_Surf = GlobalInstance.BrepTools.Extrude(oCircle1, 100, Vector3.UNIT_Z); context.ShowGeometry(Pipe01_Surf); TopoShape oCircle2 = GlobalInstance.BrepTools.MakeCircle(new Vector3(0.0f, 0.0f, 50.0f), 10, Vector3.UNIT_Y); TopoShape Pipe02_Surf = GlobalInstance.BrepTools.Extrude(oCircle2, 80, Vector3.UNIT_Y); { SceneNode node2 = context.ShowGeometry(Pipe02_Surf); FaceStyle fs = new FaceStyle(); fs.SetColor(new ColorValue(0.5f, 0.5f, 0.5f, 0.5f)); fs.SetTransparent(true); node2.SetFaceStyle(fs); } // Compute the intersection curve TopoShape Inters1 = GlobalInstance.BrepTools.SurfaceSection(Pipe01_Surf, Pipe02_Surf); if (Inters1 != null) { SceneNode node = context.ShowGeometry(Inters1); LineStyle ls = new LineStyle(); ls.SetLineWidth(3); ls.SetColor(ColorValue.RED); node.SetLineStyle(ls); // Get the curve parameters GeomCurve curve = new GeomCurve(); if (curve.Initialize(Inters1)) { LineStyle ls2 = new LineStyle(); ls2.SetColor(ColorValue.GREEN); double start = curve.FirstParameter(); double end = curve.LastParameter(); for (double ii = start; ii <= end; ii += 0.1) { List <Vector3> rt = curve.D1(ii); LineNode ln = new LineNode(); ln.SetLineStyle(ls2); ln.Set(rt[0], rt[0] + rt[1]); context.ShowSceneNode(ln); } } } return(true); }
public override bool Run(FeatureContext context) { LineStyle lineStyle = new LineStyle(); lineStyle.SetLineWidth(0.5f); lineStyle.SetColor(ColorValue.BLUE); lineStyle.SetLineWidth(1.5f); LineStyle lineStyle2 = new LineStyle(); lineStyle2.SetLineWidth(0.5f); lineStyle2.SetColor(ColorValue.GREEN); lineStyle2.SetLineWidth(2); TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z); context.ShowGeometry(arc); { GeomCurve curve = new GeomCurve(); curve.Initialize(arc); double paramStart = curve.FirstParameter(); double paramEnd = curve.LastParameter(); double step = (paramEnd - paramStart) * 0.1; for (double 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 = context.ShowGeometry(line); node.SetLineStyle(lineStyle); } // 法线 { Vector3 dirN = dir.CrossProduct(Vector3.UNIT_Z); TopoShape line = GlobalInstance.BrepTools.MakeLine(pos, pos + dirN); SceneNode node = context.ShowGeometry(line); node.SetLineStyle(lineStyle2); } } } return(true); }
public override bool Run(FeatureContext context) { TopoShape body = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 10); context.ShowGeometry(body); return(true); }
public override bool Run(FeatureContext context) { TopoShape cylinder = GlobalInstance.BrepTools.MakeCylinder(Vector3.ZERO, Vector3.UNIT_Z, 100, 200, 270); TopoShape section = GlobalInstance.BrepTools.BodySection(cylinder, new Vector3(0, 0, 50), Vector3.UNIT_Z); context.ShowGeometry(cylinder); SceneNode node = context.ShowGeometry(section); LineStyle ls = new LineStyle(); ls.SetLineWidth(3.0f); ls.SetColor(255, 0, 0); node.SetLineStyle(ls); return(true); }
public override bool Run(FeatureContext context) { TopoShape body = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(10, 20, 30)); context.ShowGeometry(body); return(true); }
public override bool Run(FeatureContext context) { AdvFeatureTools advTool = new AdvFeatureTools(); // Create the evolution spline Primitive2dTools tool2d = new Primitive2dTools(); float radius = 50; TopoShapeGroup group = new TopoShapeGroup(); group.Add(tool2d.MakeArc(new Vector2(0, radius), radius, 0, 45)); group.Add(tool2d.MakeLine(new Vector2(radius, radius), new Vector2(radius * 2, radius))); TopoShape spline = tool2d.ToBSplineCurve(group); // Create the profile section TopoShape profile = GlobalInstance.BrepTools.MakeCircle(new Vector3(100, 100, 0), 1, Vector3.UNIT_Z); // Create the path List <Vector3> pts = new List <Vector3>(); pts.Add(new Vector3(100, 100, 0)); pts.Add(new Vector3(100, 100, 100)); pts.Add(new Vector3(100, 200, 400)); TopoShape path = GlobalInstance.BrepTools.MakeSpline(pts); // Make sweep TopoShape sweepBody = advTool.MakeSweep(profile, path, spline, true); context.ShowGeometry(sweepBody); return(true); }
public override bool Run(FeatureContext context) { List <Vector3> pts = new List <Vector3>(); pts.Add(new Vector3(0, 0, 0)); pts.Add(new Vector3(10, 0, 0)); pts.Add(new Vector3(10, 100, 0)); pts.Add(new Vector3(0, 100, 0)); TopoShape rect = GlobalInstance.BrepTools.MakePolygon(pts); TopoShape arc = GlobalInstance.BrepTools.MakeArc(new Vector3(-100, 0, 100), new Vector3(0, 0, 0), new Vector3(-100, 0, 0), Vector3.UNIT_Y); //TopoShape arc = GlobalInstance.BrepTools.MakeArc(new Vector3(0, 0, 0), new Vector3(100, 100, 0), new Vector3(100, 0, 0), new Vector3(0, 0, -1)); //context.ShowGeometry(arc); //GeomCurve curve = new GeomCurve(); //curve.Initialize(arc); //var d1 = curve.D1(curve.FirstParameter()); ////Vector3 dir = d1[1]; ////dir = dir.CrossProduct(Vector3.UNIT_Z); ////float x = dir.AngleBetween(Vector3.UNIT_Y); //Matrix4 mm = GlobalInstance.MatrixBuilder.MakeRotation(90, Vector3.UNIT_X); //Matrix4 trans = GlobalInstance.MatrixBuilder.MakeTranslate(d1[0]); //Matrix4 trf = GlobalInstance.MatrixBuilder.Multiply(trans, mm); //rect = GlobalInstance.BrepTools.Transform(rect, trf); rect = GlobalInstance.BrepTools.MakePipe(rect, arc, 0); SceneNode sn = context.ShowGeometry(rect); return(true); }
public override bool Run(FeatureContext context) { var points = new 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); context.ShowGeometry(face); TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(face); MessageBox.Show(String.Format("Area: {0}", property.SurfaceArea())); return(true); }
public override bool Run(FeatureContext context) { TopoShape spiralCurve = GlobalInstance.BrepTools.MakeSpiralCurve(100, 10, 10, Coordinate3.UNIT_XYZ); context.ShowGeometry(spiralCurve); return(true); }
public override bool Run(FeatureContext context) { // 1. Create Solid by extrude the section Vector3 start = new Vector3(100, 0, 0); Vector3 end = new Vector3(0, 100, 0); TopoShapeGroup group = new TopoShapeGroup(); group.Add(GlobalInstance.BrepTools.MakeArc(start, end, Vector3.ZERO, Vector3.UNIT_Z)); group.Add(GlobalInstance.BrepTools.MakeLine(Vector3.ZERO, start)); group.Add(GlobalInstance.BrepTools.MakeLine(Vector3.ZERO, end)); TopoShape section = GlobalInstance.BrepTools.MakeWire(group); TopoShape face = GlobalInstance.BrepTools.MakeFace(section); TopoShape solid = GlobalInstance.BrepTools.Extrude(face, 50, Vector3.UNIT_Z); // 2. Fillet the specified edges with different radius. int[] edges = { 4, 6, 8 }; float[] radius = { 5, 5, 10 }; TopoShape chamfer = GlobalInstance.BrepTools.MakeFillet(solid, edges, radius); context.ShowGeometry(chamfer); return(true); }
public override bool Run(FeatureContext context) { float y = 10; TopoShape line1 = GlobalInstance.BrepTools.MakeLine(new Vector3(0, 0, 0 + y), new Vector3(4, 0, 0 + y)); TopoShape line2 = GlobalInstance.BrepTools.MakeLine(new Vector3(4, 0, 0 + y), new Vector3(4, 0, 0.5f + y)); TopoShape line3 = GlobalInstance.BrepTools.MakeLine(new Vector3(4, 0, 0.5f + y), new Vector3(1, 0, 0.5f + y)); TopoShape line4 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 0.5f + y), new Vector3(1, 0, 4 + y)); TopoShape line5 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 4 + y), new Vector3(0.5f, 0, 4 + y)); TopoShape line6 = GlobalInstance.BrepTools.MakeLine(new Vector3(0.5f, 0, 4 + y), new Vector3(0.5f, 0, 0.5f + y)); TopoShape line7 = GlobalInstance.BrepTools.MakeLine(new Vector3(0.5f, 0, 0.5f + y), new Vector3(0, 0, 0.5f + y)); TopoShape line8 = GlobalInstance.BrepTools.MakeLine(new Vector3(0, 0, 0.5f + y), new Vector3(0, 0, 0 + y)); TopoShapeGroup shapeGroup = new TopoShapeGroup(); shapeGroup.Add(line2); shapeGroup.Add(line3); shapeGroup.Add(line4); shapeGroup.Add(line5); shapeGroup.Add(line6); shapeGroup.Add(line7); shapeGroup.Add(line8); shapeGroup.Add(line1); TopoShape profile = GlobalInstance.BrepTools.MakeWire(shapeGroup); TopoShape line9 = GlobalInstance.BrepTools.MakeLine(new Vector3(0, 0, 0 + y), new Vector3(0, -20, 0 + y)); TopoShapeGroup lineGroup = new TopoShapeGroup(); lineGroup.Add(line9); TopoShape wire = GlobalInstance.BrepTools.MakeWire(lineGroup); TopoShape sweep = GlobalInstance.BrepTools.Sweep(profile, wire, true); TopoShape line10 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 0.5f + y), new Vector3(1, 0, 3 + y)); TopoShape line11 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 3 + y), new Vector3(2, 0, 3 + y)); TopoShape line12 = GlobalInstance.BrepTools.MakeLine(new Vector3(2, 0, 3 + y), new Vector3(2, 0, 0.5f + y)); TopoShape line13 = GlobalInstance.BrepTools.MakeLine(new Vector3(2, 0, 0.5f + y), new Vector3(1, 0, 0.5f + y)); TopoShapeGroup shapeGroup1 = new TopoShapeGroup(); shapeGroup1.Add(line10); shapeGroup1.Add(line11); shapeGroup1.Add(line12); shapeGroup1.Add(line13); TopoShape profile1 = GlobalInstance.BrepTools.MakeWire(shapeGroup1); TopoShape line14 = GlobalInstance.BrepTools.MakeLine(new Vector3(1, 0, 0.5f + y), new Vector3(1, -0.5f, 0.5f + y)); TopoShapeGroup lineGroup1 = new TopoShapeGroup(); lineGroup1.Add(line14); TopoShape wire1 = GlobalInstance.BrepTools.MakeWire(lineGroup1); TopoShape sweep1 = GlobalInstance.BrepTools.Sweep(profile1, wire1, true); TopoShape comp = GlobalInstance.BrepTools.BooleanAdd(sweep, sweep1); RepairTools rt = new RepairTools(); comp = rt.RemoveExtraEdges(comp); context.ShowGeometry(comp); return(true); }
public override bool Run(FeatureContext context) { // Split box with two spheres. TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(150f, 150f, 150f)); TopoShape sphere = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 100f); TopoShape sphere2 = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 50f); TopoShapeGroup tools = new TopoShapeGroup(); tools.Add(sphere); tools.Add(sphere2); TopoShape split = GlobalInstance.BrepTools.MakeSplit(box, tools); // Display the results with customized face styles. TopoExplor expo = new TopoExplor(); TopoShapeGroup bodies = expo.ExplorSolids(split); Random random = new Random(); for (int ii = 0; ii < bodies.Size(); ++ii) { SceneNode node = context.ShowGeometry(bodies.GetTopoShape(ii)); FaceStyle fs = new FaceStyle(); fs.SetColor(new ColorValue((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble(), 0.5f)); fs.SetTransparent(true); node.SetFaceStyle(fs); } return(true); }
public override bool Run(FeatureContext context) { TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(100, 50, 10, Coordinate3.UNIT_XYZ); rect = GlobalInstance.BrepTools.MakeFace(rect); context.ShowGeometry(rect); return(true); }
public override bool Run(FeatureContext context) { TopoShape tube = GlobalInstance.BrepTools.MakeTube(Vector3.ZERO, Vector3.UNIT_Z, 8, 2, 100); TopoShape cyl = GlobalInstance.BrepTools.MakeCylinder(new Vector3(0, 0, 50), Vector3.UNIT_X, 5, 10, 0); { SceneNode node = context.ShowGeometry(cyl); FaceStyle fs = new FaceStyle(); fs.SetColor(new ColorValue(0.5f, 0.5f, 0, 0.5f)); fs.SetTransparent(true); node.SetFaceStyle(fs); } TopoShape cut = GlobalInstance.BrepTools.BooleanCut(tube, cyl); context.ShowGeometry(cut); return(true); }
public override bool Run(FeatureContext context) { //1. Create the path float radius = 100; TopoShape arc = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, new Vector3(-radius, -radius, 0), new Vector3(0, -radius, 0), Vector3.UNIT_Z); TopoShape line = GlobalInstance.BrepTools.MakeLine(new Vector3(-radius, -radius, 0), new Vector3(-radius, -radius * 2, 0)); TopoShapeGroup edges = new TopoShapeGroup(); edges.Add(arc); edges.Add(line); TopoShape wire = GlobalInstance.BrepTools.MakeWire(edges); Vector3 dirZ = new Vector3(1, -1, 0); dirZ.Normalize(); Vector3 dirX = dirZ.CrossProduct(Vector3.UNIT_Z); Coordinate3 coord = new Coordinate3(Vector3.ZERO, dirX, Vector3.UNIT_Z, dirZ); TopoShape path = GlobalInstance.BrepTools.Transform(wire, coord); context.ShowGeometry(path); //2. Create the profile List <Vector3> points = new List <Vector3>(); points.Add(new Vector3()); points.Add(new Vector3(200, 0, 0)); points.Add(new Vector3(200, 200, 0)); points.Add(new Vector3(0, 200, 0)); TopoShape polygon = GlobalInstance.BrepTools.MakePolygon(points); // 3. Make body AdvFeatureTools advFT = new AdvFeatureTools(); TopoShape shape = advFT.MakeEvolved(polygon, path, 0, true); context.ShowGeometry(shape); return(true); }
public override bool Run(FeatureContext context) { TopoShape circle = GlobalInstance.BrepTools.MakeCircle(new Vector3(0, 0, 50), 10, Vector3.UNIT_Z); TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(40, 40, 5, new Coordinate3(new Vector3(-20, -20, 0), Vector3.UNIT_X, Vector3.UNIT_Y, Vector3.UNIT_Z)); TopoShape loft = GlobalInstance.BrepTools.MakeLoft(rect, circle, true); context.ShowGeometry(loft); return(true); }
public override bool Run(FeatureContext context) { context.RenderView.SetDisplayMode((int)(EnumDisplayStyle.DS_ShadeEdge | EnumDisplayStyle.DS_Vertex)); // construct a wire; TopoShape TS = GlobalInstance.BrepTools.MakeEllipse(Vector3.ZERO, 100D, 50D, Vector3.UNIT_Z); context.ShowGeometry(TS); TopoShape line = GlobalInstance.BrepTools.MakeLine(new Vector3(0, -200, 0), new Vector3(200, 200, 0)); context.ShowGeometry(line); IntersectionLineCurve intersector = new IntersectionLineCurve(); TopoExplor tp = new TopoExplor(); TopoShapeGroup tg = tp.ExplorEdges(TS); intersector.SetCurve(tg.GetAt(0)); if (intersector.Perform(line)) { int nCount = intersector.GetPointCount(); List <Vector3> LV = new List <Vector3>(); for (int ii = 0; ii < nCount; ++ii) { Vector3 pt = intersector.GetPoint(ii + 1); LV.Add(pt); context.ShowGeometry(GlobalInstance.BrepTools.MakePoint(pt)); } MessageBox.Show(String.Format("{0}", nCount)); } return(true); }
public override void OnFace(TopoShape shape) { WireClassifier wc = new WireClassifier(); if (!wc.Initialize(shape)) { return; } TopoShapeGroup innerWires = wc.GetInnerWires(); int nCount = innerWires.Size(); for (int ii = 0; ii < nCount; ++ii) { SceneNode node = _Context.ShowGeometry(innerWires.GetAt(ii)); node.SetLineStyle(_LineStyle); } SceneNode faceNode = _Context.ShowGeometry(shape); faceNode.SetFaceStyle(_FaceStyle); }
public override bool Run(FeatureContext context) { TopoShape shape = GlobalInstance.BrepTools.MakeArc(Vector3.ZERO, 100, 10, 180, Vector3.UNIT_Z); SceneNode node = context.ShowGeometry(shape); LineStyle ls = new LineStyle(); ls.SetLineWidth(2); ls.SetColor(0, 255, 0); ls.SetPatternStyle((int)EnumLinePattern.LP_DashedLine); node.SetLineStyle(ls); return(true); }
public override bool Run(FeatureContext context) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "STEP (*.stp;*.step)|*.stp;*.step"; if (dlg.ShowDialog() != DialogResult.OK) { return(false); } var shape = GlobalInstance.BrepTools.LoadFile(new Path(dlg.FileName)); if (shape == null) { return(false); } // 1. Adjust position and direction by box var box = shape.GetBBox(); var sz = box.Size(); var center = box.GetCenter(); Matrix4 trf = GlobalInstance.MatrixBuilder.MakeTranslate(-center); if (sz.X < sz.Y && sz.X < sz.Z) { trf = GlobalInstance.MatrixBuilder.MakeRotation(90, Vector3.UNIT_Y) * trf; } else if (sz.Y < sz.X && sz.Y < sz.Z) { trf = GlobalInstance.MatrixBuilder.MakeRotation(90, Vector3.UNIT_X) * trf; } shape = GlobalInstance.BrepTools.Transform(shape, trf); // 2. Find base face Solid solid = new Solid(shape); foreach (var fg in solid.SideFaceGroup) { foreach (var face in fg.Faces) { context.ShowGeometry(face.GetShape()); } break; } return(true); }
public override bool Run(FeatureContext context) { // construct a wire; var points = new System.Collections.Generic.List <Vector3>(); points.Add(new Vector3(0, 0, 0)); points.Add(new Vector3(0, 100, 0)); points.Add(new Vector3(100, 100, 0)); TopoShape wire = GlobalInstance.BrepTools.MakePolygon(points); context.ShowGeometry(wire); // project the wire to two planes Vector3 dirPlane1 = new Vector3(0, 1, 1); dirPlane1.Normalize(); TopoShape newWire1 = GlobalInstance.BrepTools.ProjectOnPlane(wire, new Vector3(0, 0, 100), dirPlane1, new Vector3(0, 0, 1)); Vector3 dirPlane2 = new Vector3(0, 1, -1); dirPlane2.Normalize(); TopoShape newWire2 = GlobalInstance.BrepTools.ProjectOnPlane(wire, new Vector3(0, 0, 500), dirPlane2, new Vector3(0, 0, 1)); // make loft TopoShapeGroup tsg = new TopoShapeGroup(); tsg.Add(newWire1); tsg.Add(newWire2); TopoShape loft = GlobalInstance.BrepTools.MakeLoft(tsg, false); context.ShowGeometry(loft); return(true); }
public override bool Run(FeatureContext context) { TopoShape box = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 100, 100)); context.ShowGeometry(box); TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(box); MessageBox.Show(String.Format("Area: {0}", property.SolidVolume())); return(true); }
public override bool Run(FeatureContext context) { TopoShape arc = GlobalInstance.BrepTools.MakeEllipseArc(Vector3.ZERO, 100, 50, 45, 270, Vector3.UNIT_Z); context.ShowGeometry(arc); TopoShapeProperty property = new TopoShapeProperty(); property.SetShape(arc); double length = property.EdgeLength(); MessageBox.Show(String.Format("Length: {0}", length)); return(true); }
public override bool Run(FeatureContext context) { if (m_Object == null) { TopoShape sphere = GlobalInstance.BrepTools.MakeSphere(Vector3.ZERO, 10); fs = new FaceStyle(); m_Object = context.ShowGeometry(sphere); m_Object.SetFaceStyle(fs); } else { context.ShowSceneNode(m_Object); } m_RenderView = context.RenderView; m_RenderView.RenderTick += new AnyCAD.Presentation.RenderEventHandler(DancingBall_RenderTick); return(false); }
public override bool Run(FeatureContext context) { TopoShape rect = GlobalInstance.BrepTools.MakeRectangle(100, 50, 10, Coordinate3.UNIT_XYZ); rect = GlobalInstance.BrepTools.MakeFace(rect); TopoShape rect2 = GlobalInstance.BrepTools.MakeRectangle(90, 40, 9, Coordinate3.UNIT_XYZ); rect2 = GlobalInstance.BrepTools.MakeFace(rect2); rect2 = GlobalInstance.BrepTools.Translate(rect2, new Vector3(5, 5, 0)); var cut = GlobalInstance.BrepTools.BooleanCut(rect, rect2); var body = GlobalInstance.BrepTools.Extrude(cut, 100, Vector3.UNIT_Z); context.ShowGeometry(body); return(true); }
public override bool Run(FeatureContext context) { TopoShape box1 = GlobalInstance.BrepTools.MakeBox(Vector3.ZERO, Vector3.UNIT_Z, new Vector3(100, 100, 100)); TopoShape box2 = GlobalInstance.BrepTools.MakeBox(new Vector3(0, 0, -100), Vector3.UNIT_Z, new Vector3(100, 100, 100)); TopoShapeGroup group = new TopoShapeGroup(); group.Add(box1); group.Add(box2); TopoShape compound = GlobalInstance.BrepTools.MakeCompound(group); RepairTools repairTool = new RepairTools(); TopoShape glue = repairTool.GlueFaces(compound, 0.00001f, true); //TopoShape newBody = repairTool.RemoveExtraEdges(glue); context.ShowGeometry(glue); return(true); }
public override bool Run(FeatureContext context) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter = "STL (*.stl)|*.stl|IGES (*.igs;*.iges)|*.igs;*.iges|STEP (*.stp;*.step)|*.stp;*.step|BREP (*.brep)|*.brep|All Files(*.*)|*.*"; if (DialogResult.OK != dlg.ShowDialog()) { return(false); } context.RenderView.RenderTimer.Enabled = false; TopoShape shape = GlobalInstance.BrepTools.LoadFile(new AnyCAD.Platform.Path(dlg.FileName)); context.RenderView.RenderTimer.Enabled = true; MessageBox.Show("loaded"); if (shape != null) { //context.ShowGeometry(shape, new ElementId(100)); //GlobalInstance.BrepTools.SaveFile(shape, new Path(dlg.FileName + ".brep")); AABox bbox = shape.GetBBox(); Vector3 size = bbox.Size(); Vector3 start = new Vector3(bbox.MinPt.X - 10, bbox.MinPt.Y + size.Y * 0.5f, bbox.MinPt.Z - 10); TopoShape boxShape = GlobalInstance.BrepTools.MakeBox(start, Vector3.UNIT_Z, new Vector3(size.X + 20, size.Y * 0.25f, size.Z + 20)); shape = GlobalInstance.BrepTools.BooleanCut(shape, boxShape); MessageBox.Show("cut!"); var groups = GlobalInstance.TopoExplor.ExplorSubShapes(shape); for (int ii = 0, len = groups.Size(); ii < len; ++ii) { shape = groups.GetAt(ii); var node = context.ShowGeometry(shape, new ElementId(100)); var fs = new FaceStyle(); fs.SetColor(ii * 100, 0, ii + 200); node.SetFaceStyle(fs); } } return(true); }