Implement "should recut" to force recutting of a diagram

This commit is contained in:
Dion Moult
2020-01-03 08:44:51 +11:00
parent 220826f141
commit 7c6e7742a8
+15 -8
View File
@@ -200,7 +200,7 @@ class IfcCutter:
break break
def get_product_shapes(self): def get_product_shapes(self):
if os.path.isfile(self.cut_pickle_file): if not self.should_recut:
return return
shape_map = {} shape_map = {}
@@ -565,11 +565,17 @@ class IfcCutter:
return edges return edges
def get_cut_polygons(self): def get_cut_polygons(self):
if os.path.isfile(self.cut_pickle_file): if self.should_recut:
with open(self.cut_pickle_file, 'rb') as pickle_file: self.get_fresh_cut_polygons()
self.cut_polygons = pickle.load(pickle_file) self.pickle_cut_polygons()
return else:
self.get_pickled_cut_polygons()
def pickle_cut_polygons(self):
with open(self.cut_pickle_file, 'wb') as pickle_file:
pickle.dump(self.cut_polygons, pickle_file, protocol=pickle.HIGHEST_PROTOCOL)
def get_fresh_cut_polygons(self):
total_product_shapes = len(self.product_shapes) total_product_shapes = len(self.product_shapes)
process_data = [(p.GlobalId, s, self.section_box['face'], self.transformation_data) for p, s in self.product_shapes] process_data = [(p.GlobalId, s, self.section_box['face'], self.transformation_data) for p, s in self.product_shapes]
@@ -583,9 +589,10 @@ class IfcCutter:
polygons = [p for p in result if p['points']] polygons = [p for p in result if p['points']]
self.cut_polygons.extend(polygons) self.cut_polygons.extend(polygons)
if not os.path.isfile(self.cut_pickle_file): def get_pickled_cut_polygons(self):
with open(self.cut_pickle_file, 'wb') as pickle_file: if os.path.isfile(self.cut_pickle_file):
pickle.dump(self.cut_polygons, pickle_file, protocol=pickle.HIGHEST_PROTOCOL) with open(self.cut_pickle_file, 'rb') as pickle_file:
self.cut_polygons = pickle.load(pickle_file)
class IfcCutterDebug(IfcCutter): class IfcCutterDebug(IfcCutter):