Skip to content

Commit

Permalink
Fixed segmentation fault in Path workbench
Browse files Browse the repository at this point in the history
Closes FreeCAD#6286.
  • Loading branch information
xtemp09 authored and chennes committed Apr 27, 2023
1 parent 3b9f89e commit 5b5e630
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 5 additions & 8 deletions src/Mod/Path/PathSimulator/App/VolSim.cpp
Expand Up @@ -783,14 +783,11 @@ cSimTool::cSimTool(const TopoDS_Shape& toolShape, float res){

float cSimTool::GetToolProfileAt(float pos) // pos is -1..1 location along the radius of the tool (0 is center)
{
try{
float radPos = std::abs(pos) * radius;
toolShapePoint test; test.radiusPos = radPos;
auto it = std::lower_bound(m_toolShape.begin(), m_toolShape.end(), test, toolShapePoint::less_than());
return it->heightPos;
}catch(...){
return 0;
}
toolShapePoint test;
test.radiusPos = std::abs(pos) * radius;

auto it = std::lower_bound(m_toolShape.begin(), m_toolShape.end(), test, toolShapePoint::less_than());
return it != m_toolShape.end() ? it->heightPos : 0.0f;
}

bool cSimTool::isInside(const TopoDS_Shape& toolShape, Base::Vector3d pnt, float res)
Expand Down
6 changes: 4 additions & 2 deletions src/Mod/Path/PathSimulator/App/VolSim.h
Expand Up @@ -107,8 +107,10 @@ class cSimTool
float GetToolProfileAt(float pos);
bool isInside(const TopoDS_Shape& toolShape, Base::Vector3d pnt, float res);

std::vector< toolShapePoint > m_toolShape;
float radius;
/* m_toolShape has to be populated with linearly increased
radiusPos to get the tool profile at given position */
std::vector <toolShapePoint> m_toolShape;
float radius;
float length;
};

Expand Down

0 comments on commit 5b5e630

Please sign in to comment.