public override void OnActivate() { base.OnActivate(); var mouseCursorInput = ActionsGraph[InputNames.MouseCursorInput]; mouseCursorInput.Send(NotificationNames.SetResourceManager, MetaActionResource.ResourceManager); mouseCursorInput.Send(NotificationNames.SetCursorName, "arcRSE.cur"); var sketchBuilder = new SketchCreator(Document, false); sketchNode = sketchBuilder.CurrentSketch; if (sketchNode == null) { ActionsGraph.SwitchAction(ModifierNames.StartSketch, ModifierNames.ArcStartEndRadius); return; } normalOnPlane = sketchBuilder.NormalOnSketch.Value.GpAxis; sketchNode = sketchBuilder.CurrentSketch; // Block drawing plane Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.Suspend); ActionsGraph[InputNames.CoordinateParser].Send(CoordinatateParserNames.SetStage, ParserStage.Unknown); Reset(); }
public override gpAx2 GetPointLocation(int index) { var transform = Node.Get <TransformationInterpreter>().CurrTransform; var ax2 = new gpAx2(); ax2.Location = Dependency[0].TransformedPoint3D.GpPnt; var circleCenter = Dependency[0].TransformedPoint3D.GpPnt; var circleAxis = new gpAx1(); circleAxis.Location = (Dependency[0].TransformedPoint3D.GpPnt); var pointOnCircle = GetPointOnCircle(circleAxis, Dependency[1].Real, transform); var radius = pointOnCircle.Distance(circleCenter); var leftArrowVector = new gpVec(circleCenter, pointOnCircle); leftArrowVector.Normalize(); leftArrowVector.Multiply(radius + DistanceToObject); var leftArrowLocation = circleCenter.Translated(leftArrowVector); var rightArrowVector = leftArrowVector.Reversed; var rightArrowLocation = circleCenter.Translated(rightArrowVector); var topArrowVector = new gpVec(leftArrowVector.XYZ); topArrowVector.Cross(new gpVec(ax2.Direction)); topArrowVector.Normalize(); topArrowVector.Multiply(radius + DistanceToObject); var topArrowLocation = circleCenter.Translated(topArrowVector); var bottomArrowVector = topArrowVector.Reversed; var bottomArrowLocation = circleCenter.Translated(bottomArrowVector); switch (index) { case 0: ax2.Location = (leftArrowLocation); ax2.XDirection = (new gpDir(leftArrowVector)); return(ax2); case 1: ax2.Location = (topArrowLocation); ax2.XDirection = (new gpDir(topArrowVector)); return(ax2); case 2: ax2.Location = (rightArrowLocation); ax2.XDirection = (new gpDir(rightArrowVector)); return(ax2); case 3: ax2.Location = (bottomArrowLocation); ax2.XDirection = (new gpDir(bottomArrowVector)); return(ax2); default: return(null); } }
public override bool Execute() { // Get the values of dimension and position attributes var firstPoint = Dependency[0].TransformedPoint3D; var secondPoint = Dependency[1].TransformedPoint3D; var thirdPoint = Dependency[2].TransformedPoint3D; var wire = OccShapeCreatorCode.BuildRectangle(firstPoint, secondPoint, thirdPoint); if ((wire == null) || (wire.IsNull)) { return(false); } // Make also the shape axis before the shape regeneration var axis = new gpAx1 { Location = firstPoint.GpPnt }; Axis = axis; Shape = wire; return(true); }
public static Vector3D AxisToVector(gpAx1 axis) { var direction = axis.Direction.XYZ; var result = new Vector3D(direction.X, direction.Y, direction.Z); return(result); }
private void BuildAndEnterSketch(Document document) { var sketchCreator = new SketchCreator(document); var currentSketch = sketchCreator.CurrentSketch; var sketchNodeBuilder = new NodeBuilder(currentSketch); Document.Transact(); Log.InfoFormat("StartSketch - Command line input"); var firstvector = new gpDir(Points[1].GpPnt.X - Points[0].GpPnt.X, Points[1].GpPnt.Y - Points[0].GpPnt.Y, Points[1].GpPnt.Z - Points[0].GpPnt.Z); var secondvector = new gpDir(Points[2].GpPnt.X - Points[0].GpPnt.X, Points[2].GpPnt.Y - Points[0].GpPnt.Y, Points[2].GpPnt.Z - Points[0].GpPnt.Z); var normal = firstvector.Crossed(secondvector); var _normalOnPlane = new gpAx1(Points[0].GpPnt, normal); var sketchAx2 = new gpAx2(); sketchAx2.Axis = (_normalOnPlane); var plane = new gpPln(new gpAx3(sketchAx2)); Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.SetPlane, plane); sketchNodeBuilder[0].Axis3D = new Axis(sketchNodeBuilder[0].Axis3D.Location, new Point3D(new gpPnt(_normalOnPlane.Direction.XYZ))); HighlightCurrentSketchNodes(sketchNodeBuilder.Node); NodeBuilderUtils.HidePlanes(Document); Document.Commit("sketch created"); AddNodeToTree(sketchNodeBuilder.Node); Document.Transact(); Document.Root.Get <DocumentContextInterpreter>().ActiveSketch = sketchNodeBuilder.Node.Index; _sketchButton.Block(); Document.Commit("Started editing sketch"); }
public override void OnActivate() { ActionsGraph[InputNames.CoordinateParser].Send(CoordinatateParserNames.SetStage, ParserStage.Unknown); //if (Document.Root.Children.Count == 0) //{ // sketchNode = CreateDefaultSketchNode(Document); //} //else //{ // var currentSketchNode = Document.Root[Document.Root.Get<DocumentContextInterpreter>().ActiveSketch]; // sketchNode = currentSketchNode; //} var sketchBuilder = new SketchCreator(Document, false); sketchNode = sketchBuilder.CurrentSketch; if (sketchNode == null) { ActionsGraph.SwitchAction(ModifierNames.StartSketch, ModifierNames.Line3D); return; } Document.Transact(); SetupHinter(sketchNode); normalOnPlane = sketchNode.Children[1].Get <Axis3DInterpreter>().GpAxis; var pointBuilder = GetSketchNode(Document, new Point3D(), sketchNode); pointBuilder.Visibility = ObjectVisibility.Hidden; var builder = new NodeBuilder(Document, FunctionNames.LineTwoPoints); builder[0].Reference = pointBuilder.Node; builder[1].Reference = pointBuilder.Node; builder.ExecuteFunction(); AddNodeToTree(builder.Node); Reset(); Hinter2D.Populate(); }
public override void OnActivate() { base.OnActivate(); var sketchBuilder = new SketchCreator(Document, false); sketchNode = sketchBuilder.CurrentSketch; if (sketchNode == null) { ActionsGraph.SwitchAction(ModifierNames.StartSketch, ModifierNames.ArcCenterStartEnd); return; } normalOnPlane = sketchBuilder.NormalOnSketch.Value.GpAxis; sketchNode = sketchBuilder.CurrentSketch; // Block drawing plane Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.Suspend); ActionsGraph[InputNames.CoordinateParser].Send(CoordinatateParserNames.SetStage, ParserStage.Unknown); var pointBuilder = GetSketchNode(Document, new Point3D(), sketchNode); var pointBuilder2 = GetSketchNode(Document, new Point3D(0.0, 0, 0), sketchNode); var pointBuilder3 = GetSketchNode(Document, new Point3D(0, 0.0, 0), sketchNode); var builder = new NodeBuilder(Document, FunctionNames.Arc); builder[0].Reference = pointBuilder.Node; builder[1].Reference = pointBuilder2.Node; builder[2].Reference = pointBuilder3.Node; builder.ExecuteFunction(); Inputs[InputNames.UiElementsItem].Send(NotificationNames.RefreshPropertyTab, builder.Node); Reset(); }
public override void OnActivate() { base.OnActivate(); var sketchBuilder = new SketchCreator(Document, false); sketchNode = sketchBuilder.CurrentSketch; if (sketchNode == null) { ActionsGraph.SwitchAction(ModifierNames.StartSketch, ModifierNames.DrawCircle); return; } Inputs[InputNames.SelectionContainerPipe].Send(NotificationNames.Disable); normalOnPlane = sketchBuilder.NormalOnSketch.Value.GpAxis; var trsf = sketchBuilder.CurrentSketch.Get <TransformationInterpreter>().CurrTransform; normalOnPlane = normalOnPlane.Transformed(trsf); sketchNode = sketchBuilder.CurrentSketch; Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.Suspend); var pointBuilder = GetSketchNode(Document, new Point3D(), sketchNode); pointBuilder.Visibility = ObjectVisibility.Hidden; builder = new NodeBuilder(Document, FunctionNames.Circle); builder[0].Reference = pointBuilder.Node; builder[1].Real = 0.0; builder.Visibility = ObjectVisibility.Hidden; builder.ExecuteFunction(); AddNodeToTree(builder.Node); ActionsGraph[InputNames.CoordinateParser].Send(CoordinatateParserNames.SetStage, ParserStage.Unknown); Reset(); }
public void RotationAroundAxisWithoutPivotSet() { var aPoint = new Point3D(10, 10, 0); var axisPoint = new Point3D(10, 0, 0); var rotationAxis = new gpAx1(axisPoint.GpPnt, new gpDir(0, 0, 1)); var document = TestUtils.DefaultsSetup(); document.Transact(); var sketchCreator = new SketchCreator(document, false); var sketchNode = sketchCreator.BuildSketchNode(); var builder = new NodeBuilder(document, FunctionNames.Point); builder[0].Reference = sketchNode; builder[1].TransformedPoint3D = aPoint; Assert.IsTrue(builder.ExecuteFunction()); var interpreter = builder.Node.Set <TransformationInterpreter>(); // Disable parent notification interpreter.Disable(); interpreter.RotateAroundAxis(rotationAxis, 90); builder.ExecuteFunction(); document.Commit("rotations done"); Assert.IsTrue(Math.Abs(0 - interpreter.CurrTransform.Value(1, 4)) < 0.1, "incorrect rotation"); }
public static Node RotateNode(NodeBuilder nodeBuilder, Document document, gpAx1 axis, double angle) { if (FunctionNames.GetSolids().Contains(nodeBuilder.FunctionName)) { RotateSolids(nodeBuilder, axis, angle); return(null); } var sketchNode = nodeBuilder.Dependency[0].ReferenceBuilder.Node; var nodes = GetSketchNodes(sketchNode, document, true); foreach (var node in nodes) { var nb = new NodeBuilder(node); if (nb.FunctionName != FunctionNames.Point) { RotateSketchNode(nb, axis, angle); } //var transformInterpreter = node.Get<TransformationInterpreter>(); //transformInterpreter.RotateAroundAxis(axis, angle); //var nb1 = new NodeBuilder(node); //if (nb1.Node != null) // nb1.ExecuteFunction(); } return(sketchNode); }
public void CircularPatternTestWithoutPivotSet() { var aPoint = new Point3D(10, 10, 0); var axisPoint = new Point3D(10, 0, 0); var rotationAxis = new gpAx1(axisPoint.GpPnt, new gpDir(0, 0, 1)); var document = TestUtils.DefaultsSetup(); document.Transact(); var sketchCreator = new SketchCreator(document, false); var sketchNode = sketchCreator.BuildSketchNode(); var pointBuilder = new NodeBuilder(document, FunctionNames.Point); pointBuilder[0].Reference = sketchNode; pointBuilder[1].TransformedPoint3D = aPoint; Assert.IsTrue(pointBuilder.ExecuteFunction()); var interpreter = pointBuilder.Node.Get <TransformationInterpreter>(); interpreter.ApplyGeneralCircularPattern(rotationAxis, 180, 10); document.Commit("rotations done"); Assert.IsTrue(Math.Abs(10 - interpreter.CurrTransform.Value(1, 4)) < 0.1, "incorrect rotation base point"); Assert.IsTrue(Math.Abs(-10 - interpreter.CurrTransform.Value(2, 4)) < 0.1, "incorrect rotation base point"); Assert.IsTrue(Math.Abs(10 - interpreter.CurrTransform.Value(3, 4)) < 0.1, "incorrect rotation base point"); Assert.IsTrue(Math.Abs(10 - interpreter.Pivot.X) < 0.1, "incorrect rotation pivot"); Assert.IsTrue(Math.Abs(-10 - interpreter.Pivot.Y) < 0.1, "incorrect rotation pivot"); Assert.IsTrue(Math.Abs(10 - interpreter.Pivot.Z) < 0.1, "incorrect rotation pivot"); }
public int Cone(double x, double y, double z, double radius1, double radius2, double height, double angle) { var axis = new gpAx1(new gpPnt(x, y, z), new gpDir()); var node = TreeUtils.AddCone(Document, axis, radius1, radius2, height, GeomUtils.DegreesToRadians(angle)); return(node.Index); }
private bool IsNodeValid(int dependencyIndex, Node node) { var builder = new NodeBuilder(node); if (dependencyIndex != 1) { return(true); } if (!_collection.HasConcept(builder.FunctionName)) { return(false); } if (!_collection.IsRelatedWith(builder.FunctionName, ConceptNames.Axis)) { return(false); } try { _axis = GeomUtils.ExtractAxis(builder.Shape); Ensure.IsNotNull(_axis); return(true); } catch (Exception) { return(false); } }
public void CheckTranslateValueTest() { var colomnAxis = new gpAx1(new gpPnt(0, 0, 0), new gpDir(0, 1, 0)); var rowAxis = new gpAx1(new gpPnt(0, 0, 0), new gpDir(1, 0, 0)); var document = TestUtils.DefaultsSetup(); document.Transact(); var sketchCreator = new SketchCreator(document, false); var sketchNode = sketchCreator.BuildSketchNode(); var pointBuilder = TestUtils.Point(document, sketchNode, new Point3D(10, 10, 0)); Assert.IsTrue(pointBuilder.ExecuteFunction()); var interpreter = pointBuilder.Node.Get <TransformationInterpreter>(); interpreter.ApplyGeneralArrayPattern(rowAxis, colomnAxis, 5, 5); document.Commit("Array Pattern done"); Assert.IsTrue(Math.Abs(15 - interpreter.CurrTransform.Value(1, 4)) < 0.1, "incorrect array pattern base point"); Assert.IsTrue(Math.Abs(15 - interpreter.CurrTransform.Value(2, 4)) < 0.1, "incorrect array pattern base point"); Assert.IsTrue(Math.Abs(0 - interpreter.CurrTransform.Value(3, 4)) < 0.1, "incorrect array pattern base point"); }
private static Node AddBox(NodeBuilder builder, gpAx1 axis, Point3D secondPoint, double height) { builder[0].Axis3D = new Axis(axis); builder[1].TransformedPoint3D = secondPoint; builder[2].Real = height; return(!builder.ExecuteFunction() ? null : builder.Node); }
/// <summary> /// Build a cicle knowing the axis that describe the center (location and direction) /// and also the radius value /// </summary> public static TopoDSFace CreateCircle(gpAx1 centerAxis, double radius) { var wire = CreateWireCircle(centerAxis, radius); var face = new BRepBuilderAPIMakeFace(wire, true).Face; //face.Locat return(face); }
public int Torus(double x, double y, double z, double radius1, double radius2) { var axis = new gpAx1(new gpPnt(x, y, z), new gpDir()); var node = TreeUtils.AddTorus(Document, axis, radius1, radius2); return(node.Index); }
private void DrawRectangle(Document document, gpAx1 axis, Point3D first) { var builder = new NodeBuilder(document, FunctionNames.Rectangle); ApplyAnimationSettings(builder.Node); builder[0].Axis3D = new Axis(axis); builder[1].TransformedPoint3D = first; builder.ExecuteFunction(); }
/// <summary> /// Builds a circle with the parameters passed and extracts a point locted on the circle /// </summary> protected static gpPnt GetPointOnCircle(gpAx1 axis, double radius, gpTrsf trsf) { var centerCoord = new gpAx2(); centerCoord.Axis = (axis); var circle = new GeomCircle(centerCoord, radius); // Get the first point on the circle's parametric curve return(circle.Value(circle.FirstParameter));//.Transformed(trsf); }
public static Node AddTorus(Document document, gpAx1 centerAxis, double radius1, double radius2) { var builder = new NodeBuilder(document, FunctionNames.Torus, FunctionNames.Torus); builder[0].Axis3D = new Axis(centerAxis); builder[1].Real = radius1; builder[2].Real = radius2; return(!builder.ExecuteFunction() ? null : builder.Node); }
public int Box(double x, double y, double z, double x1, double y1, double z1, double x3, double y3, double z3, double height) { var dir = new gpDir(x1, y1, z1); var axis = new gpAx1(new gpPnt(x, y, z), dir); var point3 = new Point3D(x3, y3, z3); var node = TreeUtils.AddBox(Document, axis, point3, height); return(node.Index); }
/// <summary> /// Builds a box receiving three points that describe the base rectangle and one being the height /// </summary> /// <param name = "axis"></param> /// <param name = "secondPoint"></param> /// <param name = "height"></param> /// <returns></returns> private static TopoDSShape MakeBox(gpAx1 axis, Point3D secondPoint, double height) { var face = OccShapeCreatorCode.BuildRectangle(axis.Location, secondPoint.GpPnt, axis.Direction); // Get the direction var dir = GeomUtils.ExtractDirection(face); var vector = new gpVec(dir); vector.Multiply(height); return(new BRepPrimAPIMakePrism(face, vector, false, true).Shape); }
public Mouse3DPosition(Point3D pnt, gpAx1 axis, bool mouseDown, bool shiftDown, bool controlDown, int initial2Dx, int initial2Dy, int clicks) { Point = pnt; MouseDown = mouseDown; ShiftDown = shiftDown; ControlDown = controlDown; Axis = axis; Initial2Dx = initial2Dx; Initial2Dy = initial2Dy; Clicks = clicks; }
public static void RotateSolids(NodeBuilder nodeBuilder, gpAx1 axis, double angle) { var transformInterpreter = nodeBuilder.Node.Get <TransformationInterpreter>(); transformInterpreter.RotateAroundAxis(axis, angle); var nb1 = new NodeBuilder(nodeBuilder.Node); if (nb1.Node != null) { nb1.ExecuteFunction(); } }
public void ApplyGeneralCircularPattern(gpAx1 axis, double angle, double heigth) { GeneralRotationWithoutPivot(axis, angle); var transformation = ConvertgpTrsfToMatrix3DTransform(); var heightToAdd = new gpVec(axis.Direction); heightToAdd.Normalize(); heightToAdd.Multiply(heigth); SetTranslationValuesAndPivot(ref transformation, new Vector3D(heightToAdd.X, heightToAdd.Y, heightToAdd.Z)); OnModified(); }
/// <summary> /// Build a cicle knowing the axis that describe the center (location and direction) /// and also the radius value /// </summary> public static TopoDSWire CreateWireCircle(gpAx1 centerAxis, double radius) { var centerCoord = new gpAx2 { Axis = (centerAxis) }; var circle = new gpCirc(centerCoord, radius); var edge = new BRepBuilderAPIMakeEdge(circle).Edge; var wire = new BRepBuilderAPIMakeWire(edge).Wire; return(wire); }
public override void Deserialize(AttributeData data) { // Read location var position = data.ReadAttributePoint3D("Position"); // Read direction var dx = data.ReadAttributeDouble("DX"); var dy = data.ReadAttributeDouble("DY"); var dz = data.ReadAttributeDouble("DZ"); GpAxis = new gpAx1(position.GpPnt, new gpDir(dx, dy, dz)); }
private void SetAxis(gpAx1 axis) { try { //BlockPlane._axis= axis; /*Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.SetPlane, new gpPln(axis.Location, axis.Direction())); * Inputs[InputNames.Mouse3DEventsPipe].Send(NotificationNames.Suspend);*/ } catch (Exception) { } }
public Mouse3DPosition(Mouse3DPosition mouse3D) { Point = new Point3D(mouse3D.Point.GpPnt); MouseDown = mouse3D.MouseDown; ShiftDown = mouse3D.ShiftDown; ControlDown = mouse3D.ControlDown; Axis = new gpAx1 { Direction = (mouse3D.Axis.Direction), Location = (mouse3D.Axis.Location) }; Initial2Dx = mouse3D.Initial2Dx; Initial2Dy = mouse3D.Initial2Dy; Clicks = 1; }
public override gpAx2 GetPointLocation(int index) { var ax2 = new gpAx2(); var axis = new gpAx1(); var point = new gpPnt(); var transform = NodeBuilderUtils.GetGlobalTransformation(new NodeBuilder(NodeBuilderUtils.FindSketchNode(Node))); point = Dependency[0].Name == InterpreterNames.Reference ? Dependency[index].RefTransformedPoint3D.GpPnt : Dependency[index].TransformedPoint3D.GpPnt; axis.Location = (point); axis.Direction = axis.Direction.Transformed(transform); ax2.Axis = (axis); return(ax2); }