Commit e4941350 authored by Krzysztof Nowinski's avatar Krzysztof Nowinski

CellCenters module cleaned

parent 1e5540b8
......@@ -47,6 +47,7 @@ import pl.edu.icm.jscic.CellSet;
import pl.edu.icm.jscic.Field;
import pl.edu.icm.jscic.IrregularField;
import pl.edu.icm.jscic.RegularField;
import pl.edu.icm.jscic.TimeData;
import pl.edu.icm.jscic.cells.Cell;
import pl.edu.icm.jscic.cells.CellType;
import pl.edu.icm.jscic.dataarrays.DataArray;
......@@ -158,7 +159,6 @@ public class CellCenters extends OutFieldVisualizationModule
for (int iCellSet = 0, iout = 0; iCellSet < inField.getNCellSets(); iCellSet++) {
CellSet inCS = inField.getCellSet(iCellSet);
CellSet outCS = new CellSet(inCS.getName());
int[] outIndices = new int[nSetNodes[iCellSet]];
int[] outNodes = new int[nSetNodes[iCellSet]];
for (int iCellArray = 0, csCell = 0; iCellArray < Cell.getNProperCellTypes(); iCellArray++)
if (inCS.getCellArray(CellType.getType(iCellArray)) != null) {
......@@ -178,7 +178,7 @@ public class CellCenters extends OutFieldVisualizationModule
outNodes[csCell] = iout;
}
}
CellArray outCA = new CellArray(CellType.POINT, outNodes, null, outIndices);
CellArray outCA = new CellArray(CellType.POINT, outNodes, null, null);
outCS.setCellArray(outCA);
outIrregularField.addCellSet(outCS);
}
......@@ -186,7 +186,8 @@ public class CellCenters extends OutFieldVisualizationModule
for (int iCellSet = 0, kout = 0; iCellSet < inField.getNCellSets(); iCellSet++) {
CellSet inCS = inField.getCellSet(iCellSet);
for (int iData = 0, iout = kout; iData < inCS.getNComponents(); iData++) {
for (int iData = 0; iData < inCS.getNComponents(); iData++) {
int iout = kout;
DataArray inDA = inCS.getComponent(iData);
String name = inDA.getName();
DataArrayType type = inDA.getType();
......@@ -205,40 +206,52 @@ public class CellCenters extends OutFieldVisualizationModule
}
}
}
LargeArray in = inDA.getRawArray();
LargeArray out = dataIndex >= 0 ? outIrregularField.getComponent(dataIndex).getRawArray() :
LargeArrayUtils.create(in.getType(), vlen * nNodes, true);
TimeData inTimeData = inDA.getTimeData();
TimeData outTimeData = dataIndex >= 0 ? outIrregularField.getComponent(dataIndex).getTimeData() :
new TimeData(type);
for (int iCellArray = 0; iCellArray < Cell.getNProperCellTypes(); iCellArray++) {
CellArray inCA = inCS.getCellArray(CellType.getType(iCellArray));
if (inCA != null && inCA.getDataIndices() != null) {
int[] inIndices = inCA.getDataIndices();
for (int k = 0; k < inIndices.length; k++, iout++)
try {
LargeArrayUtils.arraycopy(in, inIndices[k] * vlen, out, iout * vlen, vlen);
} catch (Exception e) {
System.out.println("");
}
}
if (inCA != null && inCA.getDataIndices() != null)
for (int i = 0; i < inTimeData.getNSteps(); i++) {
LargeArray in = inTimeData.getValue(inTimeData.getTime(i));
LargeArray out = outTimeData.produceValue(inTimeData.getTime(i), nNodes * vlen);
int[] inIndices = inCA.getDataIndices();
for (int k = 0; k < inIndices.length; k++, iout++)
try {
LargeArrayUtils.arraycopy(in, inIndices[k] * vlen, out, iout * vlen, vlen);
} catch (Exception e) {
System.out.println("");
}
}
else if (inCA != null)
iout += inCA.getNCells();
}
if (dataIndex < 0)
outIrregularField.addComponent(DataArray.create(out, vlen, inDA.getName() + "_" + iCellSet + "." + iData));
outIrregularField.addComponent(DataArray.create(outTimeData, vlen,
dataIndex == -1 ? inDA.getName() :
inDA.getName() + "_" + iCellSet + "." + iData));
}
for (CellArray inCA : inCS.getCellArrays())
kout += inCA.getNCells();
if (inCA != null)
kout += inCA.getNCells();
}
for (int iData = 0; iData < inField.getNComponents(); iData++) {
DataArray inDA = inField.getComponent(iData);
if (inDA.isNumeric()) {
int vl = inDA.getVectorLength();
int vlen = inDA.getVectorLength();
String name = inDA.getName();
boolean round = inDA.getType() == FIELD_DATA_BYTE || inDA.getType() == FIELD_DATA_SHORT ||
inDA.getType() == FIELD_DATA_INT || inDA.getType() == FIELD_DATA_LONG;
LargeArray in = inDA.getRawArray();
LargeArray out = LargeArrayUtils.create(in.getType(), nNodes * vl);
for (int iSet = 0, iout = 0; iSet < inField.getNCellSets(); iSet++)
iout = makeCellSetCentersData(inField.getCellSet(iSet), vl, in, out, iout, round);
TimeData inTimeData = inDA.getTimeData();
TimeData outTimeData = new TimeData(inDA.getType());
for (int i = 0; i < inTimeData.getNSteps(); i++) {
LargeArray in = inTimeData.getValue(inTimeData.getTime(i));
LargeArray out = outTimeData.produceValue(inTimeData.getTime(i), nNodes * vlen);
for (int iSet = 0, iout = 0; iSet < inField.getNCellSets(); iSet++)
iout = makeCellSetCentersData(inField.getCellSet(iSet), vlen, in, out, iout, round);
}
outIrregularField.addComponent(DataArray.create(outTimeData, vlen, name));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment