Exemplo n.º 1
0
void Curve::sewPeriodic(GridData& gdata)
{
	// sewing
	Triple n;

	unsigned int columns = gdata.columns();
	unsigned int rows = gdata.rows();

	if (gdata.uperiodic()) {
		for (unsigned i = 0; i != columns; ++i) {
			n = Triple(gdata.normals[i][0][0] + gdata.normals[i][rows-1][0],
				gdata.normals[i][0][1] + gdata.normals[i][rows-1][1],
				gdata.normals[i][0][2] + gdata.normals[i][rows-1][2]);

			n.normalize();        
			gdata.normals[i][0][0] = gdata.normals[i][rows-1][0] = n.x;
			gdata.normals[i][0][1] = gdata.normals[i][rows-1][1] = n.y;
			gdata.normals[i][0][2] = gdata.normals[i][rows-1][2] = n.z;
		}
	}

	if (gdata.vperiodic()) {
		for (unsigned j = 0; j != rows; ++j) {
			n = Triple(gdata.normals[0][j][0] + gdata.normals[columns-1][j][0],
				gdata.normals[0][j][1] + gdata.normals[columns-1][j][1],
				gdata.normals[0][j][2] + gdata.normals[columns-1][j][2]);

			n.normalize();        
			gdata.normals[0][j][0] = gdata.normals[columns-1][j][0] = n.x;
			gdata.normals[0][j][1] = gdata.normals[columns-1][j][1] = n.y;
			gdata.normals[0][j][2] = gdata.normals[columns-1][j][2] = n.z;
		}
	}
}
Exemplo n.º 2
0
void GridPlot::sewPeriodic(GridData& gdata)
{
    // sewing

    Triple n;

    unsigned int columns = gdata.columns();
    unsigned int rows = gdata.rows();

    if (gdata.uperiodic())
    {
        for (unsigned i = 0; i != columns; ++i)
        {
            n = gdata.normals[i][0] + gdata.normals[i][rows-1];
            n.normalize();
            gdata.normals[i][0] = gdata.normals[i][rows-1] = n;
        }
    }
    if (gdata.vperiodic())
    {
        for (unsigned j = 0; j != rows; ++j)
        {
            n = gdata.normals[0][j] + gdata.normals[columns-1][j];
            n.normalize();
            gdata.normals[0][j] = gdata.normals[columns-1][j] = n;
        }
    }
}