-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[half-edge]
PortEntry
-- connection
through HalfEdge
- `connectPorts` - `connectHalfEdges` - `connectPortWithHalfEdge` - remove active edge during `interact`
- Loading branch information
Showing
38 changed files
with
337 additions
and
132 deletions.
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
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
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,31 @@ | ||
import { HalfEdge } from "../half-edge" | ||
import { Net } from "../net" | ||
import { deleteHalfEdgeEntry } from "../net/deleteHalfEdgeEntry" | ||
import { findHalfEdgeEntryOrFail } from "../net/findHalfEdgeEntryOrFail" | ||
|
||
export function connectHalfEdges( | ||
net: Net, | ||
firstHalfEdge: HalfEdge, | ||
secondHalfEdge: HalfEdge, | ||
): void { | ||
const firstHalfEdgeEntry = findHalfEdgeEntryOrFail(net, firstHalfEdge) | ||
const secondHalfEdgeEntry = findHalfEdgeEntryOrFail(net, secondHalfEdge) | ||
|
||
const firstOtherHalfEdge = firstHalfEdgeEntry.otherHalfEdge | ||
const secondOtherHalfEdge = secondHalfEdgeEntry.otherHalfEdge | ||
|
||
const firstOtherHalfEdgeEntry = findHalfEdgeEntryOrFail( | ||
net, | ||
firstOtherHalfEdge, | ||
) | ||
const secondOtherHalfEdgeEntry = findHalfEdgeEntryOrFail( | ||
net, | ||
secondOtherHalfEdge, | ||
) | ||
|
||
firstOtherHalfEdgeEntry.otherHalfEdge = secondOtherHalfEdge | ||
secondOtherHalfEdgeEntry.otherHalfEdge = firstOtherHalfEdge | ||
|
||
deleteHalfEdgeEntry(net, firstHalfEdge) | ||
deleteHalfEdgeEntry(net, secondHalfEdge) | ||
} |
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,42 @@ | ||
import { edgeEqual } from "../edge" | ||
import { HalfEdge } from "../half-edge" | ||
import { Net } from "../net" | ||
import { findHalfEdgeEntryOrFail } from "../net/findHalfEdgeEntryOrFail" | ||
import { findPortRecordOrFail } from "../net/findPortRecordOrFail" | ||
import { Port } from "../port" | ||
|
||
export function connectPortWithHalfEdge( | ||
net: Net, | ||
port: Port, | ||
halfEdge: HalfEdge, | ||
): void { | ||
const portRecord = findPortRecordOrFail(net, port.node) | ||
portRecord[port.name].connection = { halfEdge } | ||
|
||
const halfEdgeEntry = findHalfEdgeEntryOrFail(net, halfEdge) | ||
if (halfEdgeEntry.port !== undefined) { | ||
throw new Error( | ||
`[connectPortWithHalfEdge] halfEdgeEntry is already connected`, | ||
) | ||
} | ||
|
||
halfEdgeEntry.port = port | ||
|
||
const otherHalfEdgeEntry = findHalfEdgeEntryOrFail( | ||
net, | ||
halfEdgeEntry.otherHalfEdge, | ||
) | ||
|
||
if (otherHalfEdgeEntry.port !== undefined) { | ||
if (port.isPrincipal && otherHalfEdgeEntry.port.isPrincipal) { | ||
const edge = { | ||
first: port, | ||
second: otherHalfEdgeEntry.port, | ||
} | ||
|
||
if (!net.activeEdges.find((activeEdge) => edgeEqual(activeEdge, edge))) { | ||
net.activeEdges.push(edge) | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { Mod } from "../mod" | ||
import { globalHalfEdgeInfo } from "./globalHalfEdgeInfo" | ||
|
||
export function createHalfEdgeId(mod: Mod): string { | ||
const n = mod.halfEdgeCounter++ | ||
export function createHalfEdgeId(): string { | ||
const n = globalHalfEdgeInfo.counter++ | ||
return n.toString() | ||
} |
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,3 @@ | ||
export const globalHalfEdgeInfo = { | ||
counter: 0, | ||
} |
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
Oops, something went wrong.