... | @@ -508,30 +508,52 @@ The result for h0 = 0.1, 0.03 and 0.01. |
... | @@ -508,30 +508,52 @@ The result for h0 = 0.1, 0.03 and 0.01. |
|
|
|
|
|
![simple_combine](uploads/9156ad93e1147040f96032d76433d146/simple_combine.png)
|
|
![simple_combine](uploads/9156ad93e1147040f96032d76433d146/simple_combine.png)
|
|
|
|
|
|
### Example 3 (Subtract rectangle from disc)
|
|
### Example 3 (Combining distance functions)
|
|
|
|
|
|
We can not only define our own distance function d and edge length function h but crucially h can depend on d:
|
|
We can also construct geometries by the union and intersection of distance functions. For example, the above figure illustrate the result of the following code.
|
|
|
|
|
|
```java
|
|
```java
|
|
// define a bounding box
|
|
// inner rectangle
|
|
VRectangle bound = new VRectangle(-0.1, -0.1, 2.2, 2.2);
|
|
VRectangle rect = new VRectangle(-0.5, -0.5, 1, 1);
|
|
|
|
|
|
// distance function d that defines a disc with radius 1 at (1,1).
|
|
// outer rectangle
|
|
IDistanceFunction d = p -> Math.sqrt((p.getX() - 1) * (p.getX() - 1) + (p.getY() - 1) * (p.getY() - 1)) - 1.0;
|
|
VRectangle boundary = new VRectangle(-2,-0.7,4,1.4);
|
|
|
|
|
|
// define h0
|
|
|
|
double h0 = 0.1;
|
|
|
|
|
|
|
|
// define edge length function h by using d
|
|
// construction of the distance function, define the 2 discs
|
|
IEdgeLengthFunction h = p -> h0 + 0.5 * Math.abs(d.apply(p));
|
|
IDistanceFunction d1_c = IDistanceFunction.createDisc(-0.5, 0, 0.5);
|
|
|
|
IDistanceFunction d2_c = IDistanceFunction.createDisc(0.5, 0, 0.5);
|
|
|
|
|
|
// define the EikMesh generator
|
|
// define the two rectangles
|
|
PEikMeshGen<EikMeshPoint, Double, Double> meshImprover = new PEikMeshGen<>(
|
|
IDistanceFunction d_r = IDistanceFunction.create(rect);
|
|
d, h, h0, bound, (x, y) -> new EikMeshPoint(x, y, false));
|
|
IDistanceFunction d_b = IDistanceFunction.create(boundary);
|
|
|
|
|
|
// mesh the geometry
|
|
// combine distance functions
|
|
meshImprover.generate();
|
|
IDistanceFunction d_unionTmp = IDistanceFunction.union(d1_c, d_r)
|
|
```
|
|
IDistanceFunction d_union = IDistanceFunction.union(d_unionTmp, d2_c);
|
|
|
|
IDistanceFunction d = IDistanceFunction.substract(d_b,d_union);
|
|
|
|
|
|
|
|
// h_min
|
|
|
|
double edgeLength = 0.03;
|
|
|
|
|
|
|
|
var meshImprover = new PEikMeshGen<EikMeshPoint, Double, Double>(
|
|
|
|
d,
|
|
|
|
p -> edgeLength + 0.5 * Math.abs(d.apply(p)),
|
|
|
|
edgeLength,
|
|
|
|
GeometryUtils.boundRelative(boundary.getPath()),
|
|
|
|
Arrays.asList(rect),
|
|
|
|
(x, y) -> new EikMeshPoint(x, y, false));
|
|
|
|
|
|
|
|
// generate the mesh
|
|
|
|
var triangulation = meshImprover.generate();
|
|
|
|
````
|
|
|
|
|
|
|
|
Here we define two circles and a rectangle and compute the union ``d_union`` of these three distance functions in line 7. Finally we subtract ``d_union`` from a larger rectangle.
|
|
|
|
|
|
|
|
****Remark****: The definition of the distance function d, the edge length function h, the minimum edge length h0 and the bounding box have to be carefully defined by the user. For example, if h0 is too large EikMesh might fail to construct a valid mesh.
|
|
|
|
|
|
|
|
#### Result:
|
|
|
|
|
|
|
|
![eikmesh_d_combined_png](uploads/4f86de4de6bec3e4aa77870b63216685/eikmesh_d_combined_png.png)
|
|
|
|
|
|
## Videos
|
|
## Videos
|
|
|
|
|
... | | ... | |