Skip to content

Commit

Permalink
special group upgrade - final update prior to 16.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BobHanson committed Oct 16, 2024
1 parent fdff634 commit e554d6c
Show file tree
Hide file tree
Showing 16 changed files with 522 additions and 554 deletions.
19 changes: 14 additions & 5 deletions src/org/jmol/modelkit/ModelKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -4227,40 +4227,49 @@ private String getDrawAxes(String id, String swidth) {
"originPoint", 0);
P3d[] axisPoints = (P3d[]) vwr.shm.getShapePropertyIndex(JC.SHAPE_AXES,
"axisPoints", 0);

String s = "";
String[] colors = new String[] { "red", "green", "blue" };
int nDim = sym.getDimensionality();
int per = sym.getPeriodicity();
boolean shiftA = (per == 0x4 && nDim == 3); // rod group
boolean shiftB = (shiftA || per == 0x1 && nDim == 2); // rod or frieze
boolean shiftC = (per == 0x1 && nDim == 2 || per == 0x3 && nDim == 3); // frieze or layer
int periodicity = sym.getPeriodicity();
boolean shiftA = ((periodicity & 0x1) == 0); // rod (ab)c, rod b(ca)
boolean shiftB = ((periodicity & 0x2) == 0); // frieze a(b), rod (ab)c, rod a(bc)
boolean shiftC = ((periodicity & 0x4) == 0); // plane ab, layer ab(c), frieze a(b), rod a(bc), rod b(ca)
P3d[] pts = axisPoints;
P3d[] opts = null;
if (shiftA || shiftB || shiftC) {
pts = new P3d[] { new P3d(), new P3d(), new P3d() };
opts = new P3d[] { new P3d(), new P3d(), new P3d() };

if (shiftA) {
opts[0].sub2(origin, axisPoints[0]);
opts[0].scale(0.5d);
pts[0].sub2(origin, opts[0]);
} else if (nDim == 3) {
pts[0] = axisPoints[0];
}
if (shiftB) {
opts[1].sub2(origin, axisPoints[1]);
opts[1].scale(0.5d);
pts[1].sub2(origin, opts[1]);
} else if (nDim == 3) {
pts[1] = axisPoints[1];
}
if (shiftC) {
opts[2].sub2(origin, axisPoints[2]);
opts[2].scale(0.5d);
pts[2].sub2(origin, opts[2]);
} else if (nDim == 3) {
pts[2] = axisPoints[2];
}
}
for (int i = 0, a = JC.AXIS_A; i < 3; i++, a++) {
s += "\ndraw ID " + PT.esc(id + "_axis_" + JC.axisLabels[a]) + " "
+ swidth + " line "
+ (opts == null
|| i == 0 && !shiftA
|| i == 1 && !shiftB ? origin : opts[i])
|| i == 1 && !shiftB
|| i == 2 && !shiftC ? origin : opts[i])
+ " " + pts[i] + " color " + colors[i];
}
return s;
Expand Down
8 changes: 4 additions & 4 deletions src/org/jmol/render/CageRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class CageRenderer extends FontLineShapeRenderer {
protected BS bsPeriod;
protected P3d pt = new P3d();

protected P3d[] vvert, vvertA;
protected P3d[] vvert;

/**
* Uccage only
Expand Down Expand Up @@ -165,9 +165,9 @@ protected void setBSPeriod() {}
protected boolean shiftA, shiftB, shiftC, shifting;

protected void setShifts() {
shiftA = (nDims == 3 && periodicity == 0x4); // rod
shiftB = shiftA || (nDims == 2 && periodicity == 0x1); // rod or frieze
shiftC = (nDims == 3 && periodicity == 0x3); // layer
shiftA = ((periodicity & 0x1) == 0); // rod (ab)c, rod (a)b(c)
shiftB = ((periodicity & 0x2) == 0); // frieze a(b), rod (ab)c, rod a(bc)
shiftC = ((periodicity & 0x4) == 0); // plane ab, layer ab(c), frieze a(b), rod (a)b(c)
shifting = (shiftA || shiftB || shiftC);
}
}
Expand Down
72 changes: 56 additions & 16 deletions src/org/jmol/render/UccageRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class UccageRenderer extends CageRenderer {

private final P3d[] verticesT = new P3d[8];

private P3d[] vvertA;

@Override
protected void initRenderer() {
for (int i = 8; --i >= 0; )
Expand All @@ -58,6 +60,7 @@ protected void initRenderer() {
@Override
protected void setPeriodicity(P3d[] vertices, double scale) {
setShifts();
P3d p0;
if (shifting) {
// layer group shifts axes and unit cell down 50%
if (vvert == null) { //v[1] is c, v[2,3] is b, v[4,5] is a
Expand All @@ -66,9 +69,25 @@ protected void setPeriodicity(P3d[] vertices, double scale) {
vvert[i] = new P3d();
}
}
P3d p0;
P3d p1;
if (shiftA) {

if (shiftC && periodicity == 0x1) {
if (vvertA == null) { //v[1] is c, v[2,3] is b, v[4,5] is a
vvertA = new P3d[8];
for (int i = 8; --i >= 0;) {
vvertA[i] = new P3d();
}
}
p0 = P3d.newP(vertices[1]);
p0.sub(vertices[0]);
p0.scale(0.5);
for (int i = 8; --i >= 0;) {
pt.setT(vertices[i]);
pt.sub(vertices[0]);
pt.scaleAdd2(scale, pt, vertices[0]);
pt.sub(p0);
tm.transformPtNoClip(pt, vvertA[i]);
}
} else if (shiftA) {
if (vvertA == null) { //v[1] is c, v[2,3] is b, v[4,5] is a
vvertA = new P3d[8];
for (int i = 8; --i >= 0;) {
Expand Down Expand Up @@ -156,6 +175,7 @@ private void render1(int mad10) {
Axes axes = (Axes) vwr.shm.getShape(JC.SHAPE_AXES);
if (axes != null && vwr.areAxesTainted())
axes.reinitShape();

P3d[] axisPoints = (axes == null
|| vwr.getObjectMad10(StateManager.OBJ_AXIS1) == 0
|| axes.axisXY.z != 0 && (axes.axes2 == null || axes.axes2.length() == 3)
Expand Down Expand Up @@ -213,12 +233,14 @@ private void render1(int mad10) {
renderInfo();
}


@Override
protected void renderCageLine(int i, int edge0, int edge1, int d, boolean drawTicks) {
P3d p1;
P3d p2;
if (bsVerticals != null && bsVerticals.get(i)) {
if (vvertA != null && (i == 4 || i == 8)) {
if (vvertA != null && (i == 4 || i == 8 || i == 12 || i == 16
|| i == 0 && periodicity != 0x2)) {
p1 = vvertA[edge0];
p2 = vvertA[edge1];
} else {
Expand Down Expand Up @@ -246,9 +268,10 @@ protected void setBSPeriod() {
case 0x7:
return;
case 0x3:
// plane, layer ab(c)
bs = (bsPeriod == null ? (bsPeriod = new BS()) : bsPeriod);
if (nDims == 3) {
// verticals
// verticals for four layer c-posts, all set the same direction
bs.set(0);
bs.set(10);
bs.set(16);
Expand All @@ -267,9 +290,9 @@ protected void setBSPeriod() {
case 0x4:
// rod
bs = (bsPeriod == null ? (bsPeriod = new BS()) : bsPeriod);
bs.set(2);
bs.set(4);
bs.set(2); // these offset in b
bs.set(6);
bs.set(4); // these two offset in a
bs.set(8);
if (bsVerticals == null) {
bsVerticals = new BS();
Expand All @@ -279,17 +302,34 @@ protected void setBSPeriod() {
bs.set(0);
break;
case 0x1:
// rod-a, frieze
bs = (bsPeriod == null ? (bsPeriod = new BS()) : bsPeriod);
if (nDims == 2) {
// frieze
bs.set(2);
bs.set(18);
if (bsVerticals == null) {
bsVerticals = new BS();
}
BSUtil.copy2(bs, bsVerticals);
bs.set(4);
bs.set(2);
bs.set(18);
if (nDims == 3) {
//rod-a
bs.set(0);
bs.set(16);
}
if (bsVerticals == null) {
bsVerticals = new BS();
}
BSUtil.copy2(bs, bsVerticals);
bs.set(4);
break;
case 0x2:
// rod-b
bs = (bsPeriod == null ? (bsPeriod = new BS()) : bsPeriod);
bs.set(0);
bs.set(4);
bs.set(12); //"A" shift
bs.set(10);
//bs.set(16);
if (bsVerticals == null) {
bsVerticals = new BS();
}
BSUtil.copy2(bs, bsVerticals);
bs.set(2);
break;
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/org/jmol/scriptext/IsoExt.java
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,13 @@ private void draw() throws ScriptException {
int[][] faces;
switch (uc.getPeriodicity()) {
case 0x1:
faces = Triangulator.friezeEdge;
faces = Triangulator.edgeA;
break;
case 0x2:
faces = Triangulator.edgeB;
break;
case 0x4:
faces = Triangulator.rodEdge;
faces = Triangulator.edgeC;
break;
case 0x3:
faces = Triangulator.abFace;
Expand Down
4 changes: 3 additions & 1 deletion src/org/jmol/shape/Axes.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,10 @@ public P3d getAxisPoint(int i, boolean actual, P3d ptTemp) {
public Object getProperty(String property, int index) {
if (property == "originPoint")
return originPoint;
if (property == "axisPoints")
if (property == "axisPoints") {
setPoints(vwr.g.axesMode);
return axisPoints;
}
if (property == "axesTypeXY")
return (axisXY.z == 0 ? Boolean.FALSE : Boolean.TRUE);
if (property == "origin")
Expand Down
17 changes: 8 additions & 9 deletions src/org/jmol/symmetry/CLEG.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* org.jmol.modelkit.Modelkit to process CLEG strings.
*
* This code access multiple methods in Jmol, so it is not independently
* implemented outside that context. But it encapsulates the essentals of
* implemented outside that context. But it enca psulates the essentals of
*
*/
final public class CLEG {
Expand Down Expand Up @@ -259,11 +259,6 @@ public ClegNode(ClegData data, int index, String name) {
if (name == null)
return;
this.index = index;
int pt = isProbableClegSetting(name);
if (pt > 0) {
myIta = name.substring(0, pt);
myTrm = name.substring(pt + 1);
}
// sets this.name
init(data, name);
}
Expand Down Expand Up @@ -304,7 +299,11 @@ private String checkSpecial(String name) {
}

private void init(ClegData data, String name) {
int pt;
int pt = isProbableClegSetting(name);
if (pt > 0) {
myIta = name.substring(0, pt);
myTrm = name.substring(pt + 1);
}
if (name.equals(TYPE_REFERENCE)) {
isThisModelCalc = true;
}
Expand Down Expand Up @@ -374,7 +373,7 @@ private void init(ClegData data, String name) {
myIta = (String) data.sym.getSpaceGroupInfoObj("itaNumber", specialPrefix + name,
false, false);
if (myTrm == null)
myTrm = (String) data.sym.getSpaceGroupInfoObj("itaTransform", name,
myTrm = (String) data.sym.getSpaceGroupInfoObj("itaTransform", specialPrefix + name,
false, false);

if (hallSymbol != null && hallTrm != null) {
Expand Down Expand Up @@ -1292,7 +1291,7 @@ && isTransformOnly(tokens[index + 1])
}
// ready to roll....
boolean isP1 = (token.equalsIgnoreCase("P1") || token.equals("ITA/1.1"));

// TODO: P1 is only for space groups need isP1(token) or node.isP1
try {
BS bsAtoms;
boolean noAtoms;
Expand Down
Loading

0 comments on commit e554d6c

Please sign in to comment.