Skip to content

Commit 6a61a50

Browse files
author
Stefan Sechelmann
committed
add constant width parameter to thickened surface factory
1 parent 6da0029 commit 6a61a50

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src-core/de/jreality/geometry/ThickenedSurfaceFactory.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public class ThickenedSurfaceFactory {
7575
boolean linearHole = false;
7676
boolean thickenAlongFaceNormals = false;
7777
boolean mergeDuplicateBoundaryVerts = false;
78+
boolean constantWidth = false;
7879
double holeFactor = 1.0;
7980
double shiftAlongNormal = .5;
8081
int stepsPerEdge = 3;
@@ -237,6 +238,13 @@ public boolean isThickenAlongFaceNormals() {
237238
public void setThickenAlongFaceNormals(boolean thickedAlongFaceNormals) {
238239
this.thickenAlongFaceNormals = thickedAlongFaceNormals;
239240
}
241+
242+
public boolean isConstantWidth() {
243+
return constantWidth;
244+
}
245+
public void setConstantWidth(boolean constantWidth) {
246+
this.constantWidth = constantWidth;
247+
}
240248

241249
/**
242250
* This returns the thickened surface. This remains the same for the life of the factory.
@@ -467,12 +475,18 @@ public void update() {
467475
vb = tangentQuadricBottom[j]; //Rn.linearCombination(null, 1-t, vb1, t,vb2);
468476
vt = tangentQuadricTop[j]; //Rn.linearCombination(null, 1-t, vt1, t,vt2);
469477
}
470-
// else {
478+
if (constantWidth) {
479+
double[] vl = Rn.linearCombination(null, 1-u, vb, u, vt);
480+
double[] cl = Rn.linearCombination(null, 1-u, cb, u, ct);
481+
double cc = 1-v/Rn.euclideanDistance(vl, cl);
482+
double vc = v/Rn.euclideanDistance(vl, cl);
483+
Rn.linearCombination(allVertices[allVertCount+vertexCount], cc, vl, vc, cl);
484+
} else {
471485
Rn.bilinearInterpolation(allVertices[allVertCount+vertexCount], u, v, vb, vt, cb, ct);
472-
allTexCoords[allVertCount+vertexCount][0] = tu;
473-
allTexCoords[allVertCount+vertexCount][1] = tv;
474-
nonDuplicateVertexIndicesForThisHole[vertexCount] = allVertCount+vertexCount;
475-
// }
486+
}
487+
allTexCoords[allVertCount+vertexCount][0] = tu;
488+
allTexCoords[allVertCount+vertexCount][1] = tv;
489+
nonDuplicateVertexIndicesForThisHole[vertexCount] = allVertCount+vertexCount;
476490
vertexCount++;
477491
}
478492
}

0 commit comments

Comments
 (0)