compas-brep 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. compas_brep-0.1.0/LICENSE +21 -0
  2. compas_brep-0.1.0/PKG-INFO +105 -0
  3. compas_brep-0.1.0/README.md +57 -0
  4. compas_brep-0.1.0/pyproject.toml +88 -0
  5. compas_brep-0.1.0/src/compas_brep/__init__.py +45 -0
  6. compas_brep-0.1.0/src/compas_brep/backend/__init__.py +50 -0
  7. compas_brep-0.1.0/src/compas_brep/backend/occ/__init__.py +22 -0
  8. compas_brep-0.1.0/src/compas_brep/backend/occ/conversion.py +1009 -0
  9. compas_brep-0.1.0/src/compas_brep/backend/occ/factories.py +312 -0
  10. compas_brep-0.1.0/src/compas_brep/backend/occ/io.py +72 -0
  11. compas_brep-0.1.0/src/compas_brep/backend/occ/operations.py +408 -0
  12. compas_brep-0.1.0/src/compas_brep/backend/occ/plugins.py +343 -0
  13. compas_brep-0.1.0/src/compas_brep/backend/occ/queries.py +161 -0
  14. compas_brep-0.1.0/src/compas_brep/backend/occ/topology.py +197 -0
  15. compas_brep-0.1.0/src/compas_brep/backend/rhino/__init__.py +19 -0
  16. compas_brep-0.1.0/src/compas_brep/backend/rhino/conversion.py +670 -0
  17. compas_brep-0.1.0/src/compas_brep/backend/rhino/factories.py +204 -0
  18. compas_brep-0.1.0/src/compas_brep/backend/rhino/io.py +92 -0
  19. compas_brep-0.1.0/src/compas_brep/backend/rhino/operations.py +358 -0
  20. compas_brep-0.1.0/src/compas_brep/backend/rhino/plugins.py +346 -0
  21. compas_brep-0.1.0/src/compas_brep/backend/rhino/topology.py +197 -0
  22. compas_brep-0.1.0/src/compas_brep/brep.py +888 -0
  23. compas_brep-0.1.0/src/compas_brep/curves/__init__.py +5 -0
  24. compas_brep-0.1.0/src/compas_brep/curves/nurbs.py +483 -0
  25. compas_brep-0.1.0/src/compas_brep/data/box_with_holes.stp +1719 -0
  26. compas_brep-0.1.0/src/compas_brep/data_example.py +121 -0
  27. compas_brep-0.1.0/src/compas_brep/edge.py +163 -0
  28. compas_brep-0.1.0/src/compas_brep/errors.py +25 -0
  29. compas_brep-0.1.0/src/compas_brep/face.py +196 -0
  30. compas_brep-0.1.0/src/compas_brep/loop.py +74 -0
  31. compas_brep-0.1.0/src/compas_brep/operations.py +295 -0
  32. compas_brep-0.1.0/src/compas_brep/py.typed +0 -0
  33. compas_brep-0.1.0/src/compas_brep/scene/__init__.py +0 -0
  34. compas_brep-0.1.0/src/compas_brep/scene/rhino/__init__.py +19 -0
  35. compas_brep-0.1.0/src/compas_brep/scene/rhino/brepobject.py +23 -0
  36. compas_brep-0.1.0/src/compas_brep/scene/rhino/curveobject.py +23 -0
  37. compas_brep-0.1.0/src/compas_brep/scene/rhino/surfaceobject.py +23 -0
  38. compas_brep-0.1.0/src/compas_brep/scene/viewer/__init__.py +28 -0
  39. compas_brep-0.1.0/src/compas_brep/scene/viewer/brepobject.py +47 -0
  40. compas_brep-0.1.0/src/compas_brep/scene/viewer/curveobject.py +39 -0
  41. compas_brep-0.1.0/src/compas_brep/scene/viewer/surfaceobject.py +168 -0
  42. compas_brep-0.1.0/src/compas_brep/surfaces/__init__.py +9 -0
  43. compas_brep-0.1.0/src/compas_brep/surfaces/_codec.py +67 -0
  44. compas_brep-0.1.0/src/compas_brep/surfaces/nurbs.py +772 -0
  45. compas_brep-0.1.0/src/compas_brep/trim.py +146 -0
  46. compas_brep-0.1.0/src/compas_brep/vertex.py +21 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gramazio Kohler Research
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.3
2
+ Name: compas-brep
3
+ Version: 0.1.0
4
+ Summary: Canonical Brep wrapper based on COMPAS framework with pluggable OCC/Rhino backends
5
+ Author: Chen Kasirer
6
+ Author-email: Chen Kasirer <kasirer@arch.ethz.ch>
7
+ License: MIT License
8
+
9
+ Copyright (c) 2026 Gramazio Kohler Research
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining a copy
12
+ of this software and associated documentation files (the "Software"), to deal
13
+ in the Software without restriction, including without limitation the rights
14
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15
+ copies of the Software, and to permit persons to whom the Software is
16
+ furnished to do so, subject to the following conditions:
17
+
18
+ The above copyright notice and this permission notice shall be included in all
19
+ copies or substantial portions of the Software.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
+ SOFTWARE.
28
+ Requires-Dist: compas>=2.0
29
+ Requires-Dist: numpy
30
+ Requires-Dist: scipy
31
+ Requires-Dist: invoke ; extra == 'dev'
32
+ Requires-Dist: ruff ; extra == 'dev'
33
+ Requires-Dist: pytest ; extra == 'dev'
34
+ Requires-Dist: compas-invocations2[mkdocs] ; extra == 'dev'
35
+ Requires-Dist: bump-my-version ; extra == 'dev'
36
+ Requires-Dist: twine ; extra == 'dev'
37
+ Requires-Dist: wheel ; extra == 'dev'
38
+ Requires-Dist: build ; extra == 'dev'
39
+ Requires-Dist: mkdocstrings[python] ; extra == 'docs'
40
+ Requires-Dist: cadquery-ocp-novtk>=7.8 ; python_full_version >= '3.10' and extra == 'occ'
41
+ Requires-Dist: compas-viewer>=1.0 ; extra == 'occ'
42
+ Requires-Python: >=3.9
43
+ Project-URL: Repository, https://github.com/gramaziokohler/compas_brep
44
+ Provides-Extra: dev
45
+ Provides-Extra: docs
46
+ Provides-Extra: occ
47
+ Description-Content-Type: text/markdown
48
+
49
+ # compas_brep
50
+
51
+ [![Github Actions Build Status](https://github.com/gramaziokohler/compas_brep/actions/workflows/build.yml/badge.svg)](https://github.com/gramaziokohler/compas_brep/actions)
52
+ [![License](https://img.shields.io/github/license/gramaziokohler/compas_brep.svg)](https://pypi.python.org/pypi/compas-brep)
53
+ [![PyPI Package latest release](https://img.shields.io/pypi/v/compas-brep.svg)](https://pypi.python.org/pypi/compas-brep)
54
+ [![Supported Python versions](https://img.shields.io/pypi/pyversions/compas-brep.svg)](https://pypi.python.org/pypi/compas-brep)
55
+ [![Made with COMPAS](https://compas.dev/badge.svg)](https://compas.dev/#/)
56
+
57
+ A unified Brep wrapper for the [COMPAS](https://github.com/compas-dev/compas) framework with pluggable OCC and Rhino backends.
58
+
59
+ Provides a single `Brep` class with a stable public interface. The backend (OCC or Rhino) is selected automatically at runtime based on what is importable. All inputs and outputs are COMPAS types — never backend types.
60
+
61
+ Examples in `examples/` have mostly been copied from [COMPAS OCC](https://github.com/compas-dev/compas_occ) which is used as benchmark for this project.
62
+
63
+ ## Installation
64
+
65
+ **Base (no backend):**
66
+
67
+ ```bash
68
+ pip install compas_brep
69
+ ```
70
+
71
+ **With [OCC backend](https://github.com/CadQuery/OCP):**
72
+
73
+ ```bash
74
+ pip install "compas_brep[occ]"
75
+ ```
76
+
77
+ The Rhino backend is available automatically when running inside Rhino.
78
+
79
+ ## Usage
80
+
81
+ ```python
82
+ import os
83
+ from compas_brep import Brep, DATA
84
+ from compas_viewer import Viewer
85
+
86
+ brep = Brep.from_step(os.path.join(DATA, "box_with_holes.stp"))
87
+
88
+ for face in brep.faces:
89
+ print(face.surface) # Plane for flat faces, NurbsSurface for curved faces
90
+
91
+ viewer = Viewer()
92
+ viewer.scene.add(brep)
93
+
94
+ viewer.show()
95
+
96
+ ```
97
+
98
+ ## Running tests
99
+
100
+ Install the OCC backend and run:
101
+
102
+ ```bash
103
+ uv pip install "cadquery-ocp-novtk>=7.8"
104
+ pytest -m occ -q
105
+ ```
@@ -0,0 +1,57 @@
1
+ # compas_brep
2
+
3
+ [![Github Actions Build Status](https://github.com/gramaziokohler/compas_brep/actions/workflows/build.yml/badge.svg)](https://github.com/gramaziokohler/compas_brep/actions)
4
+ [![License](https://img.shields.io/github/license/gramaziokohler/compas_brep.svg)](https://pypi.python.org/pypi/compas-brep)
5
+ [![PyPI Package latest release](https://img.shields.io/pypi/v/compas-brep.svg)](https://pypi.python.org/pypi/compas-brep)
6
+ [![Supported Python versions](https://img.shields.io/pypi/pyversions/compas-brep.svg)](https://pypi.python.org/pypi/compas-brep)
7
+ [![Made with COMPAS](https://compas.dev/badge.svg)](https://compas.dev/#/)
8
+
9
+ A unified Brep wrapper for the [COMPAS](https://github.com/compas-dev/compas) framework with pluggable OCC and Rhino backends.
10
+
11
+ Provides a single `Brep` class with a stable public interface. The backend (OCC or Rhino) is selected automatically at runtime based on what is importable. All inputs and outputs are COMPAS types — never backend types.
12
+
13
+ Examples in `examples/` have mostly been copied from [COMPAS OCC](https://github.com/compas-dev/compas_occ) which is used as benchmark for this project.
14
+
15
+ ## Installation
16
+
17
+ **Base (no backend):**
18
+
19
+ ```bash
20
+ pip install compas_brep
21
+ ```
22
+
23
+ **With [OCC backend](https://github.com/CadQuery/OCP):**
24
+
25
+ ```bash
26
+ pip install "compas_brep[occ]"
27
+ ```
28
+
29
+ The Rhino backend is available automatically when running inside Rhino.
30
+
31
+ ## Usage
32
+
33
+ ```python
34
+ import os
35
+ from compas_brep import Brep, DATA
36
+ from compas_viewer import Viewer
37
+
38
+ brep = Brep.from_step(os.path.join(DATA, "box_with_holes.stp"))
39
+
40
+ for face in brep.faces:
41
+ print(face.surface) # Plane for flat faces, NurbsSurface for curved faces
42
+
43
+ viewer = Viewer()
44
+ viewer.scene.add(brep)
45
+
46
+ viewer.show()
47
+
48
+ ```
49
+
50
+ ## Running tests
51
+
52
+ Install the OCC backend and run:
53
+
54
+ ```bash
55
+ uv pip install "cadquery-ocp-novtk>=7.8"
56
+ pytest -m occ -q
57
+ ```
@@ -0,0 +1,88 @@
1
+ [build-system]
2
+ requires = ["uv_build>=0.10.2,<0.11.0"]
3
+ build-backend = "uv_build"
4
+
5
+ # ============================================================================
6
+ # project info
7
+ # ============================================================================
8
+
9
+ [project]
10
+ name = "compas-brep"
11
+ version = "0.1.0"
12
+ description = "Canonical Brep wrapper based on COMPAS framework with pluggable OCC/Rhino backends"
13
+ readme = "README.md"
14
+ authors = [
15
+ { name = "Chen Kasirer", email = "kasirer@arch.ethz.ch" }
16
+ ]
17
+ requires-python = ">=3.9"
18
+ license = { file = "LICENSE" }
19
+ dependencies = [
20
+ "compas>=2.0",
21
+ "numpy",
22
+ "scipy",
23
+ ]
24
+
25
+ [project.urls]
26
+ Repository = "https://github.com/gramaziokohler/compas_brep"
27
+
28
+ [project.optional-dependencies]
29
+ occ = ["cadquery-ocp-novtk>=7.8; python_version >= '3.10'", "compas_viewer>=1.0"]
30
+ dev = [
31
+ "invoke",
32
+ "ruff",
33
+ "pytest",
34
+ "compas_invocations2[mkdocs]",
35
+ "bump-my-version",
36
+ "twine",
37
+ "wheel",
38
+ "build",
39
+ ]
40
+ docs = [
41
+ #"zensical", # TODO: this works, need to figure our how to use with mike and add to compas-actions.
42
+ "mkdocstrings[python]",
43
+ ]
44
+
45
+ # ============================================================================
46
+ # Linting and formatting
47
+ # ============================================================================
48
+
49
+ [tool.ruff]
50
+ line-length = 179
51
+ target-version = "py313"
52
+
53
+ [tool.ruff.lint]
54
+ select = ["E", "F", "I", "UP"]
55
+
56
+ [tool.ruff.lint.isort]
57
+ force-single-line = true
58
+
59
+ [tool.ruff.format]
60
+ quote-style = "double"
61
+
62
+ # ============================================================================
63
+ # Testing
64
+ # ============================================================================
65
+
66
+ [tool.pytest.ini_options]
67
+ testpaths = ["tests"]
68
+ addopts = "-m occ"
69
+
70
+ # ============================================================================
71
+ # Release
72
+ # ============================================================================
73
+
74
+ [tool.bumpversion]
75
+ current_version = "0.1.0"
76
+ message = "Bump version to {new_version}"
77
+ commit = true
78
+ tag = true
79
+
80
+ [[tool.bumpversion.files]]
81
+ filename = "src/compas_brep/__init__.py"
82
+ search = "{current_version}"
83
+ replace = "{new_version}"
84
+
85
+ [[tool.bumpversion.files]]
86
+ filename = "CHANGELOG.md"
87
+ search = "Unreleased"
88
+ replace = "[{new_version}] {now:%Y-%m-%d}"
@@ -0,0 +1,45 @@
1
+ """compas_brep: Pure Python Brep implementation based on the COMPAS framework."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ import os
6
+
7
+ from compas_brep.brep import Brep
8
+ from compas_brep.curves import NurbsCurve
9
+ from compas_brep.edge import BrepEdge
10
+ from compas_brep.errors import BrepError
11
+ from compas_brep.errors import BrepFilletError
12
+ from compas_brep.errors import BrepInvalidError
13
+ from compas_brep.errors import BrepTrimmingError
14
+ from compas_brep.face import BrepFace
15
+ from compas_brep.loop import BrepLoop
16
+ from compas_brep.surfaces import NurbsSurface
17
+ from compas_brep.trim import BrepTrim
18
+ from compas_brep.vertex import BrepVertex
19
+
20
+ DATA = os.path.join(os.path.dirname(__file__), "data")
21
+
22
+
23
+ __all_plugins__ = [
24
+ "compas_brep.scene",
25
+ "compas_brep.backend.occ.plugins",
26
+ "compas_brep.backend.rhino.plugins",
27
+ "compas_brep.scene.viewer",
28
+ "compas_brep.scene.rhino",
29
+ ]
30
+
31
+ __all__ = [
32
+ "DATA",
33
+ "Brep",
34
+ "BrepVertex",
35
+ "BrepEdge",
36
+ "BrepLoop",
37
+ "BrepFace",
38
+ "BrepTrim",
39
+ "NurbsCurve",
40
+ "NurbsSurface",
41
+ "BrepError",
42
+ "BrepInvalidError",
43
+ "BrepTrimmingError",
44
+ "BrepFilletError",
45
+ ]
@@ -0,0 +1,50 @@
1
+ """Backend implementations for compas_brep.
2
+
3
+ This package contains pluggable backend sub-packages for different geometry kernels.
4
+ Each backend is a sub-package with logically split modules:
5
+
6
+ - **OCC** (``occ/``): Uses cadquery-ocp-novtk.
7
+ - ``occ/conversion.py`` — bidirectional OCC ↔ Brep conversion
8
+ - ``occ/factories.py`` — primitive constructors and shape builders
9
+ - ``occ/operations.py`` — boolean and geometric operations
10
+ - ``occ/queries.py`` — property queries and tessellation
11
+ - ``occ/io.py`` — STEP/STL/IGES import and export
12
+ - ``occ/plugins.py`` — COMPAS plugin registrations
13
+
14
+ - **Rhino** (``rhino/``): Uses Rhino.Geometry.
15
+ - ``rhino/conversion.py`` — bidirectional Rhino ↔ Brep conversion
16
+ - ``rhino/factories.py`` — primitive constructors and shape builders
17
+ - ``rhino/operations.py`` — boolean and geometric operations
18
+ - ``rhino/io.py`` — STEP import and export
19
+ - ``rhino/plugins.py`` — COMPAS plugin registrations
20
+
21
+ The plugin modules are only loaded by the COMPAS plugin system when the
22
+ corresponding kernel is available (``requires=["OCP"]`` or ``requires=["Rhino"]``).
23
+ They are **not** imported at package level so that ``compas_brep`` remains
24
+ importable in any environment.
25
+ """
26
+
27
+ from .occ.topology import OccBrepEdge as OccBrepEdge
28
+ from .occ.topology import OccBrepFace as OccBrepFace
29
+ from .occ.topology import OccBrepLoop as OccBrepLoop
30
+ from .occ.topology import OccBrepTrim as OccBrepTrim
31
+ from .occ.topology import OccBrepVertex as OccBrepVertex
32
+ from .rhino.topology import RhinoBrepEdge as RhinoBrepEdge
33
+ from .rhino.topology import RhinoBrepFace as RhinoBrepFace
34
+ from .rhino.topology import RhinoBrepLoop as RhinoBrepLoop
35
+ from .rhino.topology import RhinoBrepTrim as RhinoBrepTrim
36
+ from .rhino.topology import RhinoBrepVertex as RhinoBrepVertex
37
+
38
+ try:
39
+ from .occ.conversion import brep_to_occ as brep_to_occ
40
+ from .occ.conversion import occ_to_brep as occ_to_brep
41
+ except ImportError:
42
+ pass
43
+
44
+ try:
45
+ from .rhino.conversion import brep_to_rhino as brep_to_rhino
46
+ from .rhino.conversion import nurbs_curve_to_rhino as nurbs_curve_to_rhino
47
+ from .rhino.conversion import nurbs_surface_to_rhino as nurbs_surface_to_rhino
48
+ from .rhino.conversion import rhino_to_brep as rhino_to_brep
49
+ except ImportError:
50
+ pass
@@ -0,0 +1,22 @@
1
+ """OCC backend sub-package for compas_brep.
2
+
3
+ Modules
4
+ -------
5
+ conversion
6
+ Bidirectional conversion between canonical Brep data and OCC shapes
7
+ (``occ_to_brep``, ``brep_to_occ``, and all private helper functions).
8
+ factories
9
+ Primitive constructors and shape builders
10
+ (``make_box``, ``make_cylinder``, ``occ_sweep``, ``occ_from_surface``, …).
11
+ operations
12
+ Boolean and geometric operations
13
+ (``boolean_difference``, ``occ_trimmed``, ``occ_fillet``, ``occ_rebuild``, …).
14
+ queries
15
+ Property queries and tessellation
16
+ (``occ_area``, ``occ_aabb``, ``occ_tessellate``, …).
17
+ io
18
+ File import/export
19
+ (``occ_to_step``, ``occ_from_step``, ``occ_to_stl``, …).
20
+ plugins
21
+ COMPAS plugin registrations for the OCC backend.
22
+ """