|
From: <le...@us...> - 2006-12-08 15:17:14
|
Revision: 56
http://svn.sourceforge.net/qcell/?rev=56&view=rev
Author: lessm
Date: 2006-12-08 07:17:09 -0800 (Fri, 08 Dec 2006)
Log Message:
-----------
- some bugs removed from CalculationData, LocalFunction, Neighbourhood classes
Modified Paths:
--------------
trunk/qcell/baseheaders/CalculationData.h
trunk/qcell/basesources/CalculationData.cpp
trunk/qcell/basesources/LocalFunction.cpp
trunk/qcell/basesources/Neighbourhood.cpp
Modified: trunk/qcell/baseheaders/CalculationData.h
===================================================================
--- trunk/qcell/baseheaders/CalculationData.h 2006-12-05 18:47:39 UTC (rev 55)
+++ trunk/qcell/baseheaders/CalculationData.h 2006-12-08 15:17:09 UTC (rev 56)
@@ -21,12 +21,13 @@
bool borderExist;
-//protected:
-public:
+protected:
+//public:
bool resize(const char *dataPointer=NULL);
void * getAddressAt(int x, int y, int z, int t);
void * getAddressAtBackBuffer(int x, int y, int z, int t);
void calculateBackBufferSize(void);
+ void copyData(void);
public:
@@ -53,7 +54,7 @@
void setValueAt_d(double val, int x, int y, int z);
void setValueAt_d(double val, int x, int y, int z, int t);
- void setDataType(baseDataTypes::DATA_TYPES type = baseDataTypes::CHAR);
+ void setDataType(baseDataTypes::DATA_TYPES type = baseDataTypes::DATA_TYPES::CHAR);
baseDataTypes::DATA_TYPES getDataType(void);
int getDataSize(void);
@@ -73,13 +74,12 @@
void fill(const char *dataPointer);
- void setCalculationSpace(void);
- void setCalculationSpace(int startX, int endX);
- void setCalculationSpace(int startX, int startY, int endX, int endY);
- void setCalculationSpace(int startX, int startY, int startZ, int endX, int endY, int endZ);
- void setCalculationSpace(int startX, int startY, int startZ, int startT, int endX, int endY, int endZ, int endT);
+ void setCalculationSpace(bool noDataCopy=0);
+ void setCalculationSpace(int startX, int endX, bool noDataCopy=0);
+ void setCalculationSpace(int startX, int startY, int endX, int endY, bool noDataCopy=0);
+ void setCalculationSpace(int startX, int startY, int startZ, int endX, int endY, int endZ, bool noDataCopy=0);
+ void setCalculationSpace(int startX, int startY, int startZ, int startT, int endX, int endY, int endZ, int endT, bool noDataCopy=0);
- void removeBorder(void);
bool haveBorder(void);
QString createXmlHeader(void);
@@ -96,8 +96,9 @@
void setValueAt_d_Back(double val, int x, int y, int z);
void setValueAt_d_Back(double val, int x, int y, int z, int t);
- void clearFrontBuffer_i(int val=0);
- void clearFrontBuffer_d(double val=0.0);
+ void fillData_i(int val=0);
+ void fillData_d(double val=0.0);
+
};
#endif
Modified: trunk/qcell/basesources/CalculationData.cpp
===================================================================
--- trunk/qcell/basesources/CalculationData.cpp 2006-12-05 18:47:39 UTC (rev 55)
+++ trunk/qcell/basesources/CalculationData.cpp 2006-12-08 15:17:09 UTC (rev 56)
@@ -1,4 +1,4 @@
-#include "../baseheaders/CalculationData.h"
+#include "CalculationData.h"
bool CalculationData::resize(const char *dataPointer)
{
@@ -29,7 +29,7 @@
switch(dataType)
{
case baseDataTypes::DATA_TYPES::BOOL:
- size = 0;
+ dSize = sizeof(char);
break;
case baseDataTypes::DATA_TYPES::CHAR:
@@ -67,7 +67,7 @@
break;
case baseDataTypes::DATA_TYPES::CHAR:
- dSize = 1;
+ dSize = sizeof(char);
break;
case baseDataTypes::DATA_TYPES::INT:
@@ -100,6 +100,8 @@
if(x<0)
x=0;
+ //int index = dSize * (x + y * backBufferSizeX + z * backBufferSizeX * backBufferSizeY + t * backBufferSizeX * backBufferSizeY * backBufferSizeZ);
+
return dataBorderFree + dSize * (x + y * backBufferSizeX + z * backBufferSizeX * backBufferSizeY + t * backBufferSizeX * backBufferSizeY * backBufferSizeZ);
}
@@ -108,16 +110,46 @@
switch(dimension)
{
case 4:
- backBufferSizeT = maxT - minT;
+ backBufferSizeT = (maxT - minT) + 1;
case 3:
- backBufferSizeZ = maxZ - minZ;
+ backBufferSizeZ = (maxZ - minZ) + 1;
case 2:
- backBufferSizeY = maxY - minY;
+ backBufferSizeY = (maxY - minY) + 1;
case 1:
- backBufferSizeX = maxX - minX;
+ backBufferSizeX = (maxX - minX) + 1;
}
+
+ if(maxX<0)
+ maxX=0;
+
+ if(maxY<0)
+ maxY=0;
+
+ if(maxZ<0)
+ maxZ=0;
+
+ if(maxT<0)
+ maxT=0;
}
+void CalculationData::copyData(void)
+{
+ int counterF=0, counterB=0;
+ for(int t=minT;t<=maxT;++t)
+ {
+ for(int z=minZ;z<=maxZ;++z)
+ {
+ for(int y=minY;y<=maxY;++y)
+ {
+ counterF += minX * size;
+ memcpy(dataBorderFree + counterB, data + counterF, backBufferSizeX * size);
+ counterF += (sizeX - minX) * size;
+ counterB += backBufferSizeX * size;
+ }
+ }
+ }
+}
+
CalculationData::CalculationData()
{
dataType = baseDataTypes::DATA_TYPES::NONE;
@@ -617,17 +649,17 @@
}
}
-void CalculationData::setCalculationSpace(void)
+void CalculationData::setCalculationSpace(bool noDataCopy)
{
minX = 0;
minY = 0;
minZ = 0;
minT = 0;
- maxX = sizeX;
- maxY = sizeY;
- maxZ = sizeZ;
- maxT = sizeT;
+ maxX = sizeX - 1;
+ maxY = sizeY - 1;
+ maxZ = sizeZ - 1;
+ maxT = sizeT - 1;
borderExist = 0;
if(dataBorderFree)
@@ -636,37 +668,53 @@
}
dataBorderFree = new char[getSizeInByte()];
calculateBackBufferSize();
+ if(!noDataCopy)
+ copyData();
}
-void CalculationData::setCalculationSpace(int startX, int endX)
+void CalculationData::setCalculationSpace(int startX, int endX, bool noDataCopy)
{
minX = startX;
maxX = endX;
+ minY = 0;
+ maxY = 0;
+ minZ = 0;
+ maxZ = 0;
+ minT = 0;
+ maxT = 0;
borderExist = 1;
if(dataBorderFree)
{
delete[] dataBorderFree;
}
- dataBorderFree = new char[(maxX - minX) * size];
+ dataBorderFree = new char[((maxX - minX) + 1) * size];
calculateBackBufferSize();
+ if(!noDataCopy)
+ copyData();
}
-void CalculationData::setCalculationSpace(int startX, int startY, int endX, int endY)
+void CalculationData::setCalculationSpace(int startX, int startY, int endX, int endY, bool noDataCopy)
{
minX = startX;
maxX = endX;
minY = startY;
maxY = endY;
+ minZ = 0;
+ maxZ = 0;
+ minT = 0;
+ maxT = 0;
borderExist = 1;
if(dataBorderFree)
{
delete[] dataBorderFree;
}
- dataBorderFree = new char[((maxX - minX) * (maxY - minY)) * size];
+ dataBorderFree = new char[(((maxX - minX) + 1) * ((maxY - minY) + 1)) * size];
calculateBackBufferSize();
+ if(!noDataCopy)
+ copyData();
}
-void CalculationData::setCalculationSpace(int startX, int startY, int startZ, int endX, int endY, int endZ)
+void CalculationData::setCalculationSpace(int startX, int startY, int startZ, int endX, int endY, int endZ, bool noDataCopy)
{
minX = startX;
maxX = endX;
@@ -674,16 +722,20 @@
maxY = endY;
minZ = startZ;
maxZ = endZ;
+ minT = 0;
+ maxT = 0;
borderExist = 1;
if(dataBorderFree)
{
delete[] dataBorderFree;
}
- dataBorderFree = new char[((maxX - minX) * (maxY - minY) * (maxZ - minZ)) * size];
+ dataBorderFree = new char[(((maxX - minX) + 1) * ((maxY - minY) + 1) * ((maxZ - minZ) + 1)) * size];
calculateBackBufferSize();
+ if(!noDataCopy)
+ copyData();
}
-void CalculationData::setCalculationSpace(int startX, int startY, int startZ, int startT, int endX, int endY, int endZ, int endT)
+void CalculationData::setCalculationSpace(int startX, int startY, int startZ, int startT, int endX, int endY, int endZ, int endT, bool noDataCopy)
{
minX = startX;
maxX = endX;
@@ -698,77 +750,12 @@
{
delete[] dataBorderFree;
}
- dataBorderFree = new char[((maxX - minX) * (maxY - minY) * (maxZ - minZ) * (maxT - minT)) * size];
+ dataBorderFree = new char[(((maxX - minX) + 1) * ((maxY - minY) + 1) * ((maxZ - minZ) + 1) * ((maxT - minT) + 1)) * size];
calculateBackBufferSize();
+ if(!noDataCopy)
+ copyData();
}
-void CalculationData::removeBorder(void)
-{
- char *temp;
- int newSize = 1, counter = 0;
- if(borderExist)
- {
- switch(dimension)
- {
-
- case 4:
- newSize *= maxT - minT;
-
- case 3:
- newSize *= maxZ - minZ;
-
- case 2:
- newSize *= maxY - minY;
-
- case 1:
- newSize *= maxX - minX;
- break;
-
- default:
- newSize = 0;
- }
-
- temp = new char[newSize * size];
-
- for(int t=minT;t<maxT;++t)
- {
- for(int z=minZ;z<maxZ;++z)
- {
- for(int y=minY;y<maxY;++y)
- {
- for(int x=minX;x<maxX;++x)
- {
- memcpy(temp + counter, getAddressAt(x, y, z, t), size);
- counter += size;
- }
- }
- }
- }
-
- switch(dimension)
- {
-
- case 4:
- sizeT = maxT - minT;
-
- case 3:
- sizeZ = maxZ - minZ;
-
- case 2:
- sizeY = maxY - minY;
-
- case 1:
- sizeX = maxX - minX;
- }
-
- delete[] data;
- data = temp;
- temp = NULL;
-
- }
- borderExist = 0;
-}
-
bool CalculationData::haveBorder(void)
{
return borderExist;
@@ -1079,7 +1066,7 @@
}
}
-void CalculationData::clearFrontBuffer_i(int val)
+void CalculationData::fillData_i(int val)
{
int dSize;
switch(dataType)
@@ -1113,7 +1100,7 @@
}
}
-void CalculationData::clearFrontBuffer_d(double val)
+void CalculationData::fillData_d(double val)
{
int dSize;
switch(dataType)
Modified: trunk/qcell/basesources/LocalFunction.cpp
===================================================================
--- trunk/qcell/basesources/LocalFunction.cpp 2006-12-05 18:47:39 UTC (rev 55)
+++ trunk/qcell/basesources/LocalFunction.cpp 2006-12-08 15:17:09 UTC (rev 56)
@@ -1,4 +1,4 @@
-#include "../baseheaders/LocalFunction.h"
+#include "LocalFunction.h"
void LocalFunction::resizeValueTable(void)
{
@@ -27,6 +27,7 @@
}
valueTable.resize(numElements);
+ valueTable.fill(0);
}
int LocalFunction::mostPopularValue(void)
@@ -165,6 +166,11 @@
{
numArg = numberOfArguments;
maxArgVal = alphabetSize;
+ valueTable.clear();
+ sumArguments.clear();
+ productArguments.clear();
+ freeArguments.clear();
+ functionMode = LocalFunction::FUNCTION_TYPE::SWITCH;
}
void LocalFunction::setSumArguments(QVector<int> arg)
@@ -268,7 +274,7 @@
bool LocalFunction::addFunctionValue(int value, QVector<int> args)
{
- int i, index = 0;
+ int i, index = 0, t;
if(valueTable.empty())
resizeValueTable();
switch(functionMode)
@@ -279,12 +285,16 @@
break;
case LocalFunction::FUNCTION_TYPE::MIXED_SUM_SWITCH:
- case LocalFunction::FUNCTION_TYPE::MIXED_PRODUCT_SWITCH:
+
+ t = freeArguments.size();
for(i=0;i<freeArguments.size();++i)
index += args[i+1] * pow(maxArgVal, i);
- index *= args[0];
+ index += args[0] * pow(maxArgVal, freeArguments.size());
break;
+ case LocalFunction::FUNCTION_TYPE::MIXED_PRODUCT_SWITCH:
+ break;
+
case LocalFunction::FUNCTION_TYPE::SWITCH:
for(i=0;i<numArg;++i)
index += args[i] * pow(maxArgVal, i);
@@ -296,7 +306,7 @@
int LocalFunction::resolve(QVector<int> args)
{
- int i, index = 0;
+ int i, index = 0, temp;
if(valueTable.empty())
resizeValueTable();
if(functionMode==LocalFunction::FUNCTION_TYPE::SCRIPT)
@@ -310,12 +320,19 @@
break;
case LocalFunction::FUNCTION_TYPE::MIXED_SUM_SWITCH:
- case LocalFunction::FUNCTION_TYPE::MIXED_PRODUCT_SWITCH:
for(i=0;i<freeArguments.size();++i)
- index += args[i+1] * pow(maxArgVal, i);
- index *= args[0];
+ index += args[freeArguments[i]] * pow(maxArgVal, i);
+
+ temp = 0;
+ for(i=0;i<sumArguments.size();++i)
+ temp += args[sumArguments[i]];
+
+ index += temp * pow(maxArgVal, freeArguments.size());
break;
+ case LocalFunction::FUNCTION_TYPE::MIXED_PRODUCT_SWITCH:
+ break;
+
case LocalFunction::FUNCTION_TYPE::SWITCH:
for(i=0;i<numArg;++i)
index += args[i] * pow(maxArgVal, i);
Modified: trunk/qcell/basesources/Neighbourhood.cpp
===================================================================
--- trunk/qcell/basesources/Neighbourhood.cpp 2006-12-05 18:47:39 UTC (rev 55)
+++ trunk/qcell/basesources/Neighbourhood.cpp 2006-12-08 15:17:09 UTC (rev 56)
@@ -1,4 +1,4 @@
-#include "../baseheaders/Neighbourhood.h"
+#include "Neighbourhood.h"
Neighbourhood::Neighbourhood()
{
@@ -302,18 +302,8 @@
break;
}
- int h;
- int a, b, c, d;
-
for(int i=0;i<neighbourVector.size();i++)
- {
- a = neighbourVector[i].x;
- b = neighbourVector[i].y;
- c = neighbourVector[i].z;
- d = neighbourVector[i].t;
- h = dataSize * (neighbourVector[i].x + neighbourVector[i].y * sizeX + neighbourVector[i].z * sizeX * sizeY + neighbourVector[i].t * sizeX * sizeY * sizeZ);
- neighbourVector[i].offset = h;
- }
+ neighbourVector[i].offset = dataSize * (neighbourVector[i].x + neighbourVector[i].y * sizeX + neighbourVector[i].z * sizeX * sizeY + neighbourVector[i].t * sizeX * sizeY * sizeZ);
}
void Neighbourhood::resolveValues(const char *address)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|