Added a fix to issue #14613: tool shapes not shown correctly

This commit is contained in:
shai
2024-06-13 21:35:30 +03:00
committed by sliptonic
parent e711f4c59f
commit 1f78025e72
2 changed files with 21 additions and 9 deletions

View File

@@ -92,18 +92,24 @@ class CAMSimulation:
for edge in edges:
p1 = edge.FirstParameter
p2 = edge.LastParameter
rad = RadiusAt(edge, p1)
z = edge.valueAt(p1).z
if IsSame(px, rad) and IsSame(pz, z):
rad1 = RadiusAt(edge, p1)
z1 = edge.valueAt(p1).z
if IsSame(px, rad1) and IsSame(pz, z1):
return edge, p1, p2
rad = RadiusAt(edge, p2)
z = edge.valueAt(p2).z
if IsSame(px, rad) and IsSame(pz, z):
rad2 = RadiusAt(edge, p2)
z2 = edge.valueAt(p2).z
if IsSame(px, rad2) and IsSame(pz, z2):
return edge, p2, p1
# sometimes a flat circle is without edge, so return edge with
# same height and later a connecting edge will be interpolated
if IsSame(pz, z1):
return edge, p1, p2
if IsSame(pz, z2):
return edge, p2, p1
return None, 0.0, 0.0
def FindTopMostEdge(self, edges):
maxz = 0.0
maxz = -99999999.0
topedge = None
top_p1 = 0.0
top_p2 = 0.0
@@ -137,7 +143,6 @@ class CAMSimulation:
sideEdgeList.append(edge)
# sort edges as a single 3d line on the x-z plane
profile = [0.0, 0.0]
# first find the topmost edge
edge, p1, p2 = self.FindTopMostEdge(sideEdgeList)
@@ -167,6 +172,12 @@ class CAMSimulation:
edge, p1, p2 = self.FindClosestEdge(sideEdgeList, endrad, endz)
if edge is None:
break
startrad = RadiusAt(edge, p1)
if not IsSame(startrad, endrad):
profile.append(startrad)
startz = edge.valueAt(p1).z
profile.append(startz)
return profile
def Activate(self):

View File

@@ -62,7 +62,8 @@ EndMill::EndMill(const std::vector<float>& toolProfile, int toolid, float diamet
profilePoints[i] = toolProfile[i] + 0.01F; // add some width to reduce simulation artifacts
}
if (missingCenterPoint) {
profilePoints[srcBuffSize] = profilePoints[srcBuffSize + 1] = 0.0F;
profilePoints[srcBuffSize] = 0.0F;
profilePoints[srcBuffSize + 1] = profilePoints[srcBuffSize - 1];
}
MirrorPointBuffer();