compas-dev / compas-dev/compas
Unexpected behavior from BRep.from_extrusion()
- Dominant language
- Python
- Stars
- 386
- Forks
- 122
- Avg merge
- 11d 46m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
The BRep.from_extrusion() function does not produce the expected brep object as indicated by the area and volume measurements.
**To Reproduce**
Steps to reproduce the behavior:
1. Context: VS Code and not within another modeling environment.
2. Sample script
```
from compas.geometry import Point, Vector, Box, Frame
from compas_occ.brep import BRep
from compas_occ.geometry import OCCNurbsCurve
def test_extrusion_brep():
points = [
Point(0, 0, 0),
Point(0, 10, 0),
Point(10, 10, 0),
Point(10, 0, 0),
Point(0,0,0)
]
curve = OCCNurbsCurve.from_points(points, degree=1)
vector = Vector(0, 0, 10)
brep1 = BRep.from_extrusion(curve, vector)
print(f"curve length: {curve.length()}")
print(f"brep1 - area: {brep1.area}, volume: {brep1.volume}") # 600, 1000
print(f"brep1 - type: {brep1.type}, orientation: {brep1.orientation}") # TopAbs_FACE?, TopAbs_FORWARD
print(f"brep1 - number of vertices: {len(brep1.vertices)}")
print(f"brep1 - number of faces: {len(brep1.faces)}")
box = Box(Frame.worldXY(), 10, 10, 10)
brep2 = BRep.from_box(box)
print(f"brep2 - area: {brep2.area}, volume: {brep2.volume}") # 600, 1000
print(f"brep2 - type: {brep2.type}, orientation: {brep2.orientation}") # TopAbs_SOLID, TopAbs_FORWARD
print(f"brep2 - number of vertices: {len(brep2.vertices)}")
print(f"brep2 - number of faces: {len(brep2.faces)}")
if __name__ == "__main__":
test_extrusion_brep()
```
**Expected behavior**
The code does not fail, however, the results for brep1 and brep2 should be the same.
```
curve length: 40.0
brep1 - area: 400.0, volume: 650.804722446989
brep1 - type: 4, orientation: 0
brep1 - number of vertices: 8
brep1 - number of faces: 1
brep2 - area: 599.9999999999999, volume: 999.9999999999998
brep2 - type: 2, orientation: 0
brep2 - number of vertices: 48
brep2 - number of faces: 6
```
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: Windows 11 Pro version 21H2
- Python version: 3.10
- Python package manager: conda
**Additional context**
Found that other BRep methods and attributes like copy(), frame, BRepFace.surface and BRepFace.try_get_nurbssurface() also did not work.
Contributor guide
Assessment
This issue has not been assessed yet.