Skip to content

Commit 98310df

Browse files
comments + Face.Status.EXTERIOR => Status.BOUNDARY
1 parent 067936b commit 98310df

25 files changed

+4079
-53
lines changed

src/hgeom/hmesh/core/CycleGraphToHFaces.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ private List<HFace> cyclesToFaces(List<HEdge> cycles) {
137137
}
138138

139139
else {
140-
face = elementFactory.createFace(cycleEdge, Status.EXTERIOR,
140+
face = elementFactory.createFace(cycleEdge, Status.BOUNDARY,
141141
false);
142142

143143
faceIndices.set(face, -1);

src/hgeom/hmesh/core/HEdgeImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package hgeom.hmesh.core;
22

3+
import java.util.Objects;
34
import java.util.Optional;
45
import java.util.function.Predicate;
56
import java.util.function.UnaryOperator;
@@ -167,6 +168,7 @@ public final HEdge next() {
167168

168169
@Override
169170
public final Optional<HEdge> next(Predicate<? super HEdge> predicate) {
171+
Objects.requireNonNull(predicate);
170172
requireNotDiscarded();
171173
return Loops.findFirst(this, HEdge::next, predicate);
172174
}

src/hgeom/hmesh/core/HFaceImpl.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public InteriorHFaceImpl(int id, HEdge edge) {
3131

3232
@Override
3333
public Status status() {
34+
requireNotDiscarded();
3435
return Status.INTERIOR;
3536
}
3637
}
@@ -50,7 +51,8 @@ public ExteriorHFaceImpl(int id, HEdge edge) {
5051

5152
@Override
5253
public Status status() {
53-
return Status.EXTERIOR;
54+
requireNotDiscarded();
55+
return Status.BOUNDARY;
5456
}
5557
}
5658

@@ -87,7 +89,7 @@ public static HFace create(int id, HEdge edge, Status status,
8789
return new InteriorHFaceImpl(id, edge);
8890
}
8991

90-
if (status == Status.EXTERIOR) {
92+
if (status == Status.BOUNDARY) {
9193
return new ExteriorHFaceImpl(id, edge);
9294
}
9395

@@ -122,6 +124,7 @@ public static void setEdge(HFace face, HEdge edge) {
122124

123125
@Override
124126
public Status status() {
127+
requireNotDiscarded();
125128
return Status.UNKNOWN;
126129
}
127130

src/hgeom/hmesh/elements/HEdge.java

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ public interface HEdge extends HElement {
1414

1515
/**
1616
* @return the face to which this half-edge belongs
17+
* @throws IllegalStateException if this half-edge is discarded
1718
*/
1819
HFace face();
1920

2021
/**
2122
* @return the vertex at the head of this edge (the vertex to which this
2223
* half-edge points)
24+
* @throws IllegalStateException if this half-edge is discarded
2325
*/
2426
HVertex head();
2527

@@ -33,57 +35,65 @@ default HVertex tail() {
3335
/**
3436
* @return the half-edge following this half-edge in the half-edge cycle
3537
* this half-edge is part of
38+
* @throws IllegalStateException if this half-edge is discarded
3639
*/
3740
HEdge next();
3841

3942
/**
4043
* Starts from this half-edge and iterate over the cycle this edge belongs
41-
* to by successive calls to {@link HEdge#next()} until a half-edge is found
42-
* matching the specified predicate. If no half-edge is found, stops when
43-
* the iteration leads back to this edge
44+
* to until a half-edge is found matching the specified predicate. If no
45+
* half-edge is found, stops when the iteration leads back to this edge
4446
* <p>
4547
* Equivalent to, but faster than
4648
* <code>this.cycle().filter(predicate).findFirst()</code>
4749
*
4850
* @param predicate a predicate used to test every encountered half-edge
4951
* along the cycle
50-
* @return an {@link Optional} on a half-edge found matching the predicate
51-
* or {@link Optional#empty()} if the cycle was completly parsed and
52-
* no half-edge was found
52+
* @return an {@link Optional} on the first half-edge found matching the
53+
* predicate or {@link Optional#empty()} if the cycle was completly
54+
* parsed and no half-edge was found
55+
* @throws IllegalStateException if this half-edge is discarded
56+
* @throws NullPointerException if null argument
57+
* @see HEdge#cycle()
5358
*/
5459
Optional<HEdge> next(Predicate<? super HEdge> predicate);
5560

5661
/**
5762
* @return the previous half-edge on the cycle this half-edge belongs to
63+
* @throws IllegalStateException if this half-edge is discarded
5864
*/
5965
HEdge previous();
6066

6167
/**
6268
* @return the opposite (or sibling) half-edge
69+
* @throws IllegalStateException if this half-edge is discarded
6370
*/
6471
HEdge opposite();
6572

6673
/**
67-
* @return a sequence over all the elements of the cycle this half-edge
68-
* belongs to (along the border of a face). The first element of the
69-
* sequence is this half-Edge, the 2nd element is the
70-
* {@link HEdge#next() next} half-edge and so on
74+
* @return a ordered circular sequence over all the elements of the cycle
75+
* this half-edge belongs to (along the boundary of a face). The
76+
* first element of the sequence is this half-Edge, the 2nd element
77+
* is the {@link HEdge#next() next} half-edge and so on
78+
* @throws IllegalStateException if this half-edge is discarded
7179
*/
7280
Sequence<HEdge> cycle();
7381

7482
/**
75-
* @return a sequence over all the half-edges whose tail are this edge's
76-
* head. The {@link HEdge#opposite() opposite} of this half-edge is
77-
* included in the sequence
83+
* @return a ordered sequence over all the half-edges whose tail are this
84+
* edge's head. The {@link HEdge#opposite() opposite} of this
85+
* half-edge is included in the sequence
86+
* @throws IllegalStateException if this half-edge is discarded
7887
*/
7988
default Sequence<HEdge> outgoingEdges() {
8089
return head().outgoingEdges();
8190
}
8291

8392
/**
84-
* @return a sequence over all the half-edges whose head are this edge's
85-
* tail. The {@link HEdge#opposite() opposite} of this half-edge is
86-
* included in the sequence
93+
* @return a ordered sequence over all the half-edges whose head are this
94+
* edge's tail. The {@link HEdge#opposite() opposite} of this
95+
* half-edge is included in the sequence
96+
* @throws IllegalStateException if this half-edge is discarded
8797
*/
8898
default Sequence<HEdge> incomingEdges() {
8999
return tail().incomingEdges();

src/hgeom/hmesh/elements/HFace.java

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,47 @@ public enum Status {
2020
INTERIOR,
2121

2222
/**
23-
* The face is an external border of the {@link HMesh mesh} it is part of.
24-
* An external border is a face that surrounds the {@link HMesh mesh} (an
25-
* outer border) or a face that surrounds a hole within the {@link HMesh
26-
* mesh} (an inner border)
23+
* The face is a boundary of the {@link HMesh mesh} it is part of. A
24+
* boundary is a face that surrounds the {@link HMesh mesh} (an outer
25+
* border) or a face that surrounds a hole within the {@link HMesh mesh} (an
26+
* inner border)
2727
*/
28-
EXTERIOR,
28+
BOUNDARY,
2929

3030
/**
3131
* Unknown status. The face could be either inside or on the border of the
32-
* {@link HMesh mesh} it is part of. when a {@link HMesh mesh} is built from
32+
* {@link HMesh mesh} it is part of. When a {@link HMesh mesh} is built from
3333
* a set of edges, all its faces have an unknown status
3434
*/
3535
UNKNOWN
3636
}
3737

3838
/**
39-
* @return whether this face is a primary or a complementary face
39+
* @return the {@link Status status} of this face
40+
* @throws IllegalStateException if this face is discarded
4041
*/
4142
Status status();
4243

4344
/**
4445
* @return one of the half-edges located on the border of this face
46+
* @throws IllegalStateException if this face is discarded
4547
*/
4648
HEdge edge();
4749

4850
/**
49-
* @return a ordered sequence over the half-edges located on the border of
50-
* this face. Half-edges are ordered in the sequence so that a
51-
* half-edge is the {@link HEdge#next} of its preceeding half-edge
51+
* @return a ordered circular sequence over the half-edges located along the
52+
* border of this face. Half-edges are ordered in the sequence so
53+
* that a half-edge is the {@link HEdge#next} of its preceeding
54+
* half-edge
55+
* @throws IllegalStateException if this face is discarded
5256
*/
5357
Sequence<HEdge> edges();
5458

5559
/**
56-
* @return a ordered sequence over the vertices located on the border of
57-
* this face. Vertices are ordered so that 2 consecutive vertices in
58-
* the sequence are neighbors
60+
* @return a ordered circular sequence over the vertices located along the
61+
* border of this face. Vertices are ordered so that 2 consecutive
62+
* vertices in the sequence are neighbors
63+
* @throws IllegalStateException if this face is discarded
5964
*/
6065
Sequence<HVertex> vertices();
6166

@@ -71,9 +76,9 @@ public enum Status {
7176
boolean isNeighborOf(HFace other);
7277

7378
/**
74-
* Returns a sequence over the neighbors of this face. The neighbors are the
75-
* faces in contact with this face via a shared border conisiting of at
76-
* least one pair of twin half-edges
79+
* Returns a orderd circular sequence over the neighbors of this face. The
80+
* neighbors are the faces in contact with this face via a shared border
81+
* consisting of at least one pair of twin half-edges
7782
* <p>
7883
* In the particular case of a face being in contact with this face via two
7984
* (or more) distinct borders, the neighbor face will appear twice (or more)

src/hgeom/hmesh/elements/HMesh.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
public interface HMesh {
1717

1818
/**
19-
* @return a sequential stream of this mesh's faces
19+
* @return a sequential stream over this mesh's faces
2020
*/
2121
Stream<HFace> faces();
2222

2323
/**
24-
* @return a sequential stream of this mesh's edges
24+
* @return a sequential stream over this mesh's edges
2525
*/
2626
Stream<HEdge> edges();
2727

2828
/**
29-
* @return a sequential stream of this mesh's vertices
29+
* @return a sequential stream over this mesh's vertices
3030
*/
3131
Stream<HVertex> vertices();
3232

@@ -46,8 +46,8 @@ static Optional<HEdge> edge(HVertex tail, HVertex head) {
4646
* <p>
4747
* The split:
4848
* <p>
49-
* 1/ creates a pair of twin half-edges joining 2 vertices located o the
50-
* border of the face and dividing the specified face into 2 zones
49+
* 1/ creates a pair of twin half-edges joining 2 vertices located on the
50+
* boundary of the face and dividing the face into 2 zones
5151
* <p>
5252
* 2/ makes the face become one of the 2 zones
5353
* <p>
@@ -95,7 +95,7 @@ static Optional<HEdge> edge(HVertex tail, HVertex head) {
9595
* v1 <-------------------------------------> v2<p>
9696
* <p>
9797
* After:<p>
98-
* 1 new vertex v, 4 half-edges: he[v1 -> v], heopp[v -> v1]<p>
98+
* 1 new vertex v,<p> 4 half-edges: he[v1 -> v], heopp[v -> v1]
9999
* he2[v2 -> v], h2opp[v -> v2]<p>
100100
* <p>
101101
* v1 <----------------> v <----------------> v2<p>
@@ -113,13 +113,14 @@ static Optional<HEdge> edge(HVertex tail, HVertex head) {
113113
/**
114114
* Collapse a half-edge (and its opposite). Equivalent to "merge" the head
115115
* and the tail of the half-edge. After the collapse, the edge and its
116-
* opposite will be removed from this mesh. The head will be removed as well
117-
* and its incoming and outgoing half-edges will be reconnected to the tail
116+
* opposite will be removed from this mesh and discarded. The head will be
117+
* removed as well and its incoming and outgoing half-edges will be
118+
* reconnected to the tail
118119
*
119120
* @param edge the edge to collapse
120121
* @return {@code true} if successfull collapse ; {@code false} otherwise.
121122
* The collapse will not take place if the specified edge or its
122-
* opposite is part of a cycle / face containing only 3 elements.
123+
* opposite is part of a half-edge cycle containing only 3 elements.
123124
* Collapse would otherwise result in degenerate faces containing
124125
* only 2 half-edges
125126
* @throws IllegalStateException if the given half-edge is discarded
@@ -138,12 +139,12 @@ static Optional<HEdge> edge(HVertex tail, HVertex head) {
138139
* <p>
139140
* <code>
140141
* Before:<p>
141-
* 3 vertices, 4 half-edges: h1[v1 -> v], h1opp[v -> v1], h2[v2 -> v], h2opp[v -> v1]<p>
142+
* 3 vertices: v1, v, v2,<p>4 half-edges: h1[v1 -> v], h1opp[v -> v1], h2[v2 -> v], h2opp[v -> v1]<p>
142143
* <p>
143144
* v1 <----------------> v <----------------> v2<p>
144145
* <p>
145146
* After:<p>
146-
* 2 vertices, 2 half-edges with theirs heads changed: h1[v1 -> v2], h2[v2 -> v1]<p>
147+
* 2 vertices: v1, v2,<p>2 half-edges with theirs heads changed: h1[v1 -> v2], h2[v2 -> v1]<p>
147148
* <p>
148149
* v1 <-------------------------------------> v2<p>
149150
* <p>

src/hgeom/hmesh/elements/HVertex.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public interface HVertex extends HElement {
1111

1212
/**
1313
* @return one of the edges pointing at this vertex
14+
* @throws IllegalStateException if this vertex is discarded
1415
*/
1516
HEdge edge();
1617

@@ -19,6 +20,7 @@ public interface HVertex extends HElement {
1920
* pointing at this vertex.
2021
*
2122
* @return the degree of this vertex. Always >= 2
23+
* @throws IllegalStateException if this vertex is discarded
2224
*/
2325
int degree();
2426

@@ -28,7 +30,9 @@ public interface HVertex extends HElement {
2830
*
2931
* @param other
3032
* @return {@code true} if yhis vertex and the specified one are neighbors
31-
* @throws NullPointerException if argument is {@code null}
33+
* @throws IllegalStateException if this half-edge or the specified one is
34+
* discarded
35+
* @throws NullPointerException if argument is {@code null}
3236
* @see HVertex#neighbors()
3337
*/
3438
boolean isNeighborOf(HVertex other);
@@ -38,21 +42,20 @@ public interface HVertex extends HElement {
3842
* vertex connected to this vertex by a pair of twin half-edges
3943
*
4044
* @return
45+
* @throws IllegalStateException if this vertex is discarded
4146
* @see HVertex#isNeighborOf(HVertex)
4247
*/
4348
Sequence<HVertex> neighbors();
4449

4550
/**
46-
* Returns a sequence over the half-edges pointing at this vertex
47-
*
48-
* @return
51+
* @return an ordered sequence over the half-edges pointing at this vertex
52+
* @throws IllegalStateException if this vertex is discarded
4953
*/
5054
Sequence<HEdge> incomingEdges();
5155

5256
/**
53-
* Returns a sequence over the half-edges whose tail is this vertex
54-
*
55-
* @return
57+
* @return an ordered sequence over the half-edges whose tail is this vertex
58+
* @throws IllegalStateException if this vertex is discarded
5659
*/
5760
Sequence<HEdge> outgoingEdges();
5861
}

0 commit comments

Comments
 (0)