Skip to content

Commit

Permalink
Merge pull request #1288 from Dessia-tech/testing
Browse files Browse the repository at this point in the history
Volmdlr v0.16.0
  • Loading branch information
WirajanDASILVA authored Feb 20, 2024
2 parents f4ffdd0 + e32e52f commit deca1a9
Show file tree
Hide file tree
Showing 158 changed files with 86,814 additions and 10,923 deletions.
39 changes: 30 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,45 @@ jobs:
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels]
name: Upload to PyPi
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
# upload to PyPI on every tag starting with 'v'
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: artifact
path: dist
path: dist/

- uses: pypa/gh-action-pypi-publish@master
- name: Display structure of downloaded files
run: ls -R dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: dessia_tech
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
packages-dir: dist/*
48 changes: 44 additions & 4 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ name: Test wheel build without pypi upload
on:
push:
branches:
- master
- fix/ci
- testing
- fix_ci

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
name: Build distribution on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -34,6 +34,46 @@ jobs:
run: |
python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v4
with:
name: cibw-sdist
path: dist/*.tar.gz

upload_pypi:
name: upload to TestPyPi
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment: testpypi
permissions:
id-token: write
# upload to PyPI on every tag starting with 'v'
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
steps:
- uses: actions/download-artifact@v4
with:
path: dist/
- name: Display structure of downloaded files
run: ls -R dist

- uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
packages-dir: dist/*
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ max-spelling-suggestions=4

# Spelling dictionary name. Available dictionaries: none. To make it work,
# install the python-enchant package.
spelling-dict=en_US
spelling-dict=

# List of comma separated words that should not be checked.
spelling-ignore-words=param,type,rtype,txt,str,msh,geo,gmsh,dx,dy,u3,v3,u4,v4,du,dv,fullarc,cz,generatrix
Expand Down
114 changes: 112 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,114 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## v0.16.0 [future]

### New Features
- added missing hash and eq methods to several classes
- ArcEllipse2D/3D: get_shared_section and delete_shared_section.
- ConicalSurface3D: conicalsurface_intersections.
- cad_simplification: AlphaWrapSimplify
- nurbs/operations: link_curves

#### edges.py
- BSplineCurve: decompose into béziers patches of same degree.
- BSplineCurve: merge_with and merge_with_curves

#### faces.py
- Add primitives_mapping property: returns a dictionary containing the correspondence between the parametric and 3D boundaries of the faces.
- grid_points: returns a grid of points inside the surface2d of the face.

#### surfaces.py
- CylindricalSurface3D: parametric_points_to_3d
- ToroidalSurface3D: parametric_points_to_3d
- SphericalSurface3D: parametric_points_to_3d
- ConicalSurface3D: parametric_points_to_3d
- ExtrusionSurface3D: parametric_points_to_3d
- RevolutionSurface3D: parametric_points_to_3d
- Plane3D: parametric_points_to_3d
- BSplineSurface3D: parametric_points_to_3d
- BSplineSurface3D: decompose.
- BSplineSurface3D:extract_curves method. Extracts curves from the surface given an ordered list of parameters in u or v direction.
- ToroidalSurface3D: torus-torus intersections.

### Fixed
- review hash and eq methods.
- fix pylint.
- Add some missing docstrings.
- Add _serializable_dict to points and vectors objects. This method is important to some platform checks, as they don't inherite from DessiaObject anymore.

#### curves.py
- Ellipse2D/3D: mutualize length method.
- Circle2D: abscissa method - consider frame direction during rotation.
- Line: is_close.
- Circle3D: Line intersections

#### edges.py
- BSplineCurve: handles exceptions in simplify method.
- BSplineCurve: Consider overlaping curves also as periodic.
- BSplineCurve.simplify: handles exceptions.
- Arc2D: plot_data
- LineSegment3D: planar_revolution.
- BSplineCurve: abscissa: use curve decomposition.
- BSplineCurve: trim on periodic curves.

#### faces.py
- Face3D: enhance from_contours3d.
- Face3D: enhance from_contours3d. Checks if inner contours position are according outer contour position in parametric domain for periodical surfaces.
- Face3D: divide_face_with_closed_cutting_contours - if inner_contour.area()/outer_contour.area() < 1e-9 ignore it.
- Face3D: point_belongs

#### primitives3d.py
- RevolvedProfile: to_dict

#### surface.py
- PeriodicalSurface: handles exceptions in connect_contours method.
- ExtrusionSurface3D: fullarcellipse3d_to_2d
- ExtrusionSurface3D: generalization of the _repair_points_order method to repair the order of parametric points of edges after transformation.
- ToroidalSurface3D: increases precision of point3d_to_2d.
- Surface3D: repeair_primitives_periodicity. Treat special case on surfaces with singularities.
- ToroidalSurface3D: plane_intersections.
- Remove duplicated attributes.
- BSplineSurface3D: point_inversion_grid_search.
- BSplineSurface3D: implements a more robust point3d_to_2d method.

#### wires.py
- Contour2D: cut_by_line.
- ContourMixin: is_ordered().


#### step.py
- Step: uses Regular Expressions to improve the performance.

#### core.py
- Add missing dark_mode parameter in save_babylonjs_to_file method.

### Refactor
- Big refactor to improve and simplify complex and long methods in various modules.

#### surfaces.py
- contour3d_to_2d/contour2d_to_3d: Add option to return also a dictionary with the correspondence between the parametric and 3D primitives.
- BSplineSurface3D: point3d_to_2d, improve the method to ensure convergence

#### display.py
- refactor DisplayMesh.
- refactor DisplayMesh to Mesh3D
- enable stl / ply / 3mf / obj import and export with Mesh3D object
- implement various Mesh3D manipulations methods
- improve performance

### Changed
- Edge.split_between_two_points -> trim
- surfaces.py: point_on_surface -> point_belongs
- Numpyfy BSplines

### Build
- try adding github actions to testpypi

### Unittests
-

## 0.15.2

### build
Expand All @@ -16,8 +124,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Use pip install instead of setuptools install in order to avoid .egg being generating and preventing PyPI upload


## v0.15.0 [future]
## v0.15.0

### New Features

Expand All @@ -41,6 +148,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- BsplineCurve3D: circle_intersections.
- ArcEllipse3D/FullArcEllipse3D: line_intersections.

#### faces.py
- Face3D: get_face_polygons

#### curves.py
- Circle3D: point_distance.
#### shell.py
Expand Down
8 changes: 5 additions & 3 deletions code_pydocstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

print(f"Pydocstyle version: {pydocstyle.__version__}")

UNTRACKED_MODULES = ['fitting.py']

file_list = filter(
lambda z: not z.endswith("__init__.py"),
lambda z: not z.endswith("__init__.py") and not any(z.endswith(module) for module in UNTRACKED_MODULES),
[y for x in os.walk("./volmdlr") for y in glob(os.path.join(x[0], "*.py"))],
)

Expand All @@ -25,8 +27,8 @@
# If the error code is not in this dict, then there is no tolerance on the error.
# http://www.pydocstyle.org/en/stable/error_codes.html
"D101": 53,
"D102": 354,

"D102": 347,
"D103": 3,
"D205": 77,

"D400": 67,
Expand Down
12 changes: 6 additions & 6 deletions code_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

MIN_NOTE = 9.7

UNWATCHED_ERRORS = ['fixme', 'trailing-whitespace', 'import-error', 'missing-final-newline']
UNWATCHED_ERRORS = ['fixme', 'trailing-whitespace', 'import-error', 'missing-final-newline', 'use-maxsplit-arg']

EFFECTIVE_DATE = date(2023, 1, 31)

Expand All @@ -18,10 +18,10 @@
MAX_ERROR_BY_TYPE = {
"wrong-spelling-in-comment": 6,
'invalid-name': 1,
'arguments-differ': 64,
'too-many-locals': 103,
'unused-argument': 8,
'too-many-arguments': 26,
'arguments-differ': 67,
'too-many-locals': 75,
'unused-argument': 10,
'too-many-arguments': 30,
'line-too-long': 12,
'too-many-branches': 26,
'too-many-statements': 15,
Expand All @@ -31,7 +31,7 @@
'duplicate-code': 9,
'arguments-renamed': 56,
'too-many-ancestors': 20,
'too-many-public-methods': 15,
'too-many-public-methods': 16,
'too-many-instance-attributes': 15,
'protected-access': 4,
'too-many-nested-blocks': 3,
Expand Down
3 changes: 2 additions & 1 deletion coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import json

MIN_FILE_COVERAGE = 54.9
MIN_FILE_COVERAGE = 58.4
MIN_PROJECT_COVERAGE = 60

untracked_modules = ['volmdlr/templates.py',
Expand All @@ -18,6 +18,7 @@
"volmdlr/bspline_fitting.py",
"volmdlr/bspline_evaluators.py",
"volmdlr/discrete_representation_compiled.py",
"volmdlr/stl.py",
'nurbs/core.py',
'nurbs/helpers.py',
'nurbs/fitting.py',
Expand Down
34 changes: 34 additions & 0 deletions scripts/cad_simplification/alpha_wrap_simplify.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Showcase of the 'AlphaWrapSimplify' class.
"""
import time

from volmdlr.cad_simplification import AlphaWrapSimplify
from volmdlr.step import Step

# Load
volume_model = Step.from_file("../step/engine.step").to_volume_model()

# Simplify
start = time.perf_counter()
simplifier = AlphaWrapSimplify(volume_model=volume_model)
simplified_volume_model = simplifier.simplify(relative_alpha=15, relative_offset=420, preserve_shells=False)

print(f"Simplification took {time.perf_counter() - start:.6f} seconds\n")

# Count faces triangles:
n_faces = sum(len(shell.faces) for shell in volume_model.get_shells())
n_triangles = sum(len(shell.triangulation().faces) for shell in volume_model.get_shells())
print(f"Given model has {n_faces} faces and {n_triangles} triangles when triangulated for display.")

n_faces = sum(len(shell.faces) for shell in simplified_volume_model.get_shells())
n_triangles = sum(len(shell.triangulation().faces) for shell in simplified_volume_model.get_shells())
print(f"Simplified model has {n_faces} faces and {n_triangles} triangles when triangulated for display.")

# Display
for simplified_shell in simplified_volume_model.get_shells():
simplified_shell.color = (1.0, 0.0, 0.0)
simplified_shell.alpha = 0.6
volume_model.primitives.append(simplified_shell)

volume_model.babylonjs()
4 changes: 2 additions & 2 deletions scripts/cad_simplification/triangle_decimation_simplify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

# Simplify
start = time.perf_counter()
octre_block_simplify = TriangleDecimationSimplify(volume_model=volume_model)
simplified_volume_model = octre_block_simplify.simplify(target_ratio=0.2, preserve_border=True)
simplifier = TriangleDecimationSimplify(volume_model=volume_model)
simplified_volume_model = simplifier.simplify(target_ratio=0.2, preserve_border=True)

print(f"Simplification took {time.perf_counter() - start:.6f} seconds\n")

Expand Down
4 changes: 4 additions & 0 deletions scripts/ci_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,14 @@
# 'mesh/geo_file_1.py',
# 'mesh/geo_file_2.py',
# 'mesh/geo_file_3.py',
# display.py
"display/mesh3d.py",
"display/mesh_decimation.py",
# cad_simplification
"cad_simplification/voxelization_simplify.py",
"cad_simplification/triple_extrusion_simplify.py",
"cad_simplification/triangle_decimation_simplify.py",
"cad_simplification/alpha_wrap_simplify.py",
# Voxelization
"discrete_representation/voxelization/interference/interference_surface_showcase.py",
"discrete_representation/voxelization/interference/interference_volume_showcase.py",
Expand Down
Loading

0 comments on commit deca1a9

Please sign in to comment.