Read:
PUBLIC
AC.ReadOp ~ {
cadStructureData: CadStructureData ← NARROW[structure.instanceData];
inputPolynomialRing: AC.Structure ← cadStructureData.inputPolynomialRing;
minPolyRing: AC.Structure ← cadStructureData.minPolyRing;
minPolyRing, inputPolynomialRing, inputPolyRingSeqStructure: AC.Structure;
token: Rope.ROPE;
dimension: CARDINAL;
name: Rope.ROPE ← NIL;
inputVariables, projVariables, minPolyVariable, fieldElementVariable: VARS.VariableSeq;
projPolynomialRing: AC.Structure;
projPolyRingSeqStructure: AC.Structure;
inputPolynomials, basis: SEQ.Sequence ← NIL;
numBasisElements: CARDINAL ← 0;
contents, basisProjection: SEQ.Sequence ← NIL;
basisClusters: SEQ.Sequence ← NIL;
cells: SEQ.Sequence ← NIL;
cellsData: SEQ.SequenceData;
cellIndexStructure: AC.Structure;
basisSignatureStructure: AC.Structure;
inducedCad: Cad ← NIL;
inducedCadData: CadData;
outData: CadData;
token ← in.GetID[];
IF NOT Rope.Equal[token, "BEGINCAD"] THEN ERROR;
token ← in.GetID[];
IF Rope.Equal[token, "NAME"]
THEN {
name ← in.GetID[];
token ← in.GetID[];
};
IF NOT Rope.Equal[token, "DIMENSION"] THEN ERROR;
dimension ← in.GetCard[];
cellIndexStructure ← PTS.MakePointStructure[Ints.Ints, dimension];
token ← in.GetID[];
IF NOT Rope.Equal[token, "INPUTVARIABLES"] THEN ERROR;
inputVariables ← VARS.ReadVariableSeq[in];
inputPolynomialRing ← POL.MakePolynomialStructure[BR.BigRats, inputVariables];
inputPolyRingSeqStructure ← SEQ.MakeSequenceStructure[inputPolynomialRing];
token ← in.GetID[];
IF NOT Rope.Equal[token, "MINPOLYVARIABLE"] THEN ERROR;
minPolyVariable ← VARS.ReadVariableSeq[in];
minPolyRing ← POL.MakePolynomialStructure[BR.BigRats, minPolyVariable];
Should check that minPolyVariable read = minPolyRing.allVariables
token ← in.GetID[];
IF NOT Rope.Equal[token, "FIELDELEMENTVARIABLE"] THEN ERROR;
fieldElementVariable ← VARS.ReadVariableSeq[in];
IF NOT Rope.Equal[fieldElementVariable[1], minPolyVariable[1] ] THEN ERROR; -- quick fix; the entire use of fieldElementVariable should be removed
token ← in.GetID[];
IF NOT Rope.Equal[token, "INPUTPOLYNOMIALS"] THEN ERROR;
inputPolynomials ← inputPolyRingSeqStructure.class.read[in, inputPolyRingSeqStructure];
token ← in.GetID[];
IF Rope.Equal[token, "BASIS"]
THEN {
basisData: SEQ.SequenceData;
basis ← inputPolyRingSeqStructure.class.read[in, inputPolyRingSeqStructure];
basisData ← NARROW[basis.data];
numBasisElements ← basisData.lengthPlus1 - 1;
basisSignatureStructure ← PTS.MakePointStructure[FormulaOperators.Operators, numBasisElements];
token ← in.GetID[];
};
projVariables ← VARS.RemoveMainVariable[inputVariables];
projPolynomialRing ← POL.MakePolynomialStructure[BR.BigRats, projVariables];
projPolyRingSeqStructure ← SEQ.MakeSequenceStructure[projPolynomialRing];
IF Rope.Equal[token, "CONTENTS"]
THEN {
contents ← projPolyRingSeqStructure.class.read[in, projPolyRingSeqStructure];
token ← in.GetID[];
};
IF Rope.Equal[token, "PROJECTION"]
THEN {
basisProjection ← projPolyRingSeqStructure.class.read[in, projPolyRingSeqStructure];
token ← in.GetID[];
};
IF Rope.Equal[token, "CELLS"]
THEN {
cellStructure: AC.Structure ← Cells.MakeCellStructure[inputPolynomialRing, minPolyRing, numBasisElements];
cellSeqStructure: AC.Structure ← SEQ.MakeSequenceStructure[cellStructure];
cells ← cellSeqStructure.class.read[in, cellSeqStructure];
token ← in.GetID[];
};
IF Rope.Equal[token, "CLUSTERS"] THEN
[basisClusters, token] ← ReadSignedRegionSeq[in, cellIndexStructure, inputPolynomialRing, minPolyRing, basisSignatureStructure];
IF Rope.Equal[token, "INDUCEDCAD"]
THEN {
inducedCadStructure: AC.Structure ← MakeCadStructure[projPolynomialRing, minPolyRing];
inducedCad ← Read[in, structure];
token ← in.GetID[];
};
IF NOT Rope.Equal[token, "ENDCAD"] THEN ERROR;
outData ←
NEW[CadDataRec ← [
dimension: dimension,
inputPolynomials: inputPolynomials,
basis: basis,
contents: contents,
basisProjection: basisProjection,
cells: cells,
basisClusters: basisClusters,
inducedCad: inducedCad
] ];
out ← NEW[AC.ObjectRec ← [name: name, structure: structure, data: outData] ];
IF inducedCad#
NIL
THEN {
inducedCadData ← NARROW[inducedCad.data];
inducedCadData.parentCad ← out;
};
cellsData ← NARROW[cells.data];
FOR i:
NAT
IN [1..cellsData.lengthPlus1 - 1]
DO
cellData: Cells.CellData ← NARROW[cellsData[i].data];
cellData.cad ← out;
ENDLOOP;
outData.abstractGraph ← NEW [Graphs.GraphPrivate ← [
class: cadGraphClass,
rep: out
]];
RETURN[out];
};
ToRope:
PUBLIC
AC.ToRopeOp ~ {
inData: CadData ← NARROW[in.data];
inStructureData: CadStructureData ← NARROW[in.structure.instanceData];
inputPolyRingSeqStructure: AC.Structure ← inData.inputPolynomials.structure;
sequenceStructureData: SEQ.SequenceStructureData ← NARROW[inputPolyRingSeqStructure.instanceData];
inputPolynomialRing: AC.Structure ← sequenceStructureData.elementStructure;
inputVariables: VARS.VariableSeq ← NARROW[inputPolynomialRing.instanceData, POL.PolynomialRingData].allVariables;
minPolyVariable: VARS.VariableSeq ← NARROW[inStructureData.minPolyRing.instanceData, POL.PolynomialRingData].allVariables;
out ← "BEGINCAD\n";
IF in.name#NIL THEN out ← Rope.Cat[out, "NAME\n", in.name, "\n"];
out ← Rope.Concat[out, "DIMENSION\n"];
out ← Rope.Cat[out, Convert.RopeFromCard[inData.dimension], "\n"];
out ← Rope.Concat[out, "INPUTVARIABLES\n"];
out ← Rope.Cat[out, VARS.VariableSeqToRope[inputVariables], "\n"];
out ← Rope.Concat[out, "MINPOLYVARIABLE\n"];
out ← Rope.Cat[out, VARS.VariableSeqToRope[inData.minPolyVariable], "\n"];
out ← Rope.Concat[out, "FIELDELEMENTVARIABLE\n"];
out ← Rope.Cat[out, VARS.VariableSeqToRope[inData.minPolyVariable], "\n"];
IF inData.inputPolynomials#
NIL
THEN {
out ← Rope.Concat[out, "INPUTPOLYNOMIALS\n"];
out ← Rope.Cat[out, inData.inputPolynomials.structure.class.toRope[inData.inputPolynomials], "\n"];
};
IF inData.basis#
NIL
THEN {
out ← Rope.Concat[out, "BASIS\n"];
out ← Rope.Cat[out, inData.basis.structure.class.toRope[inData.basis], "\n"];
};
IF inData.contents#
NIL
THEN {
out ← Rope.Concat[out, "CONTENTS\n"];
out ← Rope.Cat[out, inData.contents.structure.class.toRope[inData.contents], "\n"];
};
IF inData.basisProjection#
NIL
THEN {
out ← Rope.Concat[out, "PROJECTION\n"];
out ← Rope.Cat[out, inData.basisProjection.structure.class.toRope[inData.basisProjection], "\n"];
};
IF inData.cells#
NIL
THEN {
out ← Rope.Concat[out, "CELLS\n"];
out ← Rope.Cat[out, inData.cells.structure.class.toRope[inData.cells], "\n"];
};
IF inData.basisClusters#NIL THEN {
out ← Rope.Concat[out, "CLUSTERS\n"];
out ← Rope.Cat[out, SignedRegionSeqToRope[inData.basisClusters], "\n"];
};
IF inData.inducedCad#
NIL
THEN {
out ← Rope.Concat[out, "INDUCEDCAD\n"];
out ← Rope.Cat[out, ToRope[inData.inducedCad], "\n"];
};
out ← Rope.Concat[out, "ENDCAD\n"];