From ef4074a6a8ebbd2310cb91251376b48c309a8099 Mon Sep 17 00:00:00 2001 From: Daniel Wood Date: Mon, 4 May 2020 20:19:25 +0100 Subject: [PATCH] check the toolbit shape is valid --- src/Mod/Path/PathScripts/PathSimulatorGui.py | 4 ++++ src/Mod/Path/PathSimulator/App/VolSim.cpp | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Mod/Path/PathScripts/PathSimulatorGui.py b/src/Mod/Path/PathScripts/PathSimulatorGui.py index a6a7d2770fa8..0045d5ed6120 100644 --- a/src/Mod/Path/PathScripts/PathSimulatorGui.py +++ b/src/Mod/Path/PathScripts/PathSimulatorGui.py @@ -134,6 +134,10 @@ def SetupOperation(self, itool): # handle tool bits self.cutTool.Shape = self.tool.Shape + if not self.cutTool.Shape.isValid() or self.cutTool.Shape.isNull(): + self.EndSimulation() + raise RuntimeError("Path Simulation: Error in tool geometry - {}".format(self.tool.Name)) + self.cutTool.ViewObject.show() self.voxSim.SetToolShape(self.cutTool.Shape, 0.05 * self.accuracy) self.icmd = 0 diff --git a/src/Mod/Path/PathSimulator/App/VolSim.cpp b/src/Mod/Path/PathSimulator/App/VolSim.cpp index ed696aec8420..c9cb49bcbf0d 100644 --- a/src/Mod/Path/PathSimulator/App/VolSim.cpp +++ b/src/Mod/Path/PathSimulator/App/VolSim.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #include +#include #include #include @@ -717,7 +718,14 @@ void Point3D::UpdateCmd(Path::Command & cmd) // Simulation tool //************************************************************************************************************ cSimTool::cSimTool(const TopoDS_Shape& toolShape, float res){ - + + BRepCheck_Analyzer aChecker(toolShape); + bool shapeIsValid = aChecker.IsValid() ? true : false; + + if(!shapeIsValid){ + throw Base::RuntimeError("Path Simulation: Error in tool geometry"); + } + Bnd_Box boundBox; BRepBndLib::Add(toolShape, boundBox);