void PhysicObject::savePhysProperties(FILE* f) { writeChar(isEnabledPhysics(), f); if (!isEnabledPhysics()) return; writeFloat(getMass(), f); writeVector(getAngularFactor(), f); writeVector(getLinearFactor(), f); //writeVector(getLinearVelocity(), f); writeChar(isTrigger(), f); writeChar(getCollisionShapeType(), f); writeChar(isEnableDeactivation(), f); writeFloat(getFriction(), f); writeFloat(getRestitution(), f); writeFloat(getLinearDumping(), f); writeFloat(getAngularDumping(), f); // save custom collision shape if (getCollisionShapeType() == CST_CUSTOM) { if (getCollisionShape() == NULL) Log::error("Can't save custom col. shape. (shape is NULL) id=%s", objectID.c_str()); writeChar(getCollisionShape()->getCollisionShapeType() , f); getCollisionShape()->save(f); } // save constraints writeChar(getConstrains().size(), f); for (unsigned int i = 0; i < getConstrains().size(); i++) { writeChar(getConstrains().at(i)->getType(), f); getConstrains().at(i)->save(f); } }
int main( int argc, const char** argv ) { // Info for user std::cout << "GenDataMP5: Generates data files to use as input for assignment MP5.\n"; std::cout << "Invoke as: GenDataMP5 [VectorLength]\n\n"; // Read input if ( 2 != argc ) { std::cout << "Error! Wrong number of arguments to program.\n"; return 0; } // Create vectors const int vecLen = atoi( argv[1] ); FloatVec vecA; FloatVec vecB; genVector( vecA, vecLen ); scanVector( vecA, vecB ); // Write to files writeVector( vecA, "vecA.txt" ); writeVector( vecB, "vecB.txt" ); return 0; }
void GOConstraint::save(FILE* f) { if (hasID) writeString(id, f); else writeString("", f); writeVector(pivot, f); if (secondObject) writeString(secondObject->getObjectID(), f); else writeString("", f); writeVector(secondPivot, f); }
int main(int argc,char* argv[]){ vector* vec = createVector(); printf("\nnew vector-pointer generated\n\n"); writeVector(vec,argv[1]); printVector(vec); int searchResult = search(vec,10); printf("%d\n\n",searchResult); data* newData1 = createData(51,44,19.290122); addBegin(vec,newData1); printf("new data added to beginning\n\n"); data* newData2 = createData(10,59,82.430034); addNpos(vec,newData2,6); printf("new data added to position 6\n\n"); searchResult = search(vec,10); printf("%d\n\n",searchResult); printVector(vec); freeVector(vec); printf("vector freed\n"); return 0; }
virtual status_t setMediaDrmSession(const Vector<uint8_t> &sessionId) { Parcel data, reply; data.writeInterfaceToken(ICrypto::getInterfaceDescriptor()); writeVector(data, sessionId); remote()->transact(SET_MEDIADRM_SESSION, data, &reply); return reply.readInt32(); }
/***************************************** * Interface to write a vector in a file * *****************************************/ ALGEB lbWriteVector (MKernelVector kv, ALGEB *argv){ try { std::ofstream os(MapleToString(kv, argv[2])); const VectorKey *key = &MapleToVectorKey(kv, argv[1]); writeVector(*key, os); return ToMapleNULL(kv); } catch (lb_runtime_error &t) { lbRaiseError(kv, t);} return ToMapleNULL(kv); }
Persistent::Base::Error CelAnimMesh::write( StreamIO & sio, int version, int user ) { version, user; sio.write( (Int32)fVerts.size() ); sio.write( fnVertsPerFrame ); sio.write( (Int32)fTextureVerts.size() ); sio.write( (Int32)fFaces.size() ); sio.write( (Int32)fFrames.size() ); sio.write( fnTextureVertsPerFrame ); // fScale.write( sio ); // fOrigin.write( sio ); sio.write( fRadius ); writeVector( sio, fVerts ); writeVector( sio, fTextureVerts ); writeVector( sio, fFaces ); writeVector( sio, fFrames ); return Ok; }
int main( int argc, char** argv ) { //// User's choice if ( argc == 1 ) { std::cout << "Usage: " << argv[0] << "<output> <inputFile1> <inputFile2> ..." << std::endl; std::cout << " - computes the difference of results between the" << std::endl; std::cout << " CPU version of the estimator and the GPU version" << std::endl; std::cout << " GPU file : positions are between [0;size]." << std::endl; std::cout << " CPU file : positions are between [0;2*size]" << std::endl; std::cout << " or [-size;size]." << std::endl; std::cout << " Error type : 1 is l_1, 2 is l_2, 3 is l_\\infty." << std::endl; std::cout << "Example:" << std::endl; std::cout << argv[ 0 ] << " file1.txt file2.txt 64 3" << std::endl; return 0; } std::string fileOutput = argc > 1 ? std::string( argv[ 1 ] ) : "file1.txt"; std::string fileInput = argc > 2 ? std::string( argv[ 2 ] ) : "file2.txt"; convertCPUtoKhalimsky predicateCPU; std::vector< std::pair<Position*, Curvatures*> > v_export; std::vector< std::pair<Position*, Value> > v_temp; loadFile2( fileInput, v_temp, predicateCPU ); writeVector(v_temp, v_export, 0 ); deleteVector2( v_temp ); for(int i = 3; i < argc; ++i) { fileInput = std::string( argv[ i ] ); loadFile2( fileInput, v_temp, predicateCPU ); writeVector(v_temp, v_export, i-2); deleteVector2( v_temp ); } writeFile( fileOutput, v_export ); deleteVector( v_export ); return 0; }
void fileManager::writeTract (const std::string& tractFilename, std::vector<float> tractogram ) const { ValueType tractValueType; if(m_floatFlag) { tractValueType = VTFloat32; } else { tractValueType = VTUINT8; for( size_t i=0; i<tractogram.size(); ++i) { tractogram[i] = tractogram[i] * 255.; } } writeVector( tractFilename, tractValueType, tractogram, m_zipFlag ); return; }//end fileManager::writeTract() -----------------------------------------------------
void readWriteMatrix::getRandom(std::vector<std::vector<double>*>* mat,std::vector<double>* b,int m, int n, double low, double high){ if(!mat->empty()){ for(auto v : *mat) delete v; mat->clear(); } if(!b->empty()) b->clear(); unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); //64 bit word length mersenne twister has always given the best rands for me std::mt19937_64 generator (seed); std::uniform_real_distribution<double> distribution(low,high); auto rand = std::bind(distribution,generator); std::vector<double> _tt; bool tt = true; for(int i =0; i < m; ++i){ mat->push_back(new std::vector<double>()); for(int j = 0; j < n; ++j){ mat->at(i)->push_back(round(rand())); if(tt) _tt.push_back(round(rand())); } tt = false; (*mat->at(i))[i] = domSum(mat->at(i)); } std::cout<<"Saving random x to file called randX.txt"<<std::endl; writeVector("randX.txt",&_tt); for(auto v : *mat){ double d = 0.0; for(int j = 0; j < n; ++j) d += v->at(j) * _tt[j]; b->push_back(d); } }
/* Grid output wrapper function: prints arrays related to the grid (rho, u etc) */ void writeGridOutput(struct grid *g, int nGridPoints, double t) { writeScalar(g->rho, t, nGridPoints, "output/rho1D.txt"); writeScalar(g->u, t, nGridPoints, "output/potential1D.txt"); writeVector(g->J, t, nGridPoints, "output/J1D.txt"); }
/* Field output function: prints arrays related to the field (E, B) */ void writeFieldOutput(struct field *f, int nGridPoints, double t) { writeScalar(f->Bz, t, nGridPoints, "output/Bz1D.txt"); writeVector(f->E, t, nGridPoints, "output/E1D.txt"); }
void GOPlate::save(FILE* f) { GameObject::save(f); writeVector(size, f); writeString(textureName, f); writeFloat(density, f); }
void GOGround::save(FILE* f) { GameObject::save(f); writeVector(size, f); writeString(modelPrefix, f); writeString(texturePrefix, f); }
void FBXWriter::encodeFBXProperty(QDataStream& out, const QVariant& prop) { auto type = prop.userType(); switch (type) { case QMetaType::Short: out.device()->write("Y", 1); out << prop.value<int16_t>(); break; case QVariant::Type::Bool: out.device()->write("C", 1); out << prop.toBool(); break; case QMetaType::Int: out.device()->write("I", 1); out << prop.toInt(); break; case QMetaType::Float: out.device()->write("F", 1); out << prop.toFloat(); break; case QMetaType::Double: out.device()->write("D", 1); out << prop.toDouble(); break; case QMetaType::LongLong: out.device()->write("L", 1); out << prop.toLongLong(); break; case QMetaType::QString: { auto bytes = prop.toString().toUtf8(); out.device()->write("S", 1); out << (int32_t)bytes.size(); out.writeRawData(bytes, bytes.size()); break; } case QMetaType::QByteArray: { auto bytes = prop.toByteArray(); out.device()->write("S", 1); out << (int32_t)bytes.size(); out.writeRawData(bytes, bytes.size()); break; } default: { if (prop.canConvert<QVector<float>>()) { writeVector(out, 'f', prop.value<QVector<float>>()); } else if (prop.canConvert<QVector<double>>()) { writeVector(out, 'd', prop.value<QVector<double>>()); } else if (prop.canConvert<QVector<qint64>>()) { writeVector(out, 'l', prop.value<QVector<qint64>>()); } else if (prop.canConvert<QVector<qint32>>()) { writeVector(out, 'i', prop.value<QVector<qint32>>()); } else if (prop.canConvert<QVector<bool>>()) { writeVector(out, 'b', prop.value<QVector<bool>>()); } else { qDebug() << "Unsupported property type in FBXWriter::encodeNode: " << type << prop; throw("Unsupported property type in FBXWriter::encodeNode: " + QString::number(type) + " " + prop.toString()); } } } }
void GOCube::save(FILE* f) { GameObject::save(f); writeVector(size, f); }