static void dump_score(void) { int f; int p; int v; int staff; newline(); fprintf(lily_out, "\\score {"); indup(); fprintf(lily_out, "<<"); indup(); staff = 0; for (p = 0; p < n_part; p++) { if (ONLY != -1 && p != ONLY) { continue; fprintf(stderr, "Skip staff %d, do only staff %d\n", p, ONLY); } for (f = 0; f < part[p].n_staff; f++) { fprintf(lily_out, " \\new Staff = staff%c <<", 'A' + staff); staff++; indup(); if (part[p].staff[f].n_voice == 1) { fprintf(lily_out, " \\%s", part_name(p, f, 0)); } else { for (v = 0; v < part[p].staff[f].n_voice; v++) { char *count = i2count(v); fprintf(lily_out, " \\new Voice=%s {", count); indup(); fprintf(lily_out, " \\voice%s \\%s", count, part_name(p, f, v)); indown(); fprintf(lily_out, "}"); newline(); } } indown(); fprintf(lily_out, " >>"); newline(); } } indown(); fprintf(lily_out, ">>"); indown(); fprintf(lily_out, "}"); newline(); }
static void dump_notes(int do_beams) { int f; int p; int v; fprintf(stderr, "Now write parts...\n"); for (p = 0; p < n_part; p++) { if (ONLY != -1 && p != ONLY) { fprintf(stderr, "Skip staff %d, do only staff %d\n", p, ONLY); continue; } fprintf(stderr, " ........ part %d, ", p); for (f = 0; f < part[p].n_staff; f++) { fprintf(stderr, "staff %d, ", f); for (v = 0; v < part[p].staff[f].n_voice; v++) { fprintf(stderr, "voice %d ", v); VPRINTF("Now dump part %d staff %d voice %d", p, f, v); voice_reset(); fprintf(lily_out, "%s = {", part_name(p, f, v)); indup(); dumpVoice(&part[p].staff[f].voice[v], do_beams); indown(); fprintf(lily_out, "}"); newline(); newline(); } } fprintf(stderr, "\n"); } }
/** * Function FindRescues * Grab all possible RESCUE_CACHE_CANDIDATEs into a vector. * @param aRescuer - the working RESCUER instance. * @param aCandidates - the vector the will hold the candidates. */ static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates ) { typedef std::map<wxString, RESCUE_CACHE_CANDIDATE> candidate_map_t; candidate_map_t candidate_map; wxString part_name_suffix = aRescuer.GetPartNameSuffix(); for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) ) { wxString part_name( each_component->GetPartName() ); LIB_PART* cache_match = find_component( part_name, aRescuer.GetLibs(), /* aCached */ true ); LIB_PART* lib_match = aRescuer.GetLibs()->FindLibPart( part_name ); // Test whether there is a conflict if( !cache_match || !lib_match ) continue; if( !cache_match->PinsConflictWith( *lib_match, /* aTestNums */ true, /* aTestNames */ true, /* aTestType */ true, /* aTestOrientation */ true, /* aTestLength */ false )) continue; RESCUE_CACHE_CANDIDATE candidate( part_name, part_name + part_name_suffix, cache_match, lib_match ); candidate_map[part_name] = candidate; } // Now, dump the map into aCandidates for( const candidate_map_t::value_type& each_pair : candidate_map ) { aCandidates.push_back( new RESCUE_CACHE_CANDIDATE( each_pair.second ) ); } }
/** * Function FindRescues * Grab all possible RESCUE_CASE_CANDIDATES into a vector. * @param aRescuer - the working RESCUER instance. * @param aCandidates - the vector the will hold the candidates. */ static void FindRescues( RESCUER& aRescuer, boost::ptr_vector<RESCUE_CANDIDATE>& aCandidates ) { typedef std::map<wxString, RESCUE_CASE_CANDIDATE> candidate_map_t; candidate_map_t candidate_map; for( SCH_COMPONENT* each_component : *( aRescuer.GetComponents() ) ) { wxString part_name( each_component->GetPartName() ); LIB_ALIAS* case_sensitive_match = aRescuer.GetLibs()->FindLibraryAlias( part_name ); std::vector<LIB_ALIAS*> case_insensitive_matches; aRescuer.GetLibs()->FindLibraryNearEntries( case_insensitive_matches, part_name ); if( case_sensitive_match || !( case_insensitive_matches.size() ) ) continue; RESCUE_CASE_CANDIDATE candidate( part_name, case_insensitive_matches[0]->GetName(), case_insensitive_matches[0]->GetPart() ); candidate_map[part_name] = candidate; } // Now, dump the map into aCandidates for( const candidate_map_t::value_type& each_pair : candidate_map ) { aCandidates.push_back( new RESCUE_CASE_CANDIDATE( each_pair.second ) ); } }
//CP_XML_SERIALIZE_ATTR(L"Extension", extension()); //CP_XML_SERIALIZE_ATTR(L"ContentType", content_type()); //_Wostream << L" />"; return _Wostream; } const wchar_t * override_content_type::ns = L""; const wchar_t * override_content_type::name = L"Override"; ::std::wostream & override_content_type::xml_to_stream(::std::wostream & _Wostream) const { CP_XML_WRITER(_Wostream) { CP_XML_NODE(L"Override") { CP_XML_ATTR(L"PartName", part_name()); CP_XML_ATTR(L"ContentType", content_type()); } } //_Wostream << L"<Override "; //CP_XML_SERIALIZE_ATTR(L"PartName", part_name()); //CP_XML_SERIALIZE_ATTR(L"ContentType", content_type()); //_Wostream << L" />"; return _Wostream; } const wchar_t * content_type::ns = L""; const wchar_t * content_type::name = L"Types"; ::std::wostream & content_type::xml_to_stream(::std::wostream & _Wostream) const
void BlenderReader::operate() { try { QFileInfo file_info(GuiMainWindow::pointer()->getFilename()); readInputFileName(file_info.completeBaseName() + ".begc", false); if (isValid()) { // read raw data from exported file QFile file(getFileName()); file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream f(&file); QList<vec3_t> rnodes; QList<QVector<int> > rfaces; int num_parts; f >> num_parts; QVector<QString> part_name(num_parts); for (int i_part = 0; i_part < num_parts; ++i_part) { f >> part_name[i_part]; } QVector<QString> sorted_part_name = part_name; qSort(sorted_part_name); QVector<int> part_bc(part_name.size()); for (int i_part = 0; i_part < num_parts; ++i_part) { part_bc[i_part] = sorted_part_name.indexOf(part_name[i_part]) + 1; } for (int i_part = 0; i_part < num_parts; ++i_part) { int num_nodes, num_faces; f >> num_nodes >> num_faces; for (int i = 0; i < num_nodes; ++i) { vec3_t x; f >> x[0] >> x[1] >> x[2]; rnodes.push_back(x); } for (int i = 0; i < num_faces; ++i) { int N; f >> N; QVector<int> face(N+1); face[0] = i_part; for (int j = 0; j < N; ++j) { f >> face[j+1]; } rfaces.push_back(face); } } QVector<vec3_t> nodes(rnodes.size()); qCopy(rnodes.begin(), rnodes.end(), nodes.begin()); QVector<QVector<int> > faces(rfaces.size()); qCopy(rfaces.begin(), rfaces.end(), faces.begin()); // find smallest edge length double L = 1e99; foreach (QVector<int> face, faces) { for (int i = 1; i < face.size(); ++i) { int n1 = face[i]; int n2 = face[1]; if (i < face.size() - 1) { n2 = face[i+1]; } double l = (nodes[n1] - nodes[n2]).abs(); L = min(l, L); } } cout << "smallest edge length is " << L << endl; // delete duplicate nodes PointFinder finder; finder.setPoints(nodes); QList<vec3_t> non_dup; QVector<int> o2n(nodes.size()); int num_non_dup = 0; for (int i = 0; i < nodes.size(); ++i) { o2n[i] = num_non_dup; bool dup = false; QVector<int> close_points; finder.getClosePoints(nodes[i], close_points); foreach (int j, close_points) { if (i > j) { double l = (nodes[i] - nodes[j]).abs(); if (l < m_RelativeTolerance*L || l == 0) { o2n[i] = o2n[j]; dup = true; break; } } } if (!dup) { non_dup.push_back(nodes[i]); ++num_non_dup; } } EG_VTKSP(vtkUnstructuredGrid, new_grid); allocateGrid(new_grid, faces.size(), non_dup.size()); EG_VTKDCC(vtkIntArray, cell_code, new_grid, "cell_code"); EG_VTKDCC(vtkIntArray, orgdir, new_grid, "cell_orgdir"); EG_VTKDCC(vtkIntArray, voldir, new_grid, "cell_voldir"); EG_VTKDCC(vtkIntArray, curdir, new_grid, "cell_curdir"); vtkIdType id_node = 0; foreach (vec3_t x, non_dup) { new_grid->GetPoints()->SetPoint(id_node, x.data()); ++id_node; } foreach (QVector<int> face, faces) { if (face.size() == 4) { vtkIdType pts[3]; pts[0] = o2n[face[1]]; pts[1] = o2n[face[2]]; pts[2] = o2n[face[3]]; vtkIdType id_cell = new_grid->InsertNextCell(VTK_TRIANGLE, 3, pts); cell_code->SetValue(id_cell, part_bc[face[0]]); orgdir->SetValue(id_cell, 0); voldir->SetValue(id_cell, 0); curdir->SetValue(id_cell, 0); } if (face.size() == 5) { vtkIdType pts[4]; pts[0] = o2n[face[1]]; pts[1] = o2n[face[2]]; pts[2] = o2n[face[3]]; pts[3] = o2n[face[4]]; vtkIdType id_cell = new_grid->InsertNextCell(VTK_QUAD, 4, pts); cell_code->SetValue(id_cell, part_bc[face[0]]); orgdir->SetValue(id_cell, 0); voldir->SetValue(id_cell, 0); curdir->SetValue(id_cell, 0); } } if (m_Append) { EG_BUG; MeshPartition new_part(new_grid); new_part.setAllCells(); m_Part.addPartition(new_part); } else { makeCopy(new_grid, m_Grid); } UpdateNodeIndex(m_Grid); UpdateCellIndex(m_Grid); // check and set the boundary names if required int update_required = true; QSet<int> old_bcs = GuiMainWindow::pointer()->getAllBoundaryCodes(); if (old_bcs.size() == part_name.size()) { QSet<QString> old_names; foreach (int bc, old_bcs) { old_names.insert(GuiMainWindow::pointer()->getBC(bc).getName()); } QSet<QString> new_names; foreach (QString name, part_name) { new_names.insert(name); }