void DeformationPath::badMorphing() { for(double t = 0; t <= 1.0; t += scheduler->timeStep) { // Current nodes geometry QMap<Structure::Node*, Array1D_Vector3> startGeometry; for(auto n : scheduler->activeGraph->nodes) { if(n->property["taskTypeReal"].toInt() == Task::GROW) { Array1D_Vector3 pnts = n->controlPoints(); Vector3 p = pnts.front(); Array1D_Vector3 newpnts(pnts.size(), p); for(auto & p: newpnts) p += Eigen::Vector3d(starlab::uniformRand(), starlab::uniformRand(), starlab::uniformRand()) * 1e-5; n->setControlPoints(newpnts); } if(n->property["taskTypeReal"].toInt() == Task::SHRINK) { auto tn = scheduler->targetGraph->getNode( n->property["correspond"].toString() ); Array1D_Vector3 pnts = tn->controlPoints(); Vector3 p = pnts[pnts.size() / 2]; Array1D_Vector3 newpnts(pnts.size(), p); for(auto & p: newpnts) p += Eigen::Vector3d(starlab::uniformRand(), starlab::uniformRand(), starlab::uniformRand()) * 1e-5; tn->setControlPoints(newpnts); } startGeometry[n] = n->controlPoints(); } // Morph nodes for(auto n : scheduler->activeGraph->nodes) { auto tn = scheduler->targetGraph->getNode( n->property["correspond"].toString() ); if(!tn) continue; Array1D_Vector3 finalGeometry = tn->controlPoints(); Array1D_Vector3 newGeometry; for(int i = 0; i < (int) finalGeometry.size(); i++) newGeometry.push_back( AlphaBlend(t, startGeometry[n][i], Vector3(finalGeometry[i])) ); n->setControlPoints( newGeometry ); n->property["t"].setValue( t ); if(t > 0.5 && n->property["taskTypeReal"].toInt() == Task::SHRINK) n->property["shrunk"].setValue( true ); } scheduler->allGraphs.push_back( new Structure::Graph( *scheduler->activeGraph ) ); } property["progressDone"] = true; }
Patch::Patch(string id, int order, int partsU, int partsV, string compute, vector<vector<float>> controlPoints) : Primitive(id) { this->order = order; this->partsU = partsU; this->partsV = partsV; this->compute = compute; setControlPoints(controlPoints); if(order == 1) { /** control points when the order is 1 */ for (int i = 0; i < this->controlPoints.size(); i++) { vector<float> controlPoint = this->controlPoints[i]; for (int k = 0; k < controlPoint.size(); k++) { this->vecControlPointsOrder1[i][k] = controlPoint[k]; } } } else if(order == 2) { /** control points when the order is 1 */ for (int i = 0; i < this->controlPoints.size(); i++) { vector<float> controlPoint = this->controlPoints[i]; for (int k = 0; k < controlPoint.size(); k++) { this->vecControlPointsOrder2[i][k] = controlPoint[k]; } } } else if(order == 3) { /** control points when the order is 1 */ for (int i = 0; i < this->controlPoints.size(); i++) { vector<float> controlPoint = this->controlPoints[i]; for (int k = 0; k < controlPoint.size(); k++) { this->vecControlPointsOrder3[i][k] = controlPoint[k]; } } } /** texture points */ this->textPoints[1][0] = 0; this->textPoints[1][1] = 0; this->textPoints[0][0] = 0; this->textPoints[0][1] = 1; this->textPoints[3][0] = 1; this->textPoints[3][1] = 0; this->textPoints[2][0] = 1; this->textPoints[2][1] = 1; }