Skip to content

Commit

Permalink
git subrepo pull dual-mesh
Browse files Browse the repository at this point in the history
subrepo:
  subdir:   "dual-mesh"
  merged:   "7dc1d22"
upstream:
  origin:   "../../x/2312-dual-mesh"
  branch:   "master"
  commit:   "7dc1d22"
git-subrepo:
  version:  "0.4.9"
  origin:   "https://github.com/Homebrew/brew"
  commit:   "3994768349"
  • Loading branch information
redblobgames committed Oct 3, 2024
1 parent 754dbda commit 785e38c
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 63 deletions.
6 changes: 3 additions & 3 deletions dual-mesh/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = ../../x/2312-dual-mesh
branch = master
commit = fdb9a63e2bdd9666628529b8d727bbccea430bca
parent = 542e3bb206304a9e9025b5285fae7c7d1665445e
commit = 7dc1d22fed5d4433991140ea43968d95c52018c6
parent = 754dbda04e43cf56032a32f321e931f0504fe151
method = merge
cmdver = 0.4.6
cmdver = 0.4.9
2 changes: 1 addition & 1 deletion dual-mesh/README.org
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is a wrapper around [[https://mapbox.github.io/delaunator/][Delaunator]]. I

[[https://redblobgames.github.io/dual-mesh/][Documentation is here]], but it's a bit rough. See [[http://www.redblobgames.com/x/1721-voronoi-alternative/][my blog post about centroid polygons]] and [[http://www.redblobgames.com/x/1722-b-rep-triangle-meshes/][my blog post about the dual mesh data structure]] for the history. Those blog posts used the names “seeds, edges, triangles” but now I call them “regions, sides, triangles”, and I use “ghost” elements to eliminate the boundaries.

The naming convention is output-from-input: =x_name_y= takes type =y= (r, s, t) as input and produces type =x= (r, s, t) as output. For example, =r_begin_s= is a function that takes a side (=s=) as input and returns a region (=r=), and could be called ~r = mesh.r_begin_s(s)~. A previous version of this library used the opposite naming convention, input-to-output, but the author was persuaded to switch by [[https://tomforsyth1000.github.io/blog.wiki.html][Tom Forsyth's article on naming]].
The naming convention is output-from-input: =x_name_y= takes type =y= (r, s, t) as input and produces type =x= (r, s, t) as output. For example, =r_begin_s= is a function that takes a side (=s=) as input and returns a region (=r=), and could be called ~r = mesh.r_begin_s(s)~. A previous version of this library used the opposite naming convention, input-to-output, but the author was persuaded to switch by [[https://tomforsyth1000.github.io/blog.wiki.html#\[\[BMatrix maths and names\]\]][Tom Forsyth's article on naming]].

For efficiency, functions that return an array take an optional parameter where the result should be written:

Expand Down
2 changes: 1 addition & 1 deletion dual-mesh/dist/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
let points = generateInteriorBoundaryPoints(bounds, spacing);
let numBoundaryPoints = points.length;
let generator = new Poisson({
shape: [bounds.width, bounds.height]
shape: [bounds.width, bounds.height],
minDistance: spacing / Math.sqrt(2),
});
for (let p of points) { generator.addPoint(p); }
Expand Down
12 changes: 6 additions & 6 deletions dual-mesh/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ export declare class TriangleMesh {
s_next_s(s: number): number;
s_prev_s(s: number): number;
s_opposite_s(s: number): number;
s_around_t(t: number, out_s?: number[]): number[];
r_around_t(t: number, out_r?: number[]): number[];
t_around_t(t: number, out_t?: number[]): number[];
s_around_r(r: number, out_s?: number[]): number[];
r_around_r(r: number, out_r?: number[]): number[];
t_around_r(r: number, out_t?: number[]): number[];
s_around_t(t: number, s_out?: number[]): number[];
r_around_t(t: number, r_out?: number[]): number[];
t_around_t(t: number, t_out?: number[]): number[];
s_around_r(r: number, s_out?: number[]): number[];
r_around_r(r: number, r_out?: number[]): number[];
t_around_r(r: number, t_out?: number[]): number[];
r_ghost(): number;
is_ghost_s(s: number): boolean;
is_ghost_r(r: number): boolean;
Expand Down
42 changes: 21 additions & 21 deletions dual-mesh/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,47 +181,47 @@ export class TriangleMesh {
s_next_s(s) { return TriangleMesh.s_next_s(s); }
s_prev_s(s) { return TriangleMesh.s_prev_s(s); }
s_opposite_s(s) { return this._halfedges[s]; }
s_around_t(t, out_s = []) { out_s.length = 3; for (let i = 0; i < 3; i++) {
out_s[i] = 3 * t + i;
} return out_s; }
r_around_t(t, out_r = []) { out_r.length = 3; for (let i = 0; i < 3; i++) {
out_r[i] = this._triangles[3 * t + i];
} return out_r; }
t_around_t(t, out_t = []) { out_t.length = 3; for (let i = 0; i < 3; i++) {
out_t[i] = this.t_outer_s(3 * t + i);
} return out_t; }
s_around_r(r, out_s = []) {
s_around_t(t, s_out = []) { s_out.length = 3; for (let i = 0; i < 3; i++) {
s_out[i] = 3 * t + i;
} return s_out; }
r_around_t(t, r_out = []) { r_out.length = 3; for (let i = 0; i < 3; i++) {
r_out[i] = this._triangles[3 * t + i];
} return r_out; }
t_around_t(t, t_out = []) { t_out.length = 3; for (let i = 0; i < 3; i++) {
t_out[i] = this.t_outer_s(3 * t + i);
} return t_out; }
s_around_r(r, s_out = []) {
const s0 = this._s_of_r[r];
let incoming = s0;
out_s.length = 0;
s_out.length = 0;
do {
out_s.push(this._halfedges[incoming]);
s_out.push(this._halfedges[incoming]);
let outgoing = TriangleMesh.s_next_s(incoming);
incoming = this._halfedges[outgoing];
} while (incoming !== -1 && incoming !== s0);
return out_s;
return s_out;
}
r_around_r(r, out_r = []) {
r_around_r(r, r_out = []) {
const s0 = this._s_of_r[r];
let incoming = s0;
out_r.length = 0;
r_out.length = 0;
do {
out_r.push(this.r_begin_s(incoming));
r_out.push(this.r_begin_s(incoming));
let outgoing = TriangleMesh.s_next_s(incoming);
incoming = this._halfedges[outgoing];
} while (incoming !== -1 && incoming !== s0);
return out_r;
return r_out;
}
t_around_r(r, out_t = []) {
t_around_r(r, t_out = []) {
const s0 = this._s_of_r[r];
let incoming = s0;
out_t.length = 0;
t_out.length = 0;
do {
out_t.push(TriangleMesh.t_from_s(incoming));
t_out.push(TriangleMesh.t_from_s(incoming));
let outgoing = TriangleMesh.s_next_s(incoming);
incoming = this._halfedges[outgoing];
} while (incoming !== -1 && incoming !== s0);
return out_t;
return t_out;
}
r_ghost() { return this.numRegions - 1; }
is_ghost_s(s) { return s >= this.numSolidSides; }
Expand Down
1 change: 1 addition & 0 deletions dual-mesh/dual-mesh-diagrams.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Vue.component('a-side-white-edges', {
`,
methods: {
w_side: function(s) {
if (this.graph.is_ghost_s(s)) return ``;
const alpha = this.alpha || 0.0;
let begin = this.graph.pos_of_t(this.graph.t_inner_s(s));
let end = this.graph.pos_of_t(this.graph.t_outer_s(s));
Expand Down
18 changes: 15 additions & 3 deletions dual-mesh/index.org
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,24 @@ But, barely inside means there's a tiny gap between the boundary points and the
</figure>
#+end_export

The accessor functions are named ~output = output_from_input(input)~. Some of them return an array, and will take an optional parameter to reuse an existing array (to avoid memory allocations).
Public data includes:

- ~numSides, ~numSolidSides~
- ~numRegions, ~numSolidRegions~
- ~numTriangles~, ~numSolidTriangles~
- ~numBoundaryRegions~

Static helpers:

- ~t_from_s(s)~ :: returns the triangle id from a side id
- ~s_next_s(s)~, ~s_prev_s(s)~ :: next/prev around triangle. The black edge =s2= has /next/ edge ={{test('s_next_s',2)}}= and /previous/ edge ={{test('s_prev_s',2)}}=.

The accessor functions are named ~output = output_from_input(input)~. Some of them return an array, and will take an optional parameter to reuse an existing array (to avoid memory allocations).

- ~x_of_r(r)~, ~y_of_r(r)~, ~pos_of_r(r, out=[])~ :: the position of region =r= (red point).
- ~x_of_t(t)~, ~y_of_t(t)~, ~pos_of_t(t, out=[])~ :: the center position of triangle =t= (blue point).
- ~r_begin_s(s)~, ~r_end_s(s)~ :: the black edge endpoints (red). The black edge =s2= /begins/ at ={{test('r_begin_s',2)}}= and /ends/ at ={{test('r_end_s',2)}}=.
- ~t_inner_s(s)~, ~t_outer_s(s)~ :: the white edge endpoints (blue). The black edge =s2= has a white edge connecting /inner/ triangle ={{test('t_inner_s',2)}}= to /outer/ triangle ={{test('t_outer_s',2)}}=.
- ~s_next_s(s)~, ~s_prev_s(s)~ :: next/prev around triangle. The black edge =s2= has /next/ edge ={{test('s_next_s',2)}}= and /previous/ edge ={{test('s_prev_s',2)}}=.
- ~s_opposite_s(s)~ :: opposite of half-edge. The black edge =s2='s opposite is ={{test('s_opposite_s',2)}}= and =s5='s opposite is ={{test('s_opposite_s',5)}}=. If an edge has no opposite, it will return =-1=.
- ~s_around_t(t, out=[])~ :: sides around a triangle. Triangle =t0='s sides are ={{test('s_around_t',0)}}=
- ~r_around_t(t, out=[])~ :: regions around a triangle. Triangle =t0='s regions are ={{test('r_around_t',0)}}=
Expand Down Expand Up @@ -216,6 +226,8 @@ Properties of circulation:
- If =s= is returned by ~s_around_r(r)~, then ~r_begin_s(s)~ === =r=
- If =s= is returned by ~s_around_t(t)~, then ~t_inner_s(s)~ === =t=

- constructor, ~addGhostStructure()~, ~_update()~ set the internal data structures from Delaunator's data, type =MeshInitializer { points: Point[]; delaunator: Delaunator; numBoundaryPoints?: number; numSolidSides?: number }=

** History
:PROPERTIES:
:CUSTOM_ID: history
Expand Down Expand Up @@ -291,6 +303,6 @@ Feel free to look at [[https://github.com/redblobgames/dual-mesh][@redblobgames/
</x:head>
<x:footer>
Created 31 Mar 2023 with the help of <a href="https://v2.vuejs.org/">Vue.js v2</a>; &#160;
<!-- hhmts start -->Last modified: 02 May 2023<!-- hhmts end -->
<!-- hhmts start -->Last modified: 24 Jun 2024<!-- hhmts end -->
</x:footer>
#+end_export
44 changes: 44 additions & 0 deletions dual-mesh/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dual-mesh/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"module": "nodenext",
"moduleResolution": "nodenext",
"declaration": true,
"declarationDir": "dist",
Expand Down
27 changes: 0 additions & 27 deletions dual-mesh/yarn.lock

This file was deleted.

0 comments on commit 785e38c

Please sign in to comment.