int main(void) { ap2(); ap3(); printf( "done\n" ); return( 0 ); }
//void test(){ // SharedPtr sp(new int(2)); //} void test(){ AutoPtr<int> ap1(new int(1)); //DoSomthing(); { AutoPtr<int> ap2(ap1); } *ap1._ptr = 2; }
void test() { B* p1 = new B(1); std::auto_ptr<B> ap1(p1); std::auto_ptr_ref<A> apr = ap1; std::auto_ptr<A> ap2(apr); assert(ap1.get() == nullptr); assert(ap2.get() == p1); ap2.release(); delete p1; }
void test() { { A* p = new A(1); const std::auto_ptr<A> ap1(p); std::auto_ptr<A> ap2(ap1); assert(ap1.get() == 0); assert(ap2.get() == p); assert(A::count == 1); } assert(A::count == 0); }
int main() { std::auto_ptr<foo> ap1(new foo); ap1->print(); std::cout << "ap1 pointer: " << ap1.get() << std::endl; std::auto_ptr<foo> ap2(ap1); ap2->print(); std::cout << "ap1 pointer: " << ap1.get() << std::endl; std::cout << "ap2 pointer: " << ap2.get() << std::endl; return 0; }
void test() { { B* p1 = new B(1); std::auto_ptr<B> ap1(p1); std::auto_ptr_ref<A> apr = ap1; std::auto_ptr<A> ap2(apr); assert(ap2.get() == p1); assert(ap1.get() == 0); } assert(A::count == 0); assert(B::count == 0); }
void leeNombres (ifstream &arch, Cadena *personas, int &cant) { Cadena ap1(50); Cadena ap2(50); Cadena nomb(50); cant = 0; char buff[200]; while (arch.getline(buff,200)){ obtieneNombres(buff, ap1, ap2, nomb); ap1.append("/"); ap2.append("/"); personas[cant] = ap1 + ap2 + nomb;; cant++; } }
void test() { { B* p = new B(1); std::auto_ptr<B> ap1(p); std::auto_ptr<A> ap2(ap1); assert(ap1.get() == 0); assert(ap2.get() == p); assert(A::count == 1); assert(B::count == 1); } assert(A::count == 0); assert(B::count == 0); }
void test() { { A* p1 = new A(1); std::auto_ptr<A> ap1(p1); std::auto_ptr_ref<A> apr = ap1; std::auto_ptr<A> ap2(new A(2)); ap2 = apr; assert(A::count == 1); assert(ap2.get() == p1); assert(ap1.get() == 0); } assert(A::count == 0); }
void test() { { B* p1 = new B(1); const std::auto_ptr<B> ap1(p1); A* p2 = new A(2); std::auto_ptr<A> ap2(p2); assert(A::count == 2); assert(B::count == 1); assert(ap1.get() == p1); assert(ap2.get() == p2); std::auto_ptr<A>& apr = ap2 = ap1; assert(&apr == &ap2); assert(A::count == 1); assert(B::count == 1); assert(ap1.get() == 0); assert(ap2.get() == p1); } assert(A::count == 0); assert(B::count == 0); }
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(); }
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));*/ }