void displayFunc() { /* define initial position for triangle */ GLint nVerts = 3; wcPt2D verts[3] = { { 50.0, 25.0 },{ 150.0, 25.0 },{ 100.0, 100.0 } }; /* calculate position of triangle centroid */ wcPt2D centroidPt; GLint k, xSum = 0, ySum = 0; for (k = 0; k < nVerts; k++) { xSum += verts[k].x; ySum += verts[k].y; } centroidPt.x = GLfloat(xSum) / GLfloat(nVerts); centroidPt.y = GLfloat(ySum) / GLfloat(nVerts); /* set geometric transformation parameters */ wcPt2D pivPt, fixedPt; pivPt = centroidPt; fixedPt = centroidPt; GLfloat tx = 0.0, ty = 100.0; GLfloat sx = 0.5, sy = 0.5; GLdouble theta = pi / 2.0; glClear(GL_COLOR_BUFFER_BIT); // clear display window glColor3f(0.0, 0.0, 1.0); // set initial fill coor to blue triangle(verts); // display blue triangle /* initialize composite matrix to identity */ matrix3x3SetIndentity(matComposite); // here will not copy matrix, because it sent a pointer which point to the matrix /* construc composite matrix to triangle vertices */ scale2D(sx, sy, fixedPt); rotate2D(pivPt, theta); translate2D(tx, ty); /* apply composite matrix to triangle verteices*/ transformVerts2D(nVerts, verts); glColor3f(1.0, 0.0, 0.0); // set color for transform triangle triangle(verts); // display red transformed triangle glFlush(); }
SimulationInitData_V2 CellInitHelper::initInputsV3(RawDataInput& rawData) { SimulationInitData_V2 initData; initData.isStab = rawData.isStab; initData.simuType = rawData.simuType; uint FnmCellCount = rawData.FNMCellCenters.size(); uint MxCellCount = rawData.MXCellCenters.size(); uint ECMCount = rawData.ECMCenters.size(); uint maxNodePerCell = globalConfigVars.getConfigValue("MaxNodePerCell").toInt(); uint maxNodePerECM = 0; if (initData.simuType == Beak) { maxNodePerECM = globalConfigVars.getConfigValue("MaxNodePerECM").toInt(); } uint initTotalCellCount = rawData.initCellNodePoss.size(); //uint initTotalECMCount = rawData.ECMCenters.size(); initData.initBdryNodeVec.resize(rawData.bdryNodes.size()); initData.initProfileNodeVec.resize(rawData.profileNodes.size()); if (simuType == Beak && !initData.isStab) { transformRawCartData(rawData.cartilageData, initData.cartPara, initData.initCartNodeVec); } initData.initECMNodeVec.resize(maxNodePerECM * ECMCount); initData.initFNMNodeVec.resize(maxNodePerCell * FnmCellCount); initData.initMXNodeVec.resize(maxNodePerCell * MxCellCount); for (uint i = 0; i < FnmCellCount; i++) { initData.cellTypes.push_back(FNM); initData.numOfInitActiveNodesOfCells.push_back(initTotalCellCount); } for (uint i = 0; i < MxCellCount; i++) { initData.cellTypes.push_back(MX); initData.numOfInitActiveNodesOfCells.push_back(initTotalCellCount); } for (uint i = 0; i < rawData.bdryNodes.size(); i++) { initData.initBdryNodeVec[i] = rawData.bdryNodes[i]; } for (uint i = 0; i < rawData.profileNodes.size(); i++) { initData.initProfileNodeVec[i] = rawData.profileNodes[i]; } uint index; uint ECMInitNodeCount = rawData.initECMNodePoss.size(); for (uint i = 0; i < ECMCount; i++) { vector<CVector> rotatedCoords = rotate2D(rawData.initECMNodePoss, rawData.ECMAngles[i]); for (uint j = 0; j < ECMInitNodeCount; j++) { index = i * maxNodePerECM + j; initData.initECMNodeVec[index] = rawData.ECMCenters[i] + rotatedCoords[j]; } } for (uint i = 0; i < FnmCellCount; i++) { for (uint j = 0; j < initTotalCellCount; j++) { index = i * maxNodePerCell + j; initData.initFNMNodeVec[index] = rawData.FNMCellCenters[i] + rawData.initCellNodePoss[j]; } } for (uint i = 0; i < MxCellCount; i++) { for (uint j = 0; j < initTotalCellCount; j++) { index = i * maxNodePerCell + j; initData.initMXNodeVec[index] = rawData.MXCellCenters[i] + rawData.initCellNodePoss[j]; } } return initData; }
SimulationInitData CellInitHelper::initInputsV2(RawDataInput &rawData) { SimulationInitData initData; uint FnmCellCount = rawData.FNMCellCenters.size(); uint MxCellCount = rawData.MXCellCenters.size(); uint ECMCount = rawData.ECMCenters.size(); uint maxNodePerCell = globalConfigVars.getConfigValue("MaxNodePerCell").toInt(); uint maxNodePerECM = 0; if (rawData.simuType == Beak) { maxNodePerECM = globalConfigVars.getConfigValue("MaxNodePerECM").toInt(); } uint initTotalCellCount = rawData.initCellNodePoss.size(); initData.initBdryCellNodePosX.resize(rawData.bdryNodes.size(), 0.0); initData.initBdryCellNodePosY.resize(rawData.bdryNodes.size(), 0.0); initData.initProfileNodePosX.resize(rawData.profileNodes.size()); initData.initProfileNodePosY.resize(rawData.profileNodes.size()); initData.initECMNodePosX.resize(maxNodePerECM * ECMCount); initData.initECMNodePosY.resize(maxNodePerECM * ECMCount); initData.initFNMCellNodePosX.resize(maxNodePerCell * FnmCellCount, 0.0); initData.initFNMCellNodePosY.resize(maxNodePerCell * FnmCellCount, 0.0); initData.initMXCellNodePosX.resize(maxNodePerCell * MxCellCount, 0.0); initData.initMXCellNodePosY.resize(maxNodePerCell * MxCellCount, 0.0); for (uint i = 0; i < FnmCellCount; i++) { initData.cellTypes.push_back(FNM); initData.numOfInitActiveNodesOfCells.push_back(initTotalCellCount); } for (uint i = 0; i < MxCellCount; i++) { initData.cellTypes.push_back(MX); initData.numOfInitActiveNodesOfCells.push_back(initTotalCellCount); } for (uint i = 0; i < rawData.bdryNodes.size(); i++) { initData.initBdryCellNodePosX[i] = rawData.bdryNodes[i].x; initData.initBdryCellNodePosY[i] = rawData.bdryNodes[i].y; } for (uint i = 0; i < rawData.profileNodes.size(); i++) { initData.initProfileNodePosX[i] = rawData.profileNodes[i].x; initData.initProfileNodePosY[i] = rawData.profileNodes[i].y; } uint index; uint ECMInitNodeCount = rawData.initECMNodePoss.size(); for (uint i = 0; i < ECMCount; i++) { vector<CVector> rotatedCoords = rotate2D(rawData.initECMNodePoss, rawData.ECMAngles[i]); for (uint j = 0; j < ECMInitNodeCount; j++) { index = i * maxNodePerECM + j; initData.initECMNodePosX[index] = rawData.ECMCenters[i].x + rotatedCoords[j].x; initData.initECMNodePosY[index] = rawData.ECMCenters[i].y + rotatedCoords[j].y; } } for (uint i = 0; i < FnmCellCount; i++) { for (uint j = 0; j < initTotalCellCount; j++) { index = i * maxNodePerCell + j; initData.initFNMCellNodePosX[index] = rawData.FNMCellCenters[i].x + rawData.initCellNodePoss[j].x; initData.initFNMCellNodePosY[index] = rawData.FNMCellCenters[i].y + rawData.initCellNodePoss[j].y; } } for (uint i = 0; i < MxCellCount; i++) { for (uint j = 0; j < initTotalCellCount; j++) { index = i * maxNodePerCell + j; initData.initMXCellNodePosX[index] = rawData.MXCellCenters[i].x + rawData.initCellNodePoss[j].x; initData.initMXCellNodePosY[index] = rawData.MXCellCenters[i].y + rawData.initCellNodePoss[j].y; } } return initData; }