Code 2
Code 2
//Logging
m_logging.resize(100);
m_logging[0] = "Standard constructor invoked";
Springdatastructure::~Springdatastructure()
{
}
Springdatastructure::Springdatastructure(double width = -1, double height = -1, int granularity = -1)
{
if (width < 0)
{
m_width = defWIDTH;
}
else {
m_width = width;
}
if (height < 0)
{
m_height = defHEIGHT;
}
else {
m_height = height;
}
if (granularity <= 0)
{
m_granularity = defGRANULARITY;
}
else {
m_granularity = granularity;
}
void Springdatastructure::setCoordinates(void)
{
double dWidthrange = m_width * m_granularity;
double dHeightrange = m_height * m_granularity;
int iVectorsize = 0;
if (m_linktype == SIMPLETYPE)
{
iVectorsize = 4;
} else
{
iVectorsize = 8;
}
// Top Lane
for (int i = 1; i < meshwidth - 1; i++)
{
p_pointdata = &m_dataMesh[i][0];
// Mid Row
p_pointdata->vpNeighbours[3] = &m_dataMesh[i - 1][0];
p_pointdata->vpNeighbours[4] = &m_dataMesh[i + 1][0];
// Bottom Row
p_pointdata->vpNeighbours[5] = &m_dataMesh[i - 1][1];
p_pointdata->vpNeighbours[6] = &m_dataMesh[i][1];
p_pointdata->vpNeighbours[7] = &m_dataMesh[i + 1][1];
}
// Bottom Lane
for (int i = 1; i < meshwidth - 1; i++)
{
p_pointdata = &m_dataMesh[i][meshheight-1];
// Top Row
p_pointdata->vpNeighbours[0] = &m_dataMesh[i - 1][meshheight - 2];
p_pointdata->vpNeighbours[1] = &m_dataMesh[i][meshheight - 2];
p_pointdata->vpNeighbours[2] = &m_dataMesh[i + 1][meshheight - 2];
// Mid Row
p_pointdata->vpNeighbours[3] = &m_dataMesh[i - 1][meshheight - 1];
p_pointdata->vpNeighbours[4] = &m_dataMesh[i + 1][meshheight - 1];
// Left Lane
for (int j = 1; j < meshheight- 1; j++)
{
p_pointdata = &m_dataMesh[0][j];
// Right Row
p_pointdata->vpNeighbours[2] = &m_dataMesh[1][j - 1];
p_pointdata->vpNeighbours[4] = &m_dataMesh[1][j];
p_pointdata->vpNeighbours[7] = &m_dataMesh[1][j + 1];
// Mid Row
p_pointdata->vpNeighbours[1] = &m_dataMesh[0][j - 1];
p_pointdata->vpNeighbours[6] = &m_dataMesh[0][j + 1];
// Right Lane
for (int j = 1; j < meshheight - 1; j++)
{
p_pointdata = &m_dataMesh[meshwidth - 1][j];
// Left Row
p_pointdata->vpNeighbours[0] = &m_dataMesh[meshwidth - 2][j - 1];
p_pointdata->vpNeighbours[1] = &m_dataMesh[meshwidth - 2][j];
p_pointdata->vpNeighbours[5] = &m_dataMesh[meshwidth - 2][j + 1];
// Mid Row
p_pointdata->vpNeighbours[1] = &m_dataMesh[meshwidth - 1][j - 1];
p_pointdata->vpNeighbours[6] = &m_dataMesh[meshwidth - 1][j + 1];
}
/*
// Corner Points
*/
// Left-UP
p_cornerpoints = &m_dataMesh[0][0];
p_cornerpoints->vpNeighbours[4] = &m_dataMesh[1][0];
p_cornerpoints->vpNeighbours[7] = &m_dataMesh[1][1];
p_cornerpoints->vpNeighbours[6] = &m_dataMesh[0][1];
// Right-Up
p_cornerpoints = &m_dataMesh[meshwidth - 1][0];
p_cornerpoints->vpNeighbours[3] = &m_dataMesh[meshwidth - 2][0];
p_cornerpoints->vpNeighbours[5] = &m_dataMesh[meshwidth - 2][1];
p_cornerpoints->vpNeighbours[6] = &m_dataMesh[meshwidth - 1][1];
// Left-Down
p_cornerpoints = &m_dataMesh[0][meshheight - 1];
p_cornerpoints->vpNeighbours[1] = &m_dataMesh[0][meshheight - 2];
p_cornerpoints->vpNeighbours[2] = &m_dataMesh[1][meshheight - 1];
p_cornerpoints->vpNeighbours[4] = &m_dataMesh[1][meshheight - 1];
//Right-Down
p_cornerpoints = &m_dataMesh[meshwidth - 1][meshheight - 1];
void Springdatastructure::linkDataPointsSimple(void)
{
//Inner Rectangle
int meshwidth = m_dataMesh.size();
int meshheight = m_dataMesh[0].size();
Pointdata* p_cornerpoints;
Pointdata* p_pointdata;
// Bottom Row
p_pointdata->vpNeighbours[3] = &m_dataMesh[i][j + 1];
}
// Top Lane
for (int i = 1; i < meshwidth - 1; i++)
{
p_pointdata = &m_dataMesh[i][0];
// Mid Row
p_pointdata->vpNeighbours[1] = &m_dataMesh[i - 1][0];
p_pointdata->vpNeighbours[2] = &m_dataMesh[i + 1][0];
// Bottom Row
p_pointdata->vpNeighbours[3] = &m_dataMesh[i][1];
// Bottom Lane
for (int i = 1; i < meshwidth - 1; i++)
{
p_pointdata = &m_dataMesh[i][meshheight - 1];
// Top Row
p_pointdata->vpNeighbours[0] = &m_dataMesh[i][meshheight - 2];
// Mid Row
p_pointdata->vpNeighbours[1] = &m_dataMesh[i - 1][meshheight - 1];
p_pointdata->vpNeighbours[2] = &m_dataMesh[i + 1][meshheight - 1];
}
// Left Lane
for (int j = 1; j < meshheight - 1; j++)
{
p_pointdata = &m_dataMesh[0][j];
// Right Row
p_pointdata->vpNeighbours[2] = &m_dataMesh[1][j];
// Mid Row
p_pointdata->vpNeighbours[0] = &m_dataMesh[0][j - 1];
p_pointdata->vpNeighbours[3] = &m_dataMesh[0][j + 1];
// Right Lane
for (int j = 1; j < meshheight - 1; j++)
{
p_pointdata = &m_dataMesh[meshwidth - 1][j];
// Left Row
p_pointdata->vpNeighbours[1] = &m_dataMesh[meshwidth - 2][j];
// Mid Row
p_pointdata->vpNeighbours[0] = &m_dataMesh[meshwidth - 1][j - 1];
p_pointdata->vpNeighbours[3] = &m_dataMesh[meshwidth - 1][j + 1];
/*
// Corner Points
*/
// Left-UP
p_cornerpoints = &m_dataMesh[0][0];
p_cornerpoints->vpNeighbours[2] = &m_dataMesh[1][0];
p_cornerpoints->vpNeighbours[3] = &m_dataMesh[0][1];
// Right-Up
p_cornerpoints = &m_dataMesh[meshwidth - 1][0];
p_cornerpoints->vpNeighbours[1] = &m_dataMesh[meshwidth - 2][0];
p_cornerpoints->vpNeighbours[3] = &m_dataMesh[meshwidth - 1][1];
// Left-Down
p_cornerpoints = &m_dataMesh[0][meshheight - 1];
p_cornerpoints->vpNeighbours[0] = &m_dataMesh[0][meshheight - 2];
p_cornerpoints->vpNeighbours[2] = &m_dataMesh[1][meshheight - 1];
//Right-Down
p_cornerpoints = &m_dataMesh[meshwidth - 1][meshheight - 1];
p_cornerpoints->vpNeighbours[0] = &m_dataMesh[meshwidth - 1][meshheight - 2];
p_cornerpoints->vpNeighbours[1] = &m_dataMesh[meshwidth - 2][meshheight - 1];
}
void Springdatastructure::calculateNodeForces(void)
{
if (m_calculationtype == SIMPLECALCULATION)
{
calculateForcesSimple();
}
else if (m_calculationtype == ADVANCEDCALCULATION)
{
calculateForcesSimple();
calculateForcesAdvanced();
}
void Springdatastructure::calculateForcesSimple(void)
{
int meshwidth = m_dataMesh.size();
int meshheight = m_dataMesh[0].size();
int ineighbourcount = 0;
vector<CHVector> vtemp;
Pointdata* pdata;
vtemp.resize(4);
void Springdatastructure::calculateForcesAdvanced(void)
{
//TODO
}
psGeoPlacement->geosphere = geosphere;
psGeoPlacement->placement.AddGeo(&geosphere);
psGeoPlacement->placement.Translate(m_springDataMesh[0][i][j].gridpoint);
m_placementmesh.placement.AddPlacement(&psGeoPlacement->placement);
geosphere.Fini();
}
}
/*
* Update Sphere Position
*/
void StructureVisualisation::updateSpheres(void)
{
int width = m_springDataMesh->size();
int height = m_springDataMesh[0].size();
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
// TODO: Translate Delta
CPlacement* pPlacement = &m_placementmesh.subplacements[i][j].placement;
CHVector placementTranslation = pPlacement->GetTranslation();
CHVector newPostion = m_springDataMesh[0][i][j].gridpoint;
placementTranslation - newPostion;
pPlacement->TranslateDelta(placementTranslation);
}
}
}