-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create body from surface (#1454)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
- Loading branch information
1 parent
f5f4a7a
commit 052448f
Showing
10 changed files
with
290 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create body from surface |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
jupytext: | ||
text_representation: | ||
extension: .mystnb | ||
format_name: myst | ||
format_version: 0.13 | ||
jupytext_version: 1.16.4 | ||
kernelspec: | ||
display_name: Python 3 (ipykernel) | ||
language: python | ||
name: python3 | ||
--- | ||
|
||
# Modeling: Surface bodies and trimmed surfaces | ||
This example will show how to trim different surfaces, and how to use those surfaces to create surface bodies. | ||
|
||
## Create a surface | ||
Create a sphere surface. This can be done without launching the modeler. | ||
|
||
```{code-cell} ipython3 | ||
from ansys.geometry.core.shapes.surfaces import Sphere | ||
from ansys.geometry.core.math import Point3D | ||
|
||
surface = Sphere(origin=Point3D([0, 0, 0]), radius=1) | ||
``` | ||
|
||
Now get information on how the surface is defined and parameterized. | ||
|
||
```{code-cell} ipython3 | ||
surface.parameterization() | ||
``` | ||
|
||
## Trim the surface | ||
For a sphere, its parametization is (`u: [0, 2*pi]`, `v:[-pi/2, pi/2]`), where u corresponds to longitude and v corresponds to latitude. We can **trim** a surface by providing new parameters. | ||
|
||
```{code-cell} ipython3 | ||
from ansys.geometry.core.shapes.box_uv import BoxUV | ||
from ansys.geometry.core.shapes.parameterization import Interval | ||
import math | ||
|
||
trimmed_surface = surface.trim(BoxUV(range_u=Interval(0, math.pi), range_v=Interval(0, math.pi/2))) | ||
``` | ||
|
||
From a TrimmedSurface, you can always refer back to the underlying Surface if needed. | ||
|
||
```{code-cell} ipython3 | ||
trimmed_surface.geometry | ||
``` | ||
|
||
## Create a surface body | ||
|
||
Now create a surface body by launching the modeler session and providing the trimmed surface. Then plot the body to see how we created a quarter of a sphere as a surface body. | ||
|
||
```{code-cell} ipython3 | ||
from ansys.geometry.core import launch_modeler | ||
|
||
modeler = launch_modeler() | ||
print(modeler) | ||
``` | ||
|
||
```{code-cell} ipython3 | ||
design = modeler.create_design("SurfaceBodyExample") | ||
body = design.create_body_from_surface("trimmed_sphere", trimmed_surface) | ||
design.plot() | ||
``` | ||
|
||
If the sphere was left untrimmed, it would create a solid body since the surface is fully closed. In this case, since the surface was open, it created a surface body. | ||
|
||
This same process can be used with other surfaces including: | ||
- cone | ||
- cylinder | ||
- plane | ||
- torus | ||
|
||
Each surface has its own unique parameterization, which must be understood before trying to trim it. | ||
|
||
+++ | ||
|
||
## Close session | ||
When you finish interacting with your modeling service, you should close the active server session. This frees resources wherever the service is running. | ||
|
||
Close the server session. | ||
|
||
```{code-cell} ipython3 | ||
modeler.close() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters