public static Plane GetPlaneCenteredOnFace(DesignFace face) { PointUV centerUV = face.Shape.BoxUV.Center; SurfaceEvaluation evaluation = face.Shape.Geometry.Evaluate(centerUV); Point point = evaluation.Point; Direction dirU = (face.Shape.Geometry.Evaluate(PointUV.Create(centerUV.U + 0.001, centerUV.V)).Point.Vector - face.Shape.Geometry.Evaluate(PointUV.Create(centerUV.U - 0.001, centerUV.V)).Point.Vector).Direction; Direction dirVTemp = Direction.Cross(evaluation.Normal, dirU); if (face.Shape.Geometry as Plane != null) { if (!Accuracy.Equals(Vector.Dot(dirU.UnitVector, Direction.DirZ.UnitVector), 0.0)) // if our U direction has a Z component, the text might be slanted { if (Accuracy.Equals(Vector.Dot(dirVTemp.UnitVector, Direction.DirZ.UnitVector), 0.0)) // if our V direction has no Z component, use it { dirU = dirVTemp; } } } if (face.Shape.Geometry as Cylinder != null) { dirU = dirVTemp; } dirVTemp = Direction.Cross(evaluation.Normal, dirU); if (Vector.Dot(dirVTemp.UnitVector, Direction.DirZ.UnitVector) < 0.0) // Prevent upside-down notes { dirU = -dirU; } return(Plane.Create(Frame.Create(point, dirU, Direction.Cross(evaluation.Normal, dirU)))); }
public bool Equals(Location other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(Latitude.Equals(other.Latitude) && Longitude.Equals(other.Longitude) && Accuracy.Equals(other.Accuracy) && Altitude.Equals(other.Altitude) && VerticalAccuracy.Equals(other.VerticalAccuracy) && Bearing.Equals(other.Bearing) && Speed.Equals(other.Speed)); }
static void Skeletize_Executing(object sender, EventArgs e) { double sphereDiameter = cylinderDiameter * 2; Window activeWindow = Window.ActiveWindow; ICollection <ITrimmedCurve> iTrimmedCurves = activeWindow.GetAllSelectedITrimmedCurves(); if (iTrimmedCurves.Count == 0) { return; } Part parent = activeWindow.ActiveContext.Context as Part; if (parent == null) { return; } Part part = Part.Create(parent.Document, "Skeleton"); Component component = Component.Create(parent, part); List <Point> allPoints = new List <Point>(); foreach (ITrimmedCurve iTrimmedCurve in iTrimmedCurves) { if (isCreatingSpheres && !Accuracy.Equals(iTrimmedCurve.StartPoint, iTrimmedCurve.EndPoint)) { allPoints.Add(iTrimmedCurve.StartPoint); allPoints.Add(iTrimmedCurve.EndPoint); } if (iTrimmedCurve.Geometry.GetType().Name == "Line") { if (isCreatingCylinders) { ShapeHelper.CreateCylinder(iTrimmedCurve.StartPoint, iTrimmedCurve.EndPoint, cylinderDiameter, part); } if (isCreatingSausages) { ShapeHelper.CreateSausage(iTrimmedCurve.StartPoint, iTrimmedCurve.EndPoint, cylinderDiameter, part); } } else { if (isCreatingCylinders || isCreatingSausages) { ShapeHelper.CreateCable(iTrimmedCurve, cylinderDiameter, part); } if (isCreatingSausages && !Accuracy.Equals(iTrimmedCurve.StartPoint, iTrimmedCurve.EndPoint)) { ShapeHelper.CreateSphere(iTrimmedCurve.StartPoint, cylinderDiameter, part); ShapeHelper.CreateSphere(iTrimmedCurve.EndPoint, cylinderDiameter, part); // TBD boolean these with cable } } } if (isCreatingSpheres) { List <Point> points = new List <Point>(); while (allPoints.Count > 0) { Point testPoint = allPoints[0]; allPoints.Remove(allPoints[0]); bool isDuplicate = false; foreach (Point point in allPoints) { if (Accuracy.Equals(testPoint, point)) { isDuplicate = true; break; } } if (!isDuplicate) { points.Add(testPoint); } } foreach (Point point in points) { ShapeHelper.CreateSphere(point, sphereDiameter, part); } } }
static void notesImageSpherical_Executing(object sender, EventArgs e) { Bitmap bitmap = OpenBitmap(); if (bitmap == null) { return; } Part part = CreateImagePart(); int width = bitmap.Width; int height = bitmap.Height; double radius = 0.5 * stepSize / Math.Sin(Math.PI / width) * Math.PI; Point startPoint = Point.Create(radius, 0, 0); Line yAxis = Line.Create(Point.Origin, Direction.DirY); Line zAxis = Line.Create(Point.Origin, Direction.DirZ); List <Point> points = new List <Point>(4); for (int i = 0; i < 4; i++) { points.Add(Point.Origin); } for (int i = 0; i < width; i++) { double angle1 = (double)i / width * 2 * Math.PI; double angle2 = (double)(i + 1) / width * 2 * Math.PI; for (int j = 0; j < height; j++) { double azimuth1 = ((double)j) / height * Math.PI - Math.PI / 2; double azimuth2 = ((double)j + 1) / height * Math.PI - Math.PI / 2; points[0] = Matrix.CreateRotation(zAxis, angle1) * Matrix.CreateRotation(yAxis, azimuth1) * startPoint; points[1] = Matrix.CreateRotation(zAxis, angle1) * Matrix.CreateRotation(yAxis, azimuth2) * startPoint; points[2] = Matrix.CreateRotation(zAxis, angle2) * Matrix.CreateRotation(yAxis, azimuth2) * startPoint; points[3] = Matrix.CreateRotation(zAxis, angle2) * Matrix.CreateRotation(yAxis, azimuth1) * startPoint; Point?extraPoint = null; if (Accuracy.Equals(points[3], points[0])) { extraPoint = points[0]; points.Remove(points[0]); } else { for (int k = 0; k < 3; k++) { if (Accuracy.Equals(points[k], points[k + 1])) { extraPoint = points[k]; points.Remove(points[k]); break; } } } DesignBody designBody = ShapeHelper.CreatePolygon(points, null, 0, part); designBody.SetColor(null, GetOpaquePixel(bitmap, i, j)); if (extraPoint != null) { points.Add(extraPoint.Value); } } } }
public static Body CreatePolygon(IList <Point> inputPoints, Plane plane, double thickness) { List <ITrimmedCurve> profile = new List <ITrimmedCurve>(); if (plane == null) { if (!AddInHelper.TryCreatePlaneFromPoints(inputPoints, out plane)) { return(null); } } Point newPoint; Point lastPoint = inputPoints[inputPoints.Count - 1].ProjectToPlane(plane); List <Point> points = new List <Point>(); foreach (Point point in inputPoints) { newPoint = point.ProjectToPlane(plane); if (!Accuracy.Equals(newPoint, lastPoint)) { points.Add(newPoint); lastPoint = newPoint; } } for (int i = 0; i < points.Count; i++) { if (i < points.Count - 1) { profile.Add(CurveSegment.Create(points[i], points[i + 1])); } else { profile.Add(CurveSegment.Create(points[i], points[0])); } } Body body = null; try { if (thickness == 0) { body = Body.CreatePlanarBody(plane, profile); } else { body = Body.ExtrudeProfile(plane, profile, thickness); } } catch { string error = "Exception thrown creating planar body:\n"; foreach (Point point in inputPoints) { error += string.Format("{0}, {1}, {2}\n", point.X, point.Y, point.Z); } Debug.Assert(false, error); } if (body == null) { Debug.Fail("Profile was not connected, not closed, or not in order."); return(null); } return(body); }