//-------------------------------------------------------------------------------------------------- void _AddBSplineCurve(Geom2d_BSplineCurve bspline, double first, double last) { // Cut spline bspline = Geom2dConvert.SplitBSplineCurve(bspline, first, last, 0.00001); if (_Document.Flags.HasFlag(DxfFlags.ExportSplineAsPolygon)) { _AddPolygonCurve(bspline); return; } if (bspline.Degree() > 3) { // Try to reduce the order of the curve var continuity = bspline.Continuity(); if (continuity != GeomAbs_Shape.GeomAbs_C0) { continuity = GeomAbs_Shape.GeomAbs_C1; } var converter = new Geom2dConvert_ApproxCurve(bspline, _Precision * 10.0, continuity, 100, 3); if (!(converter.IsDone() && converter.HasResult())) { Messages.Warning("DxfExporter: BSpline curve has an undecreasable degree of " + bspline.Degree() + "."); return; } bspline = converter.Curve(); } var knotSource = bspline.KnotSequence(); var knots = new double[knotSource.Length()]; int sourceStart = knotSource.Lower(); for (int i = 0; i < knots.Length; i++) { knots[i] = knotSource.Value(sourceStart + i); } var points = new Pnt2d[bspline.NbPoles()]; var weights = new double[points.Length]; for (int i = 0; i < bspline.NbPoles(); i++) { points[i] = bspline.Pole(i + 1); weights[i] = bspline.Weight(i + 1); } var flags = DxfDomSpline.SplineFlags.None; if (bspline.IsRational()) { flags = flags.Added(DxfDomSpline.SplineFlags.IsRational); } var entity = new DxfDomSpline(_CurrentLayer, bspline.Degree(), knots, points, weights, flags); _Document.Entities.Add(entity); }
//-------------------------------------------------------------------------------------------------- void _AddBSplineCurve(Geom2d_BSplineCurve geom2dBSpline) { var converter = new Geom2dConvert_BSplineCurveToBezierCurve(geom2dBSpline); for (int i = 1; i <= converter.NbArcs(); i += 1) { var arc = converter.Arc(i); _AddBezierCurve(arc, arc.FirstParameter(), arc.LastParameter()); } }
//-------------------------------------------------------------------------------------------------- protected void AddBSplineCurve(Geom2d_BSplineCurve geom2DBSpline, double first, double last, bool reverse) { var converter = new Geom2dConvert_BSplineCurveToBezierCurve(geom2DBSpline, first, last, 0.001 /*Precision.PConfusion() * 10*/); if (reverse) { for (int i = converter.NbArcs(); i >= 1; i -= 1) { var arc = converter.Arc(i); AddBezierCurve(arc, arc.FirstParameter(), arc.LastParameter(), true); } } else { for (int i = 1; i <= converter.NbArcs(); i += 1) { var arc = converter.Arc(i); AddBezierCurve(arc, arc.FirstParameter(), arc.LastParameter(), false); } } }
public void SetValue(int theIndex, Geom2d_BSplineCurve theItem) { throw new NotImplementedException(); }
public Geom2dConvert_BSplineCurveKnotSplitting(Geom2d_BSplineCurve Bas_isCurve, int ContinuityRange) : base() { throw new NotImplementedException(); }
public void FixTangentOnCurve(Geom2d_BSplineCurve theCurve, bool FirstFlag, bool LastFlag) { throw new NotImplementedException(); }
public Geom2d_BSplineCurve Solution(Geom2d_BSplineCurve BS, double TolPoles) { throw new NotImplementedException(); }
public Geom2dConvert_BSplineCurveToBezierCurve(Geom2d_BSplineCurve Bas_isCurve) : base() { throw new NotImplementedException(); }
public Geom2d_BSplineCurve SplitBSplineCurve(Geom2d_BSplineCurve C, int FromK1, int ToK2, bool SameOrientation) { throw new NotImplementedException(); }
public bool C0BSplineToSequenceOfC1BSplineCurve(Geom2d_BSplineCurve BS, TColGeom2d_HSequenceOfBoundedCurve seqBS) { throw new NotImplementedException(); }
public void ApproxBSplineCurve(Geom2d_BSplineCurve bspline, TColGeom2d_SequenceOfCurve seq) { throw new NotImplementedException(); }
public TColGeom2d_HArray1OfBSplineCurve(int theLower, int theUpper, Geom2d_BSplineCurve theValue) : base() { throw new NotImplementedException(); }
//-------------------------------------------------------------------------------------------------- public static bool RenderBSplineCurve(IDrawingRenderer renderer, Geom2d_BSplineCurve bspline, double first, double last, bool reverse) { if (renderer.Capabilities.BSplineCurveMaxDegree > 0) { bspline = Geom2dConvert.SplitBSplineCurve(bspline, first, last, 0.00001); if (bspline.Degree() > renderer.Capabilities.BSplineCurveMaxDegree) { // Try to reduce the order of the curve var continuity = bspline.Continuity(); if (continuity != GeomAbs_Shape.GeomAbs_C0) { continuity = GeomAbs_Shape.GeomAbs_C1; } var converter = new Geom2dConvert_ApproxCurve(bspline, 0.0001, continuity, 100, 3); if (!(converter.IsDone() && converter.HasResult())) { Messages.Warning("BrepRenderHelper: BSpline curve has an undecreasable degree of " + bspline.Degree() + "."); return(false); } bspline = converter.Curve(); } var knotSource = bspline.KnotSequence(); var knots = new double[knotSource.Length()]; int sourceStart = knotSource.Lower(); for (int i = 0; i < knots.Length; i++) { knots[i] = knotSource.Value(sourceStart + i); } var points = new Pnt2d[bspline.NbPoles()]; var weights = new double[points.Length]; for (int i = 0; i < bspline.NbPoles(); i++) { points[i] = bspline.Pole(i + 1); weights[i] = bspline.Weight(i + 1); } renderer.BSplineCurve(bspline.Degree(), knots, points, weights, bspline.IsRational()); return(true); } else { // Cannot render BSpline, Try bezier var converter = new Geom2dConvert_BSplineCurveToBezierCurve(bspline, first, last, 0.001 /*Precision.PConfusion() * 10*/); bool result = true; if (reverse) { for (int i = converter.NbArcs(); i >= 1; i -= 1) { var arc = converter.Arc(i); result &= RenderBezierCurve(renderer, arc, arc.FirstParameter(), arc.LastParameter(), true); } } else { for (int i = 1; i <= converter.NbArcs(); i += 1) { var arc = converter.Arc(i); result &= RenderBezierCurve(renderer, arc, arc.FirstParameter(), arc.LastParameter(), false); } } return(result); } }
public TColGeom2d_Array1OfBSplineCurve(Geom2d_BSplineCurve theBegin, int theLower, int theUpper) : base() { throw new NotImplementedException(); }
public Geom2d_BSplineCurve SplitBSplineCurve(Geom2d_BSplineCurve C, int FromK1, int ToK2) { throw new NotImplementedException(); }
public void Init(Geom2d_BSplineCurve theValue) { throw new NotImplementedException(); }
public Geom2d_BSplineCurve SplitBSplineCurve(Geom2d_BSplineCurve C, double FromU1, double ToU2, double ParametricTolerance) { throw new NotImplementedException(); }
public Geom2dConvert_BSplineCurveToBezierCurve(Geom2d_BSplineCurve Bas_isCurve, double U1, double U2, double ParametricTolerance) : base() { throw new NotImplementedException(); }
public void C0BSplineToC1BSplineCurve(Geom2d_BSplineCurve BS, double Tolerance) { throw new NotImplementedException(); }
public Geom2d_BSplineCurve Solution(Geom2d_BSplineCurve BS) { throw new NotImplementedException(); }
public void C0BSplineToArrayOfC1BSplineCurve(Geom2d_BSplineCurve BS, TColGeom2d_HArray1OfBSplineCurve tabBS, double AngularTolerance, double Tolerance) { throw new NotImplementedException(); }
public GeomLib_Check2dBSplineCurve(Geom2d_BSplineCurve Curve, double Tolerance, double AngularTolerance) : base() { throw new NotImplementedException(); }
public void SetBSpline(Geom2d_BSplineCurve C) { throw new NotImplementedException(); }
public void Add(Geom2d_BSplineCurve FirstCurve, Geom2d_BSplineCurve SecondCurve, bool After) { throw new NotImplementedException(); }
public bool SimplifyBSpline2d(Geom2d_BSplineCurve theBSpline2d, double theTolerance) { throw new NotImplementedException(); }