Skip to content

Commit

Permalink
Merge pull request #191 from ChrisClems/fix-warnings
Browse files Browse the repository at this point in the history
Compiler warning cleanup
  • Loading branch information
dsn27 authored Dec 10, 2024
2 parents 5db1387 + b734551 commit 46f2668
Show file tree
Hide file tree
Showing 31 changed files with 65 additions and 52 deletions.
3 changes: 0 additions & 3 deletions CADability/BSpline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ public class BSpline : IGeoObjectImpl, IColorDef, ILineWidth, ILinePattern, ISer
private GeoPoint[] interpol; // Interpolation mit einer gewissen Genauigkeit
private GeoVector[] interdir; // Interpolation mit einer gewissen Genauigkeit
private double[] interparam; // die Parameter zur Interpolation
private double maxInterpolError; // der größte Fehler bei der Interpolation
private BoundingCube extent;
private TetraederHull tetraederHull;
private GeoPoint[] approximation; // Interpolation mit der Genauigkeit der Auflösung
Expand Down Expand Up @@ -517,7 +516,6 @@ private void InvalidateSecondaryData()
interdir = null;
interparam = null;
approximation = null;
maxInterpolError = 0.0;
extent = BoundingCube.EmptyBoundingCube;
tetraederHull = null;
extrema = null;
Expand Down Expand Up @@ -551,7 +549,6 @@ public Changing(BSpline bSpline, bool keepNurbs)
bSpline.interpol = null;
bSpline.interdir = null;
bSpline.interparam = null;
bSpline.maxInterpolError = 0.0;
if (!keepNurbs)
{
bSpline.nubs3d = null;
Expand Down
2 changes: 1 addition & 1 deletion CADability/BSpline2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ public BSpline2D(GeoPoint2D[] poles, double[] weights, double[] knots, int[] mul
{
Init();
}
catch (NurbsException ne)
catch (NurbsException)
{
}
// sollte durch Start/Endparameter nur ein Teilbereich des Splines gelten, dann
Expand Down
2 changes: 1 addition & 1 deletion CADability/Block.cs
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ protected Block(SerializationInfo info, StreamingContext context)
name = (string)info.GetValue("Name", typeof(string));
// FinishDeserialization.AddToContext(context,this);
}
catch (SerializationException ex)
catch (SerializationException)
{
SerializationInfoEnumerator e = info.GetEnumerator();
while (e.MoveNext())
Expand Down
2 changes: 1 addition & 1 deletion CADability/BorderOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ private void GenerateClusterSet()
GeoVector2D dir2 = border2.DirectionAt(isp[j].par2).Normalized;
dirz = dir1.x * dir2.y - dir1.y * dir2.x;
}
catch (GeoVectorException e)
catch (GeoVectorException)
{
dirz = 0.0;
}
Expand Down
2 changes: 1 addition & 1 deletion CADability/BorderQuadTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ public BorderQuadTree(Border bdr1, Border bdr2, double precision)
position = BorderPosition.intersecting;
break;
}
catch (CriticalPosition cp)
catch (CriticalPosition)
{ // Korrekturwert für nächste Runde, wenn es einen Schnittpunkt genau auf einer Kante gab oder einen tangentialen Schnitt
center = center + korr;
width = width + korr.Length;
Expand Down
23 changes: 22 additions & 1 deletion CADability/BoundingRect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace CADability
/// so assignements always make a copy.
/// </summary>
[Serializable()]
public struct BoundingRect : IQuadTreeInsertable, IComparable<BoundingRect>, ISerializable
public struct BoundingRect : IQuadTreeInsertable, IComparable<BoundingRect>, ISerializable, IEquatable<BoundingRect>
{
public double Left;
public double Right;
Expand Down Expand Up @@ -824,6 +824,27 @@ internal GeoPoint2D[] GetLines(double v1, double v2)
}
#endregion

public bool Equals(BoundingRect other)
{
return Left.Equals(other.Left) && Right.Equals(other.Right) && Bottom.Equals(other.Bottom) && Top.Equals(other.Top);
}

public override bool Equals(object obj)
{
return obj is BoundingRect other && Equals(other);
}

public override int GetHashCode()
{
unchecked
{
var hashCode = Left.GetHashCode();
hashCode = (hashCode * 397) ^ Right.GetHashCode();
hashCode = (hashCode * 397) ^ Bottom.GetHashCode();
hashCode = (hashCode * 397) ^ Top.GetHashCode();
return hashCode;
}
}
}

}
2 changes: 1 addition & 1 deletion CADability/ColorDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public ColorDef(SerializationInfo info, StreamingContext context)
{
color = (Color)info.GetValue("Color", typeof(Color));
}
catch (Exception e)
catch (Exception)
{
color = Color.Black;
}
Expand Down
2 changes: 1 addition & 1 deletion CADability/ColorSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected ColorSetting(SerializationInfo info, StreamingContext context)
color = (Color)info.GetValue("Color", typeof(Color));
object dbg = info.GetValue("Color", typeof(object));
}
catch (Exception e)
catch (Exception)
{
color = Color.Black;
}
Expand Down
4 changes: 2 additions & 2 deletions CADability/ConstrHatchInside.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private void OnPoint(GeoPoint p)
{
findShapeThread.Abort();
}
catch (System.Threading.ThreadStateException e)
catch (System.Threading.ThreadStateException)
{
findShapeIsRunning = false;
return; // keinen weiteren thread starten
Expand All @@ -269,7 +269,7 @@ private void OnPoint(GeoPoint p)
{
findShapeThread.Join();
}
catch (System.Threading.ThreadStateException e)
catch (System.Threading.ThreadStateException)
{
findShapeIsRunning = false;
return; // keinen weiteren thread starten
Expand Down
2 changes: 1 addition & 1 deletion CADability/CoordSys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public CoordSys(GeoPoint Location, GeoVector DirectionX, GeoVector DirectionY)
directionY.Norm();
directionZ.Norm();
}
catch (GeoVectorException e)
catch (GeoVectorException)
{
throw new CoordSysException(CoordSysException.tExceptionType.ConstructorFailed);
}
Expand Down
5 changes: 0 additions & 5 deletions CADability/DualSurfaceCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,6 @@ public class ProjectedCurve : GeneralCurve2D, ISerializable
BoundingRect periodicDomain; // only for periodic domains: to which period the 3d points should be mapped
GeoPoint2D startPoint2d, endPoint2d;
bool startPointIsPole, endPointIsPole;
bool spu, epu; // starting or ending pole in u
#if DEBUG
static int debugCounter = 0;
private int debugCount; // to identify instance when debugging
Expand Down Expand Up @@ -704,14 +703,12 @@ public ProjectedCurve(ICurve curve3D, ISurface surface, bool forward, BoundingRe
GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.1));
startPoint2d = new GeoPoint2D(us[i], tmp.y);
startPointIsPole = true;
spu = true;
}
if ((pl | ep) < prec)
{
GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.9));
endPoint2d = new GeoPoint2D(us[i], tmp.y);
endPointIsPole = true;
epu = true;
}
}
double[] vs = surface.GetVSingularities();
Expand All @@ -723,14 +720,12 @@ public ProjectedCurve(ICurve curve3D, ISurface surface, bool forward, BoundingRe
GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.1));
startPoint2d = new GeoPoint2D(tmp.x, vs[i]);
startPointIsPole = true;
spu = false;
}
if ((pl | ep) < prec*10)
{
GeoPoint2D tmp = surface.PositionOf(curve3D.PointAt(0.9));
endPoint2d = new GeoPoint2D(tmp.x, vs[i]);
endPointIsPole = true;
epu = false;
}
}
if (forward)
Expand Down
2 changes: 1 addition & 1 deletion CADability/Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2713,7 +2713,7 @@ private void Approximate(SortedDictionary<double, GeoPoint2D> parpoint, ICurve2D
Polyline pdbg = Polyline.Construct();
pdbg.SetPoints(pnts, false);
}
catch (PolylineException ex) { };
catch (PolylineException) { };
}
#endif
if (curve3d != null) dist = Math.Max(dist, curve3d.DistanceTo(mp));
Expand Down
2 changes: 1 addition & 1 deletion CADability/Ellipse2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ public double NewtonPerpendicular(GeoPoint2D fromHere, double position)
MinimizationResult mres = nm.FindMinimum(iof, new DenseVector(new double[] { position }));
return mres.MinimizingPoint[0];
}
catch (Exception ex)
catch (Exception)
{
return iof.Point[0];
}
Expand Down
2 changes: 1 addition & 1 deletion CADability/ExportToWebGl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ public bool WriteToFile(string outPath)
outfile.Close();
}
}
catch (IOException e)
catch (IOException)
{
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions CADability/Face.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6305,7 +6305,7 @@ private void Triangulate(double precision)
}
}
}
catch (ApplicationException e)
catch (ApplicationException)
{ // something went wrong with the triangulation. This should not happen and needs to be debugged and fixed
}
triangleExtent = BoundingCube.EmptyBoundingCube; // needs to be recalculated
Expand Down Expand Up @@ -6606,7 +6606,7 @@ public void GetSimpleTriangulation(double precision, bool noInnerPoints, out Geo
}
#endif
}
catch (ApplicationException e)
catch (ApplicationException)
{ // Selbstüberschneidungen von Löchern und Rand oder in den Rändern selbst
List<GeoPoint2D> sumTriUv = new List<GeoPoint2D>();
List<GeoPoint> sumTriPoint = new List<GeoPoint>();
Expand Down
4 changes: 2 additions & 2 deletions CADability/Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ private static Dictionary<Type, string> FindAllGeoObjects()
}
return res;
}
catch (System.Reflection.ReflectionTypeLoadException e)
catch (System.Reflection.ReflectionTypeLoadException)
{
// MessageBox.Show(e.Message);
return new Dictionary<Type, string>();
Expand Down Expand Up @@ -770,7 +770,7 @@ public override void EndEdit(bool aborted, bool modified, string newValue)
{
Name = newValue;
}
catch (NameAlreadyExistsException e) { }
catch (NameAlreadyExistsException) { }
}
}
public override string LabelText { get => Name; set => Name = value; }
Expand Down
2 changes: 1 addition & 1 deletion CADability/GeneralCurve2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1627,7 +1627,7 @@ protected void MakeTriangulation()
if (directions[0].IsNullVector()) linterdir.Add((points[1] - points[0]).Normalized);
else linterdir.Add(directions[0].Normalized);
}
catch (GeoVectorException ex)
catch (GeoVectorException)
{
linterdir.Add(GeoVector2D.XAxis);
}
Expand Down
2 changes: 1 addition & 1 deletion CADability/LayerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ private void OnRemoveUnused()
}
} while (found);
}
catch (InvalidOperationException e)
catch (InvalidOperationException)
{ // soll mal bei der Iteration vorgekommen sein (Mail vom 21.10 13, Nürnberger) kann ich mir aber nicht erklären
}
}
Expand Down
4 changes: 2 additions & 2 deletions CADability/LayoutView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void Print(PrintDocument pd)
{
pd.Print();
}
catch (Exception e)
catch (Exception)
{
}
pd.PrintPage -= new PrintPageEventHandler(pdg.OnPrintPage);
Expand All @@ -141,7 +141,7 @@ public void Print(PrintDocument pd)
{
pd.Print();
}
catch (Exception e)
catch (Exception)
{
}
pd.PrintPage -= new PrintPageEventHandler(OnPrintPage);
Expand Down
2 changes: 1 addition & 1 deletion CADability/MultiGeoPointProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ private void OnFilterSinglePointCommand(GeoPointProperty sender, string menuId,
break;
}
}
catch (IndexOutOfRangeException e)
catch (IndexOutOfRangeException)
{
}
}
Expand Down
4 changes: 2 additions & 2 deletions CADability/NurbsSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1976,7 +1976,7 @@ bool GetSimpleSurfaceX(double precision, out ISurface simpleSurface, out ModOp2D
{
reparametrisation = ModOp2D.Fit(srcf, dstf, true);
}
catch (ModOpException mex)
catch (ModOpException)
{
return false;
}
Expand Down Expand Up @@ -2825,7 +2825,7 @@ private bool isPlanarSurface(double precision, out ISurface simpleSurface, out M
if (!isPlane) break;
}
}
catch (ModOpException mex)
catch (ModOpException)
{
isPlane = false;
}
Expand Down
2 changes: 1 addition & 1 deletion CADability/Plane.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Plane(GeoPoint Location, GeoVector DirectionX, GeoVector DirectionY)
{
coordSys = new CoordSys(Location, DirectionX, DirectionY);
}
catch (CoordSysException e)
catch (CoordSysException)
{
throw new PlaneException(PlaneException.tExceptionType.ConstructorFailed);
}
Expand Down
12 changes: 6 additions & 6 deletions CADability/PrintToGDI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ public override void Print(Graphics gr, bool doShading)
{
ff = new FontFamily(fontName);
}
catch (System.ArgumentException ae)
catch (System.ArgumentException)
{
ff = new FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif);
}
Expand Down Expand Up @@ -909,7 +909,7 @@ public override int CompareCommonPointZ(BoundingRect rect, IPrintItemImpl other)
GeoPoint2D ip = cs.SimpleShapes[0].Outline.SomeInnerPoint;
return ZPositionAt(ip).CompareTo((other as PrintTriangle).ZPositionAt(ip));
}
catch (BorderException ex)
catch (BorderException)
{
return 0;
}
Expand Down Expand Up @@ -1230,7 +1230,7 @@ public override void Print(Graphics gr, bool doShading)
br.Dispose();
}
}
catch (Exception ex)
catch (Exception)
{
}

Expand Down Expand Up @@ -1535,7 +1535,7 @@ public static void PrintSinglePage(Project pr, string nameOfView, bool print2D,
pd.PrintPage -= new PrintPageEventHandler(ptg.OnPrintPage);
(found as IView).Projection.ShowFaces = sf;
}
} catch (Exception ex)
} catch (Exception)
{
// MessageBox.Show(ex.StackTrace, "Exception in PrintSinglePage");
}
Expand Down Expand Up @@ -1844,7 +1844,7 @@ public void OnPrintPage(object sender, PrintPageEventArgs e)
e.Graphics.DrawImage(bmp, dest, src, GraphicsUnit.Pixel);
}
}
catch (Exception ex)
catch (Exception)
{
// MessageBox.Show(ex.StackTrace, "Exception in OnPrintPage");
}
Expand Down Expand Up @@ -2488,7 +2488,7 @@ void IPaintTo3D.Text(GeoVector lineDirection, GeoVector glyphDirection, GeoPoint
{
ff = new FontFamily(fontName);
}
catch (System.ArgumentException ae)
catch (System.ArgumentException)
{
ff = new FontFamily(System.Drawing.Text.GenericFontFamilies.SansSerif);
}
Expand Down
4 changes: 2 additions & 2 deletions CADability/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,7 @@ public static Project ReadFromStream(Stream stream)
}
return null;
}
catch (Exception e)
catch (Exception)
{
formatter = new BinaryFormatter(); // (null, new StreamingContext(StreamingContextStates.File, finishDeserialization));
formatter.Binder = new CondorSerializationBinder();
Expand Down Expand Up @@ -1603,7 +1603,7 @@ internal static Project ReadFromFile(string FileName, bool useProgress)
}
res.fileName = FileName;
}
catch (ProjectOldVersionException ex)
catch (ProjectOldVersionException)
{
stream.Close();
stream.Dispose();
Expand Down
2 changes: 1 addition & 1 deletion CADability/Projection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,7 @@ public GeoObjectList MakeArrow(GeoPoint p1, GeoPoint p2, Plane plane, ArrowMode
res.Add(Face.MakeFace(new PlaneSurface(arrowPlane), new SimpleShape(Border.MakeCircle(GeoPoint2D.Origin, arrowSize))));
res.Add(Face.MakeFace(new PlaneSurface(arrowPlane), new SimpleShape(Border.MakePolygon(new GeoPoint2D[] { new GeoPoint2D(headx, 0), new GeoPoint2D(headx - arrowSize, arrowSize), new GeoPoint2D(headx - arrowSize, -arrowSize) }))));
}
catch (PlaneException _) { }
catch (PlaneException) { }
}
return res;
}
Expand Down
Loading

0 comments on commit 46f2668

Please sign in to comment.