public override void Run(RenderControl renderer) { string fileName = GetResourcePath("Holes.stp"); var shape = StepIO.Open(fileName); if (shape == null) { return; } renderer.ShowShape(shape, Vector3.LightGray); var bbox = shape.GetBBox(); var shape2 = ShapeBuilder.MakeBox(new GAx2(bbox.CornerMax(), GP.DZ()), 100, 100, 10); renderer.ShowShape(shape2, Vector3.LightGray); ExtremaShapeShape ess = new ExtremaShapeShape(); if (!ess.Initialize(shape, shape2, 0.001)) { return; } var pt1 = ess.GetPointOnShape1(0); var pt2 = ess.GetPointOnShape2(0); var line = SketchBuilder.MakeLine(pt1, pt2); renderer.ShowShape(line, Vector3.Red); }
public override bool Execute(UICommandContext ctx) { var dlg = new OpenFileDialog(); dlg.Filter = "STEP Files(*.step;*.stp)|*.step;*.stp"; if (dlg.ShowDialog() == DialogResult.OK) { var shape = StepIO.Open(dlg.FileName); if (shape != null) { var transaction = new UndoTransaction(ctx.Document); transaction.Start(this.Name); var shapeElement = new ShapeElement(); shapeElement.SetName(ExtractName(dlg.SafeFileName)); ctx.Document.AddElement(shapeElement); shapeElement.SetMaterialId(ctx.DefaultMaterialId); shapeElement.SetShape(shape); ctx.ShowElement(shapeElement); transaction.Commit(); ctx.RequestUpdate(); } } return(true); }
public override void Run(RenderControl renderer) { string fileName = GetResourcePath("Holes.stp"); var shape = StepIO.Open(fileName); if (shape == null) { return; } var face = shape.FindChild(EnumTopoShapeType.Topo_FACE, 148); var surface = new ParametricSurface(face); var wireExp = new WireExplor(face); var wires = wireExp.GetInnerWires(); foreach (var wire in wires) { // Show wire renderer.ShowShape(wire, Vector3.Red); var curve = new ParametricCurve(wire); var paramList = curve.SplitByUniformLength(1, 0.01); var lines = new SegmentsSceneNode((uint)paramList.Count, Vector3.Green, 2); uint idx = 0; foreach (var p in paramList) { var pt = curve.Value(p); var pointSur = new ExtremaPointSurface(); if (pointSur.Initialize(surface, pt, GP.Resolution(), GP.Resolution())) { var uv = pointSur.GetParameter(0); var normal = surface.GetNormal(uv.X(), uv.Y()); lines.SetPositions(idx++, Vector3.From(pt), Vector3.From(pt.XYZ().Added(normal.XYZ()))); } } lines.UpdateBoundingBox(); renderer.ShowSceneNode(lines); } // Show face var faceMaterial = MeshStandardMaterial.Create("pbr.face"); faceMaterial.SetColor(Vector3.LightGray); faceMaterial.SetFaceSide(EnumFaceSide.DoubleSide); var faceNode = BrepSceneNode.Create(face, faceMaterial, null); faceNode.SetDisplayFilter(EnumShapeFilter.Face); renderer.ShowSceneNode(faceNode); }
public override void Run(RenderControl render) { string fileName = GetResourcePath("models/hole.STEP"); var shape = StepIO.Open(fileName); if (shape == null) { return; } var face = shape.FindChild(EnumTopoShapeType.Topo_FACE, 7); var wireExp = new WireExplor(face); var wires = wireExp.GetInnerWires(); foreach (var wire in wires) { render.ShowShape(wire, Vector3.Red); } render.ShowShape(shape, Vector3.LightGray); }
private void stepToolStripMenuItem1_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "STEP (*.stp;*.step)|*.stp;*.step"; if (dialog.ShowDialog() != DialogResult.OK) { return; } var shape = StepIO.Open(dialog.FileName); if (shape == null) { return; } mRenderView.ShowShape(shape, new Vector3(0.8f)); mRenderView.ZoomAll(); StlIO.Save(shape, dialog.FileName + ".stl"); }
public override void Run(RenderControl renderer) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Filter = "STEP (*.stp;*.step)|*.stp;*.step"; if (dialog.ShowDialog() != DialogResult.OK) { return; } var shape = StepIO.Open(dialog.FileName); if (shape == null) { return; } var shapeExplor = new ShapeExplor(); shapeExplor.AddShape(shape); shapeExplor.Build(); var edgeCount = shapeExplor.GetEdgeCount(); for (uint ii = 0; ii < edgeCount; ++ii) { var edge = shapeExplor.GetEdge(ii); if (edge.GetCurveType() == EnumCurveType.CurveType_Line) { renderer.ShowShape(edge.GetShape(), Vector3.Blue); } else { renderer.ShowShape(edge.GetShape(), Vector3.Red); } } }