private static TopoDSShape BuildTopoDsShapeHandle(gpAx2 axis, double edgeLength) { var axisLocation = axis.Location; var translationVector = new gpVec(axis.XDirection); translationVector.Normalize(); translationVector.Multiply(edgeLength * Math.Sqrt(2) / 2); translationVector.Rotate(axis.Axis, Math.PI / 4); var firstPoint = new Point3D(axisLocation.Translated(translationVector)); translationVector.Rotate(axis.Axis, Math.PI / 2); var secondPoint = new Point3D(axisLocation.Translated(translationVector)); translationVector.Rotate(axis.Axis, Math.PI / 2); var thirdPoint = new Point3D(axisLocation.Translated(translationVector)); translationVector.Rotate(axis.Axis, Math.PI / 2); var fourthPoint = new Point3D(axisLocation.Translated(translationVector)); var firstLine = GeomUtils.BuildLine(firstPoint, secondPoint); var secondLine = GeomUtils.BuildLine(secondPoint, thirdPoint); var thirdLine = GeomUtils.BuildLine(thirdPoint, fourthPoint); var fourthLine = GeomUtils.BuildLine(fourthPoint, firstPoint); var wireList = new List <TopoDSWire> { firstLine, secondLine, thirdLine, fourthLine }; var face = GeomUtils.MakeFace(wireList); return(face); }
/// <summary> /// Detects parallelism with other geometry points /// </summary> /// <param name = "currentPoint"></param> /// <param name = "initialPosition"></param> /// <returns></returns> public SolverPreviewObject GeometryParallel(Point3D currentPoint, Point3D initialPosition) { var qosLock = QosFactory.Instance.Get(QosNames.ParallelLineLock); qosLock.Begin(); var vec = new gpVec(initialPosition.GpPnt, currentPoint.GpPnt); foreach (var solverGeometricObject in LastGeometry) { if (solverGeometricObject.ParallelAxis.Count == 0) { continue; } foreach (var axis in solverGeometricObject.ParallelAxis) { if (vec.IsParallel(axis.Vector, _precision)) { return(ProjectPointOnDirection(initialPosition, currentPoint, new gpDir(axis.Vector), Color.Black)); } } } qosLock.End(); return(null); }
private static TopoDSShape BuildTopoDsShapeHandle(gpAx2 coordinate, double edgeLength) { var axisLocation = coordinate.Location; var thirdPointVector = new gpVec(coordinate.XDirection); thirdPointVector.Multiply(edgeLength); var thirdPoint = new Point3D(axisLocation.Translated(thirdPointVector)); var secondPointVector = new gpVec(coordinate.YDirection); secondPointVector.Multiply(edgeLength); var secondPoint = new Point3D(axisLocation.Translated(secondPointVector)); var firstPoint = new Point3D(axisLocation.Translated(secondPointVector.Reversed)); var firstLine = GeomUtils.BuildLine(firstPoint, secondPoint); var secondLine = GeomUtils.BuildLine(secondPoint, thirdPoint); var thirdLine = GeomUtils.BuildLine(thirdPoint, firstPoint); var wireList = new List <TopoDSWire> { firstLine, secondLine, thirdLine }; var face = GeomUtils.MakeFace(wireList); var extrusionVector = new gpVec(coordinate.Direction); extrusionVector.Normalize(); extrusionVector.Multiply(edgeLength / 2); return(new BRepPrimAPIMakePrism(face, extrusionVector, false, true).Shape); }
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); } }
private static TopoDSShape BuildTopoDsShapeHandle(gpAx2 coordinate, double edgeLength) { var axisLocation = coordinate.Location; var firstPoint = new Point3D(axisLocation); var secondPointVector = new gpVec(coordinate.Direction); secondPointVector.Multiply(edgeLength); var secondPoint = new Point3D(axisLocation.Translated(secondPointVector)); var thirdPointVector = new gpVec(coordinate.XDirection); thirdPointVector.Multiply(edgeLength); var thirdPoint = new Point3D(axisLocation.Translated(thirdPointVector)); var firstLine = GeomUtils.BuildLine(firstPoint, secondPoint); var secondLine = GeomUtils.BuildLine(secondPoint, thirdPoint); var thirdLine = GeomUtils.BuildLine(thirdPoint, firstPoint); var wireList = new List <TopoDSWire> { firstLine, secondLine, thirdLine }; var face = GeomUtils.MakeFace(wireList); return(face); }
public static void ShowFaceDirection(TopoDSFace face, Document Document) { var p1 = new gpPnt(); var v1 = new gpVec(); var v2 = new gpVec(); var sf = new BRepAdaptorSurface(face, true); var u = sf.FirstUParameter; var x = sf.LastUParameter; if (Precision.IsInfinite(u)) { u = (Precision.IsInfinite(x)) ? 0.0 : x; } else if (!Precision.IsInfinite(x)) { u = (u + x) / 2.0; } var v = sf.FirstVParameter; x = sf.LastVParameter; if (Precision.IsInfinite(v)) { v = (Precision.IsInfinite(x)) ? 0.0 : x; } else if (!Precision.IsInfinite(x)) { v = (v + x) / 2.0; } sf.D1(u, v, p1, v1, v2); var vector = v1.Crossed(v2); x = vector.Magnitude; // The direction vector length const double length = 70.0; if (x > 0.0000001) { vector.Multiply(length / x); } else { vector.SetCoord(length / 2.0, 0, 0); } var p2 = new gpPnt(p1.X, p1.Y, p1.Z); p2.Translate(vector); if (p1.IsEqual(p2, Precision.Confusion)) { return; } DrawArrow(Document, p1, p2, face.Orientation()); }
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); }
public static void DisplayTemporaryDimension(Document animationDocument, Node baseNode, Node extrusion, Mouse3DPosition mouseData, bool enableSelection) { var subShape = new NodeBuilder(animationDocument, FunctionNames.SubShape); subShape[0].Reference = extrusion; subShape[1].Integer = 1; subShape[2].Integer = (int)TopAbsShapeEnum.TopAbs_EDGE; subShape.ExecuteFunction(); if (subShape.Shape == null) { return; } var edge = TopoDS.Edge(subShape.Shape); var baseNodeBuilder = new NodeBuilder(baseNode); var gravityCenter = GeomUtils.ExtractGravityCenter(baseNodeBuilder.Shape); var firstPoint = new Point3D(); var firstPointCalculated = GeomUtils.CalculateEdgeFirstPoint(edge); if (firstPointCalculated != null) { firstPoint = (Point3D)firstPointCalculated; } var secondPoint = new Point3D(); var secondPointCalculated = GeomUtils.CalculateEdgeLastPoint(edge); if (secondPointCalculated != null) { secondPoint = (Point3D)secondPointCalculated; } var middlePoint = GeomUtils.ComputeMidPoint(firstPoint, secondPoint); // Translate the dimenion text at some distance from the extrude var vector = new gpVec(firstPoint.GpPnt, gravityCenter.GpPnt); vector.Reverse(); vector.Normalize(); vector.Multiply(2); middlePoint = GeomUtils.BuildTranslation(middlePoint, vector); subShape.Visibility = ObjectVisibility.Hidden; // Build a distance dimension just for animation purposes var animationBuilder = new NodeBuilder(animationDocument, FunctionNames.PointsDimension); animationBuilder[0].TransformedPoint3D = firstPoint; animationBuilder[1].TransformedPoint3D = secondPoint; animationBuilder[2].TransformedPoint3D = middlePoint; animationBuilder[3].Integer = (int)DsgPrsArrowSide.DsgPrs_AS_FIRSTPT_LASTAR; animationBuilder[4].Real = 1; animationBuilder.EnableSelection = false; animationBuilder.Color = Color.Black; animationBuilder.ExecuteFunction(); }
private static TopoDSFace BuildPlane(gpAx2 orientation, double rectangleLength) { var diagonalVector = new gpVec(orientation.XDirection); diagonalVector.Multiply(rectangleLength * Math.Sqrt(2)); var secondPoint = GeomUtils.BuildTranslation(new Point3D(orientation.Location), diagonalVector); return(OccShapeCreatorCode.BuildRectangle(orientation.Location, secondPoint.GpPnt, orientation.Direction)); }
public override void UpdatePointPosition(int index, Mouse3DPosition vertex) { var trsfInterpreter = Node.Set <TransformationInterpreter>(); if (_initialDraggingPosition == null) { InitializeDragging(vertex, trsfInterpreter); } //Log.DebugFormat("@pivot {0} {1} {2}", trsfInterpreter.Pivot.X(), trsfInterpreter.Pivot.Y(), trsfInterpreter.Pivot.Z()); var rotate = new gpPnt(0, 0, 0); var startDraggingVector = new gpVec(trsfInterpreter.Pivot, _initialDraggingPosition.Value.GpPnt); if (startDraggingVector.Magnitude <= gp.Resolution) { return; } var currentDraggingVector = new gpVec(trsfInterpreter.Pivot, vertex.Point.GpPnt); if (currentDraggingVector.Magnitude <= gp.Resolution) { return; } var currentGizmo = GetPointLocation(index); var rotationAxis = currentGizmo.Direction; if (rotationAxis.IsParallel(gp.OX.Direction, Precision.Angular)) { var rotationAngle = startDraggingVector.AngleWithRef(currentDraggingVector, new gpVec(gp.OX.Direction)) - _previousAngle; _previousAngle = startDraggingVector.AngleWithRef(currentDraggingVector, new gpVec(gp.OX.Direction)); rotate.X = GeomUtils.RadiansToDegrees(rotationAngle); } else if (rotationAxis.IsParallel(gp.OY.Direction, Precision.Angular)) { var rotationAngle = startDraggingVector.AngleWithRef(currentDraggingVector, new gpVec(gp.OY.Direction)) - _previousAngle; _previousAngle = startDraggingVector.AngleWithRef(currentDraggingVector, new gpVec(gp.OY.Direction)); rotate.Y = GeomUtils.RadiansToDegrees(rotationAngle); } else if (rotationAxis.IsParallel(gp.OZ.Direction, Precision.Angular)) { var rotationAngle = startDraggingVector.AngleWithRef(currentDraggingVector, new gpVec(gp.OZ.Direction)) - _previousAngle; _previousAngle = startDraggingVector.AngleWithRef(currentDraggingVector, new gpVec(gp.OZ.Direction)); rotate.Z = GeomUtils.RadiansToDegrees(rotationAngle); } //Log.DebugFormat("@rotation angle {0}", GeomUtils.RadiansToDegrees(rotationAngle)); trsfInterpreter.Rotate = rotate; }
/// <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); }
private static Point3D CalculateEndPointOnArc(Point3D center, Point3D startPoint, Point3D currentEndPoint) { var radius = center.Distance(startPoint); Ensure.IsTrue(radius > 0); var endPointVector = new gpVec(center.GpPnt, currentEndPoint.GpPnt); endPointVector.Normalize(); endPointVector.Multiply(radius); return(GeomUtils.BuildTranslation(center, endPointVector)); }
/// <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))); }
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(); }
private void SetSecondPointDraggingHandle(gpVec vectorV2V1, Mouse3DPosition vertex, Point3D secondPoint) { if (_secondPointProjectionDirection == null) { _secondPointProjectionDirection = new gpDir(vectorV2V1); } var secondPointProjectionPlane = new gpPln(vertex.Point.GpPnt, _secondPointProjectionDirection); var secondProjectedPoint = GeomUtils.ProjectPointOnPlane(secondPoint.GpPnt, secondPointProjectionPlane, Precision.Confusion); Dependency[1].TransformedPoint3D = new Point3D(secondProjectedPoint); Dependency[2].TransformedPoint3D = vertex.Point; }
public SolverParallelAxis(TopoDSEdge edge) { Point3D?firstPoint, lastPoint; GeomUtils.EdgeRange(edge, out firstPoint, out lastPoint); if (firstPoint == null || lastPoint == null) { return; } var first = (Point3D)firstPoint; var last = (Point3D)lastPoint; Vector = new gpVec(first.GpPnt, last.GpPnt); }
public override SolverPreviewObject InterestingShapeAroundPoint(gpPln planeOfTheView, Point3D currentPoint, Point3D initialPosition) { if (currentPoint.IsEqual(initialPosition)) { return(null); } var qosLock = QosFactory.Instance.Get(QosNames.ParallelLineLock); qosLock.Begin(); var vec = new gpVec(initialPosition.GpPnt, currentPoint.GpPnt); foreach (var solverGeometricObject in Geometry) { if (solverGeometricObject.ParallelAxis.Count == 0) { continue; } foreach (var axis in solverGeometricObject.ParallelAxis) { if (vec.IsNormal(axis.Vector, _precision)) { var planeNormal = vec.Crossed(axis.Vector); var planeNormalAxis = new gpAx1(initialPosition.GpPnt, new gpDir(planeNormal)); gpVec v2 = axis.Vector.Normalized; v2.Rotate(planeNormalAxis, Math.PI / 2.0); var parallelLine = new gceMakeLin(initialPosition.GpPnt, new gpDir(v2)).Value; var geomLine = new GeomLine(parallelLine); var projectionPoint = new GeomAPIProjectPointOnCurve(currentPoint.GpPnt, geomLine); if (projectionPoint.NbPoints <= 0) { return(null); } var secondPoint = new Point3D(projectionPoint.NearestPoint); var solverPoint = new SolverEdgeTwoPointsResult(secondPoint, initialPosition, Color.Black) { Type = "Perpendicular Line" }; return(solverPoint); } } } qosLock.End(); return(null); }
private List <NodeBuilder> PreviewRectangle(Document document, Node sketchNode) { //var axis1 = new gpAx2(); //axis1.Axis = (sketchNode.Children[1].Get<Axis3DInterpreter>().Axis.GpAxis); //var location = axis1.Axis.Location.Transformed(sketchNode.Get<TransformationInterpreter>().CurrTransform); //var direction = axis1.Axis.Direction.Transformed(sketchNode.Get<TransformationInterpreter>().CurrTransform); //var axis = new gpAx2(location, direction); var axisAll = NodeBuilderUtils.GetTransformedAxis(new NodeBuilder(sketchNode)); var axis = new gpAx2(axisAll.Location, axisAll.Direction); var vec = new gpVec(Points[0].GpPnt, Points[1].GpPnt); gpVec v2 = vec.Normalized; v2.Rotate(axis.Axis, Math.PI / 2.0); var parallelLine = new gceMakeLin(Points[1].GpPnt, new gpDir(v2)).Value; var geomLine = new GeomLine(parallelLine); var projectionPoint = new GeomAPIProjectPointOnCurve(Points[2].GpPnt, geomLine); var thirdPoint = new Point3D(projectionPoint.NearestPoint); var firstPoint2D = Points[0].ToPoint2D(axis); var secondPoint2D = Points[1].ToPoint2D(axis); var thirdPoint2D = thirdPoint.ToPoint2D(axis); var parallelLine2 = new gceMakeLin(Points[2].GpPnt, new gpDir(vec)).Value; var geomLine2 = new GeomLine(parallelLine2); var projectionPoint2 = new GeomAPIProjectPointOnCurve(Points[0].GpPnt, geomLine2); var fourthPoint = new Point3D(projectionPoint2.NearestPoint); var fourthPoint2D = fourthPoint.ToPoint2D(axis); var point3Ds = new List <Point3D>(); point3Ds.Add(GeomUtils.Point2DTo3D(axis, firstPoint2D.X, firstPoint2D.Y)); point3Ds.Add(GeomUtils.Point2DTo3D(axis, secondPoint2D.X, secondPoint2D.Y)); point3Ds.Add(GeomUtils.Point2DTo3D(axis, thirdPoint2D.X, thirdPoint2D.Y)); point3Ds.Add(GeomUtils.Point2DTo3D(axis, fourthPoint2D.X, fourthPoint2D.Y)); var pointLinker = new SketchCreator(document).PointLinker; var lines = new List <NodeBuilder> { BuildLine(Document, pointLinker, point3Ds[0], point3Ds[1]), BuildLine(Document, pointLinker, point3Ds[1], point3Ds[2]), BuildLine(Document, pointLinker, point3Ds[2], point3Ds[3]), BuildLine(Document, pointLinker, point3Ds[3], point3Ds[0]) }; return(lines); }
private static TopoDSShape BuildAxisShapeHandle(gpAx1 mainAxis, double arrowLength, double arrowWidth) { var cylinderShape = GeomUtils.MakeCylinder(mainAxis, arrowWidth, arrowLength * 3 / 4, GeomUtils.DegreesToRadians(360)); var coneVector = new gpVec(mainAxis.Direction); coneVector.Multiply(arrowLength * 3 / 4); var coneLocation = mainAxis.Translated(coneVector); var cone = GeomUtils.MakeCone(coneLocation, arrowWidth * 1.5, 0, arrowLength / 4, GeomUtils.DegreesToRadians(360)); var fuse = new BRepAlgoAPIFuse(cylinderShape, cone); return(fuse.Shape); }
public static void ParalelogramSetWidthPoints(Node node, double width) { if (width < Precision.Confusion) { return; } var builder = new NodeBuilder(node); var initialWidth = builder[1].TransformedPoint3D.Distance(builder[2].TransformedPoint3D); var widthToAdd = width - initialWidth; var widthDirection = new gpVec(builder[1].TransformedPoint3D.GpPnt, builder[2].TransformedPoint3D.GpPnt); widthDirection.Normalize(); widthDirection.Multiply(widthToAdd); builder[2].TransformedPoint3D = new Point3D(builder[2].TransformedPoint3D.GpPnt.Translated(widthDirection)); }
/// <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); }
public static void ParalelogramSetHeightPoints(Node node, double height) { if (height < Precision.Confusion) { return; } var builder = new NodeBuilder(node); var initialHeight = builder[0].TransformedPoint3D.Distance(builder[1].TransformedPoint3D); var heigthToAdd = height - initialHeight; var heigthDirection = new gpVec(builder[0].TransformedPoint3D.GpPnt, builder[1].TransformedPoint3D.GpPnt); heigthDirection.Normalize(); heigthDirection.Multiply(heigthToAdd); builder[1].TransformedPoint3D = new Point3D(builder[1].TransformedPoint3D.GpPnt.Translated(heigthDirection)); builder[2].TransformedPoint3D = new Point3D(builder[2].TransformedPoint3D.GpPnt.Translated(heigthDirection)); }
public void ApplyGeneralArrayPattern(gpAx1 rowAxis, gpAx1 colomnAxis, double rowLength, double colomnLength) { var transformation = ConvertgpTrsfToMatrix3DTransform(); var rowLengthToAdd = new gpVec(rowAxis.Direction); rowLengthToAdd.Normalize(); rowLengthToAdd.Multiply(rowLength); SetTranslationValuesAndPivot(ref transformation, new Vector3D(rowLengthToAdd.X, rowLengthToAdd.Y, rowLengthToAdd.Z)); var colomnLengthToAdd = new gpVec(colomnAxis.Direction); colomnLengthToAdd.Normalize(); colomnLengthToAdd.Multiply(colomnLength); SetTranslationValuesAndPivot(ref transformation, new Vector3D(colomnLengthToAdd.X, colomnLengthToAdd.Y, colomnLengthToAdd.Z)); OnModified(); }
private void BuildDragAxis(Document document, TopoDSShape shape, double extrudeSize) { var gravityCenter = GeomUtils.ExtractGravityCenter(shape); var dir = GeomUtils.ExtractDirection(shape); if (dir.XYZ.Z < 0) { dir.Reverse(); } var vec = new gpVec(dir); vec.Normalize(); vec.Multiply(extrudeSize); gravityCenter = GeomUtils.BuildTranslation(gravityCenter, vec); var point = new gpPnt(dir.XYZ); var gravityAxis = new Axis(gravityCenter, new Point3D(point)); DrawDragAxis(document, gravityAxis, 5, 2); // _normalPlane = BuildNormalPlane(dir, gravityAxis); }
/// <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 ExtrudeToDepth(TopoDSShape originalShape, double height) { TopoDSShape prismShape = null; // Make the Extrusion if (originalShape != null) { try { var face = originalShape;// OCTopoDS.Face(originalShape); // Get the direction var dir = GeomUtils.ExtractDirection(face); if (dir == null) { return(null); } if (dir.XYZ.Z < 0) { dir.Reverse(); } // Describe the height through a vector var vector = new gpVec(dir); vector.Multiply(height); // Make the prism return(new BRepPrimAPIMakePrism(face, vector, false, true).Shape); } catch (Exception ex) { Log.Error("Error on extrude: " + ex.Message); return(null); } } return(prismShape); }
/// <summary> /// Calculates the computer radiuses knowing the center position and two points located on the two axis /// </summary> public static bool ComputeEllipseRadiuses(Point3D center, Point3D secondPoint, Point3D thirdPoint, out double minorRadius, out double majorRadius, out bool reversed, ref gpDir dirX, ref gpDir dirY) { // Calculate the major radius majorRadius = center.GpPnt.Distance(secondPoint.GpPnt); // Calculate also the axis/direction of the major radus var vecX = new gpVec(center.GpPnt, secondPoint.GpPnt); dirX = new gpDir(vecX); var line = new gpLin(center.GpPnt, dirX); // Calculate the minor radius minorRadius = line.Distance(thirdPoint.GpPnt); reversed = false; if (minorRadius < Precision.Confusion || majorRadius < Precision.Confusion) { return(false); } // Calculate also the axis/direction of the major radus var vecY = new gpVec(center.GpPnt, thirdPoint.GpPnt); // We want the direction to be perpendicular on the direction of the major radius var vecZ = vecX.Crossed(vecY); vecY = vecX.Crossed(vecZ); dirY = new gpDir(vecY); // Major radius must be bigger than minor radius if (minorRadius > majorRadius) { var aux = majorRadius; majorRadius = minorRadius; minorRadius = aux; reversed = true; } return(true); }
public void D3(double U, gpPnt P, gpVec V1, gpVec V2, gpVec V3) { Geom_Ellipse_D356E36E6F(Instance, U, P.Instance, V1.Instance, V2.Instance, V3.Instance); }
public void D2(double U, gpPnt P, gpVec V1, gpVec V2) { Geom_Ellipse_D227877840(Instance, U, P.Instance, V1.Instance, V2.Instance); }
public void D1(double U, gpPnt P, gpVec V1) { Geom_Ellipse_D11387A81(Instance, U, P.Instance, V1.Instance); }
public override gpAx2 GetPointLocation(int index) { //var transform = Node.Get<TransformationInterpreter>().CurrTransform; var transform = NodeBuilderUtils.GetGlobalTransformation(new NodeBuilder(NodeBuilderUtils.FindSketchNode(Node))); var ax2 = new gpAx2(); var centerAxis = new gpAx1(); if (Dependency[0].Name == InterpreterNames.Reference) { var circleLocation = Dependency[0].RefTransformedPoint3D.GpPnt; var pointBuilder = Dependency[0].ReferenceBuilder; var circleNormal = pointBuilder[0].Reference.Children[1].Get <Axis3DInterpreter>().Axis.Direction; centerAxis = new gpAx1(circleLocation, new gpDir(circleNormal.GpPnt.XYZ).Transformed(transform)); ax2.Axis = (centerAxis); } if (Dependency[0].Name == InterpreterNames.Axis3D) { centerAxis = Dependency[0].TransformedAxis3D; ax2.Axis = (centerAxis); } var circleCenter = centerAxis; var pointOnCircle = GetPointOnCircle(centerAxis, Dependency[1].Real, transform); var radius = pointOnCircle.Distance(circleCenter.Location); var leftArrowVector = new gpVec(circleCenter.Location, pointOnCircle); leftArrowVector.Normalize(); leftArrowVector.Multiply(radius + DistanceToObject); var leftArrowLocation = circleCenter.Location.Translated(leftArrowVector); var rightArrowVector = leftArrowVector.Reversed; var rightArrowLocation = circleCenter.Location.Translated(rightArrowVector); var topArrowVector = new gpVec(leftArrowVector.XYZ); topArrowVector.Cross(new gpVec(ax2.Direction)); topArrowVector.Normalize(); topArrowVector.Multiply(radius + DistanceToObject); var topArrowLocation = circleCenter.Location.Translated(topArrowVector); var bottomArrowVector = topArrowVector.Reversed; var bottomArrowLocation = circleCenter.Location.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); } }