2022-02-10 22:07:11 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
2020-01-13 12:11:45 +00:00
|
|
|
|
|
|
|
# To run all tests, use
|
2020-01-17 00:13:37 +00:00
|
|
|
# BLENDER_VERBOSE=1 blender path/to/bool_regression.blend --python path/to/boolean_operator.py -- --run-all-tests
|
2020-01-13 12:11:45 +00:00
|
|
|
# To run one test, use
|
2020-01-17 00:13:37 +00:00
|
|
|
# BLENDER_VERBOSE=1 blender path/to/bool_regression.blend --python path/to/boolean_operator.py -- --run-test <index>
|
2020-01-13 12:11:45 +00:00
|
|
|
# where <index> is the index of the test specified in the list tests.
|
|
|
|
|
|
|
|
import bpy
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
|
|
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
2021-07-27 15:30:28 +00:00
|
|
|
from modules.mesh_test import SpecMeshTest, OperatorSpecEditMode, RunTest
|
2020-01-13 12:11:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
tests = [
|
2020-12-17 15:14:55 +00:00
|
|
|
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_union', 'Cubecube', 'Cubecube_result_1',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect_boolean',
|
|
|
|
{'operation': 'UNION', 'solver': 'FAST'}, 'FACE', {0, 1, 2, 3, 4, 5}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_intersect', 'Cubecube', 'Cubecube_result_2',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect_boolean', {'operation': 'INTERSECT', 'solver': 'FAST'}, 'FACE', {0, 1, 2, 3, 4, 5}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_difference', 'Cubecube', 'Cubecube_result_3',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect_boolean', {'operation': 'DIFFERENCE', 'solver': 'FAST'}, 'FACE',
|
|
|
|
{0, 1, 2, 3, 4, 5}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_cut', 'Cubecube', 'Cubecube_result_4', [OperatorSpecEditMode('intersect',
|
2022-04-19 05:25:55 +00:00
|
|
|
{'separate_mode': 'CUT', 'solver': 'FAST'}, 'FACE', {0, 1, 2, 3, 4, 5}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_all', 'Cubecube', 'Cubecube_result_5',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect',
|
|
|
|
{'separate_mode': 'ALL', 'solver': 'FAST'}, 'FACE', {0, 1, 2, 3, 4, 5}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_none', 'Cubecube', 'Cubecube_result_6',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect',
|
|
|
|
{'separate_mode': 'NONE', 'solver': 'FAST'}, 'FACE', {0, 1, 2, 3, 4, 5}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecube_intersect_select_none', 'Cubecube',
|
2022-04-19 05:25:55 +00:00
|
|
|
'Cubecube_result_7',
|
|
|
|
[OperatorSpecEditMode('intersect',
|
|
|
|
{'mode': 'SELECT', 'separate_mode': 'NONE', 'solver': 'FAST'}, 'FACE',
|
|
|
|
{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecone_intersect_union', 'Cubecone', 'Cubecone_result_1',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect_boolean',
|
|
|
|
{'operation': 'UNION', 'solver': 'FAST'}, 'FACE', {6, 7, 8, 9, 10}, )]),
|
2021-07-27 15:30:28 +00:00
|
|
|
SpecMeshTest('Cubecones_intersect_union', 'Cubecones', 'Cubecones_result_1',
|
2022-04-19 05:25:55 +00:00
|
|
|
[OperatorSpecEditMode('intersect_boolean', {'operation': 'UNION', 'solver': 'FAST'}, 'FACE', {0, 1, 2, 3, 4, 5}, )]),
|
2020-12-17 15:14:55 +00:00
|
|
|
|
2020-01-13 12:11:45 +00:00
|
|
|
]
|
|
|
|
|
2020-12-17 15:14:55 +00:00
|
|
|
operator_test = RunTest(tests)
|
2020-01-13 12:11:45 +00:00
|
|
|
|
|
|
|
command = list(sys.argv)
|
|
|
|
for i, cmd in enumerate(command):
|
|
|
|
if cmd == "--run-all-tests":
|
2020-12-17 15:14:55 +00:00
|
|
|
operator_test.do_compare = True
|
2020-01-13 12:11:45 +00:00
|
|
|
operator_test.run_all_tests()
|
|
|
|
break
|
|
|
|
elif cmd == "--run-test":
|
2020-12-17 15:14:55 +00:00
|
|
|
name = command[i + 1]
|
|
|
|
operator_test.do_compare = False
|
|
|
|
operator_test.run_test(name)
|
2020-01-13 12:11:45 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-04-27 15:43:47 +00:00
|
|
|
main()
|