private bool IsInsideSphere(Point p, SnappedSphere toBeAnnotatedSphere) { var sphereCenter = new Point(toBeAnnotatedSphere.CenterResult.X, -toBeAnnotatedSphere.CenterResult.Y); var dist = (p - sphereCenter).Length; return(dist < (1 + proximityThresholdFraction) * toBeAnnotatedSphere.RadiusResult); }
private bool HasEndpointOnSphere(PointsSequence pointsSequence, SnappedSphere sphere) { var isStartInsideSphere = IsInsideSphere(pointsSequence.Points.First(), sphere); var isEndInsideSphere = IsInsideSphere(pointsSequence.Points.Last(), sphere); return(isStartInsideSphere || isEndInsideSphere); }
private bool HasSilhouettesWithEndpointsOnSphere(SnappedPrimitive nonSphere, SnappedSphere sphere) { var sketchSilhouettes = from pointsSequence in nonSphere.SnappedTo where pointsSequence.CurveCategory == CurveCategories.Silhouette where HasEndpointOnSphere(pointsSequence, sphere) select pointsSequence; return(sketchSilhouettes.Any()); }
private IEnumerable <Annotation> InferSphereAnnotations(SnappedSphere toBeAnnotatedSphere) { // we will take the list of all non-spheres, to test against the new sphere var snappedPrimitives = sessionData.SnappedPrimitives; var notSpheres = snappedPrimitives.Except(snappedPrimitives.OfType <SnappedSphere>()); return(from notSphere in notSpheres from constraint in GetConstraintsForSphereWithNonspherePair(notSphere, toBeAnnotatedSphere) select constraint); }
public static Visual3D CreateSphereView(SnappedSphere sphereData) { Contract.Requires(sphereData != null); Contract.Ensures(Contract.Result <Visual3D>() != null); var meshBuilder = new MeshBuilder(true, true); meshBuilder.AddSphere(sphereData.CenterResult, sphereData.RadiusResult); var geometry = meshBuilder.ToMesh(); return(CreateVisual(geometry, sphereData)); }
private bool IsInsideSphere(FeatureCurve curve, SnappedSphere toBeAnnotatedSphere) { var snappedPoints = GetSnappedPoints(curve); var insideSpherePointsCount = snappedPoints.Count(p => IsInsideSphere(p, toBeAnnotatedSphere)); if (insideSpherePointsCount > 0.5 * snappedPoints.Length) // at-least half of the points are inside the sphere { return(true); } else { return(false); } }
public static void Read(this VectorsReader reader, SnappedSphere sphere) { sphere.CenterResult = reader.ReadPoint3D(); sphere.RadiusResult = reader.ReadValue(); }
public static VariableVectorsWriter Write(this VariableVectorsWriter writer, SnappedSphere sphere) { return(writer .Write(sphere.Center) .Write(sphere.Radius)); }
public static VectorsWriter Write(this VectorsWriter writer, SnappedSphere sphere) { return(writer .Write(sphere.CenterResult) .Write(sphere.RadiusResult)); }
private IEnumerable <Annotation> SilhouettesWithEndpointsOnSphereAnnotation(SnappedPrimitive nonSphere, SnappedSphere sphere) { var unsnappedFeatureCurves = from featureCurve in nonSphere.FeatureCurves where featureCurve.IsFree() select featureCurve; var firstUnsnapped = unsnappedFeatureCurves.First(); yield return(new OnSphere { CenterTouchesSphere = firstUnsnapped, SphereOwned = sphere.ProjectionParallelCircle, Elements = Utils.Enumerable.ArrayOf(firstUnsnapped, sphere.ProjectionParallelCircle), }); }
private IEnumerable <Annotation> GetConstraintsForSphereWithNonspherePair(SnappedPrimitive nonSphere, SnappedSphere sphere) { var featureCurvesOnSphere = FindFeatureCurvesOnSphere(nonSphere, sphere); if (featureCurvesOnSphere.Any()) { return(FeatureCurvesOnSphereAnnotation(featureCurvesOnSphere, sphere)); } var hasSilhouettesWithEndpointsOnSphere = HasSilhouettesWithEndpointsOnSphere(nonSphere, sphere); if (hasSilhouettesWithEndpointsOnSphere) { return(SilhouettesWithEndpointsOnSphereAnnotation(nonSphere, sphere)); } return(Enumerable.Empty <Annotation>()); }
private IEnumerable <FeatureCurve> FindFeatureCurvesOnSphere(SnappedPrimitive snappedPrimitive, SnappedSphere toBeAnnotatedSphere) { var snappedFeatureCurvesInsideSphere = from curve in snappedPrimitive.FeatureCurves where curve.IsSnapped() where IsInsideSphere(curve, toBeAnnotatedSphere) select curve; return(snappedFeatureCurvesInsideSphere.ToArray()); }
private IEnumerable <Annotation> FeatureCurvesOnSphereAnnotation(IEnumerable <FeatureCurve> featureCurvesOnSphere, SnappedSphere toBeAnnotatedSphere) { var farthestFeatureCurve = featureCurvesOnSphere.Minimizer(fc => - fc.CenterResult.Z); // maximal Z coordinate yield return(new OnSphere { CenterTouchesSphere = farthestFeatureCurve, SphereOwned = toBeAnnotatedSphere.ProjectionParallelCircle, Elements = new FeatureCurve[] { farthestFeatureCurve, toBeAnnotatedSphere.ProjectionParallelCircle } }); }