├── tests
├── __init__.py
├── cloud
│ ├── __init__.py
│ └── test_cloud.py
├── core
│ ├── __init__.py
│ ├── compound_export.stp
│ ├── compound_geometric_set.step
│ ├── test_assembly.py
│ ├── test_composite_primitive3d.py
│ ├── test_compound.py
│ └── test_functions.py
├── edges
│ ├── __init__.py
│ ├── test_edge_from_step.stp
│ ├── fullarcellipse_objects
│ │ └── fullarcellipse3d_line_intersections_line.json
│ ├── test_fullarc2d.py
│ ├── test_beziercurve3d.py
│ ├── arc_objects
│ │ ├── arc2d_rotation_test.json
│ │ └── arc_abscissa_bug.json
│ ├── bsplinecurve_objects
│ │ ├── bsplinecurve_close_points_trim_bug.json
│ │ └── bounding_box_test.json
│ └── test_beziercurve2d.py
├── faces
│ ├── __init__.py
│ ├── objects_spherical_test
│ │ ├── face_from_contours3d_and_rectangular_cut_point.json
│ │ ├── face_from_contours3d_and_rectangular_cut_surface.json
│ │ ├── sphericalface_from_contours3d_repair_primitives_periodicity_surface.json
│ │ ├── sphericalface_disconnected_contours_surface.json
│ │ └── sphericalsurface_contour3d_to_2d_bug.json
│ ├── objects_toroidal_tests
│ │ ├── face_with_inner_contour_surface.json
│ │ ├── repair_inner_contour_periodicity_surface.json
│ │ ├── repair_periodicity_toroidal_surface.json
│ │ └── surface_4.json
│ ├── objects_cylindrical_tests
│ │ ├── surface_openned_one_contour.json
│ │ ├── surface3d_1.json
│ │ ├── cylindrical_surface_repair_contour2d.json
│ │ └── cylindrical_surface_floating_point_error.json
│ ├── objects_conical_tests
│ │ ├── conical_surface3d_1.json
│ │ ├── conical_surface3d_2.json
│ │ ├── conical_surface_with_singularity.json
│ │ ├── conical_surface1.json
│ │ ├── conicalsurface_openned_contours.json
│ │ └── face_contour4_.json
│ ├── test_revolutionface3d.py
│ └── test_face3d.py
├── step
│ ├── __init__.py
│ ├── cone.step
│ ├── test_names.step
│ ├── test_wireframe.step
│ ├── test_step_read_lines.stp
│ └── test_conversion_factor.step
├── utils
│ ├── __init__.py
│ └── test_step_reader.py
├── wires
│ ├── __init__.py
│ ├── sphere_with_singularity.step
│ ├── contour_with_repeated_edge_in_contour3d.step
│ ├── test_contour.py
│ ├── strange_contour_from_step_primitives.json
│ └── test_edgecollection3d.py
├── curves
│ ├── __init__.py
│ └── circle2d_objects
│ │ └── test_circle2d_line2d_intersections.json
├── display
│ ├── __init__.py
│ └── models
│ │ └── simple.stl
├── geometry
│ ├── __init__.py
│ └── test_geometry.py
├── shells
│ ├── __init__.py
│ └── test_shell3d.py
├── surfaces
│ ├── __init__.py
│ ├── objects_extrusion_tests
│ │ ├── bspline_extruded_simple.step
│ │ ├── linesegment2d_to_self_edge.json
│ │ ├── linesegment2d_to_linesegment3d.json
│ │ ├── extrusionsurface_fullarcellipse3d_to_2d_fullarcellipse3d.json
│ │ └── periodical_extrusionsurface_bsplinecurve.json
│ ├── objects_revolution_tests
│ │ ├── linesegment2d_arc3d.json
│ │ ├── linesegment2d_rotated_primitive.json
│ │ ├── linesegment2d_split_primitive.json
│ │ └── revolutionsurface_periodical_linesegment2d_to_3d_linesegment2d.json
│ ├── objects_cylindrical_tests
│ │ ├── cylindricalsurface_linesegment3d.json
│ │ ├── test_contour3d_to_2d_surface.json
│ │ ├── cylindrical_surface_bspline_openned_contour.json
│ │ ├── cylindrical_surf_bug.json
│ │ ├── cylindricalsurface_with_linesegment3d.json
│ │ └── cylindricalsurface_small_periodic_bsplinecurve.json
│ ├── test_surface2d.py
│ ├── objects_plane_test
│ │ ├── planesurface_arc3d_to_2d.json
│ │ └── plane_parametric_operation_bug_surface.json
│ ├── objects_spherical_tests
│ │ ├── test_sphericalsurface_repair_periodicity_surface.json
│ │ ├── sphericalsurface1.json
│ │ ├── test_2_sphericalsurface_repair_periodicity_surface.json
│ │ ├── repair_primitives2d_periodicity_surface.json
│ │ ├── buggy_contour3d_to_2d_surface.json
│ │ ├── contour3d_to_2d_surface_bspline_with_singularity.json
│ │ ├── spherical_surface_arc3d_to_2d.json
│ │ └── sphericalsurface_contour3d_to_2d_positive_singularity.json
│ ├── objects_toroidal_tests
│ │ ├── surface.json
│ │ ├── degenerated_toroidalsurface_2.json
│ │ ├── toroidal_surface_bug_2.json
│ │ ├── toroidalsurface_small_arc3d.json
│ │ ├── toroidalsurface_small_bsplinecurve.json
│ │ ├── buggy_toroidalface_surface.json
│ │ ├── degenerated_toroidalsurface.json
│ │ └── toroidalsurface_bsplinecurve3d_to_2d.json
│ ├── test_periodical_surface.py
│ ├── objects_conical_tests
│ │ ├── conical_singularity_suface.json
│ │ ├── conicalsurface_contour_with_singularity_2.json
│ │ └── conicalsurface_linesegment3d_to_2d.json
│ ├── objects_bspline_test
│ │ ├── bsplinesurface_smallbsplinecurve_curve.json
│ │ └── periodic_surface_smallbsplinecurve3d_curve.json
│ └── objects_periodical_surface
│ │ └── periodicalsurface_with_theta_discontinuity.json
├── core_compiled
│ ├── __init__.py
│ ├── test_vector.py
│ ├── test_basis2d.py
│ └── test_basis3d.py
├── primitives3d
│ ├── __init__.py
│ ├── test_sphere.py
│ ├── test_block.py
│ └── test_sweep.py
├── common_operations
│ ├── __init__.py
│ └── test_common_operations.py
├── discrete_representation
│ ├── __init__.py
│ └── test_discrete_representation.py
├── line_distances_projections.py
├── test_core.py
└── test_geometry.py
├── volmdlr
├── nurbs
│ ├── __init__.py
│ └── helpers.pxd
├── utils
│ └── __init__.py
├── assets
│ └── logos
│ │ └── volmdlr.jpg
├── models
│ ├── __init__.py
│ ├── curves.py
│ ├── conical_surfaces.py
│ ├── open_rounded_line_segments.py
│ ├── cylindrical_surfaces.py
│ └── workflows
│ │ └── core.py
├── core_compiled.pxd
└── __init__.py
├── .coveragerc
├── doc
├── source
│ ├── images
│ │ ├── Castest.jpg
│ │ ├── casing.jpg
│ │ ├── polygon.jpg
│ │ ├── sweep.jpg
│ │ ├── sweep1.jpg
│ │ ├── sweepMPLPlot.jpg
│ │ ├── casing_contours.png
│ │ └── bspline_surface_split.png
│ ├── _static
│ │ └── index-images
│ │ │ ├── block.png
│ │ │ ├── cone.png
│ │ │ ├── sweep.png
│ │ │ ├── union.png
│ │ │ ├── cylinder.png
│ │ │ ├── sphere.png
│ │ │ ├── subtract.png
│ │ │ ├── triangle3d.png
│ │ │ ├── bsplineface3d.png
│ │ │ ├── closedshell3d.png
│ │ │ ├── conicalface3d.png
│ │ │ ├── intersection.png
│ │ │ ├── openshell3d.png
│ │ │ ├── planeface3d.png
│ │ │ ├── point-vector.png
│ │ │ ├── block_babylonjs.png
│ │ │ ├── extrudedprofile.png
│ │ │ ├── extrusionface3d.png
│ │ │ ├── hollowcylinder.png
│ │ │ ├── revolvedprofile.png
│ │ │ ├── sphericalface3d.png
│ │ │ ├── toroidalface3d.png
│ │ │ ├── cylindricalface3d.png
│ │ │ ├── revolutionface3d.png
│ │ │ ├── subtract_to_closedshell.png
│ │ │ ├── contributor.svg
│ │ │ ├── union-svgrepo-com.svg
│ │ │ ├── distance.svg
│ │ │ └── user_guide.svg
│ ├── modules
│ │ ├── gmsh.rst
│ │ ├── stl.rst
│ │ ├── grid.rst
│ │ ├── mesh.rst
│ │ ├── step.rst
│ │ ├── wires.rst
│ │ ├── shells.rst
│ │ ├── module_cloud.rst
│ │ ├── module_edges.rst
│ │ ├── module_faces.rst
│ │ ├── module_curves.rst
│ │ ├── surfaces.rst
│ │ ├── module_display.rst
│ │ ├── module_geometry.rst
│ │ ├── voxelization.rst
│ │ ├── cad_simplification.rst
│ │ ├── base_modules.rst
│ │ ├── primitives.rst
│ │ └── bspline_compiled.rst
│ ├── volmdlr.rst
│ ├── glossary.rst
│ ├── road_map_and_current_limitations.rst
│ ├── modules.rst
│ ├── volmdlr.utils.rst
│ ├── about_dessia.rst
│ └── authors.rst
├── Makefile
└── make.bat
├── MANIFEST.in
├── scripts
├── step
│ ├── assembly.step
│ ├── block.step
│ ├── casing.step
│ ├── cheese.step
│ ├── cone1.step
│ ├── cone2.step
│ ├── cylinder.step
│ ├── ellipse.step
│ ├── engine.step
│ ├── shell0.step
│ ├── sphere1.step
│ ├── sphere2.step
│ ├── sphere3.step
│ ├── tore1.step
│ ├── tore2.step
│ ├── STEP_test1.stp
│ ├── bracket1.step
│ ├── bracket2.step
│ ├── bracket3.step
│ ├── iso4162M16x55.step
│ ├── read_test1.STEP
│ ├── read_test3.STEP
│ ├── spanners.step
│ ├── 2_bspline_faces.stp
│ ├── 4_bspline_faces.step
│ ├── aircraft_engine.step
│ ├── strange_gasket.step
│ ├── tormach_wrench.step
│ ├── compressor_simplified.step
│ ├── usecase_inner_contour.STEP
│ └── read_steps.py
├── stl
│ ├── cube_ascii.stl
│ ├── simple.stl
│ ├── double_space.stl
│ └── read_stls.py
├── faces
│ ├── planeface_with_inner_contour.step
│ ├── BSplineSurface
│ │ ├── bspline_surface_1.step
│ │ ├── bspline_surface_2.step
│ │ └── cylindrical_surface_1.step
│ ├── bsplineface_with_inner_contours.stp
│ ├── conical.py
│ ├── toroidal.py
│ ├── cylindrical.py
│ ├── export_to_step.py
│ ├── triangle3d.py
│ ├── bezier_surface.py
│ ├── spherical.py
│ └── faces_with_inner_contours.py
├── primitives
│ ├── sphere.py
│ ├── cone.py
│ ├── cylinder.py
│ ├── sphere_points.py
│ ├── extrusion.py
│ ├── hollow_cylinder.py
│ ├── extrusion2.py
│ └── extrusion3.py
├── edges
│ ├── test_bspline3d_revolution.py
│ ├── arcs2D.py
│ ├── lines2d.py
│ ├── minimum_distance_points_line3D.py
│ ├── bspline.py
│ └── bezier_curve.py
├── core
│ ├── points.py
│ ├── frames.py
│ ├── bbox_triangle_intersection.py
│ ├── points_axial_symmetry.py
│ └── grid2d_with_direction.py
├── shells
│ ├── operations.py
│ ├── triangle_shell_mesh_data.py
│ └── decimation.py
├── collisions
│ ├── cylinder_points_belongs.py
│ ├── plot_cylinders_points.py
│ └── test_perf_min_dist.py
├── wires
│ ├── areas.py
│ ├── polygon3d.py
│ ├── triangle2D.py
│ └── axial_symmetry.py
├── center_mass.py
├── discrete_representation
│ ├── voxelization
│ │ ├── step_file_voxelization.py
│ │ ├── stl_file_voxelization.py
│ │ ├── compare_memory_usage.py
│ │ ├── volume_model_matrix_based_voxelization.py
│ │ ├── volume_model_point_based_voxelization.py
│ │ ├── octree
│ │ │ ├── inner_growing_showcase.py
│ │ │ └── non_homogeneous_showcase.py
│ │ ├── voxelization_inverse.py
│ │ └── voxelization_decimation.py
│ ├── pixelization
│ │ ├── pixelization_from_closed_polygon.py
│ │ ├── pixelization_inverse.py
│ │ └── pixelization_filling.py
│ └── octree
│ │ ├── inner_growing_showcase.py
│ │ └── non_homogeneous_showcase.py
├── showcases
│ ├── casing.py
│ └── simple_shapes.py
├── display
│ └── mesh_decimation.py
├── mesh
│ ├── mesh2D.py
│ ├── read_msh_file.py
│ └── model.msh
├── distance
│ ├── shell_intersection.py
│ └── ls3D_ls3D.py
├── cloud
│ └── cloud_debug.py
├── geometry.py
├── grid.py
└── cad_simplification
│ └── alpha_wrap_simplify.py
├── pre-commit
├── .gitattributes
├── pyproject.toml
├── .pep8
├── code_changelog.sh
├── PULL_REQUEST_TEMPLATE.md
├── ISSUE_TEMPLATE.md
├── code_pep8.sh
├── .github
└── workflows
│ └── install.yml
├── .pre-commit-config.yaml
├── .readthedocs.yaml
└── ROADMAP.md
/tests/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/cloud/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/core/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/edges/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/faces/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/step/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/utils/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/wires/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/curves/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/display/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/geometry/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/shells/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/surfaces/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/volmdlr/nurbs/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/volmdlr/utils/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/core_compiled/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/primitives3d/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/common_operations/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/discrete_representation/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.coveragerc:
--------------------------------------------------------------------------------
1 | [run]
2 | plugins =
3 | Cython.Coverage
4 | source=volmdlr
5 |
--------------------------------------------------------------------------------
/doc/source/images/Castest.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/Castest.jpg
--------------------------------------------------------------------------------
/doc/source/images/casing.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/casing.jpg
--------------------------------------------------------------------------------
/doc/source/images/polygon.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/polygon.jpg
--------------------------------------------------------------------------------
/doc/source/images/sweep.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/sweep.jpg
--------------------------------------------------------------------------------
/doc/source/images/sweep1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/sweep1.jpg
--------------------------------------------------------------------------------
/doc/source/images/sweepMPLPlot.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/sweepMPLPlot.jpg
--------------------------------------------------------------------------------
/volmdlr/assets/logos/volmdlr.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/volmdlr/assets/logos/volmdlr.jpg
--------------------------------------------------------------------------------
/doc/source/images/casing_contours.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/casing_contours.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/block.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/block.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/cone.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/cone.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/sweep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/sweep.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/union.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/union.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/cylinder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/cylinder.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/sphere.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/sphere.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/subtract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/subtract.png
--------------------------------------------------------------------------------
/doc/source/images/bspline_surface_split.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/images/bspline_surface_split.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/triangle3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/triangle3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/bsplineface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/bsplineface3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/closedshell3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/closedshell3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/conicalface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/conicalface3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/intersection.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/intersection.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/openshell3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/openshell3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/planeface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/planeface3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/point-vector.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/point-vector.png
--------------------------------------------------------------------------------
/doc/source/modules/gmsh.rst:
--------------------------------------------------------------------------------
1 | GMSH
2 | ----
3 |
4 | .. automodule:: volmdlr.gmsh_vm
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/block_babylonjs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/block_babylonjs.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/extrudedprofile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/extrudedprofile.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/extrusionface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/extrusionface3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/hollowcylinder.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/hollowcylinder.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/revolvedprofile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/revolvedprofile.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/sphericalface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/sphericalface3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/toroidalface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/toroidalface3d.png
--------------------------------------------------------------------------------
/doc/source/modules/stl.rst:
--------------------------------------------------------------------------------
1 | .. _stl:
2 | STL
3 | ---
4 |
5 | .. automodule:: volmdlr.stl
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/cylindricalface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/cylindricalface3d.png
--------------------------------------------------------------------------------
/doc/source/_static/index-images/revolutionface3d.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/revolutionface3d.png
--------------------------------------------------------------------------------
/doc/source/modules/grid.rst:
--------------------------------------------------------------------------------
1 | .. _grid:
2 | Grid
3 | ----
4 |
5 | .. automodule:: volmdlr.grid
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/doc/source/modules/mesh.rst:
--------------------------------------------------------------------------------
1 | .. _mesh:
2 | Mesh
3 | ----
4 |
5 | .. automodule:: volmdlr.mesh
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/doc/source/modules/step.rst:
--------------------------------------------------------------------------------
1 | .. _step:
2 | STEP
3 | ----
4 |
5 | .. automodule:: volmdlr.step
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/tests/step/cone.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:b997ccfb43d411db23bc092a6163a693028198d2812997322bfde1a826aaf1ad
3 | size 5206
4 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | recursive-include volmdlr/assets *.html *.js *ts *jpg *png
2 | include volmdlr/*.pyx
3 | exclude volmdlr/*.c
4 | prune .git
5 | include pyproject.toml
6 |
--------------------------------------------------------------------------------
/doc/source/modules/wires.rst:
--------------------------------------------------------------------------------
1 | .. _wires:
2 | Wires
3 | -----
4 |
5 | .. automodule:: volmdlr.wires
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/scripts/step/assembly.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:4d2d2623c8bdee0e8197f90f97ef50b0879f8a23870d920f9e2d9d7dd55e0934
3 | size 85197
4 |
--------------------------------------------------------------------------------
/scripts/step/block.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:3782b4a70c41f9f389d59c8dd8e30ad62d4c76d208d181e462abb8aabab2335b
3 | size 15899
4 |
--------------------------------------------------------------------------------
/scripts/step/casing.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:e2c83f5060887697f6fe5d42e4c0261c4eff047e2a016d2ac60c5d623088d490
3 | size 496540
4 |
--------------------------------------------------------------------------------
/scripts/step/cheese.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:207ff760c7cc09470455d039e6258025e82acd3560c5301feb1353c91b398e68
3 | size 13981
4 |
--------------------------------------------------------------------------------
/scripts/step/cone1.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:967907c7d07521c733b84926b8a6ab33ffbcf5a489e05e96d820838929799a37
3 | size 5102
4 |
--------------------------------------------------------------------------------
/scripts/step/cone2.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:d204c6d0101123a3cd939aa7b82da6d774d53a9e1468cc606c2560933a9eeba1
3 | size 6392
4 |
--------------------------------------------------------------------------------
/scripts/step/cylinder.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:5c6efd91088dc0fae39222783c11e90a9e4a63b53112b7f32c040e41ba057f71
3 | size 6168
4 |
--------------------------------------------------------------------------------
/scripts/step/ellipse.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:d39d95ec205b3460a4604cbd302e2d1f16bb830cb158d0080a6a6e7255a18de4
3 | size 6320
4 |
--------------------------------------------------------------------------------
/scripts/step/engine.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:cee6d03a66a471f26442d0e9072311e9c3b68481f8c2b4833bdde4400a0ad863
3 | size 329765
4 |
--------------------------------------------------------------------------------
/scripts/step/shell0.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:ac0adf3c8a1b917a4e30f764cc3a61582f2016e2b8194ada5c70ae01ea2e59a8
3 | size 39310
4 |
--------------------------------------------------------------------------------
/scripts/step/sphere1.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:fb4b2363c9138324065dd69cb81f606b0f63ae83fc2c4ac6990120366a379d71
3 | size 2523
4 |
--------------------------------------------------------------------------------
/scripts/step/sphere2.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:eeda064534149add05c6ab34638844633a0037f2cd79ab65e8c84fb4bda9e7ac
3 | size 5157
4 |
--------------------------------------------------------------------------------
/scripts/step/sphere3.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:161f9e09de6e9285e957526eadbd3453cead49b11901fb8b61bd8f7a0ff633d3
3 | size 10051
4 |
--------------------------------------------------------------------------------
/scripts/step/tore1.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:3b290326abf1c352d901c0728474876b446d825569248bfc8374c3a22916ccbe
3 | size 2490
4 |
--------------------------------------------------------------------------------
/scripts/step/tore2.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:d5ecf616324b161377ff48f9234a73874c16bf5e328746164bcd53d0747586d9
3 | size 6526
4 |
--------------------------------------------------------------------------------
/scripts/stl/cube_ascii.stl:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:9d1d4528e82212d47b63f79ccf9bcad02c605bb1a735237f21cbeae58fcc4ad1
3 | size 596
4 |
--------------------------------------------------------------------------------
/scripts/stl/simple.stl:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:a09adc2c0d36299c0cb85495844a82e031fc4194dfae64c837f263146c41bdb7
3 | size 83684
4 |
--------------------------------------------------------------------------------
/tests/step/test_names.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:a7b3f7f9a5d72f335d6c4642bc729d929b3718f4cbbbcbb46eb537a50827eafb
3 | size 41372
4 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/subtract_to_closedshell.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dessia-tech/volmdlr/HEAD/doc/source/_static/index-images/subtract_to_closedshell.png
--------------------------------------------------------------------------------
/doc/source/modules/shells.rst:
--------------------------------------------------------------------------------
1 | .. _shells:
2 | Shells
3 | ------
4 |
5 | .. automodule:: volmdlr.shells
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/scripts/step/STEP_test1.stp:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:b60688c59b454d0f12dc90abd649254aac89a0c9f11f2cb0c6c599a16b616e85
3 | size 5235796
4 |
--------------------------------------------------------------------------------
/scripts/step/bracket1.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:b23b0b8ad3f9c33fb7a55e96c131777a639827f75727f8efe29375cfb5548da2
3 | size 2901233
4 |
--------------------------------------------------------------------------------
/scripts/step/bracket2.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:f810bce7e0fd8d39a0aacd5889dd8e05a6b00ac348a6e57bc4adc19da7fecccd
3 | size 469263
4 |
--------------------------------------------------------------------------------
/scripts/step/bracket3.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:3e783da5b1d74e330c60ad494ed72ebef3dd13576772cda73a693c833b857582
3 | size 1921805
4 |
--------------------------------------------------------------------------------
/scripts/step/iso4162M16x55.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:e7d7e82e1bb6fac67a7e13256b9fdf0e5ef7a5b438a817b8b2ed432c8f12d82e
3 | size 77795
4 |
--------------------------------------------------------------------------------
/scripts/step/read_test1.STEP:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:71f2dacf5daaec6a4767c32f4c01357295869e0930ce478dc85f6d113139d106
3 | size 111068
4 |
--------------------------------------------------------------------------------
/scripts/step/read_test3.STEP:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:f7569f50c309fd061c478c6b311b34c44d8fb1115d21d174115be462020ea8fc
3 | size 38901
4 |
--------------------------------------------------------------------------------
/scripts/step/spanners.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:f17c7e24cff8f7d833c444dd686f4e3dc872063747e9fdc4c506c572e87b7ea5
3 | size 332832
4 |
--------------------------------------------------------------------------------
/scripts/stl/double_space.stl:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:eccf59859b42dab32b79a410a85dfa26088e0338bc9fd60152d4a8e81d80518b
3 | size 3075
4 |
--------------------------------------------------------------------------------
/tests/core/compound_export.stp:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:c485e2079b2bc6dfbb056a375703049198b48e5f35fde40f48d8cfbca4f381a6
3 | size 2764
4 |
--------------------------------------------------------------------------------
/tests/display/models/simple.stl:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:a09adc2c0d36299c0cb85495844a82e031fc4194dfae64c837f263146c41bdb7
3 | size 83684
4 |
--------------------------------------------------------------------------------
/tests/step/test_wireframe.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:656913592fc02386e3f84a28059643da7802d2eed03f2006001b7bda7e88ae65
3 | size 2019
4 |
--------------------------------------------------------------------------------
/doc/source/modules/module_cloud.rst:
--------------------------------------------------------------------------------
1 | .. _cloud:
2 | Cloud
3 | -----
4 |
5 | .. automodule:: volmdlr.cloud
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/doc/source/modules/module_edges.rst:
--------------------------------------------------------------------------------
1 | .. _edges:
2 | Edges
3 | =====
4 |
5 | .. automodule:: volmdlr.edges
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/doc/source/modules/module_faces.rst:
--------------------------------------------------------------------------------
1 | .. _faces:
2 | Faces
3 | ====
4 |
5 | .. automodule:: volmdlr.faces
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/scripts/step/2_bspline_faces.stp:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:eaa4a4ee4edfb7c1da13974c2277f495d96f94d4b501e18f4b3602de75dd6388
3 | size 1102324
4 |
--------------------------------------------------------------------------------
/scripts/step/4_bspline_faces.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:5f099eb06b0619b2319034a789ccd41a54b94e5a85c8c4f65cb59972f9bb6893
3 | size 269301
4 |
--------------------------------------------------------------------------------
/scripts/step/aircraft_engine.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:4d68b5412ac491cb95e6933a4a8a8eea8bad5664c6d4bf002c31e1d5c9c0ab91
3 | size 1292953
4 |
--------------------------------------------------------------------------------
/scripts/step/strange_gasket.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:c77e6af90df3e79d42b969425b8a8965124ba2091cfa4cfed873a6d156474214
3 | size 75716
4 |
--------------------------------------------------------------------------------
/scripts/step/tormach_wrench.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:76a1165ffad92592115f16af5de1bc7f483710db8deacee4816db5b8d7edf69f
3 | size 326238
4 |
--------------------------------------------------------------------------------
/tests/edges/test_edge_from_step.stp:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:cc7e78df8839bbec4a4d7c460be4df4ff658011e46d249673249db40ba76a26d
3 | size 5794
4 |
--------------------------------------------------------------------------------
/tests/step/test_step_read_lines.stp:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:db29ef16c3d795d425e9184095385c9e291d2581941f7f5498c5808226d9032e
3 | size 883
4 |
--------------------------------------------------------------------------------
/doc/source/modules/module_curves.rst:
--------------------------------------------------------------------------------
1 | .. _curves:
2 | Curves
3 | ------
4 |
5 | .. automodule:: volmdlr.curves
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/doc/source/modules/surfaces.rst:
--------------------------------------------------------------------------------
1 | .. _surfaces:
2 | Surfaces
3 | --------
4 |
5 | .. automodule:: volmdlr.surfaces
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/scripts/step/compressor_simplified.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:007894d7116fabd2396367ea3f50b790c6f79747f489227cce05da0119cb0e87
3 | size 5021026
4 |
--------------------------------------------------------------------------------
/scripts/step/usecase_inner_contour.STEP:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:aa0a2c4285cf3d1a6c05de33d540989f00d2bf77a03cee7cf56b87abdd79422c
3 | size 25295
4 |
--------------------------------------------------------------------------------
/tests/core/compound_geometric_set.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:791ffac39ba01ffbdf2a6af1716b77518ddd1cb598c0c0f8ce75b5e7e71224ae
3 | size 2980
4 |
--------------------------------------------------------------------------------
/tests/step/test_conversion_factor.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:0baf280c79e6f7dda05791dff8f9fd450720e70b50357480c377dee88c4e6be1
3 | size 5596
4 |
--------------------------------------------------------------------------------
/tests/wires/sphere_with_singularity.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:323f46f76888335c415e684150309e7fe9a54b81dc5598c266c8c17470f8de5c
3 | size 4265
4 |
--------------------------------------------------------------------------------
/doc/source/modules/module_display.rst:
--------------------------------------------------------------------------------
1 | .. _display:
2 | Display
3 | -------
4 |
5 | .. automodule:: volmdlr.display
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/scripts/faces/planeface_with_inner_contour.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:ac731f1f35389ba7a2ed8a17923dc0bafba49926a2d681e7384e008ada6efae3
3 | size 7710
4 |
--------------------------------------------------------------------------------
/scripts/faces/BSplineSurface/bspline_surface_1.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:770b4933cb2cfab4d6ec62bc312b7978739d56fb77af65339ad8c0edf358c520
3 | size 29325
4 |
--------------------------------------------------------------------------------
/scripts/faces/bsplineface_with_inner_contours.stp:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:4a15f877083fce5f8833f37f0864643d0d8f58e95c784e4a078e2242cb475349
3 | size 539015
4 |
--------------------------------------------------------------------------------
/scripts/faces/BSplineSurface/bspline_surface_2.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:aadc325f1cdc0ddbe47010e8f191ab106b5e37b8dc410961672cd11c68e9ab42
3 | size 187849
4 |
--------------------------------------------------------------------------------
/scripts/faces/BSplineSurface/cylindrical_surface_1.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:48c0b741da0be8823597802b7ad9d48f39f2259f4d04580798866e3c2c3ee62d
3 | size 16748
4 |
--------------------------------------------------------------------------------
/tests/wires/contour_with_repeated_edge_in_contour3d.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:e799bb16eeae17954058976f56b5da80ed5dc280d15cc9b7d340cba2c3b85d66
3 | size 16428
4 |
--------------------------------------------------------------------------------
/volmdlr/models/__init__.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Base models for volmdlr.
5 | """
6 |
7 | from .bspline_surfaces import *
8 | from .casing import casing
9 |
--------------------------------------------------------------------------------
/doc/source/modules/module_geometry.rst:
--------------------------------------------------------------------------------
1 |
2 | .. _geometry:
3 | Geometry
4 | --------
5 |
6 | .. automodule:: volmdlr.geometry
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/doc/source/modules/voxelization.rst:
--------------------------------------------------------------------------------
1 | Voxelization Compiled
2 | ---------------------
3 |
4 | .. automodule:: volmdlr.voxelization_compiled
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_extrusion_tests/bspline_extruded_simple.step:
--------------------------------------------------------------------------------
1 | version https://git-lfs.github.com/spec/v1
2 | oid sha256:abf0e44380f910004c9a510d540df8dfbe748a7d1dffd0c754e704982b36fbd7
3 | size 4580
4 |
--------------------------------------------------------------------------------
/doc/source/modules/cad_simplification.rst:
--------------------------------------------------------------------------------
1 |
2 | Cad Simplification
3 | -----------------
4 |
5 | .. automodule:: volmdlr.cad_simplification
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
9 |
--------------------------------------------------------------------------------
/tests/faces/objects_spherical_test/face_from_contours3d_and_rectangular_cut_point.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.Point3D",
3 | "x": 3e-18,
4 | "y": 8.2e-17,
5 | "z": 0.026296372000000002
6 | }
7 |
--------------------------------------------------------------------------------
/volmdlr/nurbs/helpers.pxd:
--------------------------------------------------------------------------------
1 | # helpers.pxd
2 | from libcpp.vector cimport vector
3 |
4 | cdef vector[double] linspace(double start, double stop, int num, int decimals)
5 |
6 | cdef double binomial_coefficient(int k, int i)
7 |
--------------------------------------------------------------------------------
/scripts/primitives/sphere.py:
--------------------------------------------------------------------------------
1 | """
2 | Demo script of creating and displaying a Sphere.
3 | """
4 | import volmdlr
5 | from volmdlr.primitives3d import Sphere
6 |
7 | sphere = Sphere(volmdlr.O3D, 0.1, name="Sphere")
8 | sphere.babylonjs()
9 |
--------------------------------------------------------------------------------
/pre-commit:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # To install this hook, copy this file to .git/hooks
4 |
5 | echo "checking pep8"
6 | bash code_pep8.sh
7 | echo "checking pylint"
8 | python3 code_pylint.py
9 | echo "checking pydocstyle"
10 | python3 code_pydocstyle.py
11 |
--------------------------------------------------------------------------------
/scripts/edges/test_bspline3d_revolution.py:
--------------------------------------------------------------------------------
1 |
2 | import volmdlr
3 | from volmdlr.models.edges import bspline_curve3d
4 | bspline_curve_3d = bspline_curve3d()
5 |
6 | face = bspline_curve_3d.revolution(volmdlr.O3D, volmdlr.X3D, volmdlr.TWO_PI)
7 | face.babylonjs()
8 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.step filter=lfs diff=lfs merge=lfs -text
2 | *.stp filter=lfs diff=lfs merge=lfs -text
3 | *.stl filter=lfs diff=lfs merge=lfs
4 | .step filter=lfs diff=lfs merge=lfs -text
5 | .stp filter=lfs diff=lfs merge=lfs -text
6 | .stl filter=lfs diff=lfs merge=lfs -text
7 |
--------------------------------------------------------------------------------
/scripts/core/points.py:
--------------------------------------------------------------------------------
1 | import volmdlr as vm
2 |
3 | p1 = vm.Point3D(2.2409998778799998, 1.3700006035999999, -0.452188071297)
4 | p2 = vm.Point3D(2.241, 1.37, -0.452187476119)
5 | s = set([p1, p2])
6 | if p1 == p2:
7 | print(p1.point_distance(p2))
8 | assert hash(p1) == hash(p2)
9 |
--------------------------------------------------------------------------------
/doc/source/volmdlr.rst:
--------------------------------------------------------------------------------
1 |
2 | .. _modules:
3 | ALL MODULES
4 | ===========
5 |
6 | Subpackages
7 | -----------
8 |
9 | .. toctree::
10 | :maxdepth: 2
11 |
12 | volmdlr.utils
13 |
14 | Submodules
15 | ----------
16 |
17 | .. toctree::
18 | :maxdepth: 3
19 |
20 | modules
21 |
--------------------------------------------------------------------------------
/volmdlr/core_compiled.pxd:
--------------------------------------------------------------------------------
1 | cdef class Vector:
2 | cdef public str name
3 |
4 | cdef class Vector2D(Vector):
5 | cdef public double x, y
6 |
7 | cdef class Point2D(Vector2D):
8 | pass
9 |
10 | cdef class Vector3D(Vector):
11 | cdef public double x, y, z
12 |
13 | cdef class Point3D(Vector3D):
14 | pass
15 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/contributor.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/pyproject.toml:
--------------------------------------------------------------------------------
1 | [build-system]
2 | requires = ["setuptools", "Cython>=3", "numpy"]
3 | build-backend = "setuptools.build_meta"
4 |
5 | [tool.cibuildwheel]
6 | # Skip building on CPython 3.12 on all platforms. remove in the future
7 | # Skip building PyPy wheels on python3.10 on windowns amd 64 bits. Causing numpy error.
8 | skip = ["cp312-*", "pp310-win_amd64"]
9 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_extrusion_tests/linesegment2d_to_self_edge.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment2D",
3 | "name": "",
4 | "start": {
5 | "object_class": "volmdlr.Point2D",
6 | "x": 0.0,
7 | "y": 0.0
8 | },
9 | "end": {
10 | "object_class": "volmdlr.Point2D",
11 | "x": 1.0,
12 | "y": 0.0
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_revolution_tests/linesegment2d_arc3d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment2D",
3 | "name": "arc",
4 | "start": {
5 | "object_class": "volmdlr.Point2D",
6 | "x": -3.141592653589793,
7 | "y": 0.0
8 | },
9 | "end": {
10 | "object_class": "volmdlr.Point2D",
11 | "x": 0.0,
12 | "y": 0.0
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.pep8:
--------------------------------------------------------------------------------
1 | [pycodestyle]
2 | max_line_length = 120
3 | ignore = E402, E722, E126, E731
4 | recursive = true
5 | aggressive = 1
6 |
7 | # config file used by autopep, which enhance pycodestyle
8 | # see config options at :
9 | # see https://pypi.org/project/autopep8/#features
10 | # https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes
11 | # interesting codes : E501, W6
12 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_extrusion_tests/linesegment2d_to_linesegment3d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment2D",
3 | "name": "",
4 | "start": {
5 | "object_class": "volmdlr.Point2D",
6 | "x": 0.0,
7 | "y": 0.0022999999994890528
8 | },
9 | "end": {
10 | "object_class": "volmdlr.Point2D",
11 | "x": 0.0,
12 | "y": 0.0
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/scripts/core/frames.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Tue Oct 25 15:35:13 2022
5 |
6 | @author: steven
7 | """
8 |
9 | import volmdlr as vm
10 |
11 | frame1 = vm.OXYZ
12 | center = vm.Point3D(0.6, 0, 0)
13 | frame2 = frame1.rotation(center, vm.Z3D, 0.2)
14 |
15 | ax = frame1.plot()
16 | center.plot(ax=ax, color='r')
17 | frame2.plot(ax=ax)
18 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_revolution_tests/linesegment2d_rotated_primitive.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment2D",
3 | "name": "arc",
4 | "start": {
5 | "object_class": "volmdlr.Point2D",
6 | "x": 0.0,
7 | "y": 0.0
8 | },
9 | "end": {
10 | "object_class": "volmdlr.Point2D",
11 | "x": 0.0,
12 | "y": 0.016188947159600005
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/doc/source/modules/base_modules.rst:
--------------------------------------------------------------------------------
1 | Base Modules
2 | ============
3 |
4 | .. _core_compiled:
5 | Core Compiled
6 | -------------
7 |
8 | .. automodule:: volmdlr.core_compiled
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 | .. _core:
14 | Core
15 | ----
16 |
17 | .. automodule:: volmdlr.core
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
--------------------------------------------------------------------------------
/scripts/shells/operations.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Goal: call shells methods (point_belongs, volume)
5 | """
6 |
7 | import time
8 |
9 | import volmdlr as vm
10 | from volmdlr.models import casing
11 |
12 | bottom, sides, belt = casing.primitives
13 |
14 | t1 = time.time()
15 | assert not sides.point_inside(vm.Point3D(0.1, 0.1, 0.1))
16 | t1 = time.time() - t1
17 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_revolution_tests/linesegment2d_split_primitive.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment2D",
3 | "name": "",
4 | "start": {
5 | "object_class": "volmdlr.Point2D",
6 | "x": -3.141592653589793,
7 | "y": 0.003505885384025662
8 | },
9 | "end": {
10 | "object_class": "volmdlr.Point2D",
11 | "x": -3.141592653589793,
12 | "y": 0.0
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/volmdlr/models/curves.py:
--------------------------------------------------------------------------------
1 | """
2 | Some Volmdlr models for curves.
3 |
4 | """
5 | import volmdlr
6 | from volmdlr import curves
7 |
8 | vector1 = volmdlr.Vector3D(1, 1, 1)
9 | vector1 = vector1.unit_vector()
10 | vector2 = vector1.deterministic_unit_normal_vector()
11 | vector3 = vector1.cross(vector2)
12 | frame = volmdlr.Frame3D(volmdlr.O3D, vector1, vector2, vector3)
13 |
14 | circle3d = curves.Circle3D(frame, 1)
15 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/union-svgrepo-com.svg:
--------------------------------------------------------------------------------
1 |
2 |
5 |
--------------------------------------------------------------------------------
/scripts/collisions/cylinder_points_belongs.py:
--------------------------------------------------------------------------------
1 | """
2 | Test for method Cylinder.point_belongs and Cylinder.random_point_inside
3 | """
4 | import volmdlr
5 | from volmdlr.primitives3d import Cylinder
6 |
7 | cylinder = Cylinder(position=volmdlr.O3D, axis=volmdlr.Z3D, radius=0.02, length=0.1)
8 |
9 | p = cylinder.random_point_inside()
10 |
11 | if not cylinder.point_belongs(p):
12 | raise ValueError("Point should belong to cylinder")
13 |
--------------------------------------------------------------------------------
/doc/source/glossary.rst:
--------------------------------------------------------------------------------
1 | Glossary
2 | ========
3 |
4 | Bot
5 | ---
6 |
7 | Digitalization of a process including the writing of generic knowledge and a
8 | workflow to describe the Know-How
9 |
10 | SDK
11 | ---
12 |
13 | Set of Python libraries allowing to write in low-code the Know-That bricks
14 | (generic knowledge)
15 |
16 | Platform
17 | --------
18 |
19 | Dessia's software solution based on a Web interface and a backend that emulates
20 | Python
21 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_revolution_tests/revolutionsurface_periodical_linesegment2d_to_3d_linesegment2d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment2D",
3 | "name": "parametric.fullarc",
4 | "start": {
5 | "object_class": "volmdlr.Point2D",
6 | "x": 0.0,
7 | "y": 0.023550776716126855
8 | },
9 | "end": {
10 | "object_class": "volmdlr.Point2D",
11 | "x": 6.283185307179586,
12 | "y": 0.023550776716126855
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/code_changelog.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | lines=$(git diff origin/"$DRONE_TARGET_BRANCH"..origin/pr/"$DRONE_PULL_REQUEST" -- CHANGELOG.md README.md CONTRIBUTING.md --unified=0 | wc -l)
4 | echo "$lines lines modified on CHANGELOG.md or other doc files in PR $DRONE_SOURCE_BRANCH -> $DRONE_TARGET_BRANCH"
5 |
6 |
7 | if [ "$lines" -eq 0 ]
8 | then
9 | echo -e "\nCHANGELOG.md has not been updated. Update it for the PR to be accepted in CI.\n"
10 | exit 1
11 | fi
12 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_cylindrical_tests/cylindricalsurface_linesegment3d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.LineSegment3D",
3 | "name": "",
4 | "start": {
5 | "object_class": "volmdlr.Point3D",
6 | "x": 2.58884431275,
7 | "y": 0.410735373891,
8 | "z": 0.114070767118
9 | },
10 | "end": {
11 | "object_class": "volmdlr.Point3D",
12 | "x": 2.5888140588699997,
13 | "y": 0.40989030233900003,
14 | "z": 0.114697556571
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/scripts/wires/areas.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Tue Mar 14 13:55:59 2017
5 |
6 | @author: steven
7 | """
8 |
9 | # Debug of area and inertia
10 |
11 | import volmdlr as vm
12 |
13 | r=0.05
14 |
15 | p1=vm.Point2D(0,0)
16 | p2=vm.Point2D(0,-r)
17 | p3=vm.Point2D(r,0)
18 | p4=vm.Point2D(0,r)
19 |
20 | c1=vm.edges.Arc2D(p2,p3,p4)
21 |
22 | print(c1.second_moment_area(p1))
23 |
24 | c2=vm.wires.Circle2D(p1,r)
25 |
26 | print(c2.second_moment_area(p1))
27 |
--------------------------------------------------------------------------------
/scripts/wires/polygon3d.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Mar 10 17:02:36 2017
5 |
6 | """
7 |
8 | import math
9 | import time
10 |
11 | import volmdlr as vm
12 | import volmdlr.wires as vmw
13 |
14 | p1 = vm.Point3D(0, 0, 0)
15 | p2 = vm.Point3D(1, 0, 0.1)
16 | p3 = vm.Point3D(2, 1, -0.1)
17 | p4 = vm.Point3D(1, 0.5, 0.1)
18 | p5 = vm.Point3D(-0.5, 1, 0)
19 | polygon = vm.wires.ClosedPolygon3D([p1, p2, p3, p4, p5])
20 |
21 |
22 | polygon._check_platform()
23 |
--------------------------------------------------------------------------------
/doc/source/road_map_and_current_limitations.rst:
--------------------------------------------------------------------------------
1 | Roadmap and current limitations
2 | ===============================
3 |
4 | What's new
5 | ----------
6 |
7 | The version 0.1.0 released on April 4, 2023 includes:
8 |
9 | - a documentation
10 | - method names follow the pep8 instructions, with possible backward
11 | compatibility
12 |
13 | Current limitations
14 | -------------------
15 |
16 | No limitations have been discovered.
17 |
18 | Roadmap
19 | -------
20 |
21 | No future improvements are planned.
22 |
--------------------------------------------------------------------------------
/tests/edges/fullarcellipse_objects/fullarcellipse3d_line_intersections_line.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.curves.Line3D",
3 | "name": "",
4 | "point1": {
5 | "object_class": "volmdlr.Point3D",
6 | "x": 0.3433231732887762,
7 | "y": -0.10837281809567849,
8 | "z": 0.49957129590497185
9 | },
10 | "point2": {
11 | "object_class": "volmdlr.Point3D",
12 | "x": -0.19685916358316918,
13 | "y": -0.3791181196186511,
14 | "z": 1.296377435837891
15 | },
16 | "_references": {}
17 | }
18 |
--------------------------------------------------------------------------------
/doc/source/modules/primitives.rst:
--------------------------------------------------------------------------------
1 | Primitives
2 | ==========
3 |
4 | Primitives
5 | ----------
6 |
7 | .. automodule:: volmdlr.primitives
8 | :members:
9 | :undoc-members:
10 | :show-inheritance:
11 |
12 | Primitives2d
13 | ------------
14 |
15 | .. automodule:: volmdlr.primitives2d
16 | :members:
17 | :undoc-members:
18 | :show-inheritance:
19 |
20 | .. _primitives3d:
21 | Primitives3d
22 | ------------
23 |
24 | .. automodule:: volmdlr.primitives3d
25 | :members:
26 | :undoc-members:
27 | :show-inheritance:
28 |
--------------------------------------------------------------------------------
/scripts/wires/triangle2D.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Mon Jun 7 16:23:04 2021
5 |
6 | @author: masfaraud
7 | """
8 |
9 | import volmdlr as vm
10 | import volmdlr.core as vmc
11 | import volmdlr.wires as vmw
12 |
13 | p1 = vm.Point2D(0, 0)
14 | p2 = vm.Point2D(27.768772992234517, 0.0)
15 | p3 = vm.Point2D(29.285641835268507, 0.605864117805322)
16 |
17 | # Point2D: [0.0, 0.0], Point2D: [], Point2D: []]
18 |
19 | tri = vmw.ClosedPolygon2D([p1, p2, p3])
20 | m = tri.triangulation()
21 | m.plot()
22 |
--------------------------------------------------------------------------------
/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | * **Please check if the PR fulfills these requirements**
2 | - [ ] The commit messages follows our guidelines (explicit, in english)
3 | - [ ] Tests for the changes have been added (for bug fixes / features)
4 | - [ ] Docs have been added / updated (for bug fixes / features)
5 | - [ ] CHANGELOG.md has been updated
6 |
7 | * **What kind of change does this PR introduce?** (Bug fix, feature, docs update, ...)
8 | - [ ] Bug fix:
9 | - [ ] New features:
10 | - [ ] Documentation
11 | - [ ] Optimization
12 |
13 | * **Other information**:
14 |
--------------------------------------------------------------------------------
/scripts/core/bbox_triangle_intersection.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of BoundingBox / Triangle3D intersection
3 | """
4 | from volmdlr.core import BoundingBox
5 | from volmdlr.faces import Triangle3D
6 | import volmdlr
7 |
8 | bounding_box = BoundingBox(0.0, 2.0, 0.0, 2.0, 0.0, 2.0)
9 |
10 | p0 = volmdlr.Point3D(5, -3, 0.5)
11 | p1 = volmdlr.Point3D(-3, 5, 0.5)
12 | p2 = volmdlr.Point3D(5, 5, 0.5)
13 | triangle = Triangle3D(p0, p1, p2)
14 |
15 | ax = bounding_box.plot()
16 | triangle.plot(ax=ax)
17 |
18 | print(bounding_box.is_intersecting_triangle(triangle))
19 |
--------------------------------------------------------------------------------
/scripts/faces/conical.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 | """
6 |
7 |
8 | import volmdlr as vm
9 | import volmdlr.faces as faces
10 | from volmdlr import surfaces
11 |
12 | R = 0.32
13 | alpha = 0.2
14 | cs = surfaces.ConicalSurface3D(vm.Frame3D(
15 | vm.Point3D.random(-0.1, 0.1, -0.1, 0.2, -0.2, 0.1),
16 | vm.X3D, vm.Y3D, vm.Z3D), alpha)
17 |
18 | cf = faces.ConicalFace3D.from_surface_rectangular_cut(cs, -0.01, 1.3, 0., 0.3)
19 |
20 | cf.surface2d.plot()
21 | cf.babylonjs(debug=True, use_cdn=False)
22 |
--------------------------------------------------------------------------------
/scripts/faces/toroidal.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Sep 18 12:40:31 2020
5 |
6 | @author: masfaraud
7 | """
8 |
9 | import volmdlr as vm
10 | from volmdlr import faces, surfaces
11 |
12 | # u = vm.Vector3D.random(0, 1, 0, 1, 0, 1)
13 | # u.Normalize()
14 | # v = u.RandomUnitNormalVector()
15 | # w = u.Cross(v)
16 |
17 | R = 0.2
18 | r = 0.03
19 | ts = surfaces.ToroidalSurface3D(vm.OXYZ, R, r)
20 |
21 | tf = faces.ToroidalFace3D.from_surface_rectangular_cut(ts, 0, 0.6, 0., 1.3)
22 | # tf.outer_contour2d.MPLPlot()
23 | tf.babylonjs(debug=True, use_cdn=False)
24 |
--------------------------------------------------------------------------------
/scripts/collisions/plot_cylinders_points.py:
--------------------------------------------------------------------------------
1 | """
2 | Test script for cylinder discretization
3 | """
4 |
5 | import volmdlr as vm
6 | from volmdlr.primitives3d import Cylinder
7 |
8 | c = Cylinder(
9 | position=vm.Point3D(0, 0.1, 0),
10 | axis=vm.Vector3D(1, 0, 0),
11 | radius=0.01,
12 | length=0.1,
13 | color=(1, 0, 0),
14 | )
15 |
16 | n_points = 1000
17 |
18 | ay = c.random_point_inside().plot()
19 | for _ in range(n_points):
20 | c.random_point_inside().plot(ax=ay)
21 |
22 | points = c.lhs_points_inside(n_points)
23 | ax = points[0].plot()
24 | for p in points:
25 | p.plot(ax=ax)
26 |
--------------------------------------------------------------------------------
/scripts/edges/arcs2D.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Tue Oct 23 18:06:45 2018
5 |
6 | @author: steven
7 | """
8 |
9 | import volmdlr
10 | import volmdlr.edges
11 |
12 | # Random arc
13 | i = volmdlr.Point2D.random(-1,1,-1,1)
14 | e = volmdlr.Point2D.random(-1,1,-1,1)
15 | s = volmdlr.Point2D.random(-1,1,-1,1)
16 |
17 |
18 | a = volmdlr.edges.Arc2D.from_3_points(s, i, e)
19 | ax = a.plot()
20 |
21 | for p in a.discretization_points(number_points=10):
22 | p.plot(ax=ax)
23 |
24 | s.plot(ax=ax, color='r')
25 | e.plot(ax=ax, color='g')
26 | i.plot(ax=ax, color='b')
27 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | * **I'm submitting a ...**
2 | - [ ] bug report
3 | - [ ] feature request
4 |
5 |
6 | * **What is the current behavior?**
7 |
8 |
9 |
10 | * **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** Avoid reference to other packages
11 |
12 |
13 |
14 | * **What is the expected behavior?**
15 |
16 |
17 | * **What is the motivation / use case for changing the behavior?**
18 |
19 |
20 | * **Possible fixes**
21 |
22 |
23 | * **Please tell us about your environment:**
24 |
25 | - branch:
26 | - commit:
27 | - python version:
28 |
--------------------------------------------------------------------------------
/code_pep8.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # check pep8 formatting for changed files
3 |
4 | PEP8_CMD_TO_RUN='python3 -m autopep8 -i $(git diff --cached --name-only --diff-filter MARC | grep -E \.py$)'
5 | CHANGED_FILES=$(git diff --cached --name-only --diff-filter MARC | grep -E \.py$)
6 | if [[ -z "$CHANGED_FILES" ]]
7 | then exit 0
8 | fi
9 |
10 | DETECTED_CHANGES=$(python3 -m autopep8 -d $CHANGED_FILES)
11 | if [[ -n "$DETECTED_CHANGES" ]]
12 | then
13 | echo -e "\npep8 non conforming changes detected, please run :\n"
14 | echo -e "\t$PEP8_CMD_TO_RUN\n"
15 | echo -e "& stage your changes"
16 | exit 1
17 | fi
18 |
19 | exit 0
20 |
--------------------------------------------------------------------------------
/volmdlr/models/conical_surfaces.py:
--------------------------------------------------------------------------------
1 | """
2 | Some conical surfaces models to perform unit test.
3 | """
4 | import math
5 |
6 | import volmdlr
7 | from volmdlr import surfaces
8 | conical_surface1 = surfaces.ConicalSurface3D(volmdlr.OXYZ, math.pi / 3)
9 |
10 | frame_cone = volmdlr.Frame3D(volmdlr.Point3D(0.0, 0.0, 0.1), volmdlr.X3D, -volmdlr.Y3D, -volmdlr.Z3D)
11 | conical_surface2 = surfaces.ConicalSurface3D(frame_cone, 0.336674819387)
12 |
13 | frame = volmdlr.Frame3D(volmdlr.Point3D(0.0, 0.0, -0.0022143719324716786), volmdlr.X3D, volmdlr.Y3D, volmdlr.Z3D)
14 | conical_surface3 = surfaces.ConicalSurface3D(frame, 1.0471975511966)
15 |
--------------------------------------------------------------------------------
/doc/source/modules/bspline_compiled.rst:
--------------------------------------------------------------------------------
1 | BSpline Compiled
2 | ================
3 |
4 | volmdlr.bspline\_compiled
5 | -------------------------
6 |
7 | .. automodule:: volmdlr.bspline_compiled
8 | :members:
9 | :undoc-members:
10 | :show-inheritance:
11 |
12 | volmdlr.bspline\_evaluators
13 | ---------------------------
14 |
15 | .. automodule:: volmdlr.bspline_evaluators
16 | :members:
17 | :undoc-members:
18 | :show-inheritance:
19 |
20 | volmdlr.bspline\_fitting
21 | ------------------------
22 |
23 | .. automodule:: volmdlr.bspline_fitting
24 | :members:
25 | :undoc-members:
26 | :show-inheritance:
27 |
--------------------------------------------------------------------------------
/.github/workflows/install.yml:
--------------------------------------------------------------------------------
1 | name: Test install
2 |
3 | # Build on every branch push, tag push, and pull request change:
4 | on:
5 | push:
6 | branches:
7 | - master
8 | - testing
9 |
10 |
11 |
12 |
13 | jobs:
14 | build_wheels:
15 | name: Test install on ubuntu
16 | runs-on: ubuntu-latest
17 | steps:
18 | - uses: actions/checkout@v3
19 | with:
20 | fetch-depth: 0
21 |
22 | - uses: actions/setup-python@v3
23 | name: Install Python
24 | with:
25 | python-version: 3.9
26 |
27 | - name: Install
28 | run: |
29 | pip install .
30 |
--------------------------------------------------------------------------------
/tests/core/test_assembly.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import volmdlr
3 | import volmdlr.primitives3d as p3d
4 | import volmdlr.core
5 |
6 |
7 | class TestAssembly(unittest.TestCase):
8 | def test_bounding_box(self):
9 | box1 = p3d.Block(volmdlr.OXYZ)
10 | components = [box1, box1]
11 | positions = [volmdlr.OXYZ, volmdlr.Frame3D(volmdlr.Point3D(0, 0, 1), volmdlr.X3D, volmdlr.Y3D, volmdlr.Z3D)]
12 | assembly = volmdlr.core.Assembly(components, positions)
13 | self.assertAlmostEqual(assembly.bounding_box.volume(), 2.0) # add assertion here
14 |
15 |
16 | if __name__ == '__main__':
17 | unittest.main()
18 |
--------------------------------------------------------------------------------
/tests/surfaces/test_surface2d.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | import volmdlr
4 |
5 | from volmdlr import surfaces, wires
6 |
7 |
8 | class TestSurface2D(unittest.TestCase):
9 | contour = wires.Contour2D.from_points([volmdlr.O2D, volmdlr.Point2D(1, 0), volmdlr.Point2D(1, 1),
10 | volmdlr.Point2D(0, 1)])
11 | surface2d = surfaces.Surface2D(contour, [])
12 |
13 | def test_triangulation(self):
14 | tri = self.surface2d.triangulation()
15 | tri.plot()
16 | self.assertAlmostEqual(self.surface2d.triangulation().area(), 1)
17 |
18 |
19 | if __name__ == '__main__':
20 | unittest.main()
21 |
--------------------------------------------------------------------------------
/scripts/collisions/test_perf_min_dist.py:
--------------------------------------------------------------------------------
1 | import time
2 |
3 | import volmdlr as vm
4 | from volmdlr.primitives3d import Cylinder
5 |
6 | cylinder1 = Cylinder(
7 | position=vm.Point3D(0, 0.1, 0),
8 | axis=vm.Vector3D(1, 0, 0),
9 | radius=0.01,
10 | length=0.1,
11 | )
12 |
13 | cylinder2 = Cylinder(
14 | position=vm.Point3D(1, 0.11, 0.3),
15 | axis=vm.Vector3D(1, 1, -6),
16 | radius=0.01,
17 | length=0.1,
18 | )
19 |
20 | N = 100
21 |
22 | start = time.perf_counter()
23 | for _ in range(N):
24 | dist = cylinder2.min_distance_to_other_cylinder(cylinder1)
25 |
26 | print(f"time per operation: {((time.perf_counter() - start)/N)*1000}ms")
27 |
--------------------------------------------------------------------------------
/scripts/shells/triangle_shell_mesh_data.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of TriangleShell3D import / export.
3 | """
4 |
5 | from volmdlr.stl import Stl
6 | from volmdlr.shells import ClosedTriangleShell3D
7 |
8 | triangle_shell_1 = Stl.load_from_file("../stl/simple.stl").to_closed_shell()
9 |
10 | mesh_data = triangle_shell_1.to_mesh_data(round_vertices=False)
11 | triangle_shell_2 = ClosedTriangleShell3D.from_mesh_data(mesh_data[0], mesh_data[1])
12 |
13 | triangle_shell_1.save_to_file("triangle_shell.json")
14 | triangle_shell_3 = ClosedTriangleShell3D.load_from_file("triangle_shell.json")
15 |
16 | print(triangle_shell_3 == triangle_shell_1)
17 | print(triangle_shell_2 == triangle_shell_1)
18 |
--------------------------------------------------------------------------------
/scripts/edges/lines2d.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Wed Mar 8 10:58:19 2017
5 |
6 | @author: steven
7 | """
8 |
9 | import volmdlr as vm
10 | from volmdlr import curves
11 |
12 | p1 = vm.Point2D(1,1.45)
13 | p2 = vm.Point2D(0.4,0.1)
14 | l1 = curves.Line2D(p1, p2)
15 |
16 | p3 = vm.Point2D(-1,0)
17 | p4 = vm.Point2D(1,-0.5)
18 | l2 = curves.Line2D(p3, p4)
19 |
20 | p5,bl1,bl2 = vm.Point2D.line_intersection(l1, l2,True)
21 | p6 = vm.Point2D.middle_point(p1,p3)
22 |
23 | p7 = vm.Point2D.line_projection(p6, l1)
24 | p8 = vm.Point2D.line_projection(p6, l2)
25 |
26 | ax = l1.plot()
27 | for p in [l2, p5, p6, p7 ,p8]:
28 | p.plot(ax=ax)
29 |
--------------------------------------------------------------------------------
/doc/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = Volmdlr
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
--------------------------------------------------------------------------------
/doc/source/modules.rst:
--------------------------------------------------------------------------------
1 | Volmdlr Modules
2 | ---------------
3 |
4 | .. toctree::
5 | :maxdepth: 1
6 |
7 | modules/base_modules.rst
8 | modules/bspline_compiled.rst
9 | modules/module_geometry.rst
10 | modules/module_curves.rst
11 | modules/module_edges.rst
12 | modules/wires.rst
13 | modules/primitives.rst
14 | modules/surfaces.rst
15 | modules/module_faces.rst
16 | modules/shells.rst
17 | modules/step.rst
18 | modules/stl.rst
19 | modules/module_cloud.rst
20 | modules/voxelization.rst
21 | modules/module_display.rst
22 | modules/mesh.rst
23 | modules/grid.rst
24 | modules/gmsh.rst
25 | modules/cad_simplification.rst
26 |
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | # File introduces automated checks triggered on git events
2 | # to enable run `pip install pre-commit && pre-commit install`
3 |
4 | repos:
5 | - repo: https://github.com/MarcoGorelli/cython-lint
6 | rev: v0.10.1
7 | hooks:
8 | - id: cython-lint
9 | args: [--max-line-length, "120"]
10 | - id: double-quote-cython-strings
11 |
12 | - repo: https://github.com/pre-commit/pre-commit-hooks
13 | rev: v3.2.0
14 | hooks:
15 | - id: check-json
16 | - id: check-added-large-files
17 | - id: check-yaml
18 | - id: debug-statements
19 | - id: requirements-txt-fixer
20 | - id: check-merge-conflict
21 | - id: end-of-file-fixer
22 |
--------------------------------------------------------------------------------
/.readthedocs.yaml:
--------------------------------------------------------------------------------
1 | # .readthedocs.yaml
2 | # Read the Docs configuration file
3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4 |
5 | # Required
6 | version: 2
7 |
8 | # Set the version of Python and other tools you might need
9 | build:
10 | os: ubuntu-20.04
11 | tools:
12 | python: "3.9"
13 |
14 | # Build documentation in the docs/ directory with Sphinx
15 | sphinx:
16 | configuration: doc/source/conf.py
17 |
18 | # If using Sphinx, optionally build your docs in additional formats such as PDF
19 | # formats:
20 | # - pdf
21 |
22 | python:
23 | install:
24 | - method: pip
25 | path: .
26 | extra_requirements:
27 | - doc
28 | - method: setuptools
29 | path: package
30 |
--------------------------------------------------------------------------------
/tests/primitives3d/test_sphere.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | from math import pi
3 |
4 | import volmdlr
5 | from volmdlr.primitives3d import Sphere
6 |
7 |
8 | class TestSphere(unittest.TestCase):
9 | def setUp(self):
10 | self.sphere = Sphere(
11 | center=volmdlr.O3D,
12 | radius=0.02,
13 | )
14 |
15 | def test_point_belongs(self):
16 | self.assertTrue(self.sphere.point_belongs(volmdlr.O3D))
17 | self.assertFalse(self.sphere.point_belongs(volmdlr.Point3D(1, 0, 0)))
18 |
19 | def test_volume(self):
20 | volume = 4 / 3 * pi * self.sphere.radius**3
21 | self.assertEqual(self.sphere.volume(), volume)
22 |
23 |
24 | if __name__ == "__main__":
25 | unittest.main()
26 |
--------------------------------------------------------------------------------
/scripts/core/points_axial_symmetry.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 | @author: s.bendjebla
6 | """
7 |
8 | # %% Libraries
9 |
10 | import matplotlib.pyplot as plt
11 |
12 | import volmdlr as vm
13 | import volmdlr.curves
14 |
15 | # %% Initial Data
16 |
17 | points = [vm.Point2D(0, 1),
18 | vm.Point2D(0.1, 0.8),
19 | vm.Point2D(0.2, 1.5)]
20 |
21 | line = vm.curves.Line2D(vm.Point2D(-0.5, 1), vm.Point2D(-0.5, 8))
22 |
23 | # %% Symmetry
24 |
25 | axial_points = [point.axial_symmetry(line) for point in points]
26 |
27 | fig, ax = plt.subplots()
28 | ax.set_aspect('equal')
29 | line.plot(ax)
30 | [p.plot(ax=ax, color='r') for p in points]
31 | [p.plot(ax=ax, color='g') for p in axial_points]
32 |
--------------------------------------------------------------------------------
/tests/core_compiled/test_vector.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import volmdlr
3 |
4 |
5 | class TestVector(unittest.TestCase):
6 | def test_is_colinear_to(self):
7 | vector_ref = volmdlr.Z3D
8 | vector_test = volmdlr.Vector3D(1e-3, 1e-3, 1)
9 | self.assertTrue(vector_ref.is_colinear_to(vector_test))
10 | self.assertFalse(vector_ref.is_colinear_to(vector_test, abs_tol=0))
11 |
12 | def test_is_perpendicular_to(self):
13 | vector_ref = volmdlr.Z3D
14 | vector_test = volmdlr.Vector3D(1-6, 1, 1e-6)
15 | self.assertTrue(vector_ref.is_perpendicular_to(vector_test))
16 | self.assertFalse(vector_ref.is_perpendicular_to(vector_test, abs_tol=0))
17 |
18 |
19 | if __name__ == '__main__':
20 | unittest.main()
21 |
--------------------------------------------------------------------------------
/tests/wires/test_contour.py:
--------------------------------------------------------------------------------
1 | """
2 | Unit tests for volmdlr.wires.Contour
3 | """
4 | import unittest
5 |
6 | import volmdlr.wires
7 |
8 |
9 | class TestContour(unittest.TestCase):
10 |
11 | def test_is_overlapping(self):
12 | p1 = [volmdlr.Point2D(-0.2, -0.2), volmdlr.Point2D(0.2, -0.2),
13 | volmdlr.Point2D(0.2, 0.2), volmdlr.Point2D(-0.2, 0.2)]
14 |
15 | contour1 = volmdlr.wires.ClosedPolygon2D(p1)
16 | contour2 = contour1.translation(volmdlr.Vector2D(0.5,0))
17 | contour3 = contour1.translation(volmdlr.Vector2D(0.1,0))
18 |
19 | self.assertFalse(contour1.is_overlapping(contour2))
20 | self.assertTrue(contour1.is_overlapping(contour3))
21 |
22 |
23 | if __name__ == '__main__':
24 | unittest.main()
25 |
--------------------------------------------------------------------------------
/tests/discrete_representation/test_discrete_representation.py:
--------------------------------------------------------------------------------
1 | """
2 | Unit testing of 'DiscreteRepresentation' class.
3 | """
4 | import math
5 | import unittest
6 |
7 | from volmdlr.discrete_representation import DECIMALS, DiscreteRepresentation
8 |
9 |
10 | class TestDiscreteRepresentation(unittest.TestCase):
11 | def test_check_center_is_in_implicit_grid(self):
12 | self.assertTrue(DiscreteRepresentation.check_center_is_in_implicit_grid((0.5, 0.5), 1))
13 | self.assertFalse(DiscreteRepresentation.check_center_is_in_implicit_grid((0.0, 0.0), 1))
14 |
15 | def test_check_element_size_number_of_decimals(self):
16 | self.assertWarns(
17 | Warning, DiscreteRepresentation._check_element_size_number_of_decimals, round(math.pi, DECIMALS)
18 | )
19 |
--------------------------------------------------------------------------------
/scripts/center_mass.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Tue Feb 12 19:23:27 2019
5 |
6 | @author: steven
7 | """
8 |
9 | import math
10 |
11 | import plot_data
12 |
13 | import volmdlr as vm
14 | import volmdlr.edges as edges
15 | import volmdlr.wires as wires
16 |
17 | r = 0.23
18 |
19 | p1 = vm.Point2D(0, 0)
20 | p2 = vm.Point2D(r, r)
21 | p3 = vm.Point2D(2*r, 0)
22 |
23 | a = edges.Arc2D(p1, p2, p3)
24 | l = edges.LineSegment2D(p3, p1)
25 |
26 | c = wires.Contour2D([a, l])
27 | ax = c.plot()
28 | cog = c.center_of_mass()
29 | cog.plot(ax)
30 |
31 |
32 | assert math.isclose(a.radius, r)
33 | assert math.isclose(c.area(), math.pi*r**2/2.)
34 | assert math.isclose(cog[0], r)
35 | print(cog[1], 4*r/3.*math.pi)
36 | assert math.isclose(cog[1], 4*r/3./math.pi)
37 |
--------------------------------------------------------------------------------
/tests/core/test_composite_primitive3d.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import volmdlr
3 | import volmdlr.edges
4 | from volmdlr.core import CompositePrimitive3D
5 |
6 |
7 | class TestCompositePrimitive3D(unittest.TestCase):
8 | def setUp(self):
9 | self.primitives = [volmdlr.edges.LineSegment3D(volmdlr.O3D, volmdlr.Point3D(4, 2, 1))]
10 | self.composite_3d = CompositePrimitive3D(self.primitives, name="test")
11 |
12 | def test_plot(self):
13 | ax = self.composite_3d.plot()
14 |
15 | for ls, line in zip(self.composite_3d.primitives, ax.lines):
16 | data = line.get_data_3d()
17 |
18 | for i in range(3):
19 | self.assertListEqual(data[i].tolist(), [ls.start[i], ls.end[i]])
20 |
21 |
22 | if __name__ == "__main__":
23 | unittest.main()
24 |
--------------------------------------------------------------------------------
/scripts/faces/cylindrical.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Sep 18 12:40:31 2020
5 |
6 | @author: masfaraud
7 | """
8 |
9 | from volmdlr.core import EdgeStyle
10 | import volmdlr.faces
11 | from volmdlr import faces, surfaces
12 |
13 |
14 | R = 0.32
15 |
16 | surface = surfaces.CylindricalSurface3D(volmdlr.OXYZ, R)
17 |
18 | face = faces.CylindricalFace3D.from_surface_rectangular_cut(surface, -0.01, 1.3, -0.1, 0.3)
19 | face.babylonjs(debug=True, use_cdn=False)
20 |
21 | lines_x, lines_y = face.triangulation_lines()
22 | ax = face.surface2d.plot()
23 | for line in lines_x+lines_y:
24 | line.plot(ax, EdgeStyle(color='r'))
25 |
26 | ax2 = face.surface2d.plot()
27 | for surface in face.surface2d.split_by_lines(lines_x):
28 | surface.plot(ax=ax2, color='b')
29 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/voxelization/step_file_voxelization.py:
--------------------------------------------------------------------------------
1 | """
2 | Example of voxelization from a STEP file.
3 | """
4 | from volmdlr.discrete_representation import MatrixBasedVoxelization
5 | from volmdlr.step import Step
6 |
7 | VOXEL_SIZE = 0.001
8 | STEP_MODEL_FILE_PATH = "../../step/tore1.step"
9 |
10 | # Load and convert the SETP
11 | volume_model = Step.from_file(STEP_MODEL_FILE_PATH).to_volume_model()
12 |
13 | # Voxelize the model
14 | voxelization = MatrixBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE)
15 |
16 | # Display the result
17 | voxelization_primitive = voxelization.to_mesh().split_shared_vertices()
18 | voxelization_primitive.alpha = 0.5
19 | voxelization_primitive.color = (1, 0, 0)
20 |
21 | volume_model.primitives.append(voxelization_primitive)
22 | volume_model.babylonjs()
23 |
--------------------------------------------------------------------------------
/scripts/faces/export_to_step.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Mon Feb 14 2022
5 |
6 | @author: s.bendjebla
7 | """
8 |
9 | # %% Libraries
10 |
11 | import volmdlr.core
12 | import volmdlr.step
13 | from volmdlr import faces, shells
14 | from volmdlr.models import bspline_surfaces
15 |
16 | # %% BsplineFaces3D
17 |
18 | bspline_faces = [faces.BSplineFace3D.from_surface_rectangular_cut(bspline_surfaces.bspline_surface_2, 0,1,0,1)]
19 |
20 | # %% Export
21 |
22 | model = volmdlr.core.VolumeModel([shells.OpenShell3D(bspline_faces)])
23 |
24 | model.to_step('model_to_step.stp')
25 |
26 | # %% Check
27 |
28 | filepath = 'model_to_step.stp'
29 |
30 | step = volmdlr.step.Step.from_file(filepath)
31 | model_imported = step.to_volume_model()
32 |
33 | # assert model_imported == model
34 |
--------------------------------------------------------------------------------
/tests/cloud/test_cloud.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Jul 7 16:38:35 2023
5 |
6 | @author: masfaraud
7 | """
8 |
9 | import random
10 | import volmdlr
11 | import volmdlr.cloud
12 |
13 | random.seed(561)
14 | points = [volmdlr.Point3D.random(0.1, 0.3, -0.2, 0.37, -0.4, -0.05) for _ in range(500)]
15 | # points.extend([volmdlr.Point3D.random(0.15, 0.25, -0.17, 0.05, -0.1, 0.05) for _ in range(150)])
16 |
17 |
18 | cloud3d = volmdlr.cloud.PointCloud3D(points)
19 | cloud3d.plot()
20 |
21 | wrapping = cloud3d.to_shell()
22 |
23 | # wrapping.babylonjs()
24 |
25 | ax = None
26 | for tri in wrapping.faces[1:40]:
27 | ax = tri.plot(ax=ax)
28 | normal = 0.03*tri.normal()
29 |
30 | # print('NORMAL', tri.normal())
31 | normal.plot(ax=ax, starting_point=tri.middle())
32 |
33 |
--------------------------------------------------------------------------------
/tests/common_operations/test_common_operations.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | import volmdlr
4 | from volmdlr.models.open_rounded_line_segments import open_rounded_line_segements
5 | from volmdlr.surfaces import Plane3D
6 | from volmdlr.utils.common_operations import split_wire_by_plane
7 |
8 |
9 | class TestCommonOperations(unittest.TestCase):
10 | def test_split_wire_by_plane(self):
11 | plane = Plane3D.from_plane_vectors(volmdlr.Point3D(0.4, 0.4, 0.2), volmdlr.Vector3D(1, 0, 0),
12 | volmdlr.Vector3D(0, 1, 0))
13 | wire1, wire2 = split_wire_by_plane(open_rounded_line_segements, plane)
14 | self.assertEqual(wire1.length(), 1.4187473149621863)
15 | self.assertAlmostEqual(wire2.length(), 0.6182864075957109)
16 |
17 |
18 | if __name__ == "__main__":
19 | unittest.main()
20 |
--------------------------------------------------------------------------------
/volmdlr/models/open_rounded_line_segments.py:
--------------------------------------------------------------------------------
1 | """Open rounded line segments model."""
2 | import random
3 |
4 | import volmdlr
5 | from volmdlr import primitives3d
6 |
7 | random.seed(2)
8 |
9 | p1 = volmdlr.Point3D(0, 0, 0)
10 | p2 = volmdlr.Point3D(-0.150, 0, 0)
11 | p3 = volmdlr.Point3D(-0.150, 0.215, 0)
12 | p4 = volmdlr.Point3D(-0.150, 0.215, -0.058)
13 | p5 = volmdlr.Point3D(-0.220, 0.186, -0.042)
14 |
15 | points = [p1, p2, p3, p4, p5]
16 | radius = {1: 0.015, 2: 0.020, 3: 0.03}
17 |
18 | current_point = p5
19 |
20 | for i in range(6):
21 | current_point += volmdlr.Point3D.random(-0.1, 0.3, -0.1, 0.3, -0.1, 0.3)
22 | points.append(current_point)
23 | radius[4 + i] = 0.01 + 0.03 * random.random()
24 |
25 |
26 | open_rounded_line_segements = primitives3d.OpenRoundedLineSegments3D(points, radius, adapt_radius=True, name='wire')
27 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/distance.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
11 |
--------------------------------------------------------------------------------
/tests/core/test_compound.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 |
4 | from volmdlr import step
5 |
6 | folder = os.path.dirname(os.path.realpath(__file__))
7 |
8 |
9 | class TestCompound(unittest.TestCase):
10 | def test_to_step(self):
11 | step_obj = step.Step.from_file(filepath=os.path.join(folder, "compound_geometric_set.step"))
12 | model = step_obj.to_volume_model()
13 | model.to_step("compound_export.stp")
14 | step_obj = step.Step.from_file(filepath=os.path.join(folder, "compound_export.stp"))
15 | model = step_obj.to_volume_model()
16 | self.assertEqual(len(model.primitives), 1)
17 | self.assertEqual(len(model.primitives[0].primitives), 3)
18 | self.assertEqual(model.primitives[0].compound_type, "geometric_curve_set")
19 |
20 |
21 | if __name__ == '__main__':
22 | unittest.main()
23 |
--------------------------------------------------------------------------------
/tests/faces/objects_toroidal_tests/face_with_inner_contour_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.0,
10 | "y": 0.0,
11 | "z": 0.0
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": 0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.0,
22 | "y": -1.0,
23 | "z": 0.0
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": -0.0,
28 | "y": -0.0,
29 | "z": -1.0
30 | }
31 | },
32 | "major_radius": 0.01,
33 | "minor_radius": 0.003,
34 | "_references": {}
35 | }
36 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_plane_test/planesurface_arc3d_to_2d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.Plane3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.629312525372,
10 | "y": 0.035503877863,
11 | "z": 0.30347321389000004,
12 | "name": "Axis2P3D Location"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.0,
17 | "y": 1.0,
18 | "z": 0.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.0,
23 | "y": 0.0,
24 | "z": -1.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -1.0,
29 | "y": 0.0,
30 | "z": 0.0
31 | }
32 | },
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/tests/faces/objects_spherical_test/face_from_contours3d_and_rectangular_cut_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -7e-20,
10 | "y": 1.019e-17,
11 | "z": 0.015296372
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": 0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.0,
22 | "y": 1.0,
23 | "z": -6.7e-16
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": 0.0,
28 | "y": 6.7e-16,
29 | "z": 1.0
30 | }
31 | },
32 | "radius": 0.011,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/tests/faces/objects_spherical_test/sphericalface_from_contours3d_repair_primitives_periodicity_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.0,
10 | "y": 0.0,
11 | "z": 0.0
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": 0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.0,
22 | "y": -1.0,
23 | "z": 0.0
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": 0.0,
28 | "y": 0.0,
29 | "z": -1.0
30 | }
31 | },
32 | "radius": 0.01725,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/volmdlr/models/cylindrical_surfaces.py:
--------------------------------------------------------------------------------
1 | """
2 | Some cylindrical surfaces models to perform unit test.
3 | """
4 |
5 | import volmdlr
6 | from volmdlr import surfaces
7 |
8 | cylindrical_surface = surfaces.CylindricalSurface3D(volmdlr.OXYZ, 0.32)
9 | cylindrical_surface2 = surfaces.CylindricalSurface3D(volmdlr.OXYZ, 1.0)
10 | frame = volmdlr.Frame3D(volmdlr.Point3D(-0.005829, 0.000765110438227, -0.0002349369830163),
11 | volmdlr.Vector3D(-0.6607898454031987, 0.562158151695499, -0.4973278523210991),
12 | volmdlr.Vector3D(-0.7505709694705869, -0.4949144228333324, 0.43783893597935386),
13 | volmdlr.Vector3D(-0.0, 0.6625993710787045, 0.748974013865705))
14 | cylindrical_surface3 = surfaces.CylindricalSurface3D(frame, 0.003)
15 | cylindrical_surface4 = surfaces.CylindricalSurface3D(volmdlr.OXYZ, radius=0.03)
16 |
--------------------------------------------------------------------------------
/scripts/edges/minimum_distance_points_line3D.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Minimum distance line between two lines
5 | """
6 |
7 | import volmdlr as vm
8 | import volmdlr.primitives3d as primitives3d
9 | from volmdlr import curves
10 | #import numpy as npy
11 |
12 | p11 = vm.Point3D.random(-1,1,-1,1,-1,1)
13 | p12 = vm.Point3D.random(-1,1,-1,1,-1,1)
14 | p21 = vm.Point3D.random(-1,1,-1,1,-1,1)
15 | p22 = vm.Point3D.random(-1,1,-1,1,-1,1)
16 |
17 | l1 = curves.Line3D(p11, p12)
18 | l2 = curves.Line3D(p21, p22)
19 |
20 | pmd1, pmd2 = l1.minimum_distance_points(l2)
21 |
22 | u = p12 - p11 # vector of line1
23 | v = p22 - p21 # vector of line2
24 | w = pmd2 - pmd1
25 |
26 | print(u.dot(w), v.dot(w))
27 |
28 | m = vm.core.VolumeModel([('', [l1, l2, pmd1, pmd2])])
29 |
30 | m.MPLPlot() #Problem
31 |
32 | #m.mpl_plot() ?
33 | #m.babylonjs() ?
34 |
--------------------------------------------------------------------------------
/volmdlr/models/workflows/core.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Core Workflows.
5 | """
6 |
7 | # import dessia_common.workflow
8 | # import volmdlr.core
9 | # import volmdlr
10 |
11 | # packer = dessia_common.workflow.Sequence(3, float)
12 | #
13 | # point3D_instanciation = dessia_common.workflow.InstanciateModel(
14 | # volmdlr.Point3D)
15 | # pipe_vector = dessia_common.workflow.Pipe(packer.outputs[0],
16 | # point3D_instanciation.inputs[0])
17 | # point3D_instanciator = dessia_common.workflow.Workflow(
18 | # [packer, point3D_instanciation],
19 | # [pipe_vector],
20 | # point3D_instanciation.outputs[0],
21 | # name='Point3D instanciator')
22 | # point3D_instanciator.inputs[0].name = 'X'
23 | # point3D_instanciator.inputs[1].name = 'Y'
24 | # point3D_instanciator.inputs[2].name = 'Z'
25 |
--------------------------------------------------------------------------------
/scripts/faces/triangle3d.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 |
6 | """
7 |
8 | import volmdlr as vm
9 | import volmdlr.core as vmc
10 | import volmdlr.faces as faces
11 |
12 | p1 = vm.Point3D.random(0, 0.1, 0, 0.1, -0.1, 0)
13 | p2 = vm.Point3D.random(0, 0.1, 0, 0.1, -0.1, 0)
14 | p3 = vm.Point3D.random(0, 0.1, 0, 0.1, -0.1, 0)
15 |
16 |
17 | tri = faces.Triangle3D(p1, p2, p3)
18 | # tri.babylonjs()
19 | # tri.subdescription()
20 |
21 | # vmc.VolumeModel([faces.OpenShell3D([tri])])
22 |
23 |
24 | subtriangles = tri.subdescription_to_triangles(resolution = 5e-2)
25 |
26 | ax = tri.plot(color='r')
27 | for tritri in subtriangles :
28 | tritri.plot(ax=ax)
29 | tri.plot(ax=ax, color='r')
30 |
31 |
32 | subdescription = tri.subdescription(resolution = 1e-2)
33 | ax = tri.plot(color='r')
34 | for pt in subdescription:
35 | pt.plot(ax=ax)
36 |
--------------------------------------------------------------------------------
/tests/faces/objects_cylindrical_tests/surface_openned_one_contour.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.9.2.dev421+gb87a301e",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.02,
11 | "y": 0.074,
12 | "z": 0.034
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 1.0,
17 | "y": 0.0,
18 | "z": 0.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.0,
23 | "y": 1.0,
24 | "z": 0.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.0,
29 | "y": -0.0,
30 | "z": 1.0
31 | }
32 | },
33 | "radius": 0.0045000000000000005
34 | }
35 |
--------------------------------------------------------------------------------
/tests/primitives3d/test_block.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | import volmdlr
4 | from volmdlr.primitives3d import Block
5 | from volmdlr.core import BoundingBox
6 |
7 |
8 | class TestBlock(unittest.TestCase):
9 | def setUp(self) -> None:
10 | self.block = Block(frame=volmdlr.OXYZ)
11 |
12 | def test_from_bounding_box(self):
13 | bounding_box = BoundingBox(-0.5, 0.5, -0.5, 0.5, -0.5, 0.5)
14 |
15 | block = Block.from_bounding_box(bounding_box)
16 | self.assertEqual(self.block.frame, block.frame)
17 |
18 | def test_get_bounding_box(self):
19 | bbox1 = BoundingBox(
20 | -0.0271021, 1.0271020999999998, -0.4024024, 0.8024024000000001, -0.0261011, 0.5261011000000001
21 | )
22 | block = Block.from_bounding_box(bbox1)
23 | bbox2 = block.bounding_box
24 |
25 | self.assertTrue(bbox1.is_close(bbox2))
26 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/voxelization/stl_file_voxelization.py:
--------------------------------------------------------------------------------
1 | """
2 | Example of voxelization from an STL file.
3 | """
4 | from volmdlr.discrete_representation import MatrixBasedVoxelization
5 | from volmdlr.display import Mesh3D
6 | from volmdlr.core import VolumeModel
7 |
8 | VOXEL_SIZE = 0.0015
9 | STL_MODEL_FILE_PATH = "../../stl/simple.stl"
10 |
11 | # Load and convert the STL
12 | volume_model = VolumeModel([Mesh3D.from_stl_file(STL_MODEL_FILE_PATH)])
13 |
14 | # Voxelize the model
15 | voxelization = MatrixBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE, name="Voxelization")
16 |
17 | # Display the result
18 | voxelization_primitive = voxelization.to_mesh().split_shared_vertices()
19 | voxelization_primitive.alpha = 0.5
20 | voxelization_primitive.color = (1, 0, 0)
21 |
22 | volume_model.primitives.append(voxelization_primitive)
23 | volume_model.babylonjs()
24 |
--------------------------------------------------------------------------------
/scripts/faces/bezier_surface.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | import volmdlr as vm
4 | import volmdlr.faces as vmf
5 |
6 | degree_u = 3
7 | degree_v = 2
8 |
9 | control_points = [vm.Point3D(0, 0, 0), vm.Point3D(0, 4, 0), vm.Point3D(0, 8, -3),
10 | vm.Point3D(2, 0, 6), vm.Point3D(2, 4, 0), vm.Point3D(2, 8, 0),
11 | vm.Point3D(4, 0, 0), vm.Point3D(4, 4, 0), vm.Point3D(4, 8, 3),
12 | vm.Point3D(6, 0, 0), vm.Point3D(6, 4, -3), vm.Point3D(6, 8, 0)]
13 |
14 | bezier_surface = vmf.BezierSurface3D(degree_u=degree_u, degree_v=degree_v,
15 | control_points=control_points, nb_u=4,
16 | nb_v=3, name='bezier curve 1')
17 | fig = plt.figure()
18 | ax = fig.add_subplot(111, projection='3d')
19 | bezier_surface.plot(ax=ax)
20 | [p.plot(ax=ax) for p in control_points]
21 |
--------------------------------------------------------------------------------
/scripts/showcases/casing.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Script to show volmdlr capabilities on extrusions
5 | """
6 |
7 | import math
8 |
9 | import plot_data
10 |
11 | from volmdlr.models import casing
12 | from volmdlr.primitives3d import Block
13 |
14 | casing._check_platform()
15 |
16 | bottom, sides, belt = casing.primitives
17 |
18 | bbox = casing.bounding_box
19 |
20 | assert bbox.zmin == -0.005
21 | assert math.isclose(bbox.xmax, 0.34067, abs_tol=1e-5)
22 |
23 | box = Block.from_bounding_box(bbox)
24 | box.alpha = 0.3
25 | casing.primitives.append(box)
26 | casing.babylonjs()
27 |
28 | casing.to_step('casing')
29 | casing.to_stl('casing')
30 |
31 |
32 | contour = belt.outer_contour2d.plot_data()
33 | primitive_group = plot_data.PrimitiveGroup(primitives=[contour])
34 | plot_data.plot_canvas(plot_data_object=primitive_group, local=True)
35 |
--------------------------------------------------------------------------------
/tests/faces/objects_spherical_test/sphericalface_disconnected_contours_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.174039695616,
10 | "y": 0.582313006769,
11 | "z": 0.603318945162
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": -0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": -0.0,
22 | "y": 1.0,
23 | "z": 0.0
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": 0.0,
28 | "y": 0.0,
29 | "z": 1.0
30 | }
31 | },
32 | "radius": 0.0098653606096,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_cylindrical_tests/test_contour3d_to_2d_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.10.1.dev880+gebce815c",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.054999978668734996,
11 | "y": 0.015,
12 | "z": 0.0
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 1.0,
17 | "y": 0.0,
18 | "z": 0.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.0,
23 | "y": -1.0,
24 | "z": 0.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.0,
29 | "y": -0.0,
30 | "z": -1.0
31 | }
32 | },
33 | "radius": 0.025
34 | }
35 |
--------------------------------------------------------------------------------
/doc/source/volmdlr.utils.rst:
--------------------------------------------------------------------------------
1 | Subpackage utils
2 | ================
3 |
4 |
5 | volmdlr.utils.common\_operations module
6 | ---------------------------------------
7 |
8 | .. automodule:: volmdlr.utils.common_operations
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 | volmdlr.utils.intersections module
14 | ----------------------------------
15 |
16 | .. automodule:: volmdlr.utils.intersections
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
21 | volmdlr.utils.parametric module
22 | -------------------------------
23 |
24 | .. automodule:: volmdlr.utils.parametric
25 | :members:
26 | :undoc-members:
27 | :show-inheritance:
28 |
29 | volmdlr.utils.step\_writer module
30 | ---------------------------------
31 |
32 | .. automodule:: volmdlr.utils.step_writer
33 | :members:
34 | :undoc-members:
35 | :show-inheritance:
36 |
--------------------------------------------------------------------------------
/scripts/display/mesh_decimation.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of decimation of a STL file.
3 | """
4 | import os
5 | import urllib.request
6 |
7 | from volmdlr.display import Mesh3D
8 |
9 | # Stanfrod Bunny model
10 | MODEL_URL = "https://upload.wikimedia.org/wikipedia/commons/4/43/Stanford_Bunny.stl"
11 | FILE_NAME = "Stanford_Bunny.stl"
12 |
13 | # Check if the STL file already exists
14 | if not os.path.exists(FILE_NAME):
15 | urllib.request.urlretrieve(MODEL_URL, FILE_NAME)
16 | print(f"File downloaded to {FILE_NAME}")
17 | else:
18 | print(f"File already exists at {FILE_NAME}. Skipping download.")
19 |
20 | # Load STL model using volmdlr
21 | mesh = Mesh3D.from_stl_file(FILE_NAME)
22 |
23 | # Decimate and show model
24 | decimated_mesh = mesh.decimate(500, verbose=True)
25 | decimated_mesh = decimated_mesh.split_shared_vertices() # for display purpose
26 | decimated_mesh.babylonjs()
27 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/test_sphericalsurface_repair_periodicity_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.15918830399199999,
10 | "y": 0.630264711048,
11 | "z": 0.6279207702380001
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": -0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": -0.0,
22 | "y": 1.0,
23 | "z": 0.0
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": 0.0,
28 | "y": 0.0,
29 | "z": 1.0
30 | }
31 | },
32 | "radius": 0.004,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/scripts/shells/decimation.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of decimation of a STL file.
3 | """
4 | import os
5 | import urllib.request
6 |
7 | from volmdlr.stl import Stl
8 |
9 | # Stanfrod Bunny model
10 | MODEL_URL = "https://upload.wikimedia.org/wikipedia/commons/4/43/Stanford_Bunny.stl"
11 | FILE_NAME = "Stanford_Bunny.stl"
12 |
13 | # Check if the STL file already exists
14 | if not os.path.exists(FILE_NAME):
15 | urllib.request.urlretrieve(MODEL_URL, FILE_NAME)
16 | print(f"File downloaded to {FILE_NAME}")
17 | else:
18 | print(f"File already exists at {FILE_NAME}. Skipping download.")
19 |
20 | # Load STL model using volmdlr
21 | stl_model = Stl.load_from_file(FILE_NAME)
22 | closed_triangle_shell = stl_model.to_closed_shell()
23 |
24 | # Decimate and show model
25 | decimated_closed_triangle_shell = closed_triangle_shell.decimate(50, verbose=True)
26 | decimated_closed_triangle_shell.babylonjs()
27 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/sphericalsurface1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
4 | "package_version": "0.10.1.dev658+gfad49fd5",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -8.812517441887001e-21,
11 | "y": -0.0787,
12 | "z": 0.0
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -1.0,
17 | "y": 0.0,
18 | "z": -6.123233995737e-17
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.0,
23 | "y": -1.0,
24 | "z": 0.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -6.123233995737e-17,
29 | "y": 0.0,
30 | "z": 1.0
31 | }
32 | },
33 | "radius": 0.0345
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/test_2_sphericalsurface_repair_periodicity_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.162286635124,
10 | "y": 0.622317511425,
11 | "z": 0.599743594167
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": -0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": -0.0,
22 | "y": 1.0,
23 | "z": 0.0
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": 0.0,
28 | "y": 0.0,
29 | "z": 1.0
30 | }
31 | },
32 | "radius": 0.009115396155459999,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/pixelization/pixelization_from_closed_polygon.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of creating a pixelization.
3 | """
4 |
5 | from volmdlr import Point2D
6 | from volmdlr.core import EdgeStyle
7 | from volmdlr.discrete_representation import PointBasedPixelization
8 | from volmdlr.wires import ClosedPolygon2D
9 |
10 | PIXEL_SIZE = 0.05
11 |
12 | # Define a polygon
13 | points = [
14 | Point2D(5, 1),
15 | Point2D(5.25, 0.5),
16 | Point2D(6, 0.5),
17 | Point2D(5.45, 0),
18 | Point2D(6, -1),
19 | Point2D(5, -0.5),
20 | Point2D(4, -1),
21 | Point2D(4.55, 0),
22 | Point2D(4, 0.5),
23 | Point2D(4.75, 0.5),
24 | Point2D(5, 1),
25 | ]
26 |
27 | closed_polygon = ClosedPolygon2D(points)
28 | pixelization = PointBasedPixelization.from_closed_polygon(closed_polygon, PIXEL_SIZE)
29 |
30 | ax = pixelization.plot()
31 | closed_polygon.plot(ax=ax, edge_style=EdgeStyle(color="r"))
32 |
--------------------------------------------------------------------------------
/scripts/primitives/cone.py:
--------------------------------------------------------------------------------
1 | """
2 | Demo usage of Cone class.
3 | """
4 | import math
5 |
6 | import volmdlr
7 | from volmdlr.core import VolumeModel
8 | from volmdlr.primitives3d import Cone
9 |
10 | # 1. Instantiate a red Cone directly with the init:
11 | cone1 = Cone(frame=volmdlr.OXYZ, radius=0.1, length=0.5, color=(1.0, 0.0, 0.0))
12 |
13 | # 2. Instantiate a green Cone with `from_center_point_and_axis` classmethod:
14 | cone2 = Cone.from_center_point_and_axis(
15 | center_point=volmdlr.Point3D(-0.2, -0.3, 0.1), axis=volmdlr.X3D, radius=0.06, length=0.2, color=(0.0, 1.0, 0.0)
16 | )
17 |
18 | # 3. Instantiate a blue Cone from moving the green cone:
19 | cone3 = cone2.translation(volmdlr.Vector3D(0.2, 0.1, -0.3))
20 | cone3 = cone3.rotation(volmdlr.O3D, volmdlr.Z3D, math.pi / 2)
21 | cone3.color = (0.0, 0.0, 1.0)
22 |
23 | # Display the result
24 | volume_model = VolumeModel([cone1, cone2, cone3])
25 | volume_model.babylonjs()
26 |
--------------------------------------------------------------------------------
/tests/faces/objects_toroidal_tests/repair_inner_contour_periodicity_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.0,
10 | "y": 0.0,
11 | "z": 0.0
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 1.0,
16 | "y": 0.0,
17 | "z": 0.0
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.0,
22 | "y": -1.0,
23 | "z": 0.0
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": -0.0,
28 | "y": -0.0,
29 | "z": -1.0
30 | }
31 | },
32 | "major_radius": 0.01,
33 | "minor_radius": 0.004,
34 | "inner_radius": 0.006,
35 | "outer_radius": 0.014,
36 | "_references": {}
37 | }
38 |
--------------------------------------------------------------------------------
/scripts/stl/read_stls.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 | import volmdlr.cloud
4 | import volmdlr.core
5 | import volmdlr.stl as vmstl
6 |
7 |
8 | path = os.getcwd()
9 |
10 |
11 | for stl_file in [
12 | 'simple.stl',
13 | 'cube_ascii.stl',
14 | 'double_space.stl'
15 | ]:
16 |
17 | shells = []
18 | stl = vmstl.Stl.load_from_file(stl_file)
19 | shell = stl.to_closed_shell()
20 | shell.alpha = 0.3
21 | assert len(shell.faces)
22 | shells.append(shell)
23 |
24 | list_points = stl.extract_points_bis()
25 | if len(list_points) > 50:
26 | pointcloud3d = volmdlr.cloud.PointCloud3D(list_points)
27 | shell2 = pointcloud3d.to_shell(resolution=15)
28 | shell2.alpha = 0.6
29 | shell2.color = (1, 0.1, 0.1)
30 | shells.append(shell2)
31 |
32 | volume_model = volmdlr.core.VolumeModel(shells)
33 | volume_model.babylonjs()
34 |
--------------------------------------------------------------------------------
/tests/edges/test_fullarc2d.py:
--------------------------------------------------------------------------------
1 | """
2 | Unittets for edges.Fullarc2D.
3 |
4 | """
5 | import unittest
6 | from dessia_common.core import DessiaObject
7 | import volmdlr
8 | from volmdlr import edges, curves
9 |
10 |
11 | class TestFullArc2D(unittest.TestCase):
12 | circle2d = curves.Circle2D(volmdlr.OXY, 1)
13 | fullarc2d = edges.FullArc2D(circle2d, volmdlr.Point2D(-1, 0))
14 |
15 | def test_trim(self):
16 | split_point1 = volmdlr.Point2D(-0.7071067811865475, 0.7071067811865475)
17 | split_point2 = volmdlr.Point2D(-0.7071067811865475, -0.7071067811865475)
18 | split = self.fullarc2d.trim(split_point1, split_point2)
19 | self.assertEqual(split, edges.Arc2D(self.circle2d, volmdlr.Point2D(-0.7071067811865475, -0.7071067811865475),
20 | volmdlr.Point2D(-0.7071067811865475, 0.7071067811865475)))
21 |
22 |
23 | if __name__ == '__main__':
24 | unittest.main()
25 |
--------------------------------------------------------------------------------
/scripts/faces/spherical.py:
--------------------------------------------------------------------------------
1 | import volmdlr as vm
2 | import volmdlr.edges as vme
3 | import volmdlr.faces as vmf
4 | import volmdlr.primitives3d as p3d
5 | import volmdlr.wires as vmw
6 | from volmdlr import surfaces
7 |
8 | sphere = surfaces.SphericalSurface3D(vm.Frame3D(vm.O3D, vm.X3D, vm.Y3D, vm.Z3D), 0.3)
9 | sphere.plot()
10 | # sphere.babylonjs()
11 |
12 | face = vmf.SphericalFace3D.from_surface_rectangular_cut(sphere, 0, 2.5, 0, 0.5)
13 | face.babylonjs()
14 | face.plot()
15 |
16 | # Try to generate a sphere from revoltion
17 | radius = 0.03
18 | p1 = vm.Point2D(0, -radius)
19 | p2 = vm.Point2D(radius, 0.)
20 | p3 = vm.Point2D(0, radius)
21 | arc = vme.Arc2D.from_3_points(p1, p2, p3)
22 | line = vme.LineSegment2D(p3, p1)
23 | contour = vmw.Contour2D([arc, line])
24 | sphere_revolution = p3d.RevolvedProfile(vm.X3D, vm.X3D, vm.Y3D, contour,
25 | vm.X3D, vm.Y3D, angle=1.3)
26 | sphere_revolution.babylonjs()
27 |
--------------------------------------------------------------------------------
/scripts/mesh/mesh2D.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri May 12 10:04:09 2017
5 |
6 | @author: steven
7 | """
8 |
9 | import volmdlr as vm
10 | import volmdlr.mesh as vmmesh
11 |
12 | l=0.1
13 |
14 | p1=vm.Point2D((0,0))
15 | p2=vm.Point2D((l,0))
16 | p3=vm.Point2D((l,l))
17 | p4=vm.Point2D((0,l))
18 |
19 | tr2=vmmesh.TriangularElement([p1,p3,p4])
20 | tr1=vmmesh.TriangularElement([p1,p2,p3])
21 |
22 | Triangles=[tr1,tr2]
23 |
24 | Elements=vmmesh.ElementsGroup(Triangles,'first_element')
25 |
26 | mesh=vmmesh.Mesh([Elements])
27 |
28 | # l1=vm.LineSegment2D(p1,p2)
29 | # l2=vm.LineSegment2D(p2,p3)
30 | # l3=vm.LineSegment2D(p3,p4)
31 | # l4=vm.LineSegment2D(p4,p1)
32 |
33 | # p5=vm.Point2D((l/2,l/2))
34 | # c1=vm.Circle2D(p5,l/5)
35 |
36 |
37 |
38 | # ct1=vm.Contour2D([l4,l3,l2,l1])
39 | # ct2=vm.Contour2D([c1])
40 | # mesh=vm.Mesh2D([ct1,ct2],{},0.01)
41 |
42 | print(mesh.GeoScript('mesh2D.geo'))
43 |
--------------------------------------------------------------------------------
/tests/faces/objects_cylindrical_tests/surface3d_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.8.1.dev468+g652bbe39",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.0,
11 | "y": 1.53080849893419e-19,
12 | "z": 0.00077,
13 | "name": ""
14 | },
15 | "u": {
16 | "object_class": "volmdlr.Vector3D",
17 | "x": -1.0,
18 | "y": 0.0,
19 | "z": 0.0,
20 | "name": ""
21 | },
22 | "v": {
23 | "object_class": "volmdlr.Vector3D",
24 | "x": -0.0,
25 | "y": -1.0,
26 | "z": -0.0,
27 | "name": ""
28 | },
29 | "w": {
30 | "object_class": "volmdlr.Vector3D",
31 | "x": -0.0,
32 | "y": -0.0,
33 | "z": 1.0,
34 | "name": ""
35 | }
36 | },
37 | "radius": 0.0025
38 | }
39 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_plane_test/plane_parametric_operation_bug_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.Plane3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.00638,
10 | "y": 0.0009846286278510001,
11 | "z": -0.002078,
12 | "name": "Axis2P3D Location"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 6.12323399574e-17,
17 | "y": -7.49879891331e-33,
18 | "z": 1.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 6.12323399574e-17,
23 | "y": 1.0,
24 | "z": 3.7493994566513946e-33
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -1.0,
29 | "y": 6.12323399574e-17,
30 | "z": 6.12323399574e-17
31 | }
32 | },
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/tests/faces/objects_conical_tests/conical_surface3d_1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
4 | "package_version": "0.7.1.dev905+g8a826d99",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.0,
11 | "y": 0.0,
12 | "z": -0.0022143719324716786,
13 | "name": ""
14 | },
15 | "u": {
16 | "object_class": "volmdlr.Vector3D",
17 | "x": 1.0,
18 | "y": 0.0,
19 | "z": 0.0,
20 | "name": ""
21 | },
22 | "v": {
23 | "object_class": "volmdlr.Vector3D",
24 | "x": 0.0,
25 | "y": 1.0,
26 | "z": 0.0,
27 | "name": ""
28 | },
29 | "w": {
30 | "object_class": "volmdlr.Vector3D",
31 | "x": 0.0,
32 | "y": 0.0,
33 | "z": 1.0,
34 | "name": ""
35 | }
36 | },
37 | "semi_angle": 1.0471975511966
38 | }
39 |
--------------------------------------------------------------------------------
/tests/faces/objects_conical_tests/conical_surface3d_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
4 | "package_version": "0.7.1.dev905+g8a826d99",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.0,
11 | "y": 0.0,
12 | "z": 0.32497500000000007,
13 | "name": ""
14 | },
15 | "u": {
16 | "object_class": "volmdlr.Vector3D",
17 | "x": -1.0,
18 | "y": 0.0,
19 | "z": 0.0,
20 | "name": ""
21 | },
22 | "v": {
23 | "object_class": "volmdlr.Vector3D",
24 | "x": 0.0,
25 | "y": 1.0,
26 | "z": 0.0,
27 | "name": ""
28 | },
29 | "w": {
30 | "object_class": "volmdlr.Vector3D",
31 | "x": 0.0,
32 | "y": 0.0,
33 | "z": -1.0,
34 | "name": ""
35 | }
36 | },
37 | "semi_angle": 0.0246863420555994
38 | }
39 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_cylindrical_tests/cylindrical_surface_bspline_openned_contour.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.9.2.dev421+gb87a301e",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.0428,
11 | "y": 0.0224833395016046,
12 | "z": 0.013000000000000001
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.0,
17 | "y": -1.0,
18 | "z": 0.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 6.12323399573676e-17,
23 | "y": 0.0,
24 | "z": 1.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -1.0,
29 | "y": -2.27893625898235e-64,
30 | "z": 6.12323399573676e-17
31 | }
32 | },
33 | "radius": 0.00525
34 | }
35 |
--------------------------------------------------------------------------------
/tests/faces/objects_conical_tests/conical_surface_with_singularity.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
4 | "package_version": "0.9.2.dev421+gb87a301e",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.08019222182461785,
11 | "y": 0.3024237538176261,
12 | "z": 0.0895072768854796
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.939692620786,
17 | "y": -0.342020143326,
18 | "z": 0.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.0,
23 | "y": 0.0,
24 | "z": 1.0000000000003988
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.342020143326,
29 | "y": 0.939692620786,
30 | "z": 0.0
31 | }
32 | },
33 | "semi_angle": 1.0297442575
34 | }
35 |
--------------------------------------------------------------------------------
/tests/faces/test_revolutionface3d.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 | import volmdlr
4 | from volmdlr.core import VolumeModel
5 | from volmdlr.step import Step
6 |
7 |
8 | folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'objects_revolution_tests')
9 |
10 |
11 | class TestRevolutionFace3D(unittest.TestCase):
12 |
13 | def test_to_step(self):
14 | model = VolumeModel.from_json(os.path.join(folder, "revolutionface_export_test.json"))
15 | model.to_step(os.path.join(folder, "test_export.step"))
16 | step_import = Step.from_file(os.path.join(folder, "test_export.step"))
17 | model2 = step_import.to_volume_model()
18 | revolutionface = model2.primitives[0].primitives[0]
19 | self.assertTrue(revolutionface.outer_contour3d.is_ordered())
20 | self.assertAlmostEqual(revolutionface.surface2d.area(), 0.00738824 * volmdlr.TWO_PI, 6)
21 |
22 |
23 | if __name__ == '__main__':
24 | unittest.main()
25 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
4 | "package_version": "0.9.2.dev1050+g45192f1d",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.16850001135,
11 | "y": 0.0674999872838,
12 | "z": 0.627719515715
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.516263863981257,
17 | "y": -0.8564295783934264,
18 | "z": 0.0
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.8564295783934264,
23 | "y": 0.516263863981257,
24 | "z": 0.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.0,
29 | "y": -0.0,
30 | "z": -1.0
31 | }
32 | },
33 | "tore_radius": 0.003,
34 | "small_radius": 0.0005
35 | }
36 |
--------------------------------------------------------------------------------
/doc/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 | set SPHINXPROJ=Volmdlr
13 |
14 | if "%1" == "" goto help
15 |
16 | %SPHINXBUILD% >NUL 2>NUL
17 | if errorlevel 9009 (
18 | echo.
19 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
20 | echo.installed, then set the SPHINXBUILD environment variable to point
21 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
22 | echo.may add the Sphinx directory to PATH.
23 | echo.
24 | echo.If you don't have Sphinx installed, grab it from
25 | echo.http://sphinx-doc.org/
26 | exit /b 1
27 | )
28 |
29 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
30 | goto end
31 |
32 | :help
33 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
34 |
35 | :end
36 | popd
37 |
--------------------------------------------------------------------------------
/volmdlr/__init__.py:
--------------------------------------------------------------------------------
1 | """
2 | Volmdlr init module.
3 | """
4 | # -*- coding: utf-8 -*-
5 | import math
6 |
7 | import pkg_resources
8 |
9 | __version__ = pkg_resources.require("volmdlr")[0].version
10 |
11 | from volmdlr.core_compiled import (O2D, O3D, OXY, X2D, X3D, Y2D, Y3D, Z3D,
12 | Basis2D, Basis3D, Frame2D, Frame3D,
13 | linesegment2d_point_distance, LineSegment3DDistance,
14 | linesegment3d_point_distance, get_minimum_distance_points_lines,
15 | Matrix22, Matrix33, Point2D, Point3D, Vector2D,
16 | Vector3D)
17 |
18 |
19 | TWO_PI = 2 * math.pi
20 |
21 | XYZ = Basis3D(X3D, Y3D, Z3D)
22 | YZX = Basis3D(Y3D, Z3D, X3D)
23 | ZXY = Basis3D(Z3D, X3D, Y3D)
24 |
25 | OXYZ = Frame3D(O3D, X3D, Y3D, Z3D)
26 | OYZX = Frame3D(O3D, Y3D, Z3D, X3D)
27 | OZXY = Frame3D(O3D, Z3D, X3D, Y3D)
28 |
29 | PATH_ROOT = "#"
30 |
--------------------------------------------------------------------------------
/scripts/distance/shell_intersection.py:
--------------------------------------------------------------------------------
1 | import volmdlr as vm
2 | import volmdlr.primitives3d as primitives3d
3 |
4 | resolution = 0.0010
5 |
6 | box = primitives3d.Block(
7 | vm.Frame3D(vm.Point3D(0.1, 0.1, 0.1), vm.Vector3D(0.15, 0.0, 0.0),
8 | vm.Vector3D(0.0, 0.15, 0.0), vm.Vector3D(0.0, 0.0, 0.15)),
9 | alpha=0.6)
10 |
11 | box.frame_mapping_inplace(vm.Frame3D(vm.Point3D(-0.07, -0.07, -0.07),
12 | vm.Point3D(1, 0, 0),
13 | vm.Point3D(0, 1, 0),
14 | vm.Point3D(0, 0, 1)), side='old')
15 |
16 | box_red = primitives3d.Block(
17 | vm.Frame3D(vm.Point3D(-0.04, -0.04, -0.04), vm.Vector3D(0.1, 0.0, 0.0),
18 | vm.Vector3D(0.0, 0.1, 0.0), vm.Vector3D(0.0, 0.0, 0.1)),
19 | color=(0.2, 1, 0.4), alpha=0.6)
20 |
21 | assert type(box_red.shell_intersection(box, resolution=0.001)) == tuple
22 |
23 | vol = vm.core.VolumeModel([box, box_red])
24 | vol.babylonjs()
25 |
--------------------------------------------------------------------------------
/scripts/primitives/cylinder.py:
--------------------------------------------------------------------------------
1 | """
2 | Demo usage of Cylinder class.
3 | """
4 | import volmdlr
5 | from volmdlr.core import VolumeModel
6 | from volmdlr.primitives3d import Cylinder
7 |
8 | # 1. Instantiate a red Cylinder directly with the init:
9 | cylinder1 = Cylinder(frame=volmdlr.OXYZ, radius=0.1, length=0.5, color=(1.0, 0.0, 0.0))
10 |
11 | # 2. Instantiate a blue Cylinder with `from_extremal_points` classmethod:
12 | cylinder2 = Cylinder.from_end_points(
13 | point1=volmdlr.Point3D(0.5, 0.2, 0.3), point2=volmdlr.Point3D(0.8, 0.1, 0.1), radius=0.3, color=(0.0, 1.0, 0.0)
14 | )
15 |
16 | # 3. Instantiate a green Cylinder with `from_center_point_and_axis` classmethod:
17 | cylinder3 = Cylinder.from_center_point_and_axis(
18 | center_point=volmdlr.Point3D(-0.2, -0.3, 0.1), axis=volmdlr.X3D, radius=0.06, length=0.2, color=(0.0, 0.0, 1.0)
19 | )
20 |
21 | # Display the result
22 | volume_model = VolumeModel([cylinder1, cylinder2, cylinder3])
23 | volume_model.babylonjs()
24 |
--------------------------------------------------------------------------------
/tests/faces/objects_conical_tests/conical_surface1.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
4 | "package_version": "0.7.1.dev905+g8a826d99",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.0,
11 | "y": 1.22464679914735e-19,
12 | "z": 0.002600000000000002,
13 | "name": ""
14 | },
15 | "u": {
16 | "object_class": "volmdlr.Vector3D",
17 | "x": -1.0,
18 | "y": 0.0,
19 | "z": 0.0,
20 | "name": ""
21 | },
22 | "v": {
23 | "object_class": "volmdlr.Vector3D",
24 | "x": 0.0,
25 | "y": 1.0,
26 | "z": 0.0,
27 | "name": ""
28 | },
29 | "w": {
30 | "object_class": "volmdlr.Vector3D",
31 | "x": 0.0,
32 | "y": 0.0,
33 | "z": -1.0,
34 | "name": ""
35 | }
36 | },
37 | "semi_angle": 0.785398163397448
38 | }
39 |
--------------------------------------------------------------------------------
/tests/line_distances_projections.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 | Distance to lines and projection debug
6 |
7 | """
8 |
9 | import numpy as npy
10 |
11 | import volmdlr as vm
12 |
13 | p1 = vm.Point2D(2*npy.random.random(2)-1)
14 | p2 = vm.Point2D(2*npy.random.random(2)-1)
15 |
16 | line = vm.Line2D(p1, p2)
17 |
18 | line_segment = vm.LineSegment2D(p1, p2)
19 |
20 | for i in range(100):
21 |
22 | point = vm.Point2D(4*npy.random.random(2)-2)
23 |
24 | point_projection_line = line.PointProjection(point)
25 | point_projection_line_segment = line_segment.PointProjection(point)
26 |
27 | assert point_projection_line.PointDistance(point) == line.PointDistance(point)
28 | assert point_projection_line_segment.PointDistance(point) == line_segment.PointDistance(point)
29 |
30 | #fig, ax = line.MPLPlot()
31 | #point.MPLPlot(ax=ax)
32 | #point_projection_line.MPLPlot(ax=ax)
33 | #point_projection_line_segment.MPLPlot(ax=ax)
34 |
--------------------------------------------------------------------------------
/tests/surfaces/test_periodical_surface.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 |
4 | import volmdlr
5 | import volmdlr.wires as vmw
6 | import volmdlr.edges as vme
7 | from volmdlr import surfaces
8 |
9 | folder = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'objects_periodical_surface')
10 |
11 |
12 | class TestPeriodicalSurface(unittest.TestCase):
13 |
14 | def test_bsplinecurve3d_to_2d(self):
15 | surface = surfaces.CylindricalSurface3D.from_json(os.path.join(folder, "periodicalsurface_with_theta_discontinuity.json"))
16 | bspline = vme.BSplineCurve3D.from_json(os.path.join(folder, "bsplinecurve_with_theta_discontinuity.json"))
17 | bspline2d = surface.bsplinecurve3d_to_2d(bspline)[0]
18 | theta1 = bspline2d.start.x
19 | theta2 = bspline2d.end.x
20 | self.assertEqual(theta1, 0.9979944870045463)
21 | self.assertEqual(theta2, volmdlr.TWO_PI)
22 |
23 |
24 | if __name__ == '__main__':
25 | unittest.main()
26 |
--------------------------------------------------------------------------------
/tests/edges/test_beziercurve3d.py:
--------------------------------------------------------------------------------
1 | """
2 | Unit tests for volmdlr.faces.BSplineCurve
3 | """
4 | import unittest
5 | import volmdlr
6 | import volmdlr.edges as vme
7 |
8 |
9 | class TestBezierCurve3D(unittest.TestCase):
10 | # Set up the Bézier curve
11 | degree = 3
12 | ctrlpts = [volmdlr.Point3D(0, 0, 0),
13 | volmdlr.Point3D(1, 1, 2),
14 | volmdlr.Point3D(2, 1, 1),
15 | volmdlr.Point3D(3, 0, 4)]
16 | bezier_curve3d = vme.BezierCurve3D(degree=degree,
17 | control_points=ctrlpts,
18 | name='bezier curve 1')
19 |
20 | def test_cut_before(self):
21 | new_bezier = self.bezier_curve3d.cut_before(0.5)
22 | self.assertTrue(new_bezier.start.is_close(self.bezier_curve3d.evaluate_single(0.5)))
23 | self.assertTrue(new_bezier.end.is_close(self.bezier_curve3d.end))
24 |
25 |
26 | if __name__ == '__main__':
27 | unittest.main()
28 |
--------------------------------------------------------------------------------
/scripts/edges/bspline.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Fri Jan 8 16:23:49 2021
5 |
6 | @author: steven
7 | """
8 |
9 | import volmdlr as vm
10 | import volmdlr.edges as vme
11 |
12 | # 2D
13 | points2d = [vm.Point2D(0, 0),
14 | vm.Point2D(0.1, 0.1),
15 | vm.Point2D(0, 0.2)]
16 |
17 | curve2d = vme.BSplineCurve2D(degree=2,
18 | control_points=points2d,
19 | knot_multiplicities=[1, 2, 2, 1],
20 | knots=[0.1, 0.3, 0.5, 0.7])
21 | curve2d.plot()
22 |
23 | # 3D
24 | points3d = [vm.Point3D(0, 0, 0),
25 | vm.Point3D(0.1, 0.1, 0),
26 | vm.Point3D(0, 0.2, 0.05)]
27 |
28 | curve3d = vme.BSplineCurve3D(degree=2,
29 | control_points=points3d,
30 | knot_multiplicities=[1, 2, 2, 1],
31 | knots=[0.1, 0.3, 0.5, 0.7])
32 | curve3d.plot()
33 |
--------------------------------------------------------------------------------
/scripts/wires/axial_symmetry.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 | @author: s.bendjebla
6 | """
7 |
8 | # %% Libraries
9 |
10 | import matplotlib.pyplot as plt
11 |
12 | import volmdlr as vm
13 | import volmdlr.edges
14 | import volmdlr.wires
15 | import volmdlr.curves
16 | from volmdlr.core import EdgeStyle
17 | # %% Initial Data
18 |
19 | points = [vm.Point2D(6, 0), vm.Point2D(6, 2),
20 | vm.Point2D(3, 2), vm.Point2D(3, 1),
21 | vm.Point2D(1, 1), vm.Point2D(1, 2),
22 | vm.Point2D(0, 2), vm.Point2D(0, 0)]
23 |
24 | contour = vm.wires.Contour2D.from_points(points)
25 | line = volmdlr.curves.Line2D(vm.Point2D(-1, 3), vm.Point2D(7, 3))
26 |
27 | # %% Symmetry
28 |
29 | axial_contour = contour.axial_symmetry(line)
30 |
31 | fig, ax = plt.subplots()
32 | ax.set_aspect('equal')
33 |
34 | line.plot(ax)
35 |
36 | contour.plot(ax=ax, edge_style=EdgeStyle(color='r'))
37 | axial_contour.plot(ax=ax, edge_style=EdgeStyle(color='g'))
38 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/pixelization/pixelization_inverse.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of computing the inverse of a pixelization.
3 | """
4 |
5 | from volmdlr import Point2D
6 | from volmdlr.discrete_representation import MatrixBasedPixelization
7 | from volmdlr.wires import ClosedPolygon2D
8 |
9 | PIXEL_SIZE = 0.05
10 |
11 | # Define a polygon
12 | points = [
13 | Point2D(5, 1),
14 | Point2D(5.25, 0.5),
15 | Point2D(6, 0.5),
16 | Point2D(5.45, 0),
17 | Point2D(6, -1),
18 | Point2D(5, -0.5),
19 | Point2D(4, -1),
20 | Point2D(4.55, 0),
21 | Point2D(4, 0.5),
22 | Point2D(4.75, 0.5),
23 | Point2D(5, 1),
24 | ]
25 |
26 | closed_polygon = ClosedPolygon2D(points)
27 | pixelization = MatrixBasedPixelization.from_closed_polygon(closed_polygon, PIXEL_SIZE)
28 |
29 | # Computing the inverse
30 | inverse_pixelization = pixelization.inverse()
31 | ax = pixelization.plot(color="b")
32 | inverse_pixelization.plot(ax=ax, color="r")
33 | closed_polygon.plot(ax=ax)
34 |
--------------------------------------------------------------------------------
/tests/shells/test_shell3d.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import os
3 |
4 | from dessia_common.core import DessiaObject
5 | import volmdlr
6 | from volmdlr import shells
7 |
8 | folder = os.path.join(os.path.dirname(os.path.realpath(__file__)))
9 |
10 |
11 | class TestShell3D(unittest.TestCase):
12 | def test_from_faces(self):
13 | openshell = DessiaObject.from_json(os.path.join(folder, "open_shell.json"))
14 | closedshell = DessiaObject.from_json(os.path.join(folder, "closed_shell.json"))
15 | fm_closedshell = closedshell.frame_mapping(volmdlr.Frame3D(volmdlr.Point3D(0.5, 0.5, 0.5),
16 | volmdlr.X3D, volmdlr.Y3D, volmdlr.Z3D), 'new')
17 | from_faces = shells.Shell3D.from_faces(openshell.faces + fm_closedshell.faces)
18 | self.assertEqual(from_faces[0], openshell)
19 | self.assertEqual(from_faces[1], fm_closedshell)
20 |
21 |
22 | if __name__ == '__main__':
23 | unittest.main()
24 |
--------------------------------------------------------------------------------
/scripts/mesh/read_msh_file.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Thu Jun 16 2022
5 |
6 | @author: s.bendjebla
7 | """
8 |
9 | import volmdlr
10 | import volmdlr.gmsh_vm
11 |
12 | # %% 2D
13 |
14 | file_path = 'model'
15 |
16 | gmsh_parser = volmdlr.gmsh_vm.GmshParser.from_file(file_path+'.msh')
17 |
18 | mesh = gmsh_parser.define_triangular_element_mesh()
19 |
20 | gmsh_parser.to_vtk(file_path)
21 |
22 | mesh.plot()
23 |
24 | # %% 3D
25 |
26 | file_path = 'block'
27 |
28 | gmsh_parser = volmdlr.gmsh_vm.GmshParser.from_file(file_path+'.msh')
29 |
30 | mesh = gmsh_parser.define_tetrahedron_element_mesh()
31 |
32 | gmsh_parser.to_vtk(file_path)
33 |
34 | # mesh.plot()
35 |
36 | # %% 3D (Quadratic)
37 |
38 | file_path = 'mesh_quadratic'
39 |
40 | gmsh_parser = volmdlr.gmsh_vm.GmshParser.from_file(file_path+'.msh')
41 |
42 | mesh = gmsh_parser.define_quadratic_tetrahedron_element_mesh()
43 |
44 | gmsh_parser.to_vtk(file_path)
45 |
46 | # mesh.plot()
47 |
--------------------------------------------------------------------------------
/tests/core_compiled/test_basis2d.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | import volmdlr
4 |
5 |
6 | class TestBasis2D(unittest.TestCase):
7 | local_basis = volmdlr.Basis2D(volmdlr.Y2D, volmdlr.X2D)
8 |
9 | def test_global_to_local_coordinates(self):
10 | vector_global = volmdlr.Vector2D(3, 4)
11 | vector_local = self.local_basis.global_to_local_coordinates(vector_global)
12 |
13 | # Check that the converted vector has the expected coordinates
14 | self.assertEqual(vector_local.x, 4)
15 | self.assertEqual(vector_local.y, 3)
16 |
17 | def test_local_to_global_coordinates(self):
18 | vector_local = volmdlr.Vector2D(4, 3)
19 | vector_global = self.local_basis.local_to_global_coordinates(vector_local)
20 |
21 | # Check that the converted vector has the expected coordinates
22 | self.assertEqual(vector_global.x, 3)
23 | self.assertEqual(vector_global.y, 4)
24 |
25 |
26 | if __name__ == "__main__":
27 | unittest.main()
28 |
--------------------------------------------------------------------------------
/scripts/showcases/simple_shapes.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Wed Mar 14 15:32:37 2018
5 |
6 | @author: Steven Masfaraud masfaraud@dessia.tech
7 | """
8 | #import volmdlr.primitives2D as primitives2D
9 | import numpy as npy
10 |
11 | import volmdlr as vm
12 | import volmdlr.edges as vme
13 | import volmdlr.wires as vmw
14 |
15 | #for i in range(20):
16 | triangle_points=[vm.Point2D.random(0, 1, 0, 1) for i in range(3)]
17 | triangle = vmw.ClosedPolygon2D(triangle_points)
18 |
19 |
20 | # cog_triangle = triangle.center_of_mass()
21 | # c1 = vm.core.CompositePrimitive2D([triangle, cog_triangle])
22 | # c1.plot()
23 |
24 | print(triangle.area())
25 |
26 | p0=vm.Point2D(-1,0)
27 | p1=vm.Point2D(-npy.cos(npy.pi/4),npy.sin(npy.pi/4))
28 | p2=vm.Point2D(0,1)
29 |
30 | a = vme.Arc2D.from_3_points(p2,p1,p0)
31 | l = vme.LineSegment2D(p2, a.circle.center)
32 | #list_node = a.Discretise()
33 |
34 | c = vmw.Contour2D([a, l])
35 | print(c.plot_data())
36 | print(c.area())
37 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_conical_tests/conical_singularity_suface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 2.46483191658994,
10 | "y": 0.7243068270309992,
11 | "z": 0.580670276263991
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": -0.3534164658400866,
16 | "y": 0.13697548256903827,
17 | "z": -0.9253834442262742
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": -0.1253229131892583,
22 | "y": -0.987237282786411,
23 | "z": -0.09826858554587178
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": -0.92703342394,
28 | "y": 0.08124201284082,
29 | "z": 0.366072077939
30 | }
31 | },
32 | "semi_angle": 1.0471975512,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/degenerated_toroidalsurface_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
3 | "name": "NONE",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "NONE",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.0,
10 | "y": 0.0,
11 | "z": 17.499999999999996,
12 | "name": "NONE"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.0,
17 | "y": -1.0,
18 | "z": 1.8503717077085942e-18
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 1.0,
23 | "y": 0.0,
24 | "z": 0.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.0,
29 | "y": 1.8503717077085942e-18,
30 | "z": 1.0,
31 | "name": "NONE"
32 | }
33 | },
34 | "major_radius": 21.499386962957114,
35 | "minor_radius": 25.299386962957122,
36 | "_references": {}
37 | }
38 |
--------------------------------------------------------------------------------
/tests/edges/arc_objects/arc2d_rotation_test.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.Arc2D",
3 | "name": "",
4 | "circle": {
5 | "object_class": "volmdlr.curves.Circle2D",
6 | "name": "",
7 | "radius": 0.6020797289396146,
8 | "frame": {
9 | "object_class": "volmdlr.Frame2D",
10 | "name": "",
11 | "origin": {
12 | "object_class": "volmdlr.Point2D",
13 | "x": 0.9000000000000002,
14 | "y": 1.0500000000000005
15 | },
16 | "u": {
17 | "object_class": "volmdlr.Vector2D",
18 | "x": 1.0,
19 | "y": 0.0,
20 | "name": ""
21 | },
22 | "v": {
23 | "object_class": "volmdlr.Vector2D",
24 | "x": 0.0,
25 | "y": 1.0,
26 | "name": ""
27 | }
28 | }
29 | },
30 | "start": {
31 | "object_class": "volmdlr.Point2D",
32 | "x": 1.5,
33 | "y": 1.0
34 | },
35 | "end": {
36 | "object_class": "volmdlr.Point2D",
37 | "x": 0.5,
38 | "y": 1.5
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/tests/faces/objects_cylindrical_tests/cylindrical_surface_repair_contour2d.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.9.2.dev1012+g32af9276",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.0348,
11 | "y": 0.0110524095237019,
12 | "z": 0.00583902763483635
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.0,
17 | "y": 0.8841927618961554,
18 | "z": 0.4671222107869082
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -6.385465351814778e-17,
23 | "y": 0.4671222107869082,
24 | "z": -0.8841927618961554
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -1.0,
29 | "y": -2.0794262207133e-17,
30 | "z": 6.12323399573676e-17
31 | }
32 | },
33 | "radius": 0.0016
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_bspline_test/bsplinesurface_smallbsplinecurve_curve.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.BSplineCurve3D",
3 | "name": "",
4 | "degree": 3,
5 | "control_points": [
6 | {
7 | "object_class": "volmdlr.Point3D",
8 | "x": -0.00584945717745,
9 | "y": -0.12026229657700001,
10 | "z": 0.460142799953
11 | },
12 | {
13 | "object_class": "volmdlr.Point3D",
14 | "x": -0.00585189916631,
15 | "y": -0.120264048181,
16 | "z": 0.46014398798
17 | },
18 | {
19 | "object_class": "volmdlr.Point3D",
20 | "x": -0.00585433825299,
21 | "y": -0.12026580299100001,
22 | "z": 0.460145177001
23 | },
24 | {
25 | "object_class": "volmdlr.Point3D",
26 | "x": -0.00585677443091,
27 | "y": -0.120267560999,
28 | "z": 0.460146367012
29 | }
30 | ],
31 | "knot_multiplicities": [
32 | 4,
33 | 4
34 | ],
35 | "knots": [
36 | 0.0,
37 | 1.0
38 | ],
39 | "weights": null
40 | }
41 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_bspline_test/periodic_surface_smallbsplinecurve3d_curve.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.BSplineCurve3D",
3 | "name": "",
4 | "degree": 3,
5 | "control_points": [
6 | {
7 | "object_class": "volmdlr.Point3D",
8 | "x": 0.43897344153199996,
9 | "y": 0.160922017762,
10 | "z": 0.421082923806
11 | },
12 | {
13 | "object_class": "volmdlr.Point3D",
14 | "x": 0.438978330603,
15 | "y": 0.160933580213,
16 | "z": 0.421079891586
17 | },
18 | {
19 | "object_class": "volmdlr.Point3D",
20 | "x": 0.43898336569100005,
21 | "y": 0.16094508066899998,
22 | "z": 0.421076858403
23 | },
24 | {
25 | "object_class": "volmdlr.Point3D",
26 | "x": 0.43898854518700003,
27 | "y": 0.160956515473,
28 | "z": 0.421073824314
29 | }
30 | ],
31 | "knot_multiplicities": [
32 | 4,
33 | 4
34 | ],
35 | "knots": [
36 | 0.0,
37 | 1.0
38 | ],
39 | "weights": null
40 | }
41 |
--------------------------------------------------------------------------------
/scripts/edges/bezier_curve.py:
--------------------------------------------------------------------------------
1 | import matplotlib.pyplot as plt
2 |
3 | import volmdlr as vm
4 | import volmdlr.edges as vme
5 |
6 | degree = 3
7 | points = [vm.Point2D(0, 0),
8 | vm.Point2D(1, 1),
9 | vm.Point2D(2, 0),
10 | vm.Point2D(3, 0)]
11 | bezier_curve2d = vme.BezierCurve2D(degree=degree,
12 | control_points=points,
13 | name='bezier curve 1')
14 | _, ax = plt.subplots()
15 | bezier_curve2d.plot(ax=ax)
16 | [p.plot(ax=ax) for p in points]
17 |
18 | degree = 3
19 | points = [vm.Point3D(0, 0, 0),
20 | vm.Point3D(1, 1, 2),
21 | vm.Point3D(2, 1, 1),
22 | vm.Point3D(3, 0, 4)]
23 | bezier_curve3d = vme.BezierCurve3D(degree=degree,
24 | control_points=points,
25 | name='bezier curve 1')
26 | fig = plt.figure()
27 | ax = fig.add_subplot(111, projection='3d')
28 | bezier_curve3d.plot(ax=ax)
29 | [p.plot(ax=ax) for p in points]
30 |
--------------------------------------------------------------------------------
/tests/faces/objects_toroidal_tests/repair_periodicity_toroidal_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
4 | "package_version": "0.10.1.dev658+gfad49fd5",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -1.094764425254e-50,
11 | "y": -0.009000000000000001,
12 | "z": 0.025
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -1.0,
17 | "y": -1.676329423595e-31,
18 | "z": 7.549516567451e-16
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 7.549516567451e-16,
23 | "y": -2.22044604925e-16,
24 | "z": 1.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -1.094764425254e-47,
29 | "y": 1.0,
30 | "z": 2.22044604925e-16
31 | }
32 | },
33 | "tore_radius": 0.006,
34 | "small_radius": 0.001
35 | }
36 |
--------------------------------------------------------------------------------
/tests/faces/objects_conical_tests/conicalsurface_openned_contours.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.00900000000000001,
10 | "y": 0.11964851784141177,
11 | "z": 5.515137490665171e-17
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": -0.8646277686547811,
16 | "y": 7.274680403093936e-16,
17 | "z": -0.5024129991063672
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.5024129991063672,
22 | "y": 1.2017966561130874e-15,
23 | "z": -0.8646277686547811
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": -2.51908061465977e-17,
28 | "y": -1.0,
29 | "z": -1.40459616103771e-15
30 | }
31 | },
32 | "semi_angle": 0.06669023307665163,
33 | "_references": {}
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_periodical_surface/periodicalsurface_with_theta_discontinuity.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.9.2.dev421+gb87a301e",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.09725,
11 | "y": 0.01,
12 | "z": 0.015
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 6.715189071568183e-16,
17 | "y": -0.2975977232990525,
18 | "z": 0.9546913611671682
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -2.283433425204094e-15,
23 | "y": 0.9546913611671682,
24 | "z": 0.2975977232990525
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -1.0,
29 | "y": -2.379816662765e-15,
30 | "z": -3.845128912216e-17
31 | }
32 | },
33 | "radius": 0.006500000000000001
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/toroidal_surface_bug_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
4 | "package_version": "0.9.2.dev1050+g45192f1d",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.0530011628631,
11 | "y": -4.51106e-15,
12 | "z": -1.2981e-16
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 1.109053685521875e-15,
17 | "y": 0.10670774857798797,
18 | "z": -0.9942904285938878
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 1.6425437586945144e-14,
23 | "y": 0.9942904285938878,
24 | "z": 0.10670774857798797
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": 1.0,
29 | "y": -1.645e-14,
30 | "z": -6.5e-16
31 | }
32 | },
33 | "tore_radius": 0.014855,
34 | "small_radius": 0.00012
35 | }
36 |
--------------------------------------------------------------------------------
/scripts/faces/faces_with_inner_contours.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Mon Feb 14 2022
5 |
6 | @author: s.bendjebla
7 | """
8 |
9 | import os
10 |
11 | import volmdlr.step
12 |
13 | for step_file in [
14 | 'bsplineface_with_inner_contours.stp',
15 | 'planeface_with_inner_contour.step']:
16 |
17 | print('Reading step file: ', step_file)
18 |
19 | filepath = os.path.join('../faces', step_file)
20 | step = volmdlr.step.Step.from_file(filepath=filepath)
21 | model = step.to_volume_model()
22 | primitives = model.primitives
23 |
24 | faces = []
25 | for primitive in primitives:
26 | faces.extend(primitive.faces)
27 |
28 | surfaces_3d, outer_contours_3d, inner_contours_3d = [], [], []
29 | for face in faces:
30 | surfaces_3d.append(face.surface3d)
31 | outer_contours_3d.append(face.outer_contour3d)
32 | inner_contours_3d.extend(face.inner_contours3d)
33 |
34 | assert len(inner_contours_3d) > 0
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/repair_primitives2d_periodicity_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
4 | "package_version": "0.10.1.dev658+gfad49fd5",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.247934063451,
11 | "y": 0.330343183539,
12 | "z": -0.0263800907512
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.10511771762205716,
17 | "y": 0.9301696163405057,
18 | "z": -0.3517595063091912
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.7789112690483753,
23 | "y": 0.142898566926436,
24 | "z": 0.6106367451438052
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": 0.6182616763081318,
29 | "y": -0.33817818440507214,
30 | "z": -0.7094984250871512
31 | }
32 | },
33 | "radius": 0.005
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/toroidalsurface_small_arc3d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
3 | "name": "NONE",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "NONE",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.2527095032079815,
10 | "y": -0.0683,
11 | "z": 0.435822726011444,
12 | "name": "NONE"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.9483196146266086,
17 | "y": 0.0,
18 | "z": 0.3173167321690435
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.3173167321690435,
23 | "y": -0.0,
24 | "z": -0.9483196146266086
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": 0.0,
29 | "y": -1.0,
30 | "z": 0.0,
31 | "name": "NONE"
32 | }
33 | },
34 | "major_radius": 4.344394702476925e-06,
35 | "minor_radius": 0.0005,
36 | "_references": {}
37 | }
38 |
--------------------------------------------------------------------------------
/tests/faces/test_face3d.py:
--------------------------------------------------------------------------------
1 | """
2 | Tests for faces 3D
3 | """
4 | import unittest
5 | import math
6 | import volmdlr
7 | from volmdlr import faces, surfaces
8 |
9 |
10 | class TestFace3D(unittest.TestCase):
11 | def test_point_distance(self):
12 | radius = 0.15
13 | cylindricalsurface = surfaces.CylindricalSurface3D(volmdlr.OXYZ, radius)
14 | cylindricalface = faces.CylindricalFace3D.from_surface_rectangular_cut(cylindricalsurface, 0,
15 | volmdlr.TWO_PI / 3, -.25,
16 | .25)
17 | point3d = volmdlr.Point3D(.05, .05, -0.05)
18 | distance, point1 = cylindricalface.point_distance(point3d, True)
19 | self.assertAlmostEqual(distance, 0.07871852659452186, 4)
20 | self.assertTrue(point1.is_close(volmdlr.Point3D(radius / math.sqrt(2), radius / math.sqrt(2), -0.05), 1e-3))
21 |
22 |
23 | if __name__ == '__main__':
24 | unittest.main()
25 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_cylindrical_tests/cylindrical_surf_bug.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.9.1.dev315+gc71707f1",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.29749999999999,
11 | "y": 0.4183699944751,
12 | "z": 0.28844210910124
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -5.356492657827514e-34,
17 | "y": 0.03489949670249335,
18 | "z": 0.9993908270190959
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.9999999999999998,
23 | "y": 9.226218474218244e-19,
24 | "z": -3.221866486186147e-20
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -9.231842263088887e-19,
29 | "y": -0.9993908270190959,
30 | "z": 0.03489949670249335
31 | }
32 | },
33 | "radius": 0.035052
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/buggy_contour3d_to_2d_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
4 | "package_version": "0.10.1.dev880+gebce815c",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.416502404239,
11 | "y": 0.289149622886,
12 | "z": 0.629557479802
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.0005177216601287984,
17 | "y": -0.00025833674727174905,
18 | "z": -0.9999998326131898
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.4999999354933651,
23 | "y": 0.866025440314654,
24 | "z": 3.513460724351489e-05
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": 0.8660252862768579,
29 | "y": 0.49999986998991797,
30 | "z": -0.0005775284856447052
31 | }
32 | },
33 | "radius": 0.0005
34 | }
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/contour3d_to_2d_surface_bspline_with_singularity.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
4 | "package_version": "0.10.1.dev658+gfad49fd5",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.494352345967,
11 | "y": 0.18359999999999999,
12 | "z": 0.0363
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.4332380633250017,
17 | "y": 0.1282654497050005,
18 | "z": 0.8921057980410035
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.09428464511704515,
23 | "y": 0.990840381555499,
24 | "z": -0.09667338813813281
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.8963343049227043,
29 | "y": 0.04222928712307607,
30 | "z": -0.4413632303758544
31 | }
32 | },
33 | "radius": 0.003
34 | }
35 |
--------------------------------------------------------------------------------
/ROADMAP.md:
--------------------------------------------------------------------------------
1 | # Volmdlr Road map
2 |
3 | This is the change roadmap for volmdlr.
4 | Once implemented, update CHANGELOG.md
5 |
6 | ## Short term (next month)
7 | ### Bugs
8 | * Edge width too big when rendering far from the origin
9 |
10 | ### Naming
11 | Formalize methods names:
12 | * discretise, discretization_points, polygon_points
13 |
14 | ### Refactorings
15 | * rotation, translation and frame_mapping: Divide each in two methods,
16 | where one modifies the object inplace and the other creates a new object. Delete copy parameter
17 | * replace normalize() methodes by to_normal(). The object should no more be modified inplace.
18 | * edges: CompositePrimitive Inheritance (use UML graphs)
19 | * duplicated methods
20 | * Grid of point class
21 |
22 | ### New features
23 | * BSpline3D extrusion
24 |
25 | ## Midterm (6 months)
26 | ### New features
27 | * ClosedShell3D offset
28 | * Remove triangle dependency: Surface2d with inner contour triangulation uses triangle.
29 | Wheel unavailable for windows for python3.9.
30 |
31 | ## LongTerm (1 year)
32 |
--------------------------------------------------------------------------------
/scripts/cloud/cloud_debug.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 |
4 | """
5 |
6 | import os
7 |
8 | import matplotlib.pyplot as plt
9 |
10 | import volmdlr as vm
11 | import volmdlr.cloud
12 | import volmdlr.core
13 | import volmdlr.edges as vme
14 | import volmdlr.faces as vmf
15 | import volmdlr.wires as vmw
16 |
17 | faces = []
18 | for file in os.listdir("E:/path/to/folder") :
19 | cloud = volmdlr.cloud.PointCloud3D.from_stl("E:/path/to/folder/" + file)
20 | cloud_faces = cloud.subdescription_2d()
21 |
22 | volum = volmdlr.core.VolumeModel(cloud_faces)
23 | print('len(cloud_faces)', len(cloud_faces))
24 | faces.extend(cloud_faces)
25 | # volum.save_to_file(file)
26 | print(file, len(faces))
27 |
28 | volum = volmdlr.core.VolumeModel(faces)
29 | volum.babylonjs()
30 |
31 | ################### READ STL
32 |
33 | # cloud3d = volmdlr.cloud.PointCloud3D.from_stl(path)
34 | # faces = cloud3d.subdescription_2d(resolution=20)
35 |
36 | # volum = volmdlr.core.VolumeModel(faces)
37 |
38 | # volum.babylonjs()
39 |
--------------------------------------------------------------------------------
/scripts/primitives/sphere_points.py:
--------------------------------------------------------------------------------
1 | """
2 | Demo script of spheres created on the skin of a defined sphere.
3 | """
4 | import math
5 | import random
6 |
7 | import volmdlr as vm
8 | import volmdlr.core as vmc
9 | import volmdlr.primitives3d as p3d
10 |
11 | center = vm.Point3D.random(0, 0.1, 0, 0.1, -0.1, 0)
12 | radius = random.randrange(5, 50, 5)
13 | radius *= 1e-3
14 |
15 |
16 | sphere = p3d.Sphere(center=center, radius=radius, color=(0.25, 0.33, 0.6), alpha=0.5)
17 |
18 | resolution = max([math.pi * radius / 10, 1e-3])
19 |
20 | skin_points = sphere.skin_points(resolution=resolution)
21 |
22 | spheres = [sphere]
23 | for pt in skin_points:
24 | spheres.append(p3d.Sphere(center=pt, radius=resolution / 4, color=(1, 0, 0)))
25 |
26 |
27 | points_in = sphere.inner_points(resolution=resolution)
28 |
29 | for pt in points_in:
30 | spheres.append(p3d.Sphere(center=pt, radius=resolution / 4, color=(0, 1, 0)))
31 |
32 | # all_points = point_skin + point_in
33 | # print(len(all_points))
34 |
35 | # vol = vmc.VolumeModel(spheres)
36 | # vol.babylonjs()
37 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_cylindrical_tests/cylindricalsurface_with_linesegment3d.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.10.1.dev1306+gb1e7b6c2",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 2.5816802383,
11 | "y": 0.440018305914,
12 | "z": 0.154103536225
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.07544168433179999,
17 | "y": -0.6041701140759197,
18 | "z": -0.7932761344718946
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.027252474631443698,
23 | "y": -0.7964953581999595,
24 | "z": 0.6040301705977779
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.9967777359530269,
29 | "y": -0.023950315726700644,
30 | "z": -0.07655408209200207
31 | }
32 | },
33 | "radius": 0.050000461653400004
34 | }
35 |
--------------------------------------------------------------------------------
/tests/edges/bsplinecurve_objects/bsplinecurve_close_points_trim_bug.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.BSplineCurve3D",
3 | "name": "",
4 | "degree": 3,
5 | "control_points": [
6 | {
7 | "object_class": "volmdlr.Point3D",
8 | "x": -0.54453079882,
9 | "y": -0.608700414709,
10 | "z": 0.27131578792
11 | },
12 | {
13 | "object_class": "volmdlr.Point3D",
14 | "x": -0.5441825825209999,
15 | "y": -0.609457422086,
16 | "z": 0.27134719443099997
17 | },
18 | {
19 | "object_class": "volmdlr.Point3D",
20 | "x": -0.543835646593,
21 | "y": -0.610249753327,
22 | "z": 0.271253190136
23 | },
24 | {
25 | "object_class": "volmdlr.Point3D",
26 | "x": -0.5435421630030001,
27 | "y": -0.6109197806800001,
28 | "z": 0.271104222993
29 | }
30 | ],
31 | "knot_multiplicities": [
32 | 4,
33 | 4
34 | ],
35 | "knots": [
36 | 0.0,
37 | 1.0
38 | ],
39 | "weights": [
40 | 1.0,
41 | 1.0,
42 | 1.0,
43 | 1.0
44 | ]
45 | }
46 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/spherical_surface_arc3d_to_2d.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
4 | "package_version": "0.9.2.dev1050+g45192f1d",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.22377378090900002,
11 | "y": 0.6129113573580001,
12 | "z": 0.5490037165170001
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.01718929301010151,
17 | "y": 0.06451687208023814,
18 | "z": -0.9977685610515072
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.003019055525513198,
23 | "y": -0.9979147998740441,
24 | "z": -0.06447431656156126
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.9998476951563902,
29 | "y": -0.0019040507684217431,
30 | "z": -0.01734822991331677
31 | }
32 | },
33 | "radius": 0.0005000000322590001
34 | }
35 |
--------------------------------------------------------------------------------
/scripts/mesh/model.msh:
--------------------------------------------------------------------------------
1 | $MeshFormat
2 | 4.1 0 8
3 | $EndMeshFormat
4 | $Entities
5 | 5 5 1 0
6 | 1 1 0 0 0
7 | 2 1 1 0 0
8 | 3 -1 1 0 0
9 | 4 -1 0 0 0
10 | 5 0 0 0 0
11 | 1 1 0 0 1 1 0 1 3 2 1 -2
12 | 2 -1 1 0 1 1 0 1 4 2 2 -3
13 | 3 -1 0 0 -1 1 0 1 5 2 3 -4
14 | 4 -1 0 0 0 0 0 1 1 2 4 -5
15 | 5 0 0 0 1 0 0 1 2 2 5 -1
16 | 14 -1 0 0 1 1 0 1 1 5 1 2 3 4 5
17 | $EndEntities
18 | $Nodes
19 | 11 8 1 8
20 | 0 1 0 1
21 | 1
22 | 1 0 0
23 | 0 2 0 1
24 | 2
25 | 1 1 0
26 | 0 3 0 1
27 | 3
28 | -1 1 0
29 | 0 4 0 1
30 | 4
31 | -1 0 0
32 | 0 5 0 1
33 | 5
34 | 0 0 0
35 | 1 1 0 0
36 | 1 2 0 1
37 | 6
38 | 2.752797989558076e-12 1 0
39 | 1 3 0 0
40 | 1 4 0 0
41 | 1 5 0 0
42 | 2 14 0 2
43 | 7
44 | 8
45 | -0.4999999999993118 0.5 0
46 | 0.5000000000013765 0.5 0
47 | $EndNodes
48 | $Elements
49 | 6 14 1 14
50 | 1 1 1 1
51 | 1 1 2
52 | 1 2 1 2
53 | 2 2 6
54 | 3 6 3
55 | 1 3 1 1
56 | 4 3 4
57 | 1 4 1 1
58 | 5 4 5
59 | 1 5 1 1
60 | 6 5 1
61 | 2 14 2 8
62 | 7 6 3 7
63 | 8 1 2 8
64 | 9 6 5 8
65 | 10 5 6 7
66 | 11 5 1 8
67 | 12 3 4 7
68 | 13 4 5 7
69 | 14 2 6 8
70 | $EndElements
71 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_conical_tests/conicalsurface_contour_with_singularity_2.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
3 | "name": "Cone",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "Cone Axis2P3D",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.116097844223,
10 | "y": 0.684858562185,
11 | "z": 0.643329658876
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": -0.1334834051627373,
16 | "y": 0.10304110278698116,
17 | "z": -0.9856798220936671
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.07256712264610667,
22 | "y": -0.9908942444364338,
23 | "z": -0.11341344300648959
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": -0.988390708808,
28 | "y": -0.0866667611034,
29 | "z": 0.12479054156,
30 | "name": "Axis2P3D Direction"
31 | }
32 | },
33 | "semi_angle": 1.28547682178,
34 | "_references": {}
35 | }
36 |
--------------------------------------------------------------------------------
/tests/faces/objects_toroidal_tests/surface_4.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
4 | "package_version": "0.9.2.dev1050+g45192f1d",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": -0.0151039281809,
11 | "y": -0.607972500966,
12 | "z": 0.539290846021
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.9920615864548847,
17 | "y": -0.0017710666966257943,
18 | "z": -0.1257404946839854
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.006073996234849267,
23 | "y": -0.9980589035547758,
24 | "z": 0.06198009039020319
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.12560619113106064,
29 | "y": -0.06225181409240006,
30 | "z": -0.9901251417834781
31 | }
32 | },
33 | "tore_radius": 0.029604283457000002,
34 | "small_radius": 0.00300428123044
35 | }
36 |
--------------------------------------------------------------------------------
/tests/primitives3d/test_sweep.py:
--------------------------------------------------------------------------------
1 | import unittest
2 |
3 | import volmdlr
4 | from volmdlr import wires, curves, faces, primitives3d
5 | from volmdlr.primitives3d import Sweep
6 |
7 |
8 | class TestSweep(unittest.TestCase):
9 | def test_init(self):
10 | path = primitives3d.OpenRoundedLineSegments3D([volmdlr.Point3D(1.0, 1.0, 0.0), volmdlr.Point3D(1.0, 0.5, 0.0),
11 | volmdlr.Point3D(0.5, 0.5, 0.0)], {"1": 0.2})
12 | section = wires.Contour2D([curves.Circle2D(volmdlr.OXY, 0.05)])
13 | sweep = Sweep(section, path)
14 | self.assertEqual(len(sweep.faces), 5)
15 | for face, expected_face_class in zip(sweep.faces, [faces.PlaneFace3D, faces.CylindricalFace3D,
16 | faces.ToroidalFace3D, faces.CylindricalFace3D,
17 | faces.PlaneFace3D]):
18 | self.assertTrue(isinstance(face, expected_face_class))
19 |
20 |
21 | if __name__ == '__main__':
22 | unittest.main()
23 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_conical_tests/conicalsurface_linesegment3d_to_2d.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ConicalSurface3D",
3 | "name": "Cone",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "Cone Axis2P3D",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": -0.4762151564543103,
10 | "y": -0.5229630828811836,
11 | "z": 0.2524801189661183
12 | },
13 | "u": {
14 | "object_class": "volmdlr.Vector3D",
15 | "x": 0.7288855380926383,
16 | "y": -0.6799312357076592,
17 | "z": 0.08012107755428997
18 | },
19 | "v": {
20 | "object_class": "volmdlr.Vector3D",
21 | "x": 0.6846260308854857,
22 | "y": 0.7244850219998281,
23 | "z": -0.08005404882147929
24 | },
25 | "w": {
26 | "object_class": "volmdlr.Vector3D",
27 | "x": -0.00361527229598,
28 | "y": 0.113203213768,
29 | "z": 0.993565278278,
30 | "name": "Axis2P3D Direction"
31 | }
32 | },
33 | "semi_angle": 0.0523598775598,
34 | "_references": {}
35 | }
36 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/toroidalsurface_small_bsplinecurve.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
3 | "name": "homeo Torus",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "Torus Axis2P3D",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 4.54461785509,
10 | "y": 2.54,
11 | "z": 2.54,
12 | "name": "Axis2P3D Location"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.0,
17 | "y": -0.9622890092057144,
18 | "z": -0.27202915792591925
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.0,
23 | "y": 0.27202915792591925,
24 | "z": -0.9622890092057144
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": 1.0,
29 | "y": 0.0,
30 | "z": -0.0,
31 | "name": "Axis2P3D Direction"
32 | }
33 | },
34 | "major_radius": 0.631333369262,
35 | "minor_radius": 0.009000000000000001,
36 | "_references": {}
37 | }
38 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/voxelization/compare_memory_usage.py:
--------------------------------------------------------------------------------
1 | """
2 | Compare memory usage of differents voxelization.
3 | """
4 | import math
5 | import time
6 |
7 | import volmdlr
8 | from pympler.asizeof import asizeof
9 | from volmdlr.discrete_representation import MatrixBasedVoxelization, OctreeBasedVoxelization, PointBasedVoxelization
10 | from volmdlr.step import Step
11 |
12 | STEP_MODEL_FILE_PATH = "../../step/tore1.step"
13 | VOXEL_SIZE = 0.00001
14 | TRANSLATION_VECTOR = volmdlr.Vector3D(-0.0015, 0.005, 0.01)
15 | ROTATION_ANGLE = math.pi / 2
16 |
17 | # Define the volume model from file
18 | volume_model = Step.from_file(STEP_MODEL_FILE_PATH).to_volume_model()
19 |
20 | matrix_based = MatrixBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE)
21 | print(asizeof(matrix_based) + matrix_based.matrix.nbytes)
22 |
23 | # point_based = PointBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE)
24 | # print(asizeof(point_based))
25 |
26 | octree_based = OctreeBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE)
27 | print(asizeof(octree_based))
28 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/buggy_toroidalface_surface.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
4 | "package_version": "0.10.1.dev880+gebce815c",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.433533699884,
11 | "y": -0.661941077825,
12 | "z": -0.0240598683568
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.24253156122501163,
17 | "y": -0.9701196616940465,
18 | "z": 0.006803220148360326
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.9693594462434011,
23 | "y": 0.24261146915832765,
24 | "z": 0.03849596097676366
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.038996227874565935,
29 | "y": -0.0027417198008670113,
30 | "z": 0.9992355964356396
31 | }
32 | },
33 | "tore_radius": 0.035,
34 | "small_radius": 0.007775000000000001
35 | }
36 |
--------------------------------------------------------------------------------
/tests/edges/test_beziercurve2d.py:
--------------------------------------------------------------------------------
1 | """
2 | Unit tests for volmdlr.faces.BSplineCurve
3 | """
4 | import unittest
5 | import volmdlr
6 | import volmdlr.edges as vme
7 |
8 |
9 | class TestBezierCurve2D(unittest.TestCase):
10 | # Set up the Bézier curve
11 | degree = 2
12 | ctrlpts = [volmdlr.Point2D(10, 0), volmdlr.Point2D(20, 15), volmdlr.Point2D(30, 0)]
13 |
14 | curve1 = vme.BezierCurve2D(degree, ctrlpts)
15 |
16 | # Set evaluation delta
17 | curve1.sample_size = 5
18 |
19 | def test_setup(self):
20 | points = self.curve1.points
21 | expected_points = [[10.0, 0.0], [15.0, 5.625], [20.0, 7.5], [25.0, 5.625], [30.0, 0.0]]
22 | expected_knot_vector = [0.0, 0.0, 0.0, 1.0, 1.0, 1.0]
23 |
24 | self.assertEqual(self.curve1.knotvector.tolist(), expected_knot_vector)
25 | for point, test in zip(points, expected_points):
26 | self.assertAlmostEqual(point[0], test[0], delta=1e-6)
27 | self.assertAlmostEqual(point[1], test[1], delta=1e-6)
28 |
29 |
30 | if __name__ == '__main__':
31 | unittest.main()
32 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_toroidal_tests/degenerated_toroidalsurface.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.ToroidalSurface3D",
3 | "name": "NONE",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "NONE",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.0,
10 | "y": 0.0,
11 | "z": -17.500000000000025,
12 | "name": "NONE"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.0,
17 | "y": -1.0,
18 | "z": 1.8503717077085942e-18
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 1.0,
23 | "y": 0.0,
24 | "z": 0.0
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.0,
29 | "y": 1.8503717077085942e-18,
30 | "z": 1.0,
31 | "name": "NONE"
32 | }
33 | },
34 | "major_radius": 21.499386962957114,
35 | "minor_radius": 25.249386962957125,
36 | "outer_radius": 46.748773925914236,
37 | "inner_radius": 3.7500000000000107,
38 | "_references": {}
39 | }
40 |
--------------------------------------------------------------------------------
/tests/faces/objects_spherical_test/sphericalsurface_contour3d_to_2d_bug.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "Sphere Axis2P3D",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.273051294789,
10 | "y": -0.13160032451800002,
11 | "z": 0.723556855126,
12 | "name": "Axis2P3D Location"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": 0.16154004971738017,
17 | "y": 0.1127993983299097,
18 | "z": 0.9803984435288119
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": -0.1152839969384589,
23 | "y": 0.9888013361128069,
24 | "z": -0.09477086973929691
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.98010938797,
29 | "y": -0.0977149601528,
30 | "z": 0.172734982488,
31 | "name": "Axis2P3D Direction"
32 | }
33 | },
34 | "radius": 0.001,
35 | "_references": {}
36 | }
37 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_cylindrical_tests/cylindricalsurface_small_periodic_bsplinecurve.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
3 | "name": "NONE",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "NONE",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 2.01455388806,
10 | "y": 0.695923870742,
11 | "z": 0.736781182049,
12 | "name": "NONE"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.03714375242104866,
17 | "y": -0.9322882243623151,
18 | "z": -0.3598041250061561
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.13358121197435527,
23 | "y": 0.3521891369649292,
24 | "z": -0.9263470578629593
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": 0.9903415579806526,
29 | "y": -0.08247107686492336,
30 | "z": 0.11145456481092955,
31 | "name": "NONE"
32 | }
33 | },
34 | "radius": 0.000999999999999983,
35 | "_references": {}
36 | }
37 |
--------------------------------------------------------------------------------
/tests/test_core.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Testing core module functions
5 | """
6 |
7 | import math
8 | import unittest
9 |
10 | import numpy as npy
11 |
12 | import volmdlr as vm
13 | import volmdlr.wires
14 |
15 |
16 | class TestContour(unittest.TestCase):
17 |
18 | def test_is_overlapping(self):
19 |
20 | v2D_1 = vm.Vector2D.random(-3, 3, -3, 3)
21 |
22 | # Testing if normalized vector has norm ==1 and is still colinear to original vector
23 | v2D_1_normalized = v2D_1.copy()
24 | v2D_1_normalized = v2D_1_normalized.unit_vector()
25 | self.assertAlmostEqual(v2D_1_normalized.norm(), 1)
26 | self.assertAlmostEqual(v2D_1_normalized.dot(v2D_1), v2D_1.norm())
27 | # Testing normal vector
28 | normal_v2D_1 = v2D_1.normal_vector()
29 | self.assertAlmostEqual(normal_v2D_1.dot(v2D_1), 0)
30 | normal_unit_v2D_1 = v2D_1.unit_normal_vector()
31 | self.assertAlmostEqual(normal_unit_v2D_1.norm(), 1.)
32 |
33 |
34 | if __name__ == '__main__':
35 | unittest.main(verbosity=0)
36 |
--------------------------------------------------------------------------------
/tests/wires/strange_contour_from_step_primitives.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.core.VolumeModel",
3 | "name": "",
4 | "primitives": [
5 | {
6 | "object_class": "volmdlr.edges.LineSegment3D",
7 | "name": "",
8 | "start": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.344020971284,
11 | "y": 0.150247152124,
12 | "z": 0.362454876962
13 | },
14 | "end": {
15 | "object_class": "volmdlr.Point3D",
16 | "x": 0.344020971919,
17 | "y": 0.15036965205800001,
18 | "z": 0.362454876697
19 | }
20 | },
21 | {
22 | "object_class": "volmdlr.edges.LineSegment3D",
23 | "name": "",
24 | "start": {
25 | "object_class": "volmdlr.Point3D",
26 | "x": 0.344020971919,
27 | "y": 0.15036965205800001,
28 | "z": 0.362454876697
29 | },
30 | "end": {
31 | "object_class": "volmdlr.Point3D",
32 | "x": 0.344020971284,
33 | "y": 0.150247152124,
34 | "z": 0.362454876962
35 | }
36 | }
37 | ],
38 | "_references": {}
39 | }
40 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/voxelization/volume_model_matrix_based_voxelization.py:
--------------------------------------------------------------------------------
1 | """
2 | Voxelization of a volume model using MatrixBasedVoxelization.
3 |
4 | In MatrixBasedVoxelization, voxels are stored as a 3D numpy array of np.bool_.
5 | """
6 | import volmdlr
7 | from volmdlr.core import VolumeModel
8 | from volmdlr.discrete_representation import MatrixBasedVoxelization
9 | from volmdlr.primitives3d import Cylinder, Sphere
10 |
11 | VOXEL_SIZE = 0.01
12 |
13 | # Create a volume model
14 | sphere = Sphere(volmdlr.O3D, 0.1, name="Sphere")
15 | cylinder = Cylinder(volmdlr.OXYZ.translation(0.1 * volmdlr.Z3D), 0.1, 0.2, name="Cylinder")
16 | volume_model = VolumeModel([sphere, cylinder])
17 |
18 | # Voxelize the volume model
19 | voxelization = MatrixBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE, name="Voxelization")
20 |
21 | # Display the result
22 | voxelization_primitive = voxelization.to_mesh().split_shared_vertices()
23 | voxelization_primitive.alpha = 0.5
24 | voxelization_primitive.color = (1, 0, 0)
25 |
26 | volume_model.primitives.append(voxelization_primitive)
27 | volume_model.babylonjs()
28 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/voxelization/volume_model_point_based_voxelization.py:
--------------------------------------------------------------------------------
1 | """
2 | Voxelization of a volume model using PointBasedVoxelization.
3 |
4 | In PointBasedVoxelization, voxels are stored as a Set[Tuple[float, float, float]].
5 | """
6 | import volmdlr
7 | from volmdlr.core import VolumeModel
8 | from volmdlr.discrete_representation import PointBasedVoxelization
9 | from volmdlr.primitives3d import Cylinder, Sphere
10 |
11 | VOXEL_SIZE = 0.01
12 |
13 | # Create a volume model
14 | sphere = Sphere(volmdlr.O3D, 0.1, name="Sphere")
15 | cylinder = Cylinder(volmdlr.OXYZ.translation(0.1 * volmdlr.Z3D), 0.1, 0.2, name="Cylinder")
16 | volume_model = VolumeModel([sphere, cylinder])
17 |
18 | # Voxelize the volume model
19 | voxelization = PointBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE, name="Voxelization")
20 |
21 | # Display the result
22 | voxelization_primitive = voxelization.to_mesh().split_shared_vertices()
23 | voxelization_primitive.alpha = 0.5
24 | voxelization_primitive.color = (1, 0, 0)
25 |
26 | volume_model.primitives.append(voxelization_primitive)
27 | volume_model.babylonjs()
28 |
--------------------------------------------------------------------------------
/tests/faces/objects_cylindrical_tests/cylindrical_surface_floating_point_error.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "NONE",
3 | "object_class": "volmdlr.surfaces.CylindricalSurface3D",
4 | "package_version": "0.9.2.dev937+g422e6dac",
5 | "frame": {
6 | "object_class": "volmdlr.Frame3D",
7 | "name": "",
8 | "origin": {
9 | "object_class": "volmdlr.Point3D",
10 | "x": 0.7193487918634601,
11 | "y": -0.3578372866658805,
12 | "z": 0.5720698394166079,
13 | "name": "NONE"
14 | },
15 | "u": {
16 | "object_class": "volmdlr.Vector3D",
17 | "x": -0.9284916153431515,
18 | "y": 0.2547089345361659,
19 | "z": -0.27023448874064243,
20 | "name": "NONE"
21 | },
22 | "v": {
23 | "object_class": "volmdlr.Vector3D",
24 | "x": 0.2634151418459372,
25 | "y": -0.06119424044859578,
26 | "z": -0.9627396989748601
27 | },
28 | "w": {
29 | "object_class": "volmdlr.Vector3D",
30 | "x": -0.2617551972431085,
31 | "y": -0.9650795944394129,
32 | "z": -0.01027585095647362
33 | }
34 | },
35 | "radius": 0.0004999999999999944
36 | }
37 |
--------------------------------------------------------------------------------
/scripts/geometry.py:
--------------------------------------------------------------------------------
1 | import math
2 | import random
3 |
4 | import matplotlib.pyplot as plt
5 |
6 | import volmdlr.geometry as vmg
7 |
8 | for (x1, x2, cos_min, cos_max) in [(0., 0.1, math.cos(0.1), 1),
9 | (0.1, 0.2, math.cos(0.2), math.cos(0.1))]:
10 | fx1, fx2 = vmg.cos_image(x1, x2)
11 | assert fx1 == cos_min
12 | assert fx2 == cos_max
13 |
14 |
15 | # Visual test
16 | x = [i/200.*4*math.pi-2*math.pi for i in range(200)]
17 | cosx = [math.cos(xi) for xi in x]
18 | sinx = [math.sin(xi) for xi in x]
19 |
20 |
21 | for i in range(3):
22 | fig, (ax1, ax2) = plt.subplots(2)
23 | ax1.plot(x, cosx)
24 | ax2.plot(x, sinx)
25 |
26 | x1 = random.uniform(-2*math.pi, 2*math.pi)
27 | x2 = random.uniform(-2 * math.pi, 2 * math.pi)
28 | x1, x2 = sorted([x1,x2])
29 | cos_min, cos_max = vmg.cos_image(x1, x2)
30 | sin_min, sin_max = vmg.sin_image(x1, x2)
31 |
32 | ax1.plot([x1, x2, x2, x1, x1], [cos_min, cos_min, cos_max, cos_max, cos_min], color='r')
33 | ax2.plot([x1, x2, x2, x1, x1], [sin_min, sin_min, sin_max, sin_max, sin_min], color='r')
34 | # print(x1, x2)
35 |
--------------------------------------------------------------------------------
/tests/surfaces/objects_spherical_tests/sphericalsurface_contour3d_to_2d_positive_singularity.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.surfaces.SphericalSurface3D",
3 | "name": "",
4 | "frame": {
5 | "object_class": "volmdlr.Frame3D",
6 | "name": "Sphere Axis2P3D",
7 | "origin": {
8 | "object_class": "volmdlr.Point3D",
9 | "x": 0.0033112698129500002,
10 | "y": 0.010449875793400001,
11 | "z": -0.00390121935764,
12 | "name": "Axis2P3D Location"
13 | },
14 | "u": {
15 | "object_class": "volmdlr.Vector3D",
16 | "x": -0.1500119627790206,
17 | "y": -0.9772373417171345,
18 | "z": -0.15001196277902065
19 | },
20 | "v": {
21 | "object_class": "volmdlr.Vector3D",
22 | "x": 0.6910111511573434,
23 | "y": -0.21214895228043462,
24 | "z": 0.6910111511573434
25 | },
26 | "w": {
27 | "object_class": "volmdlr.Vector3D",
28 | "x": -0.707106781187,
29 | "y": -2.77555756156e-17,
30 | "z": 0.707106781187,
31 | "name": "Axis2P3D Direction"
32 | }
33 | },
34 | "radius": 0.000199999985418,
35 | "_references": {}
36 | }
37 |
--------------------------------------------------------------------------------
/doc/source/_static/index-images/user_guide.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/scripts/core/grid2d_with_direction.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 | @author: s.bendjebla
6 | """
7 |
8 | # %% Libraries
9 |
10 | import matplotlib.pyplot as plt
11 |
12 | import volmdlr.grid
13 |
14 | # %% Grid2d definition 'with direction'
15 |
16 | fig, axs = plt.subplots(2, 4)
17 |
18 | points_x, points_y, xmin, xmax, ymin, ymax = 5, 5, 0, 1, 0, 1
19 |
20 | grid2d_directions = [[['+x','+y'], ['-x','+y'], ['+y','+x'], ['-y','+x']],
21 | [['+x','-y'], ['-x','-y'], ['+y','-x'], ['-y','-x']]]
22 |
23 | for i in range(0, len(grid2d_directions)):
24 | for j in range(0, len(grid2d_directions[i])):
25 | grid2d = volmdlr.grid.Grid2D.from_properties((xmin, xmax), (ymin, ymax), (points_x, points_y), grid2d_directions[i][j]).points
26 |
27 | for k, p in enumerate(grid2d):
28 | if k 0.
26 | model.to_step(step_file+'_reexport')
27 | model.primitives[0].alpha = 0.6
28 | model.primitives[0].color = (1, 0.1, 0.1)
29 | model.babylonjs()
30 |
31 | file_io = io.FileIO(step_file, 'r')
32 | step = volmdlr.step.Step.from_stream(stream=file_io)
33 | model = step.to_volume_model()
34 | assert len(model.primitives) > 0.
35 | model.to_step(step_file + '_reexport')
36 |
37 | model2 = model.copy()
38 |
39 | # model2 = model.copy()
40 | # assert model == model2
41 |
42 | model._check_platform()
43 |
--------------------------------------------------------------------------------
/scripts/primitives/extrusion2.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 | Created on Sun Mar 5 22:01:35 2017
5 |
6 | @author: steven
7 |
8 |
9 | """
10 |
11 | import math
12 |
13 | #import numpy as npy
14 | import volmdlr as vm
15 | import volmdlr.core
16 | import volmdlr.core as vmc
17 | import volmdlr.edges as vme
18 | import volmdlr.primitives2d as primitives2d
19 | import volmdlr.primitives3d as primitives3d
20 | import volmdlr.wires as vmw
21 |
22 | p1=vm.Point2D(0, 0)
23 | p2=vm.Point2D(0.1, 0.)
24 | p3=vm.Point2D(0.1, 0.2)
25 | p4=vm.Point2D(0, 0.1)
26 | p5=vm.Point2D(-0.01, 0.05)
27 |
28 | #p6=vm.Point2D((0.1,0.3))
29 |
30 | l1 = primitives2d.OpenedRoundedLineSegments2D([p1, p2, p3, p4], {2: 0.01})
31 | l2 = vme.Arc2D.from_3_points(p4, p5, p1)
32 | c1 = vmw.Contour2D([l1, l2])
33 | c2 = c1.rotation(vm.Point2D(0,0), math.pi)
34 | ax = c1.plot()
35 | c2.plot(ax=ax, edge_style=volmdlr.core.EdgeStyle(color='r'))
36 | #c3 = vm.Contour2D([c1, c2])
37 | #c3.MPLPlot()
38 |
39 |
40 |
41 |
42 | profile = primitives3d.ExtrudedProfile(vm.OYZX, c1, [], 0.1)
43 |
44 | model = vmc.VolumeModel([profile])
45 | model.babylonjs()
46 |
47 | #profile.MPLPlot((0,0,0),(1,0,0),(0,1,0))
48 |
49 | #model.MPLPlot()
50 |
51 | #model.FreeCADExport('extrusion2')
52 |
--------------------------------------------------------------------------------
/tests/utils/test_step_reader.py:
--------------------------------------------------------------------------------
1 | import unittest
2 | import volmdlr
3 | from volmdlr.curves import Line3D
4 | from volmdlr.utils import step_reader
5 |
6 |
7 | class TestStepReader(unittest.TestCase):
8 | def test_trimmed_curve(self):
9 | point1 = volmdlr.Point3D(2.2, -1.0, 0.05)
10 | point2 = volmdlr.Point3D(2.201, -1.0, 0.05)
11 | object_dict = {326: Line3D(point1, point2)}
12 | arguments = ["'n° 6246'", 326, '(PARAMETER_VALUE(0.0))', '(PARAMETER_VALUE(20.0))', '.T.', '.PARAMETER.']
13 | linesegment = step_reader.trimmed_curve(arguments, object_dict, length_conversion_factor=0.001)
14 | self.assertAlmostEqual(linesegment.length(), 0.02)
15 |
16 | point1 = volmdlr.Point3D(2.2, -1.0, 0.05)
17 | point2 = volmdlr.Point3D(2.201, -1.0, 0.05)
18 | object_dict = {326: Line3D(point1, point2),
19 | 327: volmdlr.Point3D(0.0, -1.0, 0.05), 328: volmdlr.Point3D(1.0, -1.0, 0.05)}
20 | arguments = ["'n° 6246'", 326, ['#327'], ['#328'], '.T.', '.CARTESIAN.']
21 | linesegment = step_reader.trimmed_curve(arguments, object_dict, length_conversion_factor=0.001)
22 | self.assertAlmostEqual(linesegment.length(), 1.0)
23 |
24 |
25 | if __name__ == '__main__':
26 | unittest.main()
27 |
--------------------------------------------------------------------------------
/tests/edges/bsplinecurve_objects/bounding_box_test.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.BSplineCurve3D",
3 | "name": "",
4 | "degree": 5,
5 | "control_points": [
6 | {
7 | "object_class": "volmdlr.Point3D",
8 | "x": -0.232426315401,
9 | "y": 0.21889228696,
10 | "z": 0.645103182834
11 | },
12 | {
13 | "object_class": "volmdlr.Point3D",
14 | "x": -0.232426315428,
15 | "y": 0.218643443105,
16 | "z": 0.639564810193
17 | },
18 | {
19 | "object_class": "volmdlr.Point3D",
20 | "x": -0.232426315462,
21 | "y": 0.22469446987,
22 | "z": 0.632789376358
23 | },
24 | {
25 | "object_class": "volmdlr.Point3D",
26 | "x": -0.232426315443,
27 | "y": 0.233204302738,
28 | "z": 0.636470842982
29 | },
30 | {
31 | "object_class": "volmdlr.Point3D",
32 | "x": -0.232426315421,
33 | "y": 0.235009149495,
34 | "z": 0.641071615372
35 | },
36 | {
37 | "object_class": "volmdlr.Point3D",
38 | "x": -0.232426315401,
39 | "y": 0.23514228696,
40 | "z": 0.645103182834
41 | }
42 | ],
43 | "knot_multiplicities": [
44 | 6,
45 | 6
46 | ],
47 | "knots": [
48 | 0.0,
49 | 1.0
50 | ],
51 | "weights": null
52 | }
53 |
--------------------------------------------------------------------------------
/tests/curves/circle2d_objects/test_circle2d_line2d_intersections.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.core.VolumeModel",
3 | "name": "",
4 | "primitives": [
5 | {
6 | "object_class": "volmdlr.curves.Circle2D",
7 | "name": "",
8 | "radius": 0.1305565935353425,
9 | "frame": {
10 | "object_class": "volmdlr.Frame2D",
11 | "name": "",
12 | "origin": {
13 | "object_class": "volmdlr.Point2D",
14 | "x": 0.0,
15 | "y": 0.0
16 | },
17 | "u": {
18 | "object_class": "volmdlr.Vector2D",
19 | "x": 1.0,
20 | "y": 0.0,
21 | "name": ""
22 | },
23 | "v": {
24 | "object_class": "volmdlr.Vector2D",
25 | "x": 0.0,
26 | "y": 1.0,
27 | "name": ""
28 | }
29 | }
30 | },
31 | {
32 | "object_class": "volmdlr.curves.Line2D",
33 | "name": "",
34 | "point1": {
35 | "object_class": "volmdlr.Point2D",
36 | "x": 0.031959341501134664,
37 | "y": -0.01426122455161768
38 | },
39 | "point2": {
40 | "object_class": "volmdlr.Point2D",
41 | "x": 0.03195934150113461,
42 | "y": 0.014261224551617544
43 | }
44 | }
45 | ],
46 | "_references": {}
47 | }
48 |
--------------------------------------------------------------------------------
/scripts/discrete_representation/voxelization/voxelization_decimation.py:
--------------------------------------------------------------------------------
1 | """
2 | Example of voxelization decimation.
3 | """
4 | from volmdlr.discrete_representation import MatrixBasedVoxelization
5 | from volmdlr.stl import Stl
6 |
7 | VOXEL_SIZE = 0.0015
8 | STL_MODEL_FILE_PATH = "../../stl/simple.stl"
9 |
10 | # Load and convert the STL
11 | volume_model = Stl.load_from_file(STL_MODEL_FILE_PATH).to_volume_model()
12 |
13 | # Voxelize the model
14 | voxelization = MatrixBasedVoxelization.from_volume_model(volume_model, VOXEL_SIZE, name="Voxelization")
15 |
16 | # Display the result
17 | voxelization_primitive = voxelization.to_mesh()
18 | voxelization_primitive.alpha = 0.5
19 | voxelization_primitive.color = (1, 0, 0)
20 |
21 | volume_model.primitives.append(voxelization_primitive)
22 | volume_model.babylonjs()
23 |
24 | voxelization_primitive_decimated = voxelization_primitive.decimate(500, preserve_border=True)
25 | voxelization_primitive_decimated.alpha = 0.5
26 | voxelization_primitive_decimated.color = (1, 0, 0)
27 |
28 | volume_model.primitives[-1] = voxelization_primitive_decimated
29 | volume_model.babylonjs()
30 |
31 | print(f"Number of triangles before decimation: {voxelization_primitive.n_triangles}")
32 | print(f"Number of triangles after decimation: {voxelization_primitive_decimated.n_triangles}")
33 |
--------------------------------------------------------------------------------
/scripts/primitives/extrusion3.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # -*- coding: utf-8 -*-
3 | """
4 |
5 | """
6 |
7 | import math
8 |
9 | import volmdlr as vm
10 | import volmdlr.core as vmc
11 | import volmdlr.edges
12 | import volmdlr.edges as vme
13 | import volmdlr.wires as vmw
14 | from volmdlr.primitives3d import ExtrudedProfile
15 | from volmdlr import curves
16 | number_holes = 5
17 |
18 | outer_circle = vmw.Contour2D([volmdlr.edges.FullArc2D.from_curve(curves.Circle2D(vm.OXY, 0.06))])
19 |
20 |
21 | delta_angle = 2*math.pi/number_holes
22 | inner_circle = vmw.Contour2D([volmdlr.edges.FullArc2D.from_curve(curves.Circle2D(vm.OXY, 0.04))])
23 | first_circle = vmw.Contour2D([volmdlr.edges.FullArc2D.from_curve(curves.Circle2D(
24 | vm.OXY.translation(vm.Vector2D(0, 0.05)), 0.005))])
25 | circles = [inner_circle, first_circle]
26 |
27 | extrusion_length = 0.1
28 |
29 | for i in range(1, number_holes):
30 | circles.append(first_circle.rotation(vm.O2D, i*delta_angle))
31 |
32 |
33 | extrusion = ExtrudedProfile(vm.OYZX, outer_circle, circles, extrusion_length)
34 |
35 | inner_circles_area = sum([c.area() for c in circles])
36 | assert math.isclose(extrusion.volume(), (outer_circle.area() - inner_circles_area)*extrusion_length)
37 |
38 | model = vmc.VolumeModel([extrusion])
39 | model.babylonjs()
40 | model._check_platform()
41 |
--------------------------------------------------------------------------------
/tests/edges/arc_objects/arc_abscissa_bug.json:
--------------------------------------------------------------------------------
1 | {
2 | "object_class": "volmdlr.edges.Arc3D",
3 | "name": "",
4 | "circle": {
5 | "object_class": "volmdlr.curves.Circle3D",
6 | "name": "",
7 | "radius": 0.0082,
8 | "frame": {
9 | "object_class": "volmdlr.Frame3D",
10 | "name": "",
11 | "origin": {
12 | "object_class": "volmdlr.Point3D",
13 | "x": 0.606019165039,
14 | "y": -0.637646466964,
15 | "z": 0.0007718529701200012
16 | },
17 | "u": {
18 | "object_class": "volmdlr.Point3D",
19 | "x": -0.7071067811863745,
20 | "y": 0.0,
21 | "z": 0.7071067811867205
22 | },
23 | "v": {
24 | "object_class": "volmdlr.Point3D",
25 | "x": 0.7071067811867205,
26 | "y": -0.0,
27 | "z": 0.7071067811863745
28 | },
29 | "w": {
30 | "object_class": "volmdlr.Point3D",
31 | "x": 0.0,
32 | "y": 1.0,
33 | "z": 0.0
34 | }
35 | }
36 | },
37 | "start": {
38 | "object_class": "volmdlr.Point3D",
39 | "x": 0.606019165039,
40 | "y": -0.637646466964,
41 | "z": -0.00742814702988
42 | },
43 | "end": {
44 | "object_class": "volmdlr.Point3D",
45 | "x": 0.606019165039,
46 | "y": -0.637646466964,
47 | "z": 0.00897185297012
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/scripts/cad_simplification/alpha_wrap_simplify.py:
--------------------------------------------------------------------------------
1 | """
2 | Showcase of the 'AlphaWrapSimplify' class.
3 | """
4 | import time
5 |
6 | from volmdlr.cad_simplification import AlphaWrapSimplify
7 | from volmdlr.step import Step
8 |
9 | # Load
10 | volume_model = Step.from_file("../step/engine.step").to_volume_model()
11 |
12 | # Simplify
13 | start = time.perf_counter()
14 | simplifier = AlphaWrapSimplify(volume_model=volume_model)
15 | simplified_volume_model = simplifier.simplify(relative_alpha=15, relative_offset=420, preserve_shells=False)
16 |
17 | print(f"Simplification took {time.perf_counter() - start:.6f} seconds\n")
18 |
19 | # Count faces triangles:
20 | n_faces = sum(len(shell.faces) for shell in volume_model.get_shells())
21 | n_triangles = sum(len(shell.triangulation().triangles) for shell in volume_model.get_shells())
22 | print(f"Given model has {n_faces} faces and {n_triangles} triangles when triangulated for display.")
23 |
24 | n_triangles = sum(len(shell.triangles) for shell in simplified_volume_model.get_shells())
25 | print(f"Simplified model mesh has {n_triangles} triangles.")
26 |
27 | # Display
28 | for simplified_shell in simplified_volume_model.get_shells():
29 | simplified_shell.color = (1.0, 0.0, 0.0)
30 | simplified_shell.alpha = 0.6
31 | volume_model.primitives.append(simplified_shell)
32 |
33 | volume_model.babylonjs()
34 |
--------------------------------------------------------------------------------
/scripts/distance/ls3D_ls3D.py:
--------------------------------------------------------------------------------
1 | # -*- coding: utf-8 -*-
2 | """
3 | Created on Fri May 22 11:14:46 2020
4 |
5 | @author: Mack Pro
6 | """
7 |
8 | import random
9 |
10 | import matplotlib.pyplot as plt
11 | import numpy as npy
12 |
13 | import volmdlr as volmdlr
14 | import volmdlr.primitives2D as primitives2D
15 | import volmdlr.primitives3D as primitives3D
16 |
17 | ### Cas random
18 | mini, maxi = -5, 5
19 |
20 | pt1 = volmdlr.Point3D((random.randint(mini, maxi),random.randint(mini, maxi),random.randint(mini, maxi)))
21 | pt2 = volmdlr.Point3D((random.randint(mini, maxi),random.randint(mini, maxi),random.randint(mini, maxi)))
22 | ptmid = ( pt1 + pt2 )/2
23 | pt3 = volmdlr.Point3D((random.randint(mini, maxi),random.randint(mini, maxi),random.randint(mini, maxi)))
24 | pt4 = volmdlr.Point3D((random.randint(mini, maxi),random.randint(mini, maxi),random.randint(mini, maxi)))
25 | ptmid2 = (pt3 + pt4)/2
26 |
27 | LS1 = volmdlr.LineSegment3D(pt1, pt2)
28 | LS2 = volmdlr.LineSegment3D(pt3, pt4)
29 |
30 |
31 | fig = plt.figure()
32 | ax = fig.add_subplot(111, projection='3d')
33 | pt1.MPLPlot(ax=ax)
34 | pt2.MPLPlot(ax=ax, color='r')
35 | LS1.MPLPlot(ax=ax)
36 |
37 | pt3.MPLPlot(ax=ax, color='g')
38 | pt4.MPLPlot(ax=ax, color='b')
39 | LS2.MPLPlot(ax=ax)
40 | ptmid.MPLPlot(ax=ax)
41 | ptmid2.MPLPlot(ax=ax)
42 |
43 | d_min = LS1.minimum_distance(LS2)
44 | print(d_min)
45 |
--------------------------------------------------------------------------------
/tests/core/test_functions.py:
--------------------------------------------------------------------------------
1 | """
2 | Unit tests for functions defined in volmdlr.core.py
3 | """
4 | import unittest
5 | import volmdlr
6 | from volmdlr.core import delete_double_point, step_ids_to_str
7 |
8 |
9 | class TestDeleteDoublePoint(unittest.TestCase):
10 | def setUp(self):
11 | self.points = [
12 | volmdlr.Point3D(0.0, 0.0, 0.0),
13 | volmdlr.Point3D(1.0, 1.0, 1.0),
14 | volmdlr.Point3D(0.0, 0.0, 0.0),
15 | volmdlr.Point3D(2.0, 2.0, 2.0),
16 | ]
17 |
18 | def test_delete_double_point(self):
19 | result = delete_double_point(self.points)
20 |
21 | self.assertEqual(len(result), 3)
22 | self.assertTrue(volmdlr.Point3D(0.0, 0.0, 0.0) in result)
23 | self.assertTrue(volmdlr.Point3D(1.0, 1.0, 1.0) in result)
24 | self.assertTrue(volmdlr.Point3D(2.0, 2.0, 2.0) in result)
25 |
26 |
27 | class TestStepIdsToStr(unittest.TestCase):
28 | ids_0 = [0]
29 | ids_1 = [1, 2, 3, 4, 5]
30 | ids_2 = [11, 22, 33, 44, 55]
31 |
32 | def test_step_ids_to_str(self):
33 | self.assertEqual(step_ids_to_str(self.ids_0), "#0")
34 | self.assertEqual(step_ids_to_str(self.ids_1), "#1,#2,#3,#4,#5")
35 | self.assertEqual(step_ids_to_str(self.ids_2), "#11,#22,#33,#44,#55")
36 |
37 |
38 | if __name__ == "__main__":
39 | unittest.main()
40 |
--------------------------------------------------------------------------------
/tests/faces/objects_conical_tests/face_contour4_.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "",
3 | "object_class": "volmdlr.wires.Contour3D",
4 | "package_version": "0.7.1.dev905+g8a826d99",
5 | "color": null,
6 | "alpha": 1,
7 | "primitives": [
8 | {
9 | "object_class": "volmdlr.edges.FullArc3D",
10 | "name": "",
11 | "circle": {
12 | "object_class": "volmdlr.curves.Circle3D",
13 | "name": "",
14 | "radius": 0.00775,
15 | "frame": {
16 | "object_class": "volmdlr.Frame3D",
17 | "name": "",
18 | "origin": {
19 | "object_class": "volmdlr.Point3D",
20 | "x": 0.0,
21 | "y": 0.0,
22 | "z": 0.0111
23 | },
24 | "u": {
25 | "object_class": "volmdlr.Vector3D",
26 | "x": 1.0,
27 | "y": 0.0,
28 | "z": 0.0
29 | },
30 | "v": {
31 | "object_class": "volmdlr.Point3D",
32 | "x": 0.0,
33 | "y": -1.0,
34 | "z": 0.0
35 | },
36 | "w": {
37 | "object_class": "volmdlr.Point3D",
38 | "x": 0.0,
39 | "y": 0.0,
40 | "z": -1.0
41 | }
42 | }
43 | },
44 | "angle": 6.283185307179586,
45 | "is_trigo": true,
46 | "start_end": {
47 | "object_class": "volmdlr.Point3D",
48 | "x": -0.00775,
49 | "y": 0.0,
50 | "z": 0.0111
51 | }
52 | }
53 | ],
54 | "basis_primitives": []
55 | }
56 |
--------------------------------------------------------------------------------