private Tuple <Term, Term[]> SingleFeatureTwoSilhouettes(SnappedStraightGenCylinder snappedPrimitive, HashSet <FeatureCurve> annotated) { //MessageBox.Show("Inside Two Silhouettes one Feature"); var leftPts = snappedPrimitive.LeftSilhouette.Points; var rightPts = snappedPrimitive.RightSilhouette.Points; var pointsProgress = snappedPrimitive.Components.Select(x => x.Progress).ToArray(); Point[] featureCurve; if (snappedPrimitive.TopFeatureCurve.SnappedTo != null) { featureCurve = snappedPrimitive.TopFeatureCurve.SnappedTo.Points; } else { featureCurve = snappedPrimitive.BottomFeatureCurve.SnappedTo.Points; } var ellipse = EllipseFitter.Fit(featureCurve); var orientationBasis = EllipseHelper.CircleOrientation(ellipse); var approxOrientation = GetOrientation(orientationBasis, snappedPrimitive.AxisResult); var spine = StraightSpine.Compute(leftPts, rightPts, pointsProgress, new Vector(approxOrientation.X, -approxOrientation.Y)); var radii = spine.Item1; var spineStart = spine.Item2; var spineEnd = spine.Item3; return(CreateSGCTerms(snappedPrimitive, radii, spineStart, spineEnd)); }
private Vector3D GetOrientation( EllipseParams topEllipse, EllipseParams botEllipse, Vector3D axisApproximation) { var topCircleBasis = EllipseHelper.CircleOrientation(topEllipse); var botCircleBasis = EllipseHelper.CircleOrientation(botEllipse); var topOrientation = GetOrientation(topCircleBasis, axisApproximation); var botOrientation = GetOrientation(botCircleBasis, axisApproximation); if (Vector3D.DotProduct(botOrientation, topOrientation) < 0) { botOrientation = -botOrientation; } var topPerimeter = EllipseHelper.ApproxPerimeter(topEllipse.XRadius, topEllipse.YRadius); var botPerimeter = EllipseHelper.ApproxPerimeter(botEllipse.XRadius, botEllipse.YRadius); //return result; if (topPerimeter > botPerimeter) { return(topOrientation); } else { return(botOrientation); } }
private Vector3D GetOrientation( EllipseParams botEllipse, Point[] spineApproximation, ref bool Reverse) { int nspine = spineApproximation.Length; Vector vnormal = new Vector(botEllipse.Center.X - spineApproximation[0].X, botEllipse.Center.Y + spineApproximation[0].Y); Vector vreverse = new Vector(botEllipse.Center.X - spineApproximation[spineApproximation.Length - 1].X, botEllipse.Center.Y + spineApproximation[spineApproximation.Length - 1].Y); Reverse = false; if (vnormal.Length > vreverse.Length) { Reverse = true; } Vector botAxis = new Vector(); if (!Reverse) { botAxis = new Vector(spineApproximation[1].X - spineApproximation[0].X, spineApproximation[0].Y - spineApproximation[1].Y); } else { botAxis = new Vector(spineApproximation[nspine - 2].X - spineApproximation[nspine - 1].X, spineApproximation[nspine - 1].Y - spineApproximation[nspine - 2].Y); } var botCircleBasis = EllipseHelper.CircleOrientation(botEllipse); var botOrientation = GetOrientation(botCircleBasis); Vector ApproxOrientationBotProj = new Vector(botOrientation.X, botOrientation.Y); if (ApproxOrientationBotProj * botAxis < 0) { botOrientation = -botOrientation; } //var topPerimeter = EllipseHelper.ApproxPerimeter(topEllipse.XRadius, topEllipse.YRadius); //var botPerimeter = EllipseHelper.ApproxPerimeter(botEllipse.XRadius, botEllipse.YRadius); //return result; //if (topPerimeter > botPerimeter) // return topOrientation; //else return(botOrientation); }