void main() { char answer[100]; printf("Enter part to search for the name of the part\r\n\n"); printf("Enter number to search for the number of the part\r\n\n"); printf("enter change if you want to change the quantity of a current product\r\n\n"); printf("Enter add part to add an item to the database\r\n\n"); printf("If you want to read the whole database then please enter read\n\r\n"); printf("If you want to exit, enter quit\r\n\n"); gets(answer); if(answer[0]=='N'||answer[0]=='n'){get_number();} else if(answer[0]=='P'||answer[0]=='p'){get_part_name();} else if(answer[0]=='C'||answer[0]=='c'){change_quantity();} else if(answer[0]=='A'||answer[0]=='a'){add_part();} else if(answer[0]=='R'||answer[0]=='r'){read_out();} else if(answer[0]=='Q'||answer[0]=='q'){exit(0);} else { printf("Answer was none of the statements , thank you for using this\r\n"); } }
Part * PartRepository::declare_part_impl( const std::string & name, EntityRank rank, bool force_no_induce ) { size_t ordinal = get_all_parts().size(); Part * part = new Part(m_meta_data, name, rank, ordinal, force_no_induce); declare_subset_impl(*m_universal_part, *part); add_part(part); return part; }
PartRepository::PartRepository(MetaData * meta) : m_meta_data(meta), m_universal_part(NULL), m_all_parts(), m_name_to_parts_map() { m_universal_part = new Part( m_meta_data, universal_part_name(), stk::topology::INVALID_RANK, 0 /*ordinal*/); add_part(m_universal_part); }
static void interpret_att(GSList** stack, gchar** args) { GMimePart* pt = g_mime_part_new_with_type(args[1], args[2]); g_mime_part_set_filename(pt, args[0]); g_mime_part_set_content_encoding(pt, GMIME_CONTENT_ENCODING_BASE64); g_mime_object_set_content_id(GMIME_OBJECT(pt), args[0]); add_content(GMIME_CONTENT_ENCODING_BASE64, args[0], pt); add_part(stack, GMIME_OBJECT(pt)); }
static void interpret_text(GSList** stack, gchar** args) { GMimePart* pt = g_mime_part_new(); g_mime_part_set_content_encoding(pt, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE); g_mime_object_set_content_disposition( GMIME_OBJECT(pt), g_mime_content_disposition_new_from_string(GMIME_DISPOSITION_INLINE)); add_content(GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE, args[0], pt); add_part(stack, GMIME_OBJECT(pt)); }
void CreateHexCore::transferOctreeGrid() { QVector<bool> delete_node(m_Octree.getNumNodes(), false); QVector<bool> delete_cell(m_Octree.getNumCells(), false); for (vtkIdType id_node = 0; id_node < m_Grid->GetNumberOfPoints(); ++id_node) { vec3_t x; m_Grid->GetPoint(id_node, x.data()); int i_cell = m_Octree.findCell(x); if (m_Octree.hasChildren(i_cell)) { EG_BUG; } delete_cell[i_cell] = true; for (int i = 0; i < 8; ++i) { delete_node[m_Octree.getNode(i_cell, i)] = true; } } for (int layer = 0; layer < m_NumBreakOutLayers; ++layer) { for (int i = 0; i < m_Octree.getNumCells(); ++i) { if (delete_cell[i] && !m_Octree.hasChildren(i)) { for (int j = 0; j < 8; ++j) { delete_node[m_Octree.getNode(i,j)] = true; } } } for (int i = 0; i < m_Octree.getNumCells(); ++i) { if (!m_Octree.hasChildren(i)) { for (int j = 0; j < 8; ++j) { if (delete_node[m_Octree.getNode(i,j)]) { delete_cell[i] = true; break; } } } } } EG_VTKSP(vtkUnstructuredGrid, otgrid); m_Octree.toVtkGridPolyhedral(otgrid, true); //m_Octree.toVtkGridConforming(otgrid, true); MeshPartition add_part(otgrid); QList<vtkIdType> add_cells; for (vtkIdType id_cell = 0; id_cell < otgrid->GetNumberOfCells(); ++id_cell) { int i_cell = m_Octree.findCell(cellCentre(otgrid, id_cell)); if (!delete_cell[i_cell]) { add_cells.append(id_cell); } } add_part.setCells(add_cells); m_Part.addPartition(add_part); m_Part.setAllCells(); deleteOutside(m_Grid); }
static void fold_to(GSList** stack, guint level) { guint min_level = level ? level : 1; while ( g_slist_length(*stack) > min_level ) { /* pop and add to top */ GSList* top = *stack; GMimeObject* part = GMIME_OBJECT(top->data); if ( GMIME_IS_MESSAGE(part) ) { GMimeMessagePart* mgp = g_mime_message_part_new_with_message( "rfc822", GMIME_MESSAGE(part)); part = GMIME_OBJECT(mgp); } *stack = g_slist_remove_link(*stack, top); add_part(stack, part); g_slist_free(top); } }
/* We want "finished in100 seconds to match "finished in 5 seconds". */ struct pattern *get_pattern(const char *line, struct values **vals) { enum pattern_type state = LITERAL; size_t len, i, max_parts = 3; struct pattern_part part; struct pattern *p; *vals = malloc(valsize(max_parts)); p = malloc(partsize(max_parts)); p->text = line; p->num_parts = 0; for (i = len = 0; state != TERM; i++, len++) { enum pattern_type old_state = state; bool starts_num; union val v; starts_num = (line[i] == '-' && cisdigit(line[i+1])) || cisdigit(line[i]); switch (state) { case LITERAL: if (starts_num) { state = INTEGER; break; } else if (cisspace(line[i])) { state = PRESPACES; break; } break; case PRESPACES: if (starts_num) { state = INTEGER; break; } else if (!cisspace(line[i])) { state = LITERAL; } break; case INTEGER: if (line[i] == '.') { if (cisdigit(line[i+1])) { /* Was float all along... */ state = old_state = FLOAT; } else state = LITERAL; break; } /* fall thru */ case FLOAT: if (cisspace(line[i])) { state = PRESPACES; break; } else if (!cisdigit(line[i])) { state = LITERAL; break; } break; case TERM: abort(); } if (!line[i]) state = TERM; if (state == old_state) continue; part.type = old_state; part.len = len; part.off = i - len; /* Make sure identical values memcmp in find_literal_numbers */ memset(&v, 0, sizeof(v)); if (old_state == FLOAT) { char *end; v.dval = strtod(line + part.off, &end); if (end != line + i) { warnx("Could not parse float '%.*s'", (int)len, line + i - len); } else { add_part(&p, vals, &part, &v, &max_parts); } len = 0; } else if (old_state == INTEGER) { char *end; v.ival = strtoll(line + part.off, &end, 10); if (end != line + i) { warnx("Could not parse integer '%.*s'", (int)len, line + i - len); } else { add_part(&p, vals, &part, &v, &max_parts); } len = 0; } else if (old_state == LITERAL && len > 0) { /* Since we can go to PRESPACES and back, we can * have successive literals. Collapse them. */ if (p->num_parts > 0 && p->part[p->num_parts-1].type == LITERAL) { p->part[p->num_parts-1].len += len; len = 0; continue; } add_part(&p, vals, &part, &v, &max_parts); len = 0; } } return p; }
static grub_err_t susp_iterate_dir (struct grub_iso9660_susp_entry *entry, void *_ctx) { struct iterate_dir_ctx *ctx = _ctx; /* The filename in the rock ridge entry. */ if (grub_strncmp ("NM", (char *) entry->sig, 2) == 0) { /* The flags are stored at the data position 0, here the filename type is stored. */ /* FIXME: Fix this slightly improper cast. */ if (entry->data[0] & GRUB_ISO9660_RR_DOT) ctx->filename = (char *) "."; else if (entry->data[0] & GRUB_ISO9660_RR_DOTDOT) ctx->filename = (char *) ".."; else if (entry->len >= 5) { grub_size_t off = 0, csize = 1; char *old; csize = entry->len - 5; old = ctx->filename; if (ctx->filename_alloc) { off = grub_strlen (ctx->filename); ctx->filename = grub_realloc (ctx->filename, csize + off + 1); } else { off = 0; ctx->filename = grub_zalloc (csize + 1); } if (!ctx->filename) { ctx->filename = old; return grub_errno; } ctx->filename_alloc = 1; grub_memcpy (ctx->filename + off, (char *) &entry->data[1], csize); ctx->filename[off + csize] = '\0'; } } /* The mode information (st_mode). */ else if (grub_strncmp ((char *) entry->sig, "PX", 2) == 0) { /* At position 0 of the PX record the st_mode information is stored (little-endian). */ grub_uint32_t mode = ((entry->data[0] + (entry->data[1] << 8)) & GRUB_ISO9660_FSTYPE_MASK); switch (mode) { case GRUB_ISO9660_FSTYPE_DIR: ctx->type = GRUB_FSHELP_DIR; break; case GRUB_ISO9660_FSTYPE_REG: ctx->type = GRUB_FSHELP_REG; break; case GRUB_ISO9660_FSTYPE_SYMLINK: ctx->type = GRUB_FSHELP_SYMLINK; break; default: ctx->type = GRUB_FSHELP_UNKNOWN; } } else if (grub_strncmp ("SL", (char *) entry->sig, 2) == 0) { unsigned int pos = 1; /* The symlink is not stored as a POSIX symlink, translate it. */ while (pos + sizeof (*entry) < entry->len) { /* The current position is the `Component Flag'. */ switch (entry->data[pos] & 30) { case 0: { /* The data on pos + 2 is the actual data, pos + 1 is the length. Both are part of the `Component Record'. */ if (ctx->symlink && !ctx->was_continue) add_part (ctx, "/", 1); add_part (ctx, (char *) &entry->data[pos + 2], entry->data[pos + 1]); ctx->was_continue = (entry->data[pos] & 1); break; } case 2: add_part (ctx, "./", 2); break; case 4: add_part (ctx, "../", 3); break; case 8: add_part (ctx, "/", 1); break; } /* In pos + 1 the length of the `Component Record' is stored. */ pos += entry->data[pos + 1] + 2; } /* Check if `grub_realloc' failed. */ if (grub_errno) return grub_errno; } return 0; }
/* * Read symbol specified by name. * Name: group/name | group/name@mapset * (later add syntax to prefer symbol from GISBASE) * S_read() searches first in mapsets (standard GRASS search) and * then in GISBASE/etc/symbol/ */ SYMBOL *S_read(const char *sname) { int i, j, k, l; FILE *fp; char group[500], name[500], buf[2001]; const char *ms; char *c; double x, y, x2, y2, rad, ang1, ang2; int r, g, b; double fr, fg, fb; int ret; char clock; SYMBOL *symb; int current; /* current part_type */ SYMBPART *part; /* current part */ SYMBCHAIN *chain; /* current chain */ SYMBEL *elem; /* current element */ G_debug(3, "S_read(): sname = %s", sname); /* Find file */ /* Get group and name */ strcpy(group, sname); c = strchr(group, '/'); if (c == NULL) { G_warning(_("Incorrect symbol name: '%s' (should be: group/name or group/name@mapset)"), sname); return NULL; } c[0] = '\0'; c++; strcpy(name, c); G_debug(3, " group: '%s' name: '%s'", group, name); /* Search in mapsets */ sprintf(buf, "symbol/%s", group); ms = G_find_file(buf, name, NULL); if (ms != NULL) { /* Found in mapsets */ fp = G_fopen_old(buf, name, ms); } else { /* Search in GISBASE */ sprintf(buf, "%s/etc/symbol/%s", G_gisbase(), sname); fp = fopen(buf, "r"); } if (fp == NULL) { G_warning(_("Cannot find/open symbol: '%s'"), sname); return NULL; } /* create new symbol */ symb = new_symbol(); current = OBJ_NONE; /* no part */ /* read file */ while (G_getl2(buf, 2000, fp) != 0) { G_chop(buf); G_debug(3, " BUF: [%s]", buf); /* skip empty and comment lines */ if ((buf[0] == '#') || (buf[0] == '\0')) continue; get_key_data(buf); if (strcmp(key, "VERSION") == 0) { if (strcmp(data, "1.0") != 0) { sprintf(buf, "Wrong symbol version: '%s'", data); return (err(fp, symb, buf)); } } else if (strcmp(key, "BOX") == 0) { if (sscanf(data, "%lf %lf %lf %lf", &x, &y, &x2, &y2) != 4) { sprintf(buf, "Incorrect box definition: '%s'", data); return (err(fp, symb, buf)); } symb->xscale = 1 / (x2 - x); symb->yscale = 1 / (y2 - y); if (x2 - x > y2 - y) { symb->scale = symb->xscale; } else { symb->scale = symb->yscale; } } else if (strcmp(key, "STRING") == 0) { G_debug(4, " STRING >"); current = OBJ_STRING; part = new_part(S_STRING); add_part(symb, part); chain = new_chain(); add_chain(part, chain); } else if (strcmp(key, "POLYGON") == 0) { G_debug(4, " POLYGON >"); current = OBJ_POLYGON; part = new_part(S_POLYGON); add_part(symb, part); } else if (strcmp(key, "RING") == 0) { G_debug(4, " RING >"); current = OBJ_RING; chain = new_chain(); add_chain(part, chain); } else if (strcmp(key, "LINE") == 0) { G_debug(4, " LINE >"); elem = new_line(); add_element(chain, elem); read_coor(fp, elem); } else if (strcmp(key, "ARC") == 0) { G_debug(4, " ARC"); ret = sscanf(data, "%lf %lf %lf %lf %lf %c", &x, &y, &rad, &ang1, &ang2, &clock); if (ret < 5) { sprintf(buf, "Incorrect arc definition: '%s'", buf); return (err(fp, symb, buf)); } if (ret == 6 && (clock == 'c' || clock == 'C')) i = 1; else i = 0; elem = new_arc(x, y, rad, ang1, ang2, i); add_element(chain, elem); } else if (strcmp(key, "END") == 0) { switch (current) { case OBJ_STRING: G_debug(4, " STRING END"); current = OBJ_NONE; break; case OBJ_POLYGON: G_debug(4, " POLYGON END"); current = OBJ_NONE; break; case OBJ_RING: G_debug(4, " RING END"); current = OBJ_POLYGON; break; } } else if (strcmp(key, "COLOR") == 0) { if (G_strcasecmp(data, "NONE") == 0) { part->color.color = S_COL_NONE; } else if (sscanf(data, "%d %d %d", &r, &g, &b) == 3) { if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) G_warning(_("Incorrect symbol color: '%s', using default."), buf); else { fr = r / 255.0; fg = g / 255.0; fb = b / 255.0; part->color.color = S_COL_DEFINED; part->color.r = r; part->color.g = g; part->color.b = b; part->color.fr = fr; part->color.fg = fg; part->color.fb = fb; G_debug(4, " color [%d %d %d] = [%.3f %.3f %.3f]", r, g, b, fr, fg, fb); } } else { G_warning(_("Incorrect symbol color: '%s', using default."), buf); } } else if (strcmp(key, "FCOLOR") == 0) { if (G_strcasecmp(data, "NONE") == 0) { part->fcolor.color = S_COL_NONE; } else if (sscanf(data, "%d %d %d", &r, &g, &b) == 3) { if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255) G_warning(_("Incorrect symbol color: '%s', using default."), buf); else { fr = r / 255.0; fg = g / 255.0; fb = b / 255.0; part->fcolor.color = S_COL_DEFINED; part->fcolor.r = r; part->fcolor.g = g; part->fcolor.b = b; part->fcolor.fr = fr; part->fcolor.fg = fg; part->fcolor.fb = fb; G_debug(4, " color [%d %d %d] = [%.3f %.3f %.3f]", r, g, b, fr, fg, fb); } } else { G_warning(_("Incorrect symbol color: '%s', using default."), buf); } } else { sprintf(buf, "Unknown keyword in symbol: '%s'", buf); return (err(fp, symb, buf)); break; } } /* Debug output */ G_debug(3, "Number of parts: %d", symb->count); for (i = 0; i < symb->count; i++) { part = symb->part[i]; G_debug(4, " Part %d: type: %d number of chains: %d", i, part->type, part->count); G_debug(4, " color: %d: fcolor: %d", part->color.color, part->fcolor.color); for (j = 0; j < part->count; j++) { chain = part->chain[j]; G_debug(4, " Chain %d: number of elements: %d", j, chain->count); for (k = 0; k < chain->count; k++) { elem = chain->elem[k]; G_debug(4, " Element %d: type: %d", k, elem->type); if (elem->type == S_LINE) { G_debug(4, " Number of points %d", elem->coor.line.count); for (l = 0; l < elem->coor.line.count; l++) { G_debug(4, " x, y: %f %f", elem->coor.line.x[l], elem->coor.line.y[l]); } } else { G_debug(4, " arc r = %f", elem->coor.arc.r); } } } } fclose(fp); return symb; }
bool create_cube(NodeInstance& node, const Context& context, uint32_t flags) { add_part(node.mesh); return create_cube(node.mesh, context, flags); }
bool create_conus(NodeInstance& node, const Context& context, float radius, float height, int subdivision) { add_part(node.mesh); return create_conus(node.mesh, context, radius, height, subdivision); }
bool create_sphere(NodeInstance& node, const Context& context, int subdivision, uint32_t flags) { add_part(node.mesh); return create_sphere(node.mesh, context, subdivision, flags); }