private void GetCacheItem(int index, gpTrsf mirrorTransform) { var node = _document.Root.Children[index]; var builder = new NodeBuilder(node); MirrorBuilder(builder, mirrorTransform); }
public override bool Execute() { var profile = Dependency[0].ReferedShape; var path = Dependency[1].ReferedShape; var profileLocation = profile.Location(); var profileTranslation = new gpTrsf(); profileTranslation.TranslationPart = (profileLocation.Transformation.TranslationPart.Reversed); var newProfileLocation = new TopLocLocation(profileTranslation); profile.Move(newProfileLocation); path.Move(newProfileLocation); var finalShape = MakeEvolve(path, profile); profile.Move(newProfileLocation.Inverted); path.Move(newProfileLocation.Inverted); Shape = finalShape; if (Shape == null) { return(false); } return(true); }
private static gpTrsf GetRotateXTrsf(double angle) { var rotateXTrsf = new gpTrsf(); rotateXTrsf.SetRotation(gp.OX, angle); return(rotateXTrsf); }
public static void TranslateSketchNode(NodeBuilder nodeBuilder, Point3D translateValue, Node sketchNode)//, gpTrsf translation) { if (nodeBuilder.FunctionName == FunctionNames.Point) { gpTrsf translation = new gpTrsf(); var sketchAxisLocation = NodeBuilderUtils.GetTransformedAxis(new NodeBuilder(sketchNode)).Location; var newValue = new Point3D(sketchAxisLocation.X + translateValue.X, sketchAxisLocation.Y + translateValue.Y, sketchAxisLocation.Z + translateValue.Z); translation.SetTranslation(sketchAxisLocation, newValue.GpPnt); nodeBuilder.Node.Set <TransformationInterpreter>().CurrTransform = translation; nodeBuilder.ExecuteFunction(); } else { var affectedPoints = GetPointNodes(nodeBuilder.Node); if (affectedPoints == null) { return; } var sketchAxisLocation = NodeBuilderUtils.GetTransformedAxis(new NodeBuilder(sketchNode)).Location; foreach (var point in affectedPoints) { var nb = new NodeBuilder(point); var oldValue = nb[1].TransformedPoint3D; var newValue = new Point3D(oldValue.X + translateValue.X, oldValue.Y + translateValue.Y, oldValue.Z + translateValue.Z); var translation = new gpTrsf(); translation.SetTranslation(sketchAxisLocation, newValue.GpPnt); nb.Node.Set <TransformationInterpreter>().CurrTransform = translation; nb.ExecuteFunction(); } } }
public void AllocDeallocSimpleTest() { //NaroMessage.Show("start test"); //Console.WriteLine("---- wrapper start test ----"); var watch = new Stopwatch(); watch.Start(); for (var i = 0; i < 300000; i++) { var pnt = new gpPnt(i, i, i); var pnt2 = new gpPnt(i + 10, i + 10, i + 10); var aEdge = new BRepBuilderAPIMakeEdge(pnt, pnt2).Edge; var wire = new BRepBuilderAPIMakeWire(aEdge).Wire; TopoDSShape shape = wire; new AISShape(shape); var pln = new gpPln(i + 10, i + 10, i + 10, i + 10); var geomPln = new GeomPlane(pln); var trsf = new gpTrsf(); geomPln.Transform(trsf); } watch.Stop(); //Console.WriteLine("---- wrapper end test - took {0} ms ----", watch.ElapsedMilliseconds); //NaroMessage.Show(String.Format("---- wrapper end test - took {0} ms ----", watch.ElapsedMilliseconds)); }
public void SetTransformationTestRotationAndTranslation() { var originBaseSketch = new gpPnt(1, 1, 0); var originSecondSketch = new gpPnt(10, 1, 0); var T = new gpTrsf(); var oldSystemAxis = new gpAx3(originBaseSketch, new gpDir(0, 0, 1)); var newSystemAxis = new gpAx3(originSecondSketch, new gpDir(1, 0, 0)); T.SetTransformation(oldSystemAxis, newSystemAxis); var point = new gpPnt(10, 3, 8).Transformed(T); var translationPart = new gpTrsf(); translationPart.SetTranslation(new gpPnt(0, 0, 0), point); gpTrsf mult1 = T.Inverted.Multiplied(translationPart); var try1 = new gpPnt(0, 0, 0).Transformed(mult1); // ok Assert.AreEqual(try1.X, 10); Assert.AreEqual(try1.Y, 3); Assert.AreEqual(try1.Z, 8); gpTrsf mult2 = translationPart.Multiplied(T.Inverted); var try2 = new gpPnt(0, 0, 0).Transformed(mult2); // nok Assert.AreEqual(try2.X, 17); Assert.AreEqual(try2.Y, -3); Assert.AreEqual(try2.Z, 1); }
public static gpTrsf ExtractPlaneMirrorTransform(gpPln plane) { var transform = new gpTrsf(); transform.SetMirror(plane.Position.Ax2); return(transform); }
private void GetRotateValue(ref object resultvalue) { var nb = new NodeBuilder(Parent); if (nb.FunctionName != FunctionNames.Sketch) { return; } var interpreter = Parent.Get <TransformationInterpreter>(); if (interpreter == null) { return; } var transformations = NodeBuilderUtils.GetTransformations(nb); var multiplied = new gpTrsf(); foreach (var trsf in transformations) { multiplied = multiplied.Multiplied(trsf); } var matr = multiplied.VectorialPart; // extract rotation from matrix }
public static gpTrsf ConvertCoordinatesToGlobalTransformation(gpTrsf currentAxisSystem, double X, double Y, double Z) { var currentTransformation = new gpTrsf(); currentTransformation.SetValues(1, 0, 0, X, 0, 1, 0, Y, 0, 0, 1, Z, _angularPrecision, _distancePrecision); return(ConvertToGlobalTransformation(currentAxisSystem, currentTransformation)); }
private static gpTrsf BuildTranslation(Point3D point1, Point3D point2) { var vector = new gpVec(point1.GpPnt, point2.GpPnt); var transformation = new gpTrsf(); transformation.SetTranslation(vector);//{Translation = vector}; return(transformation); }
private static void ApplyMatrixString(gpTrsf aTrans, IList <double> values) { aTrans.SetValues( values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7], values[8], values[9], values[10], values[11], Precision.Angular, Precision.Confusion); }
private static gpTrsf GetScaleTrsf(double scaleFactor) { var scaleTrsf = new gpTrsf { ScaleFactor = scaleFactor }; return(scaleTrsf); }
private static gpTrsf GetTranslateTrsf(Point3D transformedPosition) { var translateTrsf = new gpTrsf(); translateTrsf.SetTranslation(new gpVec(transformedPosition.X, transformedPosition.Y, transformedPosition.Z)); return(translateTrsf); }
/// <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); }
private AISShape AddToContext(NodeBuilder builder, TopoDSShape sourceShape, gpTrsf mirrorTransform) { var shape = new BRepBuilderAPITransform(sourceShape, mirrorTransform, true).Shape; var aisShape = new AISShape(shape); _context.Display(aisShape, false); _context.SetTransparency(aisShape, 0.8, false); ApplyColor(builder, aisShape); return(aisShape); }
/// <summary> /// Build a vector from the two pints, scale the vector with the desired value /// and calculate a transformation applied on the first point to generate where /// the second point should be. /// </summary> public static Point3D ScaleSegment(Point3D point1, Point3D point2, double scale) { var vector = new gpVec(point1.GpPnt, point2.GpPnt); vector.Scale(scale); var transformation = new gpTrsf(); transformation.SetTranslation(vector); // Apply the transformation on the vertex return(new Point3D(point1.GpPnt.Transformed(transformation))); }
private static double[] MatrixToList(gpTrsf aTrans) { var tranformData = new double[16]; for (var i = 1; i <= 3; i++) { for (var j = 1; j <= 4; j++) { tranformData[(i - 1) * 4 + (j - 1)] = aTrans.Value(i, j); } } return(tranformData); }
public void SetTransformationTestMultipleTrsf() { var originBaseSketch = new gpPnt(1, 1, 0); var originSecondSketch = new gpPnt(10, 1, 0); var T = new gpTrsf(); var oldSystemAxis = new gpAx3(originBaseSketch, new gpDir(0, 0, 1)); var newSystemAxis = new gpAx3(originSecondSketch, new gpDir(1, 0, 0)); T.SetTransformation(oldSystemAxis, newSystemAxis); var point = new gpPnt(10, 3, 8).Transformed(T); var translationPart = new gpTrsf(); translationPart.SetTranslation(new gpPnt(0, 0, 0), point); gpTrsf mult1 = T.Inverted.Multiplied(translationPart); var try1 = new gpPnt(0, 0, 0).Transformed(mult1); // ok: transformations needed to obtain global point (10, 3, 8) Assert.AreEqual(try1.X, 10); Assert.AreEqual(try1.Y, 3); Assert.AreEqual(try1.Z, 8); //reversed order doesn't work gpTrsf mult2 = translationPart.Multiplied(T.Inverted); var try2 = new gpPnt(0, 0, 0).Transformed(mult2); Assert.AreEqual(try2.X, 17); Assert.AreEqual(try2.Y, -3); Assert.AreEqual(try2.Z, 1); //translate entire 'object' var translation1 = new gpTrsf(); translation1.SetTranslation(new gpPnt(1, 1, 0), new gpPnt(7, 1, 0)); var multipleTrsfs = translation1.Multiplied(mult1); var try11 = new gpPnt(0, 0, 0).Transformed(multipleTrsfs); Assert.AreEqual(try11.X, 16); Assert.AreEqual(try11.Y, 3); Assert.AreEqual(try11.Z, 8); //reversed order doesn't work var multipleTrsfs2 = mult1.Multiplied(translation1); var try12 = new gpPnt(0, 0, 0).Transformed(multipleTrsfs2); Assert.AreEqual(try12.X, 10); Assert.AreEqual(try12.Y, 3); Assert.AreEqual(try12.Z, 14); }
protected static TopoDSShape ApplyEvolveOnShape(gpTrsf mirrorTransform, TopoDSShape sourceShape) { try { var myBRepTransformation = new BRepBuilderAPITransform(mirrorTransform); myBRepTransformation.Perform(sourceShape, true); return(myBRepTransformation.IsDone ? myBRepTransformation.Shape : null); } catch (Exception ex) { Log.Error("Error on making mirror: " + ex.Message); return(null); } }
public static gpTrsf ConvertToGlobalTransformation(gpTrsf currentAxisSystem, gpTrsf currentTransformation) { var transformedCoordinates = new gpTrsf(); transformedCoordinates = currentAxisSystem; transformedCoordinates.Multiply(currentTransformation); transformedCoordinates.SetValues( 1, 0, 0, transformedCoordinates.Value(1, 4), 0, 1, 0, transformedCoordinates.Value(2, 4), 0, 0, 1, transformedCoordinates.Value(3, 4), _angularPrecision, _distancePrecision ); return(transformedCoordinates); }
/// <summary> /// Make an extrusion starting from a shape until a height. /// </summary> /// <param name = "originalShape"></param> /// <param name = "height"></param> /// <returns></returns> private static TopoDSShape ExtrudeMidPlane(TopoDSShape originalShape, double height) { TopoDSShape prismShape = null; // Make the Extrusion if (originalShape != null) { try { // Get the Face to be extruded var face = originalShape;// OCTopoDS.Face(originalShape); // Get the direction var dir = GeomUtils.ExtractDirection(face); if (dir == null) { return(null); } // Build the translated shape var translationVector = new gpVec(dir); translationVector.Multiply(-1 * height / 2); var transformation = new gpTrsf(); transformation.SetTranslation(translationVector); var brepTrans = new BRepBuilderAPITransform(originalShape, transformation, false); var translatedShape = brepTrans.Shape; // Extract the face of the translated shape //baseEx.Init(translatedShape, TopAbsShapeEnum.TopAbs_FACE, TopAbsShapeEnum.TopAbs_SHAPE); //baseEx.Next(); var translatedFace = translatedShape;// OCTopoDS.Face(translatedShape); // Describe the height through a vector var vector = new gpVec(dir); vector.Multiply(height); // Make the prism prismShape = new BRepPrimAPIMakePrism(translatedFace, vector, false, true).Shape; } catch (Exception ex) { Log.Error("Error on extrude: " + ex.Message); return(null); } } return(prismShape); }
private void MirrorBuilder(NodeBuilder builder, gpTrsf mirrorTransform) { if (builder.Visibility == ObjectVisibility.Hidden) { return; } var sourceShape = builder.Shape; if (sourceShape == null) { return; } var aisShape = AddToContext(builder, sourceShape, mirrorTransform); _mirrorShapeList.Add(aisShape); }
public static gpTrsf GetRotateTrsf(Point3D rotateAngle) { var angle = DegreesToRadians(rotateAngle.X); var rotateXTrsf = GetRotateXTrsf(angle); angle = DegreesToRadians(rotateAngle.Y); var rotateYTrsf = GetRotateYTrsf(angle); angle = DegreesToRadians(rotateAngle.Z); var rotateZTrsf = GetRotateZTrsf(angle); var rotateTrsf = new gpTrsf(); rotateTrsf.Multiply(rotateZTrsf); rotateTrsf.Multiply(rotateYTrsf); rotateTrsf.Multiply(rotateXTrsf); return(rotateTrsf); }
private gpTrsf ExtractNodeTransform() { if (Shape == null) { return(null); } gpTrsf transform; var transformInter = Parent.Get <TransformationInterpreter>(); var baseTransform = new gpTrsf(); if (transformInter != null) { transform = transformInter.CurrTransform; baseTransform.Multiply(transform); } transform = baseTransform; return(transform); }
private static void ApplyTranslate(gpPnt currentLocation, Point3D increment, Node sketchNode) { var currentAxis = NodeBuilderUtils.GetTransformedAxis(new NodeBuilder(sketchNode)); var trsfCurrent = sketchNode.Get <TransformationInterpreter>().CurrTransform; var newPosition = new Point3D(currentAxis.Location.X + increment.X, currentAxis.Location.Y + increment.Y, currentAxis.Location.Z + increment.Z); var newSystemAxis = new gpAx3(newPosition.GpPnt, currentAxis.Direction); gpTrsf T = new gpTrsf(); T.SetDisplacement(new gpAx3(currentAxis.Location, currentAxis.Direction), newSystemAxis); trsfCurrent = T.Multiplied(trsfCurrent); sketchNode.Set <TransformationInterpreter>().CurrTransform = trsfCurrent; var nb = new NodeBuilder(sketchNode); nb.ExecuteFunction(); }
public void SetTransformationTestTranslationOnZ() { var originBaseSketch = new gpPnt(1, 1, 0); var originSecondSketch = new gpPnt(2, 2, 10); var T = new gpTrsf(); var oldSystemAxis = new gpAx3(originBaseSketch, new gpDir(0, 0, 1)); var newSystemAxis = new gpAx3(originSecondSketch, new gpDir(0, 0, 1)); T.SetTransformation(oldSystemAxis, newSystemAxis); var secondOriginTransformed = originSecondSketch.Transformed(T); Assert.AreEqual(secondOriginTransformed.X, originBaseSketch.X); Assert.AreEqual(secondOriginTransformed.Y, originBaseSketch.Y); Assert.AreEqual(secondOriginTransformed.Z, originBaseSketch.Z); var point = new gpPnt(2, 3, 10).Transformed(T); Assert.AreEqual(point.X, 1); Assert.AreEqual(point.Y, 2); Assert.AreEqual(point.Z, 0); }
private List <Point3D> ExecuteTrim(SceneSelectedEntity wireToTrim, List <SceneSelectedEntity> trimmingWires, gpPnt clickPoint) { var profileLocation = wireToTrim.TargetShape().Location(); var profileTranslation = new gpTrsf(); var profileTranslationVector = profileLocation.Transformation.TranslationPart.Reversed; profileTranslation.TranslationPart = (profileTranslationVector); var newProfileLocation = new TopLocLocation(profileTranslation); foreach (var wire in trimmingWires) { if (wire.Node.Get <TopoDsShapeInterpreter>().Shape != null) { wire.Node.Get <TopoDsShapeInterpreter>().Shape.Move(newProfileLocation); } } wireToTrim.Node.Get <TopoDsShapeInterpreter>().Shape.Move(newProfileLocation); clickPoint.Translate(profileTranslationVector); var trimmingEdges = new List <TopoDSEdge>(); foreach (var trimming in trimmingWires) { var trimmingE = GeomUtils.ExtractEdges(trimming.TargetShape()); if (trimmingE.Count > 0) { trimmingEdges.AddRange(trimmingE); } } if (trimmingEdges.Count <= 0) { return(null); } var resultPoints = GeomUtils.TrimKnownShape(trimmingEdges, wireToTrim, new Point3D(clickPoint)); return(resultPoints); }
public void TestTranslate() { var customAxisSystem = new gpTrsf(); customAxisSystem.SetValues(1, 0, 0, 10, 0, 1, 0, 10, 0, 0, 1, 10, _angularPrecision, _distancePrecision); var aShapesTransformation = new gpTrsf(); aShapesTransformation.SetValues(1, 0, 0, 10, 0, 1, 0, 10, 0, 0, 1, 10, _angularPrecision, _distancePrecision); var globalSystemtransformation = TransformationInterpreter.ConvertToGlobalTransformation(customAxisSystem, aShapesTransformation); Assert.IsTrue(Math.Abs(1 - globalSystemtransformation.Value(1, 1)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(0 - globalSystemtransformation.Value(1, 2)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(0 - globalSystemtransformation.Value(1, 3)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(20 - globalSystemtransformation.Value(1, 4)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(0 - globalSystemtransformation.Value(2, 1)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(1 - globalSystemtransformation.Value(2, 2)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(0 - globalSystemtransformation.Value(2, 3)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(20 - globalSystemtransformation.Value(2, 4)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(0 - globalSystemtransformation.Value(3, 1)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(0 - globalSystemtransformation.Value(3, 2)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(1 - globalSystemtransformation.Value(3, 3)) < 0.1, "incorrect transformation"); Assert.IsTrue(Math.Abs(20 - globalSystemtransformation.Value(3, 4)) < 0.1, "incorrect transformation"); }
public void Transform(gpTrsf T) { Geom_Ellipse_Transform72D78650(Instance, T.Instance); }
public double ParametricTransformation(gpTrsf T) { return(Geom_Line_ParametricTransformation72D78650(Instance, T.Instance)); }