public override void PrerenderUpdate() { var bezier = Shape as BezierCurveC2; if (bezier == null) { return; } bezier.ControlPoints = Objects.Select(t => t.Reference.Position).ToList(); if (bezier.ControlPoints.Count > 3) { var bernstein = BSplineToBernsteinConverter.ConvertAssumingEquidistantKnots(bezier.ControlPoints); if (_virtualPoints.Count == bernstein.Count) { for (var i = 0; i < _virtualPoints.Count; ++i) { _virtualPoints[i].Position = bernstein[i]; } } else { _virtualPoints = bernstein.Select(t => new BSplineBernsteinVirtualPoint(this) { Position = t }).ToList(); } } else { _virtualPoints.Clear(); } }
public void UpdateGeometry(Func <Point3D, Point3D, double> estimateScreenDistanceWithoutClip, Predicate <Point3D> isInsideProjectiveCubePredicate) { IList <Point3D> chosenControlPoints; var controlPointsColor = Colors.White; IList <Vertex> rawPointsList = new List <Vertex>(); switch (Basis) { case CurveBasis.Bernstein: chosenControlPoints = BSplineToBernsteinConverter.ConvertAssumingEquidistantKnots( ControlPoints ); rawPointsList = BezierCurveC0.SampleBezierCurveC0( chosenControlPoints, estimateScreenDistanceWithoutClip, 3 ); controlPointsColor = Colors.Red; break; case CurveBasis.BSpline: chosenControlPoints = ControlPoints; rawPointsList = SampleBSplineCurve(ControlPoints, CustomKnots, ApplyParameterCorrection, estimateScreenDistanceWithoutClip); break; default: throw new ArgumentOutOfRangeException(); } RawPoints = new List <Vertex>(); Vertices = new List <Vertex>(); MarkerPoints = new List <Vertex>(); Lines = new List <IndexedLine>(); if (rawPointsList.Count > 0) { Vertices = rawPointsList; Lines = Enumerable.Range(0, rawPointsList.Count - 1).Select(t => new IndexedLine(t, t + 1)).ToList(); } if (IsPolygonRenderingEnabled && ControlPoints.Count >= 2) { var additionalVertices = ControlPoints.Select(t => new Vertex(t, Colors.Gray)).ToList(); var additionalLines = Enumerable.Range(Vertices.Count, ControlPoints.Count - 1).Select(t => new IndexedLine(t, t + 1)).ToList(); Vertices = Vertices.Concat(additionalVertices).ToList(); Lines = Lines.Concat(additionalLines).ToList(); } if (!ReferenceEquals(chosenControlPoints, ControlPoints)) { MarkerPoints = chosenControlPoints.Select(t => new Vertex(t, controlPointsColor)).ToList(); } // display bernstein points /* * MarkerPoints = new List<Vertex>(); * if (ControlPoints.Count > 3) * { * var bernsteinVertices = * BSplineToBernsteinConverter.ConvertAssumingEquidistantKnots(ControlPoints); * MarkerPoints = bernsteinVertices * } */ // *** }