|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# Copyright (c) 2019 - 2026 Geode-solutions |
| 3 | +# |
| 4 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | +# of this software and associated documentation files (the "Software"), to deal |
| 6 | +# in the Software without restriction, including without limitation the rights |
| 7 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | +# copies of the Software, and to permit persons to whom the Software is |
| 9 | +# furnished to do so, subject to the following conditions: |
| 10 | +# |
| 11 | +# The above copyright notice and this permission notice shall be included in |
| 12 | +# all copies or substantial portions of the Software. |
| 13 | +# |
| 14 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 20 | +# SOFTWARE. |
| 21 | + |
| 22 | +import os |
| 23 | +import sys |
| 24 | +import platform |
| 25 | + |
| 26 | +if sys.version_info >= (3, 8, 0) and platform.system() == "Windows": |
| 27 | + for path in [x.strip() for x in os.environ["PATH"].split("") if x]: |
| 28 | + os.add_dll_directory(path) |
| 29 | + |
| 30 | +import opengeode as geode |
| 31 | +import opengeode_inspector_py_validity as validity |
| 32 | + |
| 33 | +def data_dir(): |
| 34 | + test_dir = os.path.dirname(__file__) |
| 35 | + return os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) |
| 36 | + |
| 37 | + |
| 38 | +def check_a1(): |
| 39 | + model_brep = geode.load_brep(data_dir() + "/model_A1.og_brep") |
| 40 | + result = validity.is_brep_valid(model_brep) |
| 41 | + if result.nb_issues()!=7: |
| 42 | + raise ValueError( "[Test] model model_A1 should have 7 issues." ) |
| 43 | + |
| 44 | + |
| 45 | +def check_a1_valid(): |
| 46 | + model_brep = geode.load_brep(data_dir() + "/model_A1_valid.og_brep") |
| 47 | + result = validity.is_brep_valid(model_brep) |
| 48 | + if result.nb_issues()!=7: |
| 49 | + raise ValueError( "[Test] model model_A1_valid should have 7 issues." ) |
| 50 | + |
| 51 | + |
| 52 | +def check_model_mss(): |
| 53 | + model_brep = geode.load_brep(data_dir() + "/mss.og_brep") |
| 54 | + result = validity.is_brep_valid(model_brep) |
| 55 | + if result.nb_issues()!=5: |
| 56 | + raise ValueError( "[Test] model_mss should have 5 issues." ) |
| 57 | + |
| 58 | + |
| 59 | +def check_model_D(): |
| 60 | + model_brep = geode.load_brep(data_dir() + "/model_D.og_brep") |
| 61 | + result = validity.is_brep_valid(model_brep) |
| 62 | + if result.nb_issues()!=0: |
| 63 | + raise ValueError( "[Test] model_D should have 0 issues." ) |
| 64 | + |
| 65 | + |
| 66 | +if __name__ == "__main__": |
| 67 | + validity.OpenGeodeInspectorValidityLibrary.initialize() |
| 68 | + check_a1() |
| 69 | + check_a1_valid() |
| 70 | + check_model_mss() |
| 71 | + check_model_D() |
0 commit comments