Skip to content

Commit 93b74b7

Browse files
authored
Merge pull request #322 from twobrainsgmbh/perf/improve-events
[twobrains] A faster way for change notifications
2 parents 23308d9 + 59b2471 commit 93b74b7

17 files changed

Lines changed: 441 additions & 437 deletions

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root = true
2+
3+
[*.cs]
4+
indent_style = space
5+
tab_width = 4
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
spelling_languages = en-us,de-de
10+
dotnet_sort_system_directives_first = true

CADability/BSpline.cs

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CADability.Attribute;
1+
using CADability.Attribute;
22
using CADability.Curve2D;
33
using CADability.UserInterface;
44
using System;
@@ -61,7 +61,7 @@ public class BSpline : IGeoObjectImpl, IColorDef, ILineWidth, ILinePattern, ISer
6161
private Plane? plane; // liegt in dieser Ebene, wenn spezifiziert
6262
#if NET_45
6363
private WeakReference<ExplicitPCurve3D> explicitPCurve3D;
64-
#else
64+
#else
6565
private WeakReference explicitPCurve3D;
6666
#endif
6767
// NurbsHelper Daten
@@ -197,20 +197,20 @@ private void MakeNurbsHelper()
197197
{
198198
double dknot = knots[knots.Length - 1] - knots[0];
199199
// letztlich ist es komisch, dass zwei knoten vornedran müssen
200-
//for (int i = 0; i < 1; ++i) //
200+
//for (int i = 0; i < 1; ++i) //
201201
//{
202202
// knotslist.Insert(0, knotslist[knotslist.Count - degree - i] - dknot);
203203
//}
204204
//for (int i = 0; i < 2 * degree - 2; ++i)
205205
//{
206206
// knotslist.Add(knotslist[2 * (degree - 1) + i] + dknot);
207207
//}
208-
// neue Idee:
208+
// neue Idee:
209209
// 1. es werden immer "degree" poles hinten angehängt
210210
// 2. der 1. Knoten muss immer degree+1 mal vorkommen ( siehe STEP/piece0: dort sind alle Knoten 4-fach
211211
// bei degree=5 und FindSpan muss immer eine Stelle finden, an der es gerade wechselt
212212
// 3. es werden soviele Knoten hinten angehängt, dass "knotslist.Length-degree-1 == poles.length" gilt
213-
//for (int i = 0; i < 1; ++i) //
213+
//for (int i = 0; i < 1; ++i) //
214214
//{
215215
// knotslist.Insert(0, knotslist[knotslist.Count - degree - i] - dknot);
216216
//}
@@ -458,7 +458,7 @@ private void InsertInterpol(double sp, double ep, List<GeoPoint> pointList, List
458458
//bool ok = false;
459459
//if (sa >= 0 && sm >= 0) ok = sm <= sa;
460460
//if (sa < 0 && sm < 0) ok = sm >= sa;
461-
// Die Frage ist, wie groß ist der Fehler. Man kann nicht einfach in der Mitte testen,
461+
// Die Frage ist, wie groß ist der Fehler. Man kann nicht einfach in der Mitte testen,
462462
// da der Verlauf der Kurve nicht bekannt ist, insbesondere ein Wendepunkt kann zu Fehlern
463463
// führen. So testen wir hier jeweils noch die 1/4 und 3/4 Punkte um einigerm´ßen sicher
464464
// zu gehen
@@ -708,7 +708,7 @@ public bool ThroughPoints(GeoPoint[] points, int maxDegree, bool closed, double[
708708
// SetOcasBuddy(edg.GetGeneralEdge());
709709
// FireDidChange(ce);
710710
// return true;
711-
// }
711+
// }
712712
// catch (OpenCascade.Exception)
713713
// {
714714
// return false;
@@ -921,7 +921,7 @@ public bool SetData(int degree, GeoPoint[] poles, double[] weights, double[] kno
921921
//- the Poles and Weights arrays have the same dimension and this dimension is greater than or equal to 2,
922922
//- the Knots and Multiplicities arrays have the same dimension and this dimension is greater than or equal to 2,
923923
//- the knots sequence is in ascending order, i.e. Knots(i) is less than Knots(i+1),
924-
//- the multiplicity coefficients are in the range 1 to Degree. However, on a non-periodic curve, the first and last multiplicities
924+
//- the multiplicity coefficients are in the range 1 to Degree. However, on a non-periodic curve, the first and last multiplicities
925925
// may be Degree + 1 (this is recommended if you want the curve to start and finish on the first and last poles),
926926
//- on a periodic curve the first and last multiplicities must be the same,
927927
//- on a non-periodic curve, the number of poles is equal to the sum of the multiplicity coefficients, minus Degree, minus 1,
@@ -1089,7 +1089,7 @@ public void SetThroughPoint(int Index, GeoPoint NewValue)
10891089
// throughPoints3d[Index] = NewValue;
10901090
// RecalcFromEdge(edg);
10911091
// }
1092-
// }
1092+
// }
10931093
// catch (OpenCascade.Exception)
10941094
// {
10951095
// }
@@ -1235,17 +1235,17 @@ public bool IsClosed
12351235
if (!done)
12361236
{
12371237
if (multiplicities.Length > 1)
1238-
{ // ob das so ganz allgemein gilt, muss noch überprüft werden,
1238+
{ // ob das so ganz allgemein gilt, muss noch überprüft werden,
12391239
// die Bedinungen sind so:
1240-
// 1. the multiplicity coefficients are in the range 1 to Degree.
1241-
// However, on a non-periodic curve, the first and last multiplicities may be
1242-
// Degree + 1 (this is recommended if you want the curve to start
1240+
// 1. the multiplicity coefficients are in the range 1 to Degree.
1241+
// However, on a non-periodic curve, the first and last multiplicities may be
1242+
// Degree + 1 (this is recommended if you want the curve to start
12431243
// and finish on the first and last poles),
12441244
// 2. on a periodic curve the first and last multiplicities must be the same,
1245-
// 3. on a non-periodic curve, the number of poles is equal to the sum of the
1245+
// 3. on a non-periodic curve, the number of poles is equal to the sum of the
12461246
// multiplicity coefficients, minus Degree, minus 1,
1247-
// 4. on a periodic curve, the number of poles is equal to the sum of knot
1248-
// multiplicities, excluding the last knot.
1247+
// 4. on a periodic curve, the number of poles is equal to the sum of knot
1248+
// multiplicities, excluding the last knot.
12491249
if (value)
12501250
{ // es wird geschlossen
12511251
// 1. Bedingung
@@ -1294,7 +1294,7 @@ public bool IsClosed
12941294
// die 3. Bedingung muss erfüllt werden
12951295
int sum = 0;
12961296
for (int i = 0; i < multiplicities.Length; ++i) sum += multiplicities[i];
1297-
// 3. on a non-periodic curve, the number of poles is equal to the sum of the
1297+
// 3. on a non-periodic curve, the number of poles is equal to the sum of the
12981298
// multiplicity coefficients, minus Degree, minus 1,
12991299
int dif = poles.Length - (sum - degree - 1);
13001300
int j = 0; // zuerst die beiden äußeren erhöhen
@@ -3549,13 +3549,10 @@ bool ICurve.TryPointDeriv2At(double position, out GeoPoint point, out GeoVector
35493549
private ColorDef colorDef;
35503550
public ColorDef ColorDef
35513551
{
3552-
get
3553-
{
3554-
return colorDef;
3555-
}
3552+
get => colorDef;
35563553
set
35573554
{
3558-
using (new ChangingAttribute(this, "ColorDef", colorDef))
3555+
using (ChangingAttribute.Create(this, colorDef))
35593556
{
35603557
colorDef = value;
35613558
}
@@ -3574,13 +3571,10 @@ void IColorDef.SetTopLevel(ColorDef newValue, bool overwriteChildNullColor)
35743571
private LineWidth lineWidth;
35753572
public LineWidth LineWidth
35763573
{
3577-
get
3578-
{
3579-
return lineWidth;
3580-
}
3574+
get => lineWidth;
35813575
set
35823576
{
3583-
using (new ChangingAttribute(this, "LineWidth", lineWidth))
3577+
using (ChangingAttribute.Create(this, lineWidth))
35843578
{
35853579
lineWidth = value;
35863580
}
@@ -3591,13 +3585,10 @@ public LineWidth LineWidth
35913585
private LinePattern linePattern;
35923586
public LinePattern LinePattern
35933587
{
3594-
get
3595-
{
3596-
return linePattern;
3597-
}
3588+
get => linePattern;
35983589
set
35993590
{
3600-
using (new ChangingAttribute(this, "LinePattern", linePattern))
3591+
using (ChangingAttribute.Create(this, linePattern))
36013592
{
36023593
linePattern = value;
36033594
}

CADability/BlockRef.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CADability.Actions;
1+
using CADability.Actions;
22
using CADability.Attribute;
33
using CADability.UserInterface;
44
using System;
@@ -176,7 +176,7 @@ string IGeoObjectShowProperty.GetContextMenuId()
176176
#endregion
177177
}
178178
/// <summary>
179-
///
179+
///
180180
/// </summary>
181181
[Serializable()]
182182
public class BlockRef : IGeoObjectImpl, IColorDef, IGeoObjectOwner
@@ -609,13 +609,10 @@ public override bool AttributeChanged(INamedAttribute attribute)
609609
private ColorDef colorDef;
610610
public ColorDef ColorDef
611611
{
612-
get
613-
{
614-
return colorDef;
615-
}
612+
get => colorDef;
616613
set
617614
{
618-
using (new ChangingAttribute(this, "ColorDef", colorDef))
615+
using (ChangingAttribute.Create(this, colorDef))
619616
{
620617
colorDef = value;
621618
}

CADability/Ellipse.cs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CADability.Attribute;
1+
using CADability.Attribute;
22
using CADability.Curve2D;
33
using CADability.UserInterface;
44
using System;
@@ -109,7 +109,7 @@ public ICurve2D Curve2D
109109
}
110110

111111
/// <summary>
112-
///
112+
///
113113
/// </summary>
114114
[Serializable]
115115
public class Ellipse : IGeoObjectImpl, IColorDef, ILineWidth, ILinePattern, ICurve, ISerializable,
@@ -188,7 +188,7 @@ internal virtual EllipseData2D GetProjectionData(Projection pr)
188188
// implementieren
189189
//EllipseData2D res = (EllipseData2D)projectionData[pr];
190190
//if (res==null)
191-
//{
191+
//{
192192
// res = CalculateProjectionData(pr.ProjectionPlane);
193193
// projectionData[pr] = res;
194194
//}
@@ -306,7 +306,7 @@ internal virtual EllipseData2D CalculateProjectionData(Plane pr)
306306
res.sweepAng = (double)new SweepAngle(StartDir.Angle, EndDir.Angle, ccw);
307307
if (Math.Abs(res.sweepAng) < 1e-6 && Math.Abs(this.sweepParameter) > Math.PI)
308308
{
309-
// Sonderfall: ein fast Vollkreis wird nicht als solcher erkannt und liefert
309+
// Sonderfall: ein fast Vollkreis wird nicht als solcher erkannt und liefert
310310
// allerdings exakt 0.0 für sweepAng
311311
if (ccw) res.sweepAng = Math.Abs(this.sweepParameter);
312312
else res.sweepAng = -Math.Abs(this.sweepParameter);
@@ -358,7 +358,7 @@ internal virtual EllipseData2D CalculateProjectionData(Plane pr)
358358
res.sweepParameter = sw.Radian;
359359
if (Math.Abs(res.sweepParameter) < 1e-6 && Math.Abs(res.sweepAng) > Math.PI)
360360
{
361-
// Sonderfall: ein fast Vollkreis wird nicht als solcher erkannt und liefert
361+
// Sonderfall: ein fast Vollkreis wird nicht als solcher erkannt und liefert
362362
// allerdings exakt 0.0 für sweepAng
363363
if (ccw) res.sweepParameter = Math.Abs(res.sweepAng);
364364
else res.sweepParameter = -Math.Abs(res.sweepAng);
@@ -932,7 +932,7 @@ public void SetArcPlane2PointsRadiusLocation(Plane p, GeoPoint arcPoint1, GeoPoi
932932
if (Geometry.Dist(p.ToGlobal(pl[0].p), locationP) <
933933
Geometry.Dist(p.ToGlobal(pl[1].p), locationP))
934934
{
935-
if (distLoc > dist12) // ausserhalb
935+
if (distLoc > dist12) // ausserhalb
936936
centerIndex = 0;
937937
else centerIndex = 1;
938938
}
@@ -943,7 +943,7 @@ public void SetArcPlane2PointsRadiusLocation(Plane p, GeoPoint arcPoint1, GeoPoi
943943
else centerIndex = 0;
944944
}
945945

946-
// falls eine abweichende Lösong gewünscht ist (es gibt vier),
946+
// falls eine abweichende Lösong gewünscht ist (es gibt vier),
947947
// hier für die selSol-Fälle 1 und drei umkehrung des Mittelpunktes
948948
// if ((selSol % 2) != 0)
949949
if ((selSol & 0x1) != 0)
@@ -961,7 +961,7 @@ public void SetArcPlane2PointsRadiusLocation(Plane p, GeoPoint arcPoint1, GeoPoi
961961

962962
this.startParameter = new Angle(this.plane.Project(arcPoint1), this.plane.Project(this.Center));
963963
bool dir = (distLoc1 < 0.0);
964-
// falls eine abweichende Lösung gewünscht ist (es gibt vier),
964+
// falls eine abweichende Lösung gewünscht ist (es gibt vier),
965965
// hier für die selSol-Fälle zwei und drei umkehrung der Richtung
966966
// if (((selSol % 4) == 2)||((selSol % 4) == 3)) dir = !dir;
967967
if ((selSol & 0x2) != 0) dir = !dir;
@@ -1151,7 +1151,7 @@ public double TangentParameter(GeoVector Direction)
11511151
// dir ist jetzt im Einheitskreis, aber nicht unbedingt Länge 1, ist aber
11521152
// für Atan2 nicht wichtig
11531153
// der Atan2 liefert zu einer Senkrechten zu dir den Winkel, also
1154-
// den Parameter im Sinne der Ellipse. Der 2. Tangentenpunkt hat den
1154+
// den Parameter im Sinne der Ellipse. Der 2. Tangentenpunkt hat den
11551155
// Parameter u+pi (bei Atan2 sind die Parameter vertauscht Atan2(y,x))
11561156
return Math.Atan2(dir.x, -dir.y);
11571157
}
@@ -1963,18 +1963,18 @@ internal Ellipse[] SplitAtZero()
19631963
private ColorDef colorDef;
19641964

19651965
public ColorDef ColorDef
1966-
{
1967-
get { return colorDef; }
1968-
set
1969-
{
1970-
using (new ChangingAttribute(this, "ColorDef", colorDef))
1971-
{
1972-
colorDef = value;
1973-
}
1974-
}
1975-
}
1966+
{
1967+
get => colorDef;
1968+
set
1969+
{
1970+
using (ChangingAttribute.Create(this, colorDef))
1971+
{
1972+
colorDef = value;
1973+
}
1974+
}
1975+
}
19761976

1977-
void IColorDef.SetTopLevel(ColorDef newValue)
1977+
void IColorDef.SetTopLevel(ColorDef newValue)
19781978
{
19791979
colorDef = newValue;
19801980
}
@@ -1992,10 +1992,10 @@ void IColorDef.SetTopLevel(ColorDef newValue, bool overwriteChildNullColor)
19921992

19931993
public LineWidth LineWidth
19941994
{
1995-
get { return lineWidth; }
1995+
get => lineWidth;
19961996
set
19971997
{
1998-
using (new ChangingAttribute(this, "LineWidth", lineWidth))
1998+
using (ChangingAttribute.Create(this, lineWidth))
19991999
{
20002000
lineWidth = value;
20012001
}
@@ -2010,10 +2010,10 @@ public LineWidth LineWidth
20102010

20112011
public LinePattern LinePattern
20122012
{
2013-
get { return linePattern; }
2013+
get => linePattern;
20142014
set
20152015
{
2016-
using (new ChangingAttribute(this, "LinePattern", linePattern))
2016+
using (ChangingAttribute.Create(this, linePattern))
20172017
{
20182018
linePattern = value;
20192019
}
@@ -2044,7 +2044,7 @@ public double StartParameter
20442044
/// <summary>
20452045
/// Gets or sets the sweep amount of this arc. A full circle or ellipse must have a sweepparameter of
20462046
/// either 2.0*Math.PI or -2.0*Math.PI, The sweep parameter of circular or elliptical arcs are
2047-
/// in the range of -2.0*Math.PI &lt; SweepParameter &lt; 2.0*Math.PI. SweepParameter is often used
2047+
/// in the range of -2.0*Math.PI &lt; SweepParameter &lt; 2.0*Math.PI. SweepParameter is often used
20482048
/// in connection with startParameter
20492049
/// </summary>
20502050
public double SweepParameter
@@ -2317,7 +2317,7 @@ GeoPoint ICurve.StartPoint
23172317
Plane pln = plane;
23182318
if (!Precision.IsPointOnPlane(value, this.plane))
23192319
{
2320-
// die Ebene bleibt nicht erhalten. neue Ebene gegeben durch
2320+
// die Ebene bleibt nicht erhalten. neue Ebene gegeben durch
23212321
// Startpunkt, Endpunkt und Richtung senkrecht zum jetzigen Normalenvektor
23222322
GeoVector diry = (EndPoint - value) ^ plane.Normal;
23232323
if (Precision.IsNullVector(diry)) diry = plane.DirectionY;
@@ -2376,7 +2376,7 @@ GeoPoint ICurve.EndPoint
23762376
Plane pln = plane;
23772377
if (!Precision.IsPointOnPlane(value, this.plane))
23782378
{
2379-
// die Ebene bleibt nicht erhalten. neue Ebene gegeben durch
2379+
// die Ebene bleibt nicht erhalten. neue Ebene gegeben durch
23802380
// Startpunkt, Endpunkt und Richtung senkrecht zum jetzigen Normalenvektor
23812381
GeoVector diry = (StartPoint - value) ^ plane.Normal;
23822382
if (Precision.IsNullVector(diry)) diry = plane.DirectionY;
@@ -2423,7 +2423,7 @@ GeoPoint ICurve.EndPoint
24232423
}
24242424

24252425
/// <summary>
2426-
/// Returns the Parameter of the given point projected into the plane of this ellipse (pp).
2426+
/// Returns the Parameter of the given point projected into the plane of this ellipse (pp).
24272427
/// For a circle or arc this is the
24282428
/// radian of the angle of the point. For an ellipse this is the value (a), where
24292429
/// e.x = center.x+majorradius*cos(a), e.y = center.y+minorradius*cos(a) yields a point (e)

0 commit comments

Comments
 (0)