本文整理汇总了C++中read_vector函数的典型用法代码示例。如果您正苦于以下问题:C++ read_vector函数的具体用法?C++ read_vector怎么用?C++ read_vector使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了read_vector函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: load_system
/* load a solar system specification from file, return NULL on failure */
System* load_system(FILE* file)
{
int nplanets;
long long steps_to_write;
Float duration, time_step;
fscanf(file, "%d " FLOAT_SCANF_FORMAT " " FLOAT_SCANF_FORMAT " %lld",
&nplanets, &duration, &time_step, &steps_to_write);
System* sys = alloc_system(nplanets);
if(!sys || duration < time_step)
{
free(sys);
return NULL;
}
sys->time_step = time_step;
sys->nplanets = nplanets;
sys->cur_step = 0;
sys->nsteps = ceil(duration / time_step);
if(steps_to_write > sys->nsteps)
steps_to_write = sys->nsteps;
sys->print_period = (long long)((double)sys->nsteps / steps_to_write);
for(int i = 0; i < nplanets; i++)
{
fscanf(file, FLOAT_SCANF_FORMAT, &sys->planets[i].mass);
read_vector(file, sys->planets[i].position);
read_vector(file, sys->planets[i].velocity);
}
return sys;
}
示例2: load_data
// Read binary ROM data for basis functions and coefficients
static int load_data(const char dir[], gsl_vector *cvec_amp, gsl_vector *cvec_phi, gsl_matrix *Bamp, gsl_matrix *Bphi, gsl_vector *cvec_amp_pre) {
// Load binary data for amplitude and phase spline coefficients as computed in Mathematica
int ret = XLAL_SUCCESS;
ret |= read_vector(dir, "SEOBNRv1ROM_SS_Amp_ciall.dat", cvec_amp);
ret |= read_vector(dir, "SEOBNRv1ROM_SS_Phase_ciall.dat", cvec_phi);
ret |= read_matrix(dir, "SEOBNRv1ROM_SS_Bamp_bin.dat", Bamp);
ret |= read_matrix(dir, "SEOBNRv1ROM_SS_Bphase_bin.dat", Bphi);
ret |= read_vector(dir, "SEOBNRv1ROM_SS_AmpPrefac_ci.dat", cvec_amp_pre);
return(ret);
}
示例3: decodeRig
static bool decodeRig(fsMsgRig &_msg, const std::string &buffer, Size &start) {
bool success = true;
success &= read_vector(_msg.mesh().m_quads,buffer,start); // read quads
success &= read_vector(_msg.mesh().m_tris,buffer,start); // read triangles
success &= read_vector(_msg.mesh().m_vertex_data.m_vertices,buffer,start);// read neutral vertices
success &= read_small_vector(_msg.blendshape_names(),buffer,start); // read names
uint16_t bsize = 0;
success &= read_pod(bsize,buffer,start);
_msg.blendshapes().resize(bsize);
for(uint16_t i = 0;i < bsize; i++)
success &= read_vector(_msg.blendshapes()[i].m_vertices,buffer,start); // read blendshapes
return success;
}
示例4: f_plane
int f_plane(ULONG *arg)
{
rsiVECTOR vec;
void *plane,*surf,*actor;
rsiResult err;
if (!arg[0])
return ERROR_SURFACE;
surf = FindSurfListItem((char*)arg[0]);
if (!surf)
return rsiERR_SURFACE;
err = rsiCreatePlane(&plane,surf);
if (err)
return err;
if (arg[1])
{
if (!read_vector(&vec,(char*)arg[1]))
return ERROR_VECTOR;
err = rsiSetPlane(plane, rsiTPlanePos, &vec, rsiTDone);
if (err)
return err;
}
if (arg[2])
{
if (!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
err = rsiSetPlane(plane, rsiTPlaneNorm, &vec, rsiTDone);
if (err)
return err;
}
if (arg[3])
{
actor = FindActorListItem((char*)arg[3]);
if (!actor)
return rsiERR_ACTOR;
err = rsiSetPlane(plane,rsiTPlaneActor,actor,rsiTDone);
if (err)
return err;
}
return rsiERR_NONE;
}
示例5: TEST
TEST(rust, MP4Metadata)
{
FILE* f = fopen("street.mp4", "rb");
ASSERT_TRUE(f != nullptr);
// Read just the moov header to work around the parser
// treating mid-box eof as an error.
//read_vector reader = read_vector(f, 1061);
struct stat s;
ASSERT_EQ(0, fstat(fileno(f), &s));
read_vector reader = read_vector(f, s.st_size);
fclose(f);
mp4parse_io io = { vector_reader, &reader };
mp4parse_parser* context = mp4parse_new(&io);
ASSERT_NE(nullptr, context);
mp4parse_error rv = mp4parse_read(context);
EXPECT_EQ(MP4PARSE_OK, rv);
uint32_t tracks = 0;
rv = mp4parse_get_track_count(context, &tracks);
EXPECT_EQ(MP4PARSE_OK, rv);
EXPECT_EQ(2U, tracks);
mp4parse_free(context);
}
示例6: scm_proc_read
/* R5RS library procedure read
* (read)
* (read [port])
*/
SCM scm_proc_read(FILE *file)
{
int c = skip_comment_and_space(file);
switch (c) {
case '(':
return read_list(file);
case ')': /* List end */
scheme_error("symtax error");
case '[':
case ']':
scheme_error("unsupport bracket");
case '{':
case '}':
scheme_error("unsupport brace");
case '|':
scheme_error("unsupport bar");
case '#':
c = fgetc(file);
if ('(' == c) {
return read_vector(file);
} else {
ungetc(c, file);
return read_simple_datum(file, '#');
}
case '\'': /* Quotation */
return new_cons(SCM_SYMBOL_QUOTE, new_cons(scm_proc_read(file), SCM_NULL));
case '`': /* Quasiquotation */
scheme_error("unsupport quasiquotation");
case ',': /* (Splicing) Uuquotation */
scheme_error("unsupport (splicing) unquotation");
default:
return read_simple_datum(file, c);
}
}
示例7: sphere
ULONG sphere(ULONG *arg)
{
rsiVECTOR vec;
float fnum;
void *sphere,*surf,*actor;
rsiResult err;
surf = FindSurfListItem((char*)arg[0]);
if(!surf)
return rsiERR_SURFACE;
err = rsiCreateSphere(CTXT, &sphere,surf);
if(err)
return err;
if(!read_vector(&vec,(char*)arg[1]))
return ERROR_VECTOR;
err = rsiSetSphere(CTXT, sphere,rsiTSpherePos,&vec,rsiTDone);
if(err)
return err;
fnum = (float)atof((char*)arg[2]);
err = rsiSetSphere(CTXT, sphere,rsiTSphereRadius,fnum,rsiTDone);
if(err)
return err;
if(arg[3])
{
actor = FindActorListItem((char*)arg[3]);
if(!actor)
return rsiERR_ACTOR;
err = rsiSetSphere(CTXT, sphere,rsiTSphereActor,actor,rsiTDone);
if(err)
return err;
}
if(arg[4])
{
fnum = (float)atof((char*)arg[4]);
err = rsiSetSphere(CTXT, sphere,rsiTSphereFuzzy,fnum,rsiTDone);
if(err)
return err;
}
if(arg[5])
{
err = rsiSetSphere(CTXT, sphere,rsiTSphereFlags,rsiFSphereInverted,rsiTDone);
if(err)
return err;
}
if(insideCSG > 0)
{
SetCSGObject(sphere);
insideCSG--;
}
return rsiERR_NONE;
}
示例8: sizeof
void GameObjectMessage::read_object_points() {
char point_count;
socket_->read_buffer(&point_count, sizeof(char));
for (char i = 0; i < point_count; i++) {
points_.push_back(read_vector(socket_));
}
}
示例9: read_uint32
void GameObjectMessage::read() {
object_id_ = read_uint32(socket_);
position_ = read_vector(socket_);
object_type_ = read_char(socket_);
read_object_points();
alive_ = read_bool(socket_);
}
示例10: size
ULONG size(ULONG *arg)
{
rsiVECTOR vec;
float begin,end;
int flags = rsiFActionLinear;
if(!actor)
return rsiERR_ACTOR;
begin = (float)atof((char*)arg[0]);
end = (float)atof((char*)arg[1]);
if(!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
if(arg[3])
{
if(KEYWORD((char*)arg[3], "LINEAR"))
flags |= rsiFActionLinear;
else
if(KEYWORD((char*)arg[3], "SPLINE"))
flags |= rsiFActionSpline;
else
return ERROR_INTERPOL;
}
return rsiSize(CTXT, actor->item,begin,end,&vec,/*rsiTSizeFlags,flags,*/rsiTDone);
}
示例11: f_alignment
int f_alignment(ULONG *arg)
{
rsiVECTOR vec;
float begin,end;
int flags = rsiFActionLinear;
if (!actor)
return rsiERR_ACTOR;
begin = end = 0;
if (arg[0])
begin = (float)atof((char*)arg[0]);
if (arg[1])
end = (float)atof((char*)arg[1]);
if (!read_vector(&vec,(char*)arg[2]))
return ERROR_VECTOR;
if (arg[3])
{
if (!stricmp((char*)arg[3], "LINEAR"))
flags |= rsiFActionLinear;
else
if (!stricmp((char*)arg[3], "SPLINE"))
flags |= rsiFActionSpline;
else
return ERROR_INTERPOL;
}
return rsiAlignment(actor->item,begin,end,&vec,rsiTAlignFlags,flags,rsiTDone);
}
示例12: to_string
NurbsOverAdaptedGrid::NurbsOverAdaptedGrid(int depth) {
string d = to_string(depth);
string grid_file = "grid-" + d + ".dat";
string cmd = "./generate --knots " + d + " > " + grid_file;
system(cmd.c_str());
ifstream fin(grid_file);
int N; // number of elements
fin >> N;
for (int i = 0; i < N; i++) {
Bounds b;
fin >> b.left >> b.right >> b.up >> b.down;
}
int M; // number of B-splines
fin >> M;
for (int i = 0; i < M; i++) {
string type;
// Regular or Gnomon
fin >> type;
if (type == "Regular") {
vector<double> x_knots, y_knots;
read_vector(fin, &x_knots, 4);
read_vector(fin, &y_knots, 4);
Bspline* regular = new Bspline(x_knots, y_knots);
unscaled_bsplines.push_back(regular);
} else { // type == "Gnomon"
double x_mid, y_mid, shift_x, shift_y;
fin >> x_mid >> y_mid >> shift_x >> shift_y;
GnomonBspline* gnomon = new GnomonBspline(x_mid, y_mid, shift_x, shift_y);
unscaled_bsplines.push_back(gnomon);
}
}
LinearCombination* sum_of_unscaled = new LinearCombination(unscaled_bsplines);
for (const Function2D* unscaled_bspline: unscaled_bsplines) {
const GnomonBspline* gb = dynamic_cast<const GnomonBspline*>(unscaled_bspline);
Quotient* scaled_bspline;
if (gb != nullptr)
scaled_bspline = new GnomonNurbs(*gb, *sum_of_unscaled);
else
scaled_bspline = new Quotient(*unscaled_bspline, *sum_of_unscaled);
scaled_bsplines.push_back(scaled_bspline);
}
}
示例13: read_vector
bool read_vector(const std::string& filename, boost::numeric::ublas::vector<T>& v) {
FILE* file = fopen(filename.c_str(), "rb");
if (!file)
return false;
bool res = read_vector(file, v);
fclose(file);
return res;
}
示例14: option_b
void option_b() {
/* Method solves the second subproblem:
* Given a vector of numbers, find the longest increasing contiguous subsequence.
*/
vector v = read_vector();
printf("Longest increasing contiguous subsequence: ");
print_vector(get_longest_increasing_subsequence(v));
}
示例15: triangle
ULONG triangle(ULONG *arg)
{
void *surf,*actor=NULL;
int i;
rsiVECTOR v[3];
rsiVECTOR n[3];
surf = FindSurfListItem((char*)arg[0]);
if(!surf)
return rsiERR_SURFACE;
for(i=0; i<3; i++)
{
if(!read_vector(&v[i],(char*)arg[i+1]))
return ERROR_VECTOR;
}
if(arg[7])
{
actor = FindActorListItem((char*)arg[7]);
if(!actor)
return rsiERR_ACTOR;
}
if(arg[4])
{
for(i=0; i<3; i++)
{
if(arg[i+4])
{
if(!read_vector(&n[i],(char*)arg[i+4]))
return ERROR_VECTOR;
}
}
return rsiCreateTriangle(CTXT, surf, &v[0], &v[1], &v[2],
rsiTTriangleActor, actor,
rsiTTriangleNorm1, &n[0],
rsiTTriangleNorm2, &n[1],
rsiTTriangleNorm3, &n[2], rsiTDone);
}
else
return rsiCreateTriangle(CTXT, surf, &v[0], &v[1], &v[2],
rsiTTriangleActor, actor, rsiTDone);
}