bool RenameMePhotos::checkConflict(std::vector<std::pair<boost::filesystem::path, time_t> > &vec, std::vector<std::pair<boost::filesystem::path, time_t> > &vecError, int size, std::string prefix, int suffixStart) { for(std::vector<std::pair<boost::filesystem::path, time_t> >::const_iterator it(vec.begin()); it!=vec.end(); it++) { for(unsigned int i = suffixStart; i <= vec.size(); i++) { std::stringstream ss; ss << "(.*\\/)*(" << prefix << "_" << i << ")(\\..{3,4})"; std::regex reg(ss.str()); std::string strVec((*it).first.string()); if(std::regex_match(strVec, reg)) { vecError.push_back(*it); } } } return (vecError.size() > 0); }
//-***************************************************************************** void testRepeatedScalarData() { std::string archiveName = "repeatScalarData.abc"; { A5::WriteArchive w; AbcA::ArchiveWriterPtr a = w(archiveName, AbcA::MetaData()); AbcA::ObjectWriterPtr archive = a->getTop(); AbcA::CompoundPropertyWriterPtr parent = archive->getProperties(); AbcA::ScalarPropertyWriterPtr swp = parent->createScalarProperty("int32", AbcA::MetaData(), AbcA::DataType(Alembic::Util::kInt32POD, 3), 0); std::vector <Alembic::Util::uint32_t> ui(3); ui[0] = 0; ui[1] = 1; ui[2] = 2; std::vector <Alembic::Util::uint32_t> ui2(3); ui2[0] = 41; ui2[1] = 43; ui2[2] = 47; swp->setSample(&(ui.front())); swp->setSample(&(ui.front())); swp->setSample(&(ui2.front())); swp->setSample(&(ui.front())); swp->setSample(&(ui2.front())); swp->setSample(&(ui2.front())); swp->setSample(&(ui2.front())); swp->setSample(&(ui.front())); swp->setSample(&(ui.front())); swp->setSample(&(ui.front())); AbcA::ScalarPropertyWriterPtr swp2 = parent->createScalarProperty("float32", AbcA::MetaData(), AbcA::DataType(Alembic::Util::kFloat32POD, 1), 0); Alembic::Util::float32_t f = 42.0; Alembic::Util::float32_t f2 = -3.0; swp2->setSample(&f); swp2->setSample(&f); swp2->setSample(&f); swp2->setSample(&f2); swp2->setSample(&f2); swp2->setSample(&f2); AbcA::ScalarPropertyWriterPtr swp3 = parent->createScalarProperty("uint16", AbcA::MetaData(), AbcA::DataType(Alembic::Util::kUint16POD, 1), 0); Alembic::Util::uint16_t ui16 = 17; swp3->setSample(&ui16); swp3->setSample(&ui16); swp3->setSample(&ui16); swp3->setSample(&ui16); AbcA::ScalarPropertyWriterPtr swp4 = parent->createScalarProperty("str", AbcA::MetaData(), AbcA::DataType(Alembic::Util::kStringPOD, 3), 0); std::vector < Alembic::Util::string > strVec(3); strVec[0] = "Please"; strVec[1] = ""; strVec[2] = "work"; std::vector < Alembic::Util::string > strVec2(3); strVec2[0] = "Whats"; strVec2[1] = "going"; strVec2[2] = "on?"; swp4->setSample(&(strVec.front())); swp4->setSample(&(strVec.front())); swp4->setSample(&(strVec2.front())); swp4->setSample(&(strVec2.front())); } { A5::ReadArchive r; AbcA::ArchiveReaderPtr a = r( archiveName ); AbcA::ObjectReaderPtr archive = a->getTop(); AbcA::CompoundPropertyReaderPtr parent = archive->getProperties(); TESTING_ASSERT(parent->getNumProperties() == 4); for (size_t i = 0; i < parent->getNumProperties(); ++i) { AbcA::BasePropertyReaderPtr bp = parent->getProperty( i ); AbcA::ScalarPropertyReaderPtr sp = bp->asScalarPtr(); switch (sp->getDataType().getPod()) { case Alembic::Util::kUint16POD: { TESTING_ASSERT( sp->getNumSamples() == 4 ); const AbcA::TimeSamplingPtr t = sp->getTimeSampling(); TESTING_ASSERT( sp->isConstant() ); Alembic::Util::uint16_t us; for ( size_t i = 0; i < sp->getNumSamples(); ++i ) { us = 0; sp->getSample( 0, &us); TESTING_ASSERT(us == 17); } } break; case Alembic::Util::kFloat32POD: { TESTING_ASSERT( sp->getNumSamples() == 6 ); TESTING_ASSERT( sp->getDataType().getExtent() == 1); TESTING_ASSERT( !sp->isConstant() ); Alembic::Util::float32_t f = 0; // make sure we can't get a non-existant sample TESTING_ASSERT_THROW(sp->getSample( 100, &f ), Alembic::Util::Exception); sp->getSample( 5, &f ); TESTING_ASSERT(f == -3.0); sp->getSample( 1, &f ); TESTING_ASSERT(f == 42.0); sp->getSample( 4, &f ); TESTING_ASSERT(f == -3.0); sp->getSample( 0, &f ); TESTING_ASSERT(f == 42.0); sp->getSample( 3, &f ); TESTING_ASSERT(f == -3.0); sp->getSample( 2, &f ); TESTING_ASSERT(f == 42.0); } break; case Alembic::Util::kInt32POD: { TESTING_ASSERT( sp->getNumSamples() == 10 ); TESTING_ASSERT( sp->getDataType().getExtent() == 3); TESTING_ASSERT( !sp->isConstant() ); std::vector< Alembic::Util::uint32_t > ui(3); // lets explicitly test each sample sp->getSample( 0, &(ui.front()) ); TESTING_ASSERT(ui[0] == 0 && ui[1] == 1 && ui[2] == 2); sp->getSample( 1, &(ui.front()) ); TESTING_ASSERT(ui[0] == 0 && ui[1] == 1 && ui[2] == 2); sp->getSample( 2, &(ui.front()) ); TESTING_ASSERT(ui[0] == 41 && ui[1] == 43 && ui[2] == 47); sp->getSample( 3, &(ui.front()) ); TESTING_ASSERT(ui[0] == 0 && ui[1] == 1 && ui[2] == 2); sp->getSample( 4, &(ui.front()) ); TESTING_ASSERT(ui[0] == 41 && ui[1] == 43 && ui[2] == 47); sp->getSample( 5, &(ui.front()) ); TESTING_ASSERT(ui[0] == 41 && ui[1] == 43 && ui[2] == 47); sp->getSample( 6, &(ui.front()) ); TESTING_ASSERT(ui[0] == 41 && ui[1] == 43 && ui[2] == 47); sp->getSample( 7, &(ui.front()) ); TESTING_ASSERT(ui[0] == 0 && ui[1] == 1 && ui[2] == 2); sp->getSample( 8, &(ui.front()) ); TESTING_ASSERT(ui[0] == 0 && ui[1] == 1 && ui[2] == 2); sp->getSample( 9, &(ui.front()) ); TESTING_ASSERT(ui[0] == 0 && ui[1] == 1 && ui[2] == 2); } break; case Alembic::Util::kStringPOD: { TESTING_ASSERT( sp->getNumSamples() == 4 ); TESTING_ASSERT( sp->getDataType().getExtent() == 3); TESTING_ASSERT( !sp->isConstant() ); std::vector< Alembic::Util::string > val(3); sp->getSample(0, &(val.front())); TESTING_ASSERT( val[0] == "Please"); TESTING_ASSERT( val[1] == ""); TESTING_ASSERT( val[2] == "work"); sp->getSample(1, &(val.front())); TESTING_ASSERT( val[0] == "Please"); TESTING_ASSERT( val[1] == ""); TESTING_ASSERT( val[2] == "work"); sp->getSample(2, &(val.front())); TESTING_ASSERT( val[0] == "Whats"); TESTING_ASSERT( val[1] == "going"); TESTING_ASSERT( val[2] == "on?"); sp->getSample(3, &(val.front())); TESTING_ASSERT( val[0] == "Whats"); TESTING_ASSERT( val[1] == "going"); TESTING_ASSERT( val[2] == "on?"); } break; default: TESTING_ASSERT(false); break; } } // for } }
int main(int argc,char *argv[]) { double h_next,h_used; double t,t_start,t_stop; int order=4; double y1[order]; int i,err; double tolerance = 1.e-10; double t0 = 0.0; int number_of_steps = 10000; double y0[] = {1.0,0.0,0.0,1.3}; double h = 0.05; double params[10]; int met=atoi(argv[1]); printf("Method: %d\n",met); t_start = t0; t = t_start; //NUMBER OF VARIABLES params[0]=order; int status; double ysol[order],error[order]; FILE *f=fopen("solution.dat","w"); double r,E0,E; r=sqrt(y0[0]*y0[0]+y0[1]*y0[1]); E0=0.5*(y0[2]*y0[2]+y0[3]*y0[3])-1/r; for (i = 0; i < number_of_steps; i++) { h_used = h; t_stop = t_start + h; do { while(1){ status=Gragg_Bulirsch_Stoer(eom,y0,y1,t,h_used,&h_next,1.0,tolerance,met,params); if(status) h_used/=4.0; else break; } t+=h_used; copyVec(y0,y1,order); if(t+h_next>t_stop) h_used=t+h_next-t_stop; else h_used=h_next; printf("t = %e\n",t); }while(t<t_stop-1.e-10); solution(t,ysol,params); sumVec(error,1.0,ysol,-1.0,y1,order); r=sqrt(y1[0]*y1[0]+y1[1]*y1[1]); E=0.5*(y1[2]*y1[2]+y1[3]*y1[3])-1/r; printf("%3d %8.2le %s %s %s\n",i+1,t, strVec(y1,order), strVec(ysol,order), strVec(error,order) ); fprintf(f,"%3d %8.2le %s %s %s %.17e\n",i+1,t, strVec(y1,order), strVec(ysol,order), strVec(error,order), fabs(E-E0)/fabs(E0) ); t_start = t; } fclose(f); return 0; }