int main(void) { ap2(); ap3(); printf( "done\n" ); return( 0 ); }
void test1(){ AutoPtr<int> ap(new int(1)); AutoPtr<int> ap1(ap); //ap1 = ap; *ap1 = 10; //AutoPtr<int> ap2(ap1); AutoPtr<A> ap3(new A); ap3->a = 30; }
void Squid::draw() { glPushMatrix(); glTranslatef(loc.x, loc.y, loc.z); glRotatef(rot, 0, 0, 1); output.setColor(125, 125, 125); ofNoFill(); ofSetLineWidth(3); output.beginShape(); float cenX = 0; float cenY = 0; float pct = _breath / (MAX_INHALE_BREATH - MIN_INHALE_BREATH); float rad2 = (MAX_INHALE_BREATH - MIN_INHALE_BREATH) * pct; float bw = (BODY_WIDTH * .5); float bh = (BODY_HEIGHT * .25) + ( (BODY_HEIGHT * .25) * (1 - _pctBreath)); float topBw = bw * .7; float botBw = bw * 1.5; float botCtPtSpread = botBw * .25; float bodyCtPtSpread = bh * .25; ofxVec3f ap1(cenX + topBw, cenY - bh, 0); ofxVec3f cp1a(cenX + rad2, cenY - bodyCtPtSpread, 0 ); ofxVec3f cp1b(cenX + rad2, cenY + bodyCtPtSpread, 0 ); ofxVec3f ap2(cenX + botBw, cenY + bh, 0); ofxVec3f cp2a(cenX + botCtPtSpread, (cenY + bh) + (bh * .25), 0); ofxVec3f cp2b(cenX - botCtPtSpread, (cenY + bh) + (bh * .25), 0); ofxVec3f ap3(cenX - botBw, cenY + bh, 0); ofxVec3f cp3a(cenX - rad2, cenY + bodyCtPtSpread, 0); ofxVec3f cp3b(cenX - rad2, cenY - bodyCtPtSpread, 0); ofxVec3f ap4(cenX - topBw, cenY - bh, 0); ofxVec3f cp4(cenX, (cenY - bh) - (bh * .1), 0); output.polyVertex(ap1.x, ap1.y); output.bezierVertex(cp1a.x, cp1a.y, cp1b.x, cp1b.y, ap2.x, ap2.y); output.bezierVertex(cp2a.x, cp2a.y, cp2b.x, cp2b.y, ap3.x, ap3.y); output.bezierVertex(cp3a.x, cp3a.y, cp3b.x, cp3b.y, ap4.x, ap4.y); output.bezierVertex(cp4.x, cp4.y, cp4.x, cp4.y, ap1.x, ap1.y); output.endShape(true); ofFill(); ofSetColor(200, 200, 200); ofCircle(cp1a.x, cp1a.y, 2); ofCircle(cp1b.x, cp1b.y, 2); ofCircle(cp2a.x, cp2a.y, 2); ofCircle(cp2b.x, cp2b.y, 2); ofCircle(cp3a.x, cp3a.y, 2); ofCircle(cp3b.x, cp3b.y, 2); ofSetColor(0, 0, 0); //ofCircle(cp4.x, cp4.y, 2); ofSetColor(150, 150, 150); ofCircle(ap1.x, ap1.y, 1); ofCircle(ap2.x, ap2.y, 1); ofCircle(ap3.x, ap3.y, 1); ofCircle(ap4.x, ap4.y, 1); glPopMatrix(); _renderTentacles(); }
//===========================================================================// int main(int argc, char ** argv){ try{ //--- //--- create the utility class for parsing parameters //--- UtilParameters utilParam(argc, argv); bool useAlps = utilParam.GetSetting("useAlps", true); bool doCut = utilParam.GetSetting("doCut", true); bool doPrice = utilParam.GetSetting("doPrice", false); bool doPriceCut = utilParam.GetSetting("doPriceCut", false); bool doRelaxCut = utilParam.GetSetting("doRelaxCut", false); bool doModelI = utilParam.GetSetting("doModelI", true); bool doModelJ = utilParam.GetSetting("doModelJ", false); bool doModelK = utilParam.GetSetting("doModelK", false); AlpsTimer timer; double timeSetupReal = 0.0; double timeSetupCpu = 0.0; double timeSolveReal = 0.0; double timeSolveCpu = 0.0; timer.start(); //--- //--- create the user application (a DecompApp) //--- AP3_DecompApp ap3(utilParam); ap3.createModel(); //--- //--- create the algorithm(s) (a DecompAlgo) //--- DecompAlgoC2 * cut = NULL; DecompAlgoPC2 * priceI = NULL; DecompAlgoPC2 * priceJ = NULL; DecompAlgoPC2 * priceK = NULL; DecompAlgoPC2 * pcI = NULL; DecompAlgoPC2 * pcJ = NULL; DecompAlgoPC2 * pcK = NULL; DecompAlgoRC * rcI = NULL; DecompAlgoRC * rcJ = NULL; DecompAlgoRC * rcK = NULL; if(doCut){ cut = new DecompAlgoC2(&ap3, &utilParam); } if(doPrice){ CoinAssertHint(doModelI || doModelJ || doModelK, "Error: must pick some base model to price"); if(doModelI){ priceI = new DecompAlgoPC2(&ap3, &utilParam, "PRICE", true, AP3_DecompApp::MODEL_I); } if(doModelJ){ priceJ = new DecompAlgoPC2(&ap3, &utilParam, "PRICE", true, AP3_DecompApp::MODEL_J); } if(doModelK){ priceK = new DecompAlgoPC2(&ap3, &utilParam, "PRICE", true, AP3_DecompApp::MODEL_K); } } if(doPriceCut){ CoinAssertHint(doModelI || doModelJ || doModelK, "Error: must pick some base model to price"); if(doModelI){ pcI = new DecompAlgoPC2(&ap3, &utilParam, AP3_DecompApp::MODEL_I); } if(doModelJ){ pcJ = new DecompAlgoPC2(&ap3, &utilParam, AP3_DecompApp::MODEL_J); } if(doModelK){ pcK = new DecompAlgoPC2(&ap3, &utilParam, AP3_DecompApp::MODEL_K); } } if(doRelaxCut){ CoinAssertHint(doModelI || doModelJ || doModelK, "Error: must pick some base model to price"); if(doModelI){ rcI = new DecompAlgoRC(&ap3, &utilParam, AP3_DecompApp::MODEL_I); } if(doModelJ){ rcJ = new DecompAlgoRC(&ap3, &utilParam, AP3_DecompApp::MODEL_J); } if(doModelK){ rcK = new DecompAlgoRC(&ap3, &utilParam, AP3_DecompApp::MODEL_K); } } if(useAlps){ //--- //--- create the driver AlpsDecomp model //--- AlpsDecompModel alpsModel(utilParam); if(cut) alpsModel.addDecompAlgo(cut); if(priceI) alpsModel.addDecompAlgo(priceI); if(priceJ) alpsModel.addDecompAlgo(priceJ); if(priceK) alpsModel.addDecompAlgo(priceK); if(pcI) alpsModel.addDecompAlgo(pcI); if(pcJ) alpsModel.addDecompAlgo(pcJ); if(pcK) alpsModel.addDecompAlgo(pcK); if(rcI) alpsModel.addDecompAlgo(rcI); if(rcJ) alpsModel.addDecompAlgo(rcJ); if(rcK) alpsModel.addDecompAlgo(rcK); timer.stop(); timeSetupCpu = timer.getCpuTime(); timeSetupReal = timer.getWallClock(); timer.start(); alpsModel.solve(); timer.stop(); timeSolveCpu = timer.getCpuTime(); timeSolveReal = timer.getWallClock(); //--- //--- sanity check //--- cout << "Instance = " << ap3.getInstanceName() << " Solution = " << alpsModel.getBestObj() << " SetupCPU = " << timeSetupCpu << " SolveCPU = " << timeSolveCpu << endl; double diff = alpsModel.getBestObj() - ap3.getKnownOptimalBound(); CoinAssert(UtilIsZero(diff)); }else{ //--- //--- just solve the bounding problem (root node) //--- } if(cut) delete cut; if(priceI) delete priceI; if(priceJ) delete priceJ; if(priceK) delete priceK; if(pcI) delete pcI; if(pcJ) delete pcJ; if(pcK) delete pcK; if(rcI) delete rcI; if(rcJ) delete rcJ; if(rcK) delete rcK; } catch(CoinError & ex){ cerr << "COIN Exception:" << ex.message() << endl << " from method " << ex.methodName() << endl << " from class " << ex.className() << endl; } }
void quaterN::c1stitch(quaterN const& a, quaterN const& b) { // use hermite curve(); c0stitch(a, b); ///////////////////////////////// // 123 : time // _____ src motion // ++++ add motion // | con // - guess velocity of srcMotion of this frame // **** make displacementmap // m21 // p 01 //disp1 // *** //disp2 // *** //////////////////////// int con=a.rows()-1; quater sp1(row(con-1)); // src position at time 1 quater p2(row(con)); // center position at time 2 quater ap3(row(con+1)); // add position at time3 quater sv; quater av; quater cv; sv.difference(sp1, p2); av.difference(p2, ap3); cv.interpolate(0.5f, sv, av); // desired velocity at con. // guess position of desired curve quater p1, p3; p1.mult( cv.inverse(), p2); p3.mult( cv, p2); quater sp3; sp3.mult(sv, p2); quater ap1; ap1.mult(av.inverse(), p2); static quaterN disp1, disp2; quater disp_sp2, disp_sp3; disp_sp2.identity(); // p2->p2 disp_sp3.difference(sp3, p3); quater disp_ap1, disp_ap2; disp_ap1.difference(ap1, p1); disp_ap2.identity(); // only half of velocity difference is stitched disp_sp3.scale(0.5); disp_ap1.scale(0.5); disp1.hermite(quater(1,0,0,0), quater(1,0,0,0), a.rows(), disp_sp2, disp_sp3); disp2.hermite(disp_ap1, disp_ap2, b.rows(), quater(1,0,0,0), quater(1,0,0,0)); // forward filling for(int i=0; i<disp1.rows(); i++) row(i)*=disp1.row(i); // backward filling for(int i=0; i<disp2.rows(); i++) row(rows()-i-1)*=disp2.row(disp2.rows()-i-1); }
void quaterN::displacement(const quater& sp1, const quater& sp2, const quater& ap22, const quater& ap33, int start, int end) { ///////////////////////////////// // sp123 // ____ src motion // ++++ add motion // ap123 // -- guess position and velocity of srcMotion of these frames // **** make displacementmap // m21 // p 01 //disp1 // *** //disp2 // *** //////////////////////// quater ap2(ap22); quater ap3(ap33); //ASSERT(sp2%sp1>0); ap2.align(sp2); ap3.align(ap2); quater center,center_halfvel, center_3halfvel; quater sp3, ap1; quater sv; quater av; sv.difference(sp1, sp2); av.difference(ap2, ap3); center.interpolate(0.5f, sp2,ap2); center_halfvel.interpolate(0.5f, sv, av); // the following two lines are heuristic velocity adjustment. (Think about it by drawing the situation by yourself.) quater center_halfvel2; center_halfvel2.difference(sp2, ap2); center_halfvel2.align(quater(1,0,0,0)); center_halfvel2.scale(1.f/((float)(end-start)*8.f)); center_halfvel.leftMult(center_halfvel2); center_3halfvel=center_halfvel; center_3halfvel.scale(0.5f*3.f); center_halfvel.scale(0.5f); // guess position quater m2,m1,p0,p1; m2.mult( center_3halfvel.inverse(), center); m1.mult( center_halfvel.inverse(), center); p0.mult(center_halfvel, center); p1.mult(center_3halfvel, center); static quaterN disp1, disp2; quater disp_sp1, disp_sp2; disp_sp1.difference(sp1, m2); disp_sp2.difference(sp2, m1); quater disp_ap2, disp_ap3; disp_ap2.difference(ap2, p0); disp_ap3.difference(ap3, p1); disp1.hermite(quater(1,0,0,0), quater(1,0,0,0), ABS(start)-1, disp_sp1, disp_sp2); disp2.hermite(disp_ap2, disp_ap3, end-1, quater(1,0,0,0), quater(1,0,0,0)); ASSERT(end-start==disp1.rows()+disp2.rows()+2); setSize(end-start); // forward filling for(int i=0; i<disp1.rows(); i++) row(i)=disp1.row(i); // center filling row(ABS(start)-1)=disp_sp2; row(ABS(start))=disp_ap2; // backward filling for(int i=0; i<disp2.rows(); i++) row(rows()-i-1)=disp2.row(disp2.rows()-i-1); /////////////////// //testing code backup /* quaterN test; test.setSize(40); for(int i=0; i<20; i++) { test[i].setRotation(vector3(0,1,0), (20-i)/20.f); } for(int i=20; i<40; i++) { test[i].setRotation(vector3(0,1,0), (-i+10)/20.f); } matrixn temp; temp.assign(test); temp.op0(m0::drawSignals("qtemp1.bmp",-1.f,1.f,true)); quaterN disp; disp.displacement(test[18], test[19], test[20],test[21], -20,20); for(int i=0; i<40; i++) test[i].leftMult(disp[i]); temp.assign(test); temp.op0(m0::drawSignals("qtemp2.bmp",-1.f,1.f,true));*/ }