I adapted the benchmark to align it with the actual changes introduced in FreeCAD. I made it more simple and split it in two pieces. Each piece basically does only one thing. I used fuse as a reference (but cut, section and common can be used instead by changing 1 line in code).
Fuse (like it always was):
Code: Select all
# @triplus - 2016, 2017
# Boolean Benchmark
import time
import Part
from FreeCAD import Base
cols = 20
rows = 20
# ----------------------------------------
x = 5
y = 5
z = 5
h = 0
c = cols
r = rows
shapes = []
while c:
r = rows
while r:
shapes.append(Part.makeSphere(5, Base.Vector(x, y, z)))
x += 20
r -= 1
x = 5
y += 20
c -= 1
compound = Part.makeCompound(shapes)
box = Part.makeBox(18 * cols, 18 * rows, 8, Base.Vector(5, 5, 1))
t = time.time()
result = box.fuse(compound) # fuse, cut, common and section
timeBOA = time.time() - t
print(str(timeBOA) + "s - " + str(cols) + "x" + str(rows))
Part.show(result)
Fuse with multiple arguments (single/multiple argument(s) can be provided and additional tolerance value is supported):
Code: Select all
# @triplus - 2016, 2017
# Boolean Benchmark
import time
import Part
from FreeCAD import Base
cols = 20
rows = 20
# ----------------------------------------
x = 5
y = 5
z = 5
h = 0
c = cols
r = rows
shapes = []
while c:
r = rows
while r:
shapes.append(Part.makeSphere(5, Base.Vector(x, y, z)))
x += 20
r -= 1
x = 5
y += 20
c -= 1
box = Part.makeBox(18 * cols, 18 * rows, 8, Base.Vector(5, 5, 1))
try:
t = time.time()
result = box.fuse(shapes) # fuse, cut, common and section
timeBOA = time.time() - t
print(str(timeBOA) + "s - " + str(cols) + "x" + str(rows))
Part.show(result)
except:
print("Multiple arguments: N/A")
Main purpose is to test if multithreading works (when multiple arguments are used this usually results in multithreading). It can be used to compare efficiency between the method used (OSD_Parallel (available by default),
TBB or with OCE additional option OpenMP). Or to compare the results between different versions of OCC/OCE.
OCE 0.18:
- Options.png (12.96 KiB) Viewed 3760 times
P.S. As mentioned in the pull request discussion for common/section. When multiple arguments are provided s1 AND (s2 OR s3) is the result.