Skip to content

Commit

Permalink
HMesh2D & HMesh3D method renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-b-geom authored Aug 18, 2018
1 parent 766b492 commit 469f51e
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 45 deletions.
4 changes: 2 additions & 2 deletions examples/hgeom/hmesh/examples/HMeshBasicOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public static OptionalDouble averageNumberOfEdges(HMesh mesh) {
*/
public static OptionalDouble averageLengthOfEdges(HMesh2D mesh) {
return mesh.edges().mapToDouble(e -> {
double[] headCoords = mesh.xy(e.head());
double[] tailCoords = mesh.xy(e.tail());
double[] headCoords = mesh.vertexXY(e.head());
double[] tailCoords = mesh.vertexXY(e.tail());
double xDelta = headCoords[0] - tailCoords[0];
double yDelta = headCoords[1] - tailCoords[1];
return Math.sqrt(xDelta * xDelta + yDelta * yDelta);
Expand Down
14 changes: 7 additions & 7 deletions src/hgeom/hmesh/core/HMesh2DImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,41 @@ public HDData<HVertex> vertexYs() {
}

@Override
public double x(HVertex v) {
public double vertexX(HVertex v) {
return xs.get(v);
}

@Override
public void setX(HVertex v, double x) {
public void setVertexX(HVertex v, double x) {
xs.set(v, x);
}

@Override
public double y(HVertex v) {
public double vertexY(HVertex v) {
return ys.get(v);
}

@Override
public void setY(HVertex v, double y) {
public void setVertexY(HVertex v, double y) {
ys.set(v, y);
}

@Override
public double[] xy(HVertex v, double[] xy) {
public double[] vertexXY(HVertex v, double[] xy) {
double[] result = xy == null ? new double[2] : xy;
result[0] = xs.get(v);
result[1] = ys.get(v);
return result;
}

@Override
public void setXY(HVertex v, double[] xy) {
public void setVertexXY(HVertex v, double[] xy) {
xs.set(v, xy[0]);
ys.set(v, xy[1]);
}

@Override
public void setXY(HVertex v, double x, double y) {
public void setVertexXY(HVertex v, double x, double y) {
xs.set(v, x);
ys.set(v, y);
}
Expand Down
18 changes: 9 additions & 9 deletions src/hgeom/hmesh/core/HMesh3DImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,37 +55,37 @@ public HDData<HVertex> vertexZs() {
}

@Override
public double x(HVertex v) {
public double vertexX(HVertex v) {
return xs.get(v);
}

@Override
public void setX(HVertex v, double x) {
public void setVertexX(HVertex v, double x) {
xs.set(v, x);
}

@Override
public double y(HVertex v) {
public double vertexY(HVertex v) {
return ys.get(v);
}

@Override
public void setY(HVertex v, double y) {
public void setVertexY(HVertex v, double y) {
ys.set(v, y);
}

@Override
public double z(HVertex v) {
public double vertexZ(HVertex v) {
return zs.get(v);
}

@Override
public void setZ(HVertex v, double y) {
public void setVertexZ(HVertex v, double y) {
zs.set(v, y);
}

@Override
public double[] xyz(HVertex v, double[] xyz) {
public double[] vertexXYZ(HVertex v, double[] xyz) {
double[] result = xyz == null ? new double[3] : xyz;
result[0] = xs.get(v);
result[1] = ys.get(v);
Expand All @@ -94,14 +94,14 @@ public double[] xyz(HVertex v, double[] xyz) {
}

@Override
public void setXYZ(HVertex v, double[] xyz) {
public void setVertexXYZ(HVertex v, double[] xyz) {
xs.set(v, xyz[0]);
ys.set(v, xyz[1]);
zs.set(v, xyz[2]);
}

@Override
public void setXYZ(HVertex v, double x, double y, double z) {
public void setVertexXYZ(HVertex v, double x, double y, double z) {
xs.set(v, x);
ys.set(v, y);
zs.set(v, z);
Expand Down
1 change: 1 addition & 0 deletions src/hgeom/hmesh/core/HMeshTreeWalker.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public HMeshTreeWalker(HMesh mesh, TreePathType pathType) {
*/
public HMeshTreeWalker(HMesh mesh, TreePathType pathType,
int treeMaxDepth) {

this.mesh = Objects.requireNonNull(mesh);
this.pathType = Objects.requireNonNull(pathType);
this.treeMaxDepth = treeMaxDepth;
Expand Down
4 changes: 2 additions & 2 deletions src/hgeom/hmesh/core/ToStringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public static String toString(HVertex v, HMesh mesh) {
}

if (mesh instanceof HMesh2D) {
return Arrays.toString(((HMesh2D) mesh).xy(v));
return Arrays.toString(((HMesh2D) mesh).vertexXY(v));
}

if (mesh instanceof HMesh3D) {
return Arrays.toString(((HMesh3D) mesh).xyz(v));
return Arrays.toString(((HMesh3D) mesh).vertexXYZ(v));
}

return null;
Expand Down
21 changes: 10 additions & 11 deletions src/hgeom/hmesh/elements/HMesh2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,40 +32,40 @@ public interface HMesh2D extends HMesh {
* @param v
* @return the x coordinate
*/
double x(HVertex v);
double vertexX(HVertex v);

/**
* Sets the x coordinate of the given vertex
*
* @param v
* @param x the x coordinate to be set
*/
void setX(HVertex v, double x);
void setVertexX(HVertex v, double x);

/**
* Gets the y coordinate of the given vertex
*
* @param v
* @return the y coordinate
*/
double y(HVertex v);
double vertexY(HVertex v);

/**
* Sets the y coordinate of the given vertex
*
* @param v
* @param y the y coordinate to be set
*/
void setY(HVertex v, double y);
void setVertexY(HVertex v, double y);

/**
* Gets the 2D coordinates of the given vertex
*
* @param v
* @return an array [x y] containing the coordinates
*/
default double[] xy(HVertex v) {
return xy(v, null);
default double[] vertexXY(HVertex v) {
return vertexXY(v, null);
}

/**
Expand All @@ -75,15 +75,15 @@ default double[] xy(HVertex v) {
* @param xy if not {@code null}, will contain the 2D coordinates
* @return an array [x y] containing the coordinates
*/
double[] xy(HVertex v, double[] xy);
double[] vertexXY(HVertex v, double[] xy);

/**
* Sets the coordinate of the given vertex
*
* @param v
* @param xy the coordinates to be set
*/
void setXY(HVertex v, double[] xy);
void setVertexXY(HVertex v, double[] xy);

/**
* Sets the coordinate of the given vertex
Expand All @@ -92,7 +92,7 @@ default double[] xy(HVertex v) {
* @param x the x coordinate to be set
* @param y the y coordinate to be set
*/
void setXY(HVertex v, double x, double y);
void setVertexXY(HVertex v, double x, double y);

/**
* Calls {@link HMesh#splitEdge(HEdge)} to split the specified half-edge;
Expand All @@ -105,8 +105,7 @@ default double[] xy(HVertex v) {
*/
default HVertex splitEdge(HEdge edge, double x, double y) {
HVertex v = splitEdge(edge);
setX(v, x);
setY(v, y);
setVertexXY(v, x, y);
return v;
}
}
26 changes: 12 additions & 14 deletions src/hgeom/hmesh/elements/HMesh3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,56 +40,56 @@ public interface HMesh3D extends HMesh {
* @param v
* @return the x coordinate
*/
double x(HVertex v);
double vertexX(HVertex v);

/**
* Sets the x coordinate of the given vertex
*
* @param v
* @param x the x coordinate to be set
*/
void setX(HVertex v, double x);
void setVertexX(HVertex v, double x);

/**
* Gets the y coordinate of the given vertex
*
* @param v
* @return the y coordinate
*/
double y(HVertex v);
double vertexY(HVertex v);

/**
* Sets the y coordinate of the given vertex
*
* @param v
* @param y the y coordinate to be set
*/
void setY(HVertex v, double y);
void setVertexY(HVertex v, double y);

/**
* Gets the z coordinate of the given vertex
*
* @param v
* @return the y coordinate
*/
double z(HVertex v);
double vertexZ(HVertex v);

/**
* Sets the z coordinate of the given vertex
*
* @param v
* @param y the y coordinate to be set
*/
void setZ(HVertex v, double y);
void setVertexZ(HVertex v, double y);

/**
* Gets the coordinates of the given vertex
*
* @param v
* @return an array [x y z] containing the coordinates
*/
default double[] xyz(HVertex v) {
return xyz(v, null);
default double[] vertexXYZ(HVertex v) {
return vertexXYZ(v, null);
}

/**
Expand All @@ -99,15 +99,15 @@ default double[] xyz(HVertex v) {
* @param xyz if not {@code null}, will contain the coordinates
* @return an array [x y z] containing the coordinates
*/
double[] xyz(HVertex v, double[] xyz);
double[] vertexXYZ(HVertex v, double[] xyz);

/**
* Sets the coordinate of the given vertex
*
* @param v
* @param xyz the coordinates to be set
*/
void setXYZ(HVertex v, double[] xyz);
void setVertexXYZ(HVertex v, double[] xyz);

/**
* Sets the coordinate of the given vertex
Expand All @@ -117,7 +117,7 @@ default double[] xyz(HVertex v) {
* @param y the y coordinate to be set
* @param z the y coordinate to be set
*/
void setXYZ(HVertex v, double x, double y, double z);
void setVertexXYZ(HVertex v, double x, double y, double z);

/**
* Calls {@link HMesh#splitEdge(HEdge)} to split the specified half-edge;
Expand All @@ -131,9 +131,7 @@ default double[] xyz(HVertex v) {
*/
default HVertex splitEdge(HEdge edge, double x, double y, double z) {
HVertex v = splitEdge(edge);
setX(v, x);
setY(v, y);
setZ(v, z);
setVertexXYZ(v, x, y, z);
return v;
}
}

0 comments on commit 469f51e

Please sign in to comment.