Skip to content

Commit

Permalink
Merge pull request #203 from FriendsOfCADability/FixCS0219
Browse files Browse the repository at this point in the history
Fix CS0219 - The variable 'variable' is assigned but its value is nev…
  • Loading branch information
dsn27 authored Dec 19, 2024
2 parents 60baaf2 + 3d23206 commit b971abf
Show file tree
Hide file tree
Showing 22 changed files with 26 additions and 84 deletions.
1 change: 0 additions & 1 deletion CADability.Forms/PaintToOpenGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ internal void Disconnect(Control ctrl)
// Wgl.wglGetCurrentContext();
// bool ok = Wgl.wglMakeCurrent(deviceContext, renderContext);
// if (ok)
bool ok = false;
// xxx ok = Wgl.wglDeleteContext(renderContext);
// man darf ihn hier nicht löschen, da er noch als Context für die SharedLists gebraucht wird
lock (ContextsToDelete)
Expand Down
7 changes: 1 addition & 6 deletions CADability/BRepIntersection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,6 @@ private void createEdgeFaceIntersections()
#if DEBUG
DebuggerContainer dcedges = new DebuggerContainer();
DebuggerContainer dcfaces = new DebuggerContainer();
int dbgcnt = 0;
foreach (EdgeFaceKey ef in edgesToFaces.Keys)
{
dcedges.Add(ef.edge.Curve3D as IGeoObject, ef.edge.GetHashCode());
Expand Down Expand Up @@ -3256,7 +3255,6 @@ public Shell[] Result()
{
DebuggerContainer dc = new DebuggerContainer();
dbgFaceTointersectionEdges[kv.Key] = dc;
int dbgc = 0;
double arrowSize = kv.Key.Area.GetExtent().Size * 0.02;
dc.Add(kv.Value, kv.Key, arrowSize, Color.Red, 0);
dc.Add(kv.Key.Edges, kv.Key, arrowSize, Color.Blue, 0);
Expand All @@ -3277,7 +3275,6 @@ public Shell[] Result()
{
DebuggerContainer dc = new DebuggerContainer();
dbgEdgePositions[kv.Key] = dc;
int dbgc = 0;
double arrowSize = kv.Key.Area.GetExtent().Size * 0.02;
dc.Add(kv.Value, kv.Key, arrowSize, Color.Red, 0);
dc.Add(kv.Key.Edges, kv.Key, arrowSize, Color.Blue, 0);
Expand Down Expand Up @@ -3499,7 +3496,6 @@ public Shell[] Result()
{
if (Math.Abs(a) > Math.Abs(biggestArea)) biggestArea = a;
}
bool totalOutlineAdded = false;
if (biggestArea < 0) // when no loop, we don't need the outline
{
foreach (Pair<List<Edge>, ICurve2D[]> item in loops.Values) faceEdges.RemoveMany(item.First);
Expand All @@ -3509,7 +3505,6 @@ public Shell[] Result()
List<Edge> outline = new List<Edge>(faceToSplit.OutlineEdges);
loops.AddUnique(outline, faceToSplit);
faceEdges.RemoveMany(outline); // we would not need that
totalOutlineAdded = true;
}
}
// we also add the holes of the faceToSplit, as long as it was not used by intersections and is not enclosed by a bigger hole
Expand Down Expand Up @@ -8613,7 +8608,7 @@ private void createNewEdges()
{
created.Add(edge);
// diese neue Kante in das Dictionary einfügen
bool addToFace1 = true, addToFace2 = true, rejected = false;
bool addToFace1 = true, addToFace2 = true;
Edge[] splitted = null;
if (j1IsOnBorder && j2IsOnBorder)
{ // a very rare case (like in BRepTest30.cdb.json): the new intersecting edge starts and ends on the border of the face AND contains an already existing vertex of that face.
Expand Down
6 changes: 1 addition & 5 deletions CADability/CylindricalSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1031,20 +1031,16 @@ public override IDualSurfaceCurve[] GetDualSurfaceCurves(BoundingRect thisBounds
{ // the smaller of this two cylinders completely penetrates the wider cylinder
// so we have two intersection curves (entering and leaving)
CylindricalSurface cyl1 = this;
bool exchanged = false;
BoundingRect bounds1, bounds2;
BoundingRect bounds1;
if (cyl2.RadiusX < cyl1.RadiusX)
{
cyl1 = cyl2;
cyl2 = this;
exchanged = true;
bounds2 = thisBounds;
bounds1 = otherBounds;
}
else
{
bounds1 = thisBounds;
bounds2 = otherBounds;
}
// cyl1 is the smaller one
GeoVector nrm = (cyl1.Axis ^ cyl2.Axis).Normalized;
Expand Down
4 changes: 0 additions & 4 deletions CADability/DimensionStyleList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,6 @@ private void UpdateAllDimensions(IGeoObject go)
{
dim.Recalc();
}
else
{
int dbg = 0;
}
}
else if (go is Block)
{
Expand Down
2 changes: 0 additions & 2 deletions CADability/DualSurfaceCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,6 @@ public ProjectedCurve(ICurve curve3D, ISurface surface, bool forward, BoundingRe
if (prec == 0.0) prec = curve3D.Length * 1e-3; // changed to 1e-3, it is used to snap endpoints to poles
startPoint2d = surface.PositionOf(curve3D.StartPoint);
endPoint2d = surface.PositionOf(curve3D.EndPoint);
bool distinctStartEndPoint = false;
if ((surface.IsUPeriodic && Math.Abs(startPoint2d.x - endPoint2d.x) < surface.UPeriod * 1e-3) ||
(surface.IsVPeriodic && Math.Abs(startPoint2d.y - endPoint2d.y) < surface.VPeriod * 1e-3))
{ // adjust start and endpoint according to its neighbors
Expand All @@ -649,7 +648,6 @@ public ProjectedCurve(ICurve curve3D, ISurface surface, bool forward, BoundingRe
SurfaceHelper.AdjustPeriodic(surface, periodicDomain, ref p2d);
ext.MinMax(p2d);
SurfaceHelper.AdjustPeriodic(surface, ext, ref endPoint2d);
distinctStartEndPoint = true;
}
periodicDomain = domain;
if (periodicDomain.IsEmpty() && (surface.IsUPeriodic || surface.IsVPeriodic))
Expand Down
1 change: 0 additions & 1 deletion CADability/Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,6 @@ private void Approximate(SortedDictionary<double, GeoPoint2D> parpoint, ICurve2D
// GeoPoint2D mp2d = curve2d.PointAt(ipar);
GeoPoint2D mp2d;
double dist = surface.MaxDist(parpoint[spar], parpoint[epar], out mp2d);
double distCurve = 0.0;
ipar = curve2d.PositionOf(mp2d);
//ipar = findMaxDist(spar, epar, curve2d, surface, out dist);
if (ipar <= spar || ipar >= epar)
Expand Down
2 changes: 0 additions & 2 deletions CADability/EllipseFit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ bool solveGeneralEigens(List<List<double>> sMtrx,
List<List<double>> eigVV)
{
//Parameter initialization
char jobvl = 'N';
char jobvr = 'V';
int nOrder = sMtrx.Count;
double[,] sArray = mtrx2array(sMtrx);
double[,] cArray = mtrx2array(cMtrx);
Expand Down
41 changes: 15 additions & 26 deletions CADability/Face.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,6 @@ internal static Face[] MakeFacesFromStepAdvancedFace(ISurface surface, List<List
}
// Some problem arise, because the curves may be not very precise. We try to adjust start- and endpoints
// so the connections are precise
bool orientationChanged = false;
for (int i = 0; i < loops.Count; i++)
{
if (loops[i].Count > 1)
Expand Down Expand Up @@ -478,20 +477,17 @@ internal static Face[] MakeFacesFromStepAdvancedFace(ISurface surface, List<List
else if (dmin == d2)
{
loops[i][jn].forward = !loops[i][jn].forward;
orientationChanged = true;
}
else if (dmin == d3)
{
loops[i][j].forward = !loops[i][j].forward;
orientationChanged = true;
}
else
{ // maybe only two curves and the other connection is a little bit better: we don't need to reverse
if (loops[i].Count > 2)
{
loops[i][j].forward = !loops[i][j].forward;
loops[i][jn].forward = !loops[i][jn].forward;
orientationChanged = true;
}
}
}
Expand Down Expand Up @@ -1580,11 +1576,9 @@ internal static Face[] MakeFacesFromStepAdvancedFace(ISurface surface, List<List
}
}
}
bool reversedii = false;
if (Geometry.InnerIntersection(loops[ii][loops[ii].Count - 1].curve2d.EndPoint, loops[oppii][0].curve2d.StartPoint, loops[oppii][loops[oppii].Count - 1].curve2d.EndPoint, loops[ii][0].curve2d.StartPoint))
{ // still self-intersecting
loops[ii].Reverse();
reversedii = true;
for (int i = 0; i < loops[ii].Count; i++)
{
loops[ii][i].forward = !loops[ii][i].forward;
Expand Down Expand Up @@ -1831,20 +1825,20 @@ internal static Face[] MakeFacesFromStepAdvancedFace(ISurface surface, List<List
if (loops[i][j].vertex2 != loops[i][j].createdEdges[0].Vertex1 && loops[i][j].vertex2 != loops[i][j].createdEdges[0].Vertex2) reverse = true;
}
if (reverse) loops[i][j].createdEdges.Reverse();
#if DEBUG
bool ok = true;
if (loops[i][j].forward)
{
if (loops[i][j].vertex2 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex1
&& loops[i][j].vertex2 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex2) ok = false;
}
else
{
if (loops[i][j].vertex1 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex1
&& loops[i][j].vertex1 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex2) ok = false;
}
// System.Diagnostics.Debug.Assert(OK); this may happen and is valid
#endif
//#if DEBUG
// bool ok = true;
// if (loops[i][j].forward)
// {
// if (loops[i][j].vertex2 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex1
// && loops[i][j].vertex2 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex2) ok = false;
// }
// else
// {
// if (loops[i][j].vertex1 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex1
// && loops[i][j].vertex1 != loops[i][j].createdEdges[loops[i][j].createdEdges.Count - 1].Vertex2) ok = false;
// }
// // System.Diagnostics.Debug.Assert(OK); this may happen and is valid
//#endif
}
for (int k = 0; k < loops[i][j].createdEdges.Count; k++)
{ // in most cases this is only a single edge, unless it has been splitted before
Expand Down Expand Up @@ -3772,8 +3766,7 @@ internal static GeoObjectList SortForWire(GeoObjectList ToSort)
GeoObjectList res = new GeoObjectList(ToSort.Count);
if (ToSort.Count == 0) return res;
GeoObjectList ToRemove = new GeoObjectList(ToSort);
double maxdist = 1e-6; // TODO: zu verbessern mit der Ausdehnung
// Ausdehnung in 3D (GeoObject, GeoObjectList)?

int found = 0;
GeoPoint LastEndPoint = new GeoPoint();
GeoPoint BestPoint = new GeoPoint();
Expand Down Expand Up @@ -4054,13 +4047,11 @@ public SimpleShape Area
if (boutline == null)
{
boutline = Border.FromOrientedList(segments); // 1. Versuch: schon richtig orientiert
bool testReverse = false;
if (boutline == null)
{
boutline = Border.FromUnorientedList(segments, true); // 2. Versuch: sortieren
// FromUnorientedList dreht u.U. die Liste um, das muss natürlich auch in der Reihenfolge der Outlines
// berücksichtigt werden
testReverse = true;
}
if (boutline == null) return null;
if (outline.Length > 1)
Expand Down Expand Up @@ -4093,14 +4084,12 @@ public SimpleShape Area
}
//Border hole = Border.FromOrientedList(holecurves);
Border hole = null;
bool testReverse = false;
if (hole == null)
{
hole = Border.FromOrientedList(holecurves); // 1. Versuch: schon richtig verbunden
if (hole == null)
{
hole = Border.FromUnorientedList(holecurves, true); // 2. Versuch: orientieren!
testReverse = true;
}
}
if (hole != null)
Expand Down
2 changes: 0 additions & 2 deletions CADability/GaussNewtonMinimizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ public bool Solve(double[] startParameters, int maxIterations, double updateLeng
{
double[] minLocation = startParameters.Clone() as double[];
minError = double.MaxValue;
double minErrorDifference = double.MaxValue;
double minUpdateLength = 0.0;
numIterations = 0;
errorFunction(startParameters, out Error);
minError = dot(Error, Error);
Expand Down
4 changes: 2 additions & 2 deletions CADability/Geometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3081,8 +3081,8 @@ internal static double DistancePointEllipse(
/// <param name="radius">radius of the circle</param>
/// <returns>maximum error</returns>
public static double CircleFit(GeoPoint2D[] points, out GeoPoint2D center, out double radius)
{ // aus GeometricTools, siehe dort auch "Wm4ApprQuadraticFit2.h" für besseren Startwert
int maxIterations = 10;
{
// aus GeometricTools, siehe dort auch "Wm4ApprQuadraticFit2.h" für besseren Startwert

// initial guess
// Startwert hier als Schnittpunkt der Mittelsenkrechten
Expand Down
1 change: 0 additions & 1 deletion CADability/HatchStyleContour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ private Path2D MakeSpiral(List<Border> borders)
ICurve2D startcurve = last.SubCurves[0]; // das ist der Eintritt in die innere Kurve
GeoPoint2D m = startcurve.PointAt(0.5); // Mittelpunkt der inneren für Parallelensuche
Path2D next = null; // der nächst äußere mit dem richtigen Anfang
double minpardist = double.MaxValue;
#if DEBUG
DebuggerContainer dc1 = new DebuggerContainer();
dc1.Add(curves.ToArray());
Expand Down
4 changes: 0 additions & 4 deletions CADability/HatchStyleList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,6 @@ private void UpdateAllHatchs(IGeoObject go)
{
hatch.Update();
}
else
{
int dbg = 0;
}
}
else if (go is Block)
{
Expand Down
2 changes: 0 additions & 2 deletions CADability/ImportDxf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,6 @@ private IGeoObject CreateText(netDxf.Entities.Text txt)
double h = txt.Height;
Plane plane = Plane(txt.Position, txt.Normal);

bool isShx = false;
if (typeface.Length > 0)
{
text.Font = typeface;
Expand All @@ -940,7 +939,6 @@ private IGeoObject CreateText(netDxf.Entities.Text txt)
if (filename.EndsWith(".shx") || filename.EndsWith(".SHX"))
{
filename = filename.Substring(0, filename.Length - 4);
isShx = true;
}
if (filename.EndsWith(".ttf") || filename.EndsWith(".TTF"))
{
Expand Down
2 changes: 0 additions & 2 deletions CADability/ImportStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5058,8 +5058,6 @@ private ISurface MakeNurbsSurface(GeoPoint[,] poles, double[,] weights, double[]
ICurve fu = res.FixedU(u, res.VKnots[0], res.VKnots[res.VKnots.Length - 1]);
double[] si = fu.GetSelfIntersections();
int bestPair = -1;
double minDist = double.MaxValue;
double minPar = double.MaxValue;
double minTan = double.MaxValue;
for (int i = 0; i < si.Length; i += 2)
{ // when there are multiple self intersection pairs, then it looks like the best pair is where the intersection is tangential
Expand Down
3 changes: 0 additions & 3 deletions CADability/NurbsSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2125,8 +2125,6 @@ public bool GetSimpleSurface(double precision, out ISurface simpleSurface, out M
double[] vpars = GetPars(vmin, vmax, IsVPeriodic, vs, 3);
GeoPoint[] cnt = new GeoPoint[6];
double[] rad = new double[6];
double minrad = 0.0;
double maxrad = 0.0;
bool ok = true;
int curvesok = 0;
#if DEBUG
Expand Down Expand Up @@ -5450,7 +5448,6 @@ internal ConicalSurface ConvertToCone(double precision)
#endif
static double findBestFitCone(GeoPoint[] samples, GeoVector[] normals, out GeoPoint location, out GeoVector direction, out double halfAngle)
{
double maxError = double.MaxValue;
for (int i = 0; i < normals.Length; i++)
{
normals[i].NormIfNotNull();
Expand Down
1 change: 0 additions & 1 deletion CADability/PHCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,6 @@ public double paramSpeedDeriv(double param)
public double curvature(double param)
{
int i = 0;
double r = 0;
while (param > theCurve.par[i + 1])
i += 1;
double pos = (param - theCurve.par[i]) / theCurve.t[i + 1];
Expand Down
6 changes: 1 addition & 5 deletions CADability/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,7 @@ public void AddModel(Model ToAdd)
if (mp != null) mp.Refresh();
}
}
bool modelViewExists = false;
foreach (ProjectedModel pm in projectedModels)
{
if (pm.Model == ToAdd) modelViewExists = true;
}

//foreach (ModelViewDescription mvd in modelViews)
//{
// if (mvd.Model == ToAdd) modelViewExists = true;
Expand Down
Loading

0 comments on commit b971abf

Please sign in to comment.