本文整理汇总了C++中array::append方法的典型用法代码示例。如果您正苦于以下问题:C++ array::append方法的具体用法?C++ array::append怎么用?C++ array::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类array
的用法示例。
在下文中一共展示了array::append方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: generate_indices
void clipmap_ring::generate_indices()
{
unsigned int indices[4];
ibuf.clear();
for (int j = 0; j < PHI_STEPS; ++j)
{
for (int i = 0; i < THETA_STEPS; ++i)
{
indices[0] = static_cast<unsigned int>( (j+0) * (THETA_STEPS+1) + (i+0) ); // lower left
indices[1] = static_cast<unsigned int>( (j+0) * (THETA_STEPS+1) + (i+1) ); // lower right
indices[2] = static_cast<unsigned int>( (j+1) * (THETA_STEPS+1) + (i+1) ); // upper right
indices[3] = static_cast<unsigned int>( (j+1) * (THETA_STEPS+1) + (i+0) ); // upper left
repair_quad(indices);
ibuf.append(indices[0]);
ibuf.append(indices[1]);
ibuf.append(indices[3]);
ibuf.append(indices[2]);
ibuf.append(indices[3]);
ibuf.append(indices[1]);
}
}
} // clipmap_ring::generate_indices()
示例2: partition
void partition_table::partition(MonomialIdeal * &I, array<MonomialIdeal *> &result)
// consumes and frees I
{
int k;
reset(I->topvar()+1);
// Create the sets
for (Index<MonomialIdeal> i = I->first(); i.valid(); i++)
if (n_sets > 1)
merge_in((*I)[i]->monom().raw());
else
break;
if (n_sets == 1)
{
result.append(I);
return;
}
int this_label = -1;
n_sets = 0;
for (k=0; k<n_vars; k++)
if (occurs[k] && dad[k] < 0)
{
dad[k] = this_label--;
n_sets++;
}
if (n_sets == 1)
{
result.append(I);
return;
}
int first = result.length();
for (k=0; k<n_sets; k++)
result.append(new MonomialIdeal(I->get_ring(), mi_stash));
// Now partition the monomials
Bag *b;
while (I->remove(b))
{
const intarray &m = b->monom();
int v = varpower::topvar(m.raw());
int loc = -1-dad[representative(v)];
result[first+loc]->insert_minimal(b);
}
delete I;
}
示例3: repair_quad
void clipmap_ring::repair_quad(unsigned int *indices)
{
int quadrant_one = 0;
int quadrant_four = 0;
for (int i = 0; i < 4; ++i)
{
double theta = cbuf[ indices[i]*2 + 1 ];
if (theta < math::PI_TIMES_2 && theta > math::PI * 0.75)
quadrant_four++;
else if (theta < math::PI_OVER_2)
quadrant_one++;
}
//
if (quadrant_one && quadrant_four)
{
for (int i = 0; i < 4; ++i)
{
double phi = cbuf[ indices[i]*2 + 0 ];
double theta = cbuf[ indices[i]*2 + 1 ];
if (theta > math::PI * 0.75)
theta -= math::PI_TIMES_2;
unsigned int orig_index = indices[i];
unsigned int new_index = vbuf.size() / 8;
indices[i] = new_index;
float s = static_cast<float>(theta / math::PI_TIMES_2);
float t = 1.0f - static_cast<float>(phi / math::PI);
vbuf.append(s);
vbuf.append(t);
vbuf.append( vbuf[orig_index*8 + 2] );
vbuf.append( vbuf[orig_index*8 + 3] );
vbuf.append( vbuf[orig_index*8 + 4] );
vbuf.append( vbuf[orig_index*8 + 5] );
vbuf.append( vbuf[orig_index*8 + 6] );
vbuf.append( vbuf[orig_index*8 + 7] );
}
}
} // clipmap_ring::repair_quad()
示例4: parseHead
//returns true if tag closes itself (<tag/>); false if not (<tag>)
inline bool parseHead(const char *&p) {
//parse name
const char *nameStart = ++p; //skip '<'
while(isName(*p)) p++;
const char *nameEnd = p;
copy(name, nameStart, nameEnd - nameStart);
if(name.empty()) throw "missing element name";
//parse attributes
while(*p) {
while(isWhitespace(*p)) p++;
if(!*p) throw "unclosed attribute";
if(*p == '?' || *p == '/' || *p == '>') break;
//parse attribute name
Node *attribute = new Node;
children.append(attribute);
attribute->attribute = true;
const char *nameStart = p;
while(isName(*p)) p++;
const char *nameEnd = p;
copy(attribute->name, nameStart, nameEnd - nameStart);
if(attribute->name.empty()) throw "missing attribute name";
//parse attribute data
if(*p++ != '=') throw "missing attribute value";
char terminal = *p++;
if(terminal != '\'' && terminal != '\"') throw "attribute value not quoted";
const char *dataStart = p;
while(*p && *p != terminal) p++;
if(!*p) throw "missing attribute data terminal";
const char *dataEnd = p++; //skip closing terminal
copy(attribute->data, dataStart, dataEnd - dataStart);
}
//parse closure
if(*p == '?' && *(p + 1) == '>') { p += 2; return true; }
if(*p == '/' && *(p + 1) == '>') { p += 2; return true; }
if(*p == '>') { p += 1; return false; }
throw "invalid element tag";
}
示例5: parseElement
//parse element and all of its child elements
inline void parseElement(const char *&p) {
Node *node = new Node;
children.append(node);
if(node->parseHead(p) == true) return;
node->parse(p);
}
示例6: tokens_get
// delit to bez tech mezer
int parametrizer::tokens_get(DATA_FILE_SECTION *p_line, array<PARAM_NODE> &nodes)
{
assert(p_line);
char *p_start = p_line->line_raw_string_get();
char *p_current = p_line->line_raw_string_get();
TOKEN_STATE state = STATE_TOKEN_START;
do {
switch(state) {
case STATE_TOKEN_START:
{
assert(p_start == p_current);
char c = *p_start;
if(c == '\0') {
state = STATE_STRING_END;
}
else if(isspace(c)) {
p_start++;
}
else if(is_token_delim(c)) {
state = STATE_TOKEN_END;
} else {
state = STATE_TOKEN_IN;
}
p_current++;
break;
}
case STATE_TOKEN_IN:
{
char c = *p_current;
if(c == '\0' || is_token_delim(c) || isspace(c)) {
state = STATE_TOKEN_END;
}
else {
p_current++;
}
break;
}
case STATE_TOKEN_END:
{
PARAM_NODE token;
memset(&token,0,sizeof(token));
char c = *p_start;
int length = p_current - p_start;
assert(c != '\0' && !isspace(c));
assert(length != 0);
if(is_token(p_start, length, token) ||
is_number(p_start, length, token)) {
// It's a number or token
nodes.append(token);
}
else {
if(!is_token_delim(p_start[0])) {
// We have a variable here
if(p_start[length-2] == '.') {
// it's a part of color variable (.r .g .b .a)
// or a vector variable (.x .y .z)
switch(p_start[length-1]) {
case 'r':
token.content_type = NODE_VAR_VARIABLE_R;
length -= 2;
break;
case 'g':
token.content_type = NODE_VAR_VARIABLE_G;
length -= 2;
break;
case 'b':
token.content_type = NODE_VAR_VARIABLE_B;
length -= 2;
break;
case 'a':
token.content_type = NODE_VAR_VARIABLE_A;
length -= 2;
break;
case 'x':
token.content_type = NODE_VAR_VARIABLE_X;
length -= 2;
break;
case 'y':
token.content_type = NODE_VAR_VARIABLE_Y;
length -= 2;
break;
case 'z':
token.content_type = NODE_VAR_VARIABLE_Z;
length -= 2;
break;
default:
p_line->ppline();
pperror(TRUE, "wrong tail .%c",p_start[length-1]);
//.........这里部分代码省略.........
示例7: generate_vertices
void clipmap_ring::generate_vertices()
{
// generate vertices (PHI_STEPS rings of THETA_STEPS+1 vertices)
cbuf.clear();
vbuf.clear();
double delta_theta = 2.0 * math::PI / static_cast<double>(THETA_STEPS);
for (int j = 0; j <= PHI_STEPS; ++j)
{
double eye_phi = 0;
if (level)
{
double exp = static_cast<double>(-j) / static_cast<double>(PHI_STEPS);
eye_phi = start_phi * ::pow(2.0, exp);
}
else
{
double delta_phi = (start_phi - end_phi) / static_cast<double>(PHI_STEPS);
eye_phi = start_phi - delta_phi * static_cast<double>(j);
}
for (int i = 0; i <= THETA_STEPS; ++i)
{
double eye_theta = delta_theta * static_cast<double>(i);
double eye_x = ::cos(eye_theta) * ::sin(eye_phi);
double eye_y = ::sin(eye_theta) * ::sin(eye_phi);
double eye_z = ::cos(eye_phi);
quaternion eye_point(0, eye_x, eye_y, eye_z);
quaternion yrot_point = (roty * eye_point) * roty_conj;
quaternion obj_point = (rotz * yrot_point) * rotz_conj;
double obj_x = obj_point.x;
double obj_y = obj_point.y;
double obj_z = obj_point.z;
double obj_phi = ::acos(obj_z);
double obj_theta = ::atan2(obj_y, obj_x) + (map_offset * math::PI_TIMES_2);
if (obj_theta < 0.0)
obj_theta += math::PI_TIMES_2;
cbuf.append(obj_phi);
cbuf.append(obj_theta);
float s = static_cast<float>(obj_theta / math::PI_TIMES_2);
float t = 1.0f - static_cast<float>(obj_phi / math::PI);
float nx = static_cast<float>(obj_x);
float ny = static_cast<float>(obj_y);
float nz = static_cast<float>(obj_z);
float x = parent->get_equatorial_radius() * nx;
float y = parent->get_equatorial_radius() * ny;
float z = parent->get_polar_radius() * nz;
if (hmap)
{
double hval, alpha;
hmap->get_data(s, t, hval, alpha);
vector old_vertex(x, y, z);
vector normal(nx, ny, nz);
gsgl::real_t alt = static_cast<gsgl::real_t>(hval * hmap->get_altitude());
vector new_vertex = old_vertex + normal*alt;
x = new_vertex[0];
y = new_vertex[1];
z = new_vertex[2];
}
vbuf.append(s);
vbuf.append(t);
vbuf.append(nx);
vbuf.append(ny);
vbuf.append(nz);
vbuf.append(x);
vbuf.append(y);
vbuf.append(z);
}
}
} // clipmap_ring::generate_vertices()
示例8: generate
void generate()
{
//entry
_output.append(entry().lines());
}