public static TopoDSShape RebuildFaces(TopoDSShape face) { if (face == null) { return(null); } TopoDSShape shape = null; if (face.ShapeType == TopAbsShapeEnum.TopAbs_SHELL) { shape = GeomUtils.ExtractFaces(face)[0]; } else { if (face.ShapeType == TopAbsShapeEnum.TopAbs_COMPOUND || face.ShapeType == TopAbsShapeEnum.TopAbs_FACE) { var faces = GeomUtils.ExtractFaces(face); TopoDSShape finalShape = faces[0]; for (int i = 1; i < faces.Count; i++) { var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(faces[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } shape = finalShape; } } return(shape); }
public override void OnActivate() { Inputs[InputNames.GeometricSolverPipe].Send(NotificationNames.DisableAll); var uiBuilder = ActionsGraph[InputNames.UiBuilderInput].Get <UiBuilder>(); var sketchControl = uiBuilder.GetItemAtPath("Ribbon/Modelling/Sketch/Sketch"); _sketchButton = (ISketchButton)sketchControl; if (Document.Root.Get <DocumentContextInterpreter>().ActiveSketch != -1) { var sketchNode = Document.Root[Document.Root.Get <DocumentContextInterpreter>().ActiveSketch]; // rebuild sketch faces sketchNode.Children[2].Set <MeshTopoShapeInterpreter>().Shape = null; var results = AutoGroupLogic.BuildAutoFaces(sketchNode, Document); Document.Transact(); if (results.Count > 0) { TopoDSShape finalShape = results[0]; // if there is more than one shape on the sketch, we need to sew the faces resulted from BuildAutoFaces for (int i = 1; i < results.Count; i++) { if (results[i] == null) { continue; } var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(results[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } sketchNode.Children[2].Set <MeshTopoShapeInterpreter>().Shape = finalShape; // we need to set transparency to 1 (don't show) before we set it to hidden sketchNode.Set <DrawingAttributesInterpreter>().Transparency = 1; sketchNode.Set <DrawingAttributesInterpreter>().Visibility = ObjectVisibility.Hidden; } int index; NodeUtils.SetSketchTransparency(Document, sketchNode, NodeUtils.SketchHas3DApplied(Document, sketchNode, out index) ? ObjectVisibility.Hidden : ObjectVisibility.ToBeDisplayed); } Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.SetPlane, new DataPackage(null)); Document.Root.Get <DocumentContextInterpreter>().ActiveSketch = -1; RemoveHighlightCurrentSketchNodes(); Document.Commit("reset active sketch"); _sketchButton.Unblock(); if (ActionsGraph.PendingAction != null && ActionsGraph.PendingAction.Name == ModifierNames.None) { Inputs[InputNames.SelectionContainerPipe].Send(NotificationNames.SwitchSelectionMode, TopAbsShapeEnum.TopAbs_FACE); } ActionsGraph.SwitchAction(ModifierNames.None); }
private static TopoDSShape MakeSew(TopoDSShape path, TopoDSShape profile) { var sewing = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sewing.Add(profile); sewing.Add(path); MessageProgressIndicator messg = new MessageProgressIndicator(); sewing.Perform(messg); return(sewing.SewedShape); }
public static TopoDSShape RebuildSketchFace(Node sketchNode, Document document) { TopoDSShape finalShape = null; var results = BuildAutoFaces(sketchNode, document); if (results.Count > 0) { finalShape = results[0]; for (int i = 1; i < results.Count; i++) { var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(results[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } } return(finalShape); }
public override bool Execute() { var point = Dependency[0].RefTransformedPoint3D; var wires = GetConstraintWires(point); TopoDSShape finalShape = wires[0]; for (int i = 1; i < wires.Count; i++) { var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(wires[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } Shape = finalShape; return(true); }
public override bool Execute() { if (Dependency[0].ReferenceBuilder.FunctionName != FunctionNames.LineTwoPoints) { return(false); } var firstPoint = Dependency[0].ReferenceBuilder.Dependency[0].RefTransformedPoint3D; var secondPoint = Dependency[0].ReferenceBuilder.Dependency[1].RefTransformedPoint3D; if (firstPoint.IsEqual(secondPoint)) { return(false); } var wires = GetConstraintWires(firstPoint, secondPoint); if (wires.Count == 0) { return(false); } TopoDSShape finalShape = wires[0]; for (int i = 1; i < wires.Count; i++) { var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(wires[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } Shape = finalShape; return(true); }
public static bool Read(TopoDSShape Sh, string File, BRepBuilder B, MessageProgressIndicator PR) { return(BRepTools_ReadEBEE9A3E(Sh.Instance, File, B.Instance, PR.Instance)); }
public static bool Write(TopoDSShape Sh, string File, MessageProgressIndicator PR) { return(BRepTools_Write4AF8BC88(Sh.Instance, File, PR.Instance)); }
public override bool Execute() { var axis = Dependency[1].ReferedShape; var angle = Dependency[2].Real / 180.0 * Math.PI; var revolvedNode = Dependency[0].ReferenceBuilder.Node; TopoDSShape originalShape = Dependency[0].ReferedShape; var sketchShapes = new List <Node>(); var nodesOnSketch = new List <Node>(); var sketchNode = NodeBuilderUtils.FindSketchNode(revolvedNode); var document = sketchNode.Root.Get <DocumentContextInterpreter>().Document; nodesOnSketch.AddRange(NodeUtils.GetSketchNodes(sketchNode, document, true)); if (revolvedNode.Get <FunctionInterpreter>().Name == FunctionNames.Sketch) { var face = revolvedNode.Children[2].Get <MeshTopoShapeInterpreter>().Shape; originalShape = AutoGroupLogic.RebuildFaces(face); } else { foreach (var node in nodesOnSketch) { if (node.Get <FunctionInterpreter>().Name != FunctionNames.Point && node.Index != Dependency[1].ReferenceBuilder.Node.Index) { sketchShapes.Add(node); } } } if (sketchShapes.Count > 0) { var shapes = new List <TopoDSShape>(); foreach (var node in sketchShapes) { var nb = new NodeBuilder(node); var tempShape = MakeRevolve(axis, nb.Shape, angle); if (tempShape != null) { shapes.Add(tempShape); } } TopoDSShape finalShape = null; if (shapes.Count > 0) { finalShape = shapes[0]; for (int i = 1; i < shapes.Count; i++) { if (shapes[i] == null) { continue; } var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(shapes[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } Shape = finalShape; foreach (var node in nodesOnSketch) { NodeUtils.Hide(node); } return(true); } } if (originalShape == null) { return(false); } Shape = MakeRevolve(axis, originalShape, angle); if (Shape == null) { return(false); } // Hide the referenece shape //NodeUtils.Hide(Dependency[0].Reference); foreach (var node in nodesOnSketch) { NodeUtils.Hide(node); } return(true); }
public void Perform(MessageProgressIndicator thePI) { BRepBuilderAPI_Sewing_Perform346F5010(Instance, thePI.Instance); }
public override bool Execute() { // NodeUtils.UpdateSketches(Dependency[0].ReferenceBuilder.Node, this.Builder); // Get the extrusion referenece shape, height and extrusion type var sketchNode = Dependency[0].ReferenceBuilder.Node; if (sketchNode == null) { return(false); } TopoDSShape face = null; if (sketchNode != null) { face = sketchNode.Children[2].Get <MeshTopoShapeInterpreter>().Shape; } var rootNode = Parent.Root; var shapes = AutoGroupLogic.BuildAutoFaces(sketchNode, rootNode.Get <DocumentContextInterpreter>().Document);// ?? face; TopoDSShape finalShape = null; if (shapes.Count > 0) { finalShape = shapes[0]; for (int i = 1; i < shapes.Count; i++) { if (shapes[i] == null) { continue; } var sew = new BRepBuilderAPISewing(1.0e-06, true, true, true, false); sew.Add(finalShape); sew.Add(shapes[i]); var messg = new MessageProgressIndicator(); sew.Perform(messg); finalShape = sew.SewedShape; } } if (finalShape == null) { finalShape = face; } var height = Dependency[2].Real; var extrusionType = Dependency[1].Integer; // Don't allow 0 height if (Math.Abs(height) < Precision.Confusion) { return(false); } // Build the extruded shape TopoDSShape resultShape = extrusionType == (int)ExtrusionTypes.MidPlane ? ExtrudeMidPlane(finalShape, height) : ExtrudeToDepth(finalShape, height); Shape = resultShape; return(true); }