static FcBool cache_print_set (FcFontSet *set, FcStrSet *dirs, const FcChar8 *base_name, FcBool verbose) { FcChar8 *dir; const FcChar8 *base; int n; int ndir = 0; FcStrList *list; list = FcStrListCreate (dirs); if (!list) goto bail2; while ((dir = FcStrListNext (list))) { base = file_base_name (base_name, dir); if (!write_string (stdout, base)) goto bail3; if (PUTC (' ', stdout) == EOF) goto bail3; if (!write_int (stdout, 0)) goto bail3; if (PUTC (' ', stdout) == EOF) goto bail3; if (!write_string (stdout, FC_FONT_FILE_DIR)) goto bail3; if (PUTC ('\n', stdout) == EOF) goto bail3; ndir++; } for (n = 0; n < set->nfont; n++) { FcPattern *font = set->fonts[n]; FcChar8 *s; s = FcPatternFormat (font, (const FcChar8 *) "%{=fccat}\n"); if (s) { printf ("%s", s); FcStrFree (s); } } if (verbose && !set->nfont && !ndir) printf ("<empty>\n"); FcStrListDone (list); return FcTrue; bail3: FcStrListDone (list); bail2: return FcFalse; }
int main(int argc, char* argv[]) { if (argc < 5) { std::cout << "Program " << argv[0] << " converts a vertical surface described by a polyline embedded in a mesh to a polygon" << std::endl; std::cout << "For this reason the polyline is projected to the bottom surface and top surface " "of the mesh. The resulting two polylines are linked to a closed polyline, i.e., a polygon." << std::endl; std::cout << "Usage: " << argv[0] << " --mesh ogs_meshfile --geometry ogs_geometry_as_gli_file [--polyline-id-lower ply_id_lower --polyline-id-upper ply_id_upper]" << std::endl; return -1; } // *** read mesh std::string tmp(argv[1]); if (tmp.find("--mesh") == std::string::npos) { std::cout << "could not extract mesh file name" << std::endl; return -1; } tmp = argv[2]; std::string file_base_name(tmp); if (tmp.find(".msh") != std::string::npos) file_base_name = tmp.substr(0, tmp.size() - 4); std::vector<MeshLib::CFEMesh*> mesh_vec; FEMRead(file_base_name, mesh_vec); if (mesh_vec.empty()) { std::cerr << "could not read mesh from file " << std::endl; return -1; } MeshLib::CFEMesh * mesh(mesh_vec[mesh_vec.size() - 1]); mesh->ConstructGrid(); // *** read geometry tmp = argv[3]; if (tmp.find("--geometry") == std::string::npos) { std::cout << "could not extract geometry file name" << std::endl; return -1; } GEOLIB::GEOObjects* geo(new GEOLIB::GEOObjects); tmp = argv[4]; std::string unique_name; std::vector<std::string> error_strings; FileIO::readGLIFileV4(tmp, geo, unique_name, error_strings); // *** get Polygon const std::vector<GEOLIB::Polyline*>* plys(geo->getPolylineVec(unique_name)); std::cout << "fetched polylines: " << std::flush << plys->size() << std::endl; if (!plys) { std::cout << "could not get vector of polylines" << std::endl; delete mesh; delete geo; return -1; } //*** extract surface out of mesh MeshLib::ExtractMeshNodes extract_mesh_nodes(mesh); // *** generate a polygon from polyline size_t ply_id_upper(plys->size()); size_t ply_id_lower(0); if (argc == 9) { ply_id_lower = str2number<size_t>(argv[6]); ply_id_upper = std::min(str2number<size_t>(argv[8]), ply_id_upper); } for (size_t k(ply_id_lower); k < ply_id_upper; k++) { bool closed((*plys)[k]->isClosed()); if (!closed) { std::cout << "converting polyline " << k << " to polygon (closed polyline) " << std::endl; GEOLIB::Polygon* polygon(NULL); extract_mesh_nodes.getPolygonFromPolyline(*((*plys)[k]), geo, unique_name, polygon); std::string *polygon_name(new std::string); geo->getPolylineVecObj(unique_name)->getNameOfElementByID(k, *polygon_name); (*polygon_name) += "-Polygon"; geo->getPolylineVecObj(unique_name)->push_back(polygon, polygon_name); } } std::string path; BaseLib::extractPath(argv[4], path); std::string const fname_of_new_file(path + "New.gli"); FileIO::writeGLIFileV4(fname_of_new_file, unique_name, *geo); delete mesh; delete geo; return 0; }
static int boot_mips_write(FILE *outfile) { struct directory_entry *boot_file; /* Boot file we need to search for */ unsigned long length = 0; unsigned long extent = 0; int i; struct volume_header vh; unsigned long long iso_size = 0; char *filename = NULL; memset(&vh, 0, sizeof(vh)); iso_size = last_extent * 2048; write_be32(VHMAGIC, (unsigned char *)&vh.vh_magic); /* Values from an IRIX cd */ write_be16(BYTES_PER_SECTOR, (unsigned char *)&vh.vh_dp.dp_secbytes); write_be16(SECTORS_PER_TRACK, (unsigned char *)&vh.vh_dp.dp_secs); write_be32(DP_RESEEK|DP_IGNOREERRORS|DP_TRKFWD, (unsigned char *)&vh.vh_dp.dp_flags); write_be16(1, (unsigned char *)&vh.vh_dp.dp_trks0); write_be16((iso_size + BYTES_PER_SECTOR - 1) / (SECTORS_PER_TRACK * BYTES_PER_SECTOR), (unsigned char *)&vh.vh_dp.dp_cyls); for(i = 0; i < boot_mips_num_files; i++) { boot_file = search_tree_file(root, boot_mips_filename[i]); if (!boot_file) { #ifdef USE_LIBSCHILY comerrno(EX_BAD, "Uh oh, I cant find the MIPS boot file '%s'!\n", boot_mips_filename[i]); #else fprintf(stderr, "Uh oh, I cant find the MIPS boot file '%s'!\n", boot_mips_filename[i]); exit(1); #endif } extent = get_733(boot_file->isorec.extent) * 4; length = ((get_733(boot_file->isorec.size) + 2047) / 2048) * 2048; filename = file_base_name(boot_mips_filename[i]); strncpy((char *)vh.vh_vd[i].vd_name, filename, MIN(VDNAMESIZE, strlen(filename))); write_be32(extent, (unsigned char *)&vh.vh_vd[i].vd_lbn); write_be32(length, (unsigned char *)&vh.vh_vd[i].vd_nbytes); fprintf(stderr, "Found mips boot image %s, using extent %lu (0x%lX), #blocks %lu (0x%lX)\n", filename, extent, extent, length, length); } /* Create volume partition on whole cd iso */ write_be32((iso_size + (BYTES_PER_SECTOR - 1))/ BYTES_PER_SECTOR, (unsigned char *)&vh.vh_pt[10].pt_nblks); write_be32(0, (unsigned char *)&vh.vh_pt[10].pt_firstlbn); write_be32(PTYPE_VOLUME, (unsigned char *)&vh.vh_pt[10].pt_type); /* Create volume header partition, also on WHOLE cd iso */ write_be32((iso_size + (BYTES_PER_SECTOR - 1))/ BYTES_PER_SECTOR, (unsigned char *)&vh.vh_pt[8].pt_nblks); write_be32(0, (unsigned char *)&vh.vh_pt[8].pt_firstlbn); write_be32(PTYPE_VOLHDR, (unsigned char *)&vh.vh_pt[8].pt_type); /* Create checksum */ vh_calc_checksum(&vh); jtwrite(&vh, sizeof(vh), 1, 0, FALSE); xfwrite(&vh, sizeof(vh), 1, outfile, 0, FALSE); last_extent_written++; return 0; }
int main(int argc, char* argv[]) { if (argc < 5) { std::cout << "program " << argv[0] << " takes a *layered* mesh file and closed polylines from a geometry and " "computes the surface mesh nodes within the closed polyline" << std::endl; std::cout << "Usage: " << std::endl << argv[0] << "\n\t--mesh ogs_meshfile\n\t--geometry ogs_geometry_as_gli_file" << std::endl; return -1; } // *** read mesh std::string tmp(argv[1]); if (tmp.find("--mesh") == std::string::npos) { std::cout << "could not extract mesh file name" << std::endl; return -1; } tmp = argv[2]; std::string file_base_name(tmp); if (tmp.find(".msh") != std::string::npos) file_base_name = tmp.substr(0, tmp.size() - 4); std::vector<MeshLib::CFEMesh*> mesh_vec; FEMRead(file_base_name, mesh_vec); if (mesh_vec.empty()) { std::cerr << "could not read mesh from file " << std::endl; return -1; } MeshLib::CFEMesh* mesh(mesh_vec[mesh_vec.size() - 1]); mesh->ConstructGrid(); // extract path std::string path; BaseLib::extractPath(argv[2], path); // *** read geometry tmp = argv[3]; if (tmp.find("--geometry") == std::string::npos) { std::cout << "could not extract geometry file name" << std::endl; return -1; } GEOLIB::GEOObjects* geo(new GEOLIB::GEOObjects); tmp = argv[4]; std::string unique_name; std::vector<std::string> error_strings; FileIO::readGLIFileV4(tmp, geo, unique_name, error_strings); // { // const std::vector<GEOLIB::Point*>* pnts (geo->getPointVec (tmp)); // if (pnts) { // std::string fname ("MeshIDs.txt"); // std::ofstream out (fname.c_str()); // // std::string fname_gli ("MeshNodesAsPnts.gli"); // std::ofstream pnt_out (fname_gli.c_str()); // pnt_out << "#POINTS" << std::endl; // // MeshLib::ExtractMeshNodes extract_mesh_nodes (mesh); // // const size_t n_pnts (pnts->size()); // for (size_t k(0); k<n_pnts; k++) { // extract_mesh_nodes.writeNearestMeshNodeToPoint (out, pnt_out, *((*pnts)[k])); // } // pnt_out << "#STOP" << std::endl; // } // return 0; // } // *** get Polygon const std::vector<GEOLIB::Polyline*>* plys(geo->getPolylineVec(unique_name)); if (!plys) { std::cout << "could not get vector of polylines" << std::endl; delete mesh; delete geo; return -1; } std::vector<size_t> mesh_ids; // size_t ply_id (0); // size_t layer(1); // getMeshNodesFromLayerAlongPolyline(mesh, geo, unique_name, ply_id, layer, mesh_ids); // writeMeshNodes(mesh, mesh_ids, "MeshIDs.txt", "MeshNodesAsPoints.gli", true); //*** extract surface out of mesh MeshLib::ExtractMeshNodes extract_mesh_nodes(mesh); // // *** generate a polygon from polyline //// std::vector<GEOLIB::Polyline*> polylines; // const size_t n_plys (plys->size()); // for (size_t k(0); k < n_plys; k++) // { // bool closed ((*plys)[k]->isClosed()); // if (!closed) // { // std::cout << "converting polyline " << k << " to closed polyline" << std::endl; // GEOLIB::Polygon* polygon(NULL); // extract_mesh_nodes.getPolygonFromPolyline(*((*plys)[k]), geo, unique_name, polygon); //// polylines.push_back (polygon); //// geo->appendPolylineVec (polylines, unique_name); // std::string *polygon_name(new std::string); // geo->getPolylineVecObj(unique_name)->getNameOfElementByID(k, *polygon_name); // (*polygon_name) += "-Polygon"; // geo->getPolylineVecObj(unique_name)->push_back(polygon, polygon_name); //// polylines.clear(); // } // } // // FileIO::writeGLIFileV4 ("New.gli", unique_name, *geo); // *** search mesh nodes for direct assigning bc, st or ic const size_t n_plys(plys->size()); for (size_t k(0); k < n_plys; k++) { bool closed((*plys)[k]->isClosed()); if (!closed) { std::cout << "polyline " << k << " is not closed" << std::endl; } else { std::string fname(path + "MeshIDs.txt"); std::ofstream out(fname.c_str()); std::string fname_gli(path + "MeshNodesAsPnts.gli"); std::ofstream pnt_out(fname_gli.c_str()); pnt_out << "#POINTS" << std::endl; GEOLIB::Polygon polygon(*((*plys)[k])); // extract_mesh_nodes.writeMesh2DNodeIDAndArea (out, pnt_out, polygon); extract_mesh_nodes.writeTopSurfaceMeshNodeIDs(out, pnt_out, polygon); // write all nodes - not only the surface nodes // extract_mesh_nodes.writeMeshNodeIDs (out, pnt_out, polygon); pnt_out << "#STOP" << std::endl; out.close(); pnt_out.close(); } } // *** for Model Pipiripau // std::vector<GEOLIB::Polygon*> holes; // size_t bounding_polygon_id(0); // while (bounding_polygon_id < n_plys && ! (*plys)[bounding_polygon_id]->isClosed()) { // bounding_polygon_id++; // } // // for (size_t k(bounding_polygon_id+1); k<n_plys; k++) { // bool closed ((*plys)[k]->isClosed()); // if (!closed) { // std::cout << "polyline " << k << " is not closed" << std::endl; // } else { // holes.push_back (new GEOLIB::Polygon(*(((*plys)[k])))); // } // } // extract_mesh_nodes.writeMesh2DNodeIDAndArea (out, pnt_out, GEOLIB::Polygon((*((*plys)[bounding_polygon_id]))), // holes); // for (size_t k(0); k<holes.size(); k++) { // delete holes[k]; // } // out << "#STOP" << std::endl; // out.close(); // // pnt_out << "#STOP" << std::endl; // pnt_out.close (); delete mesh; delete geo; return 0; }