# HG changeset patch # User Chris Cannam # Date 1227277533 0 # Node ID 1c66e199e7d9aea5943ef49586d11191764d0bcd # Parent c45e6c6722e0477769349167b42d04713aadbab5 * remove some unused code diff -r c45e6c6722e0 -r 1c66e199e7d9 rdf/RDFImporter.cpp --- a/rdf/RDFImporter.cpp Fri Nov 21 13:37:35 2008 +0000 +++ b/rdf/RDFImporter.cpp Fri Nov 21 14:25:33 2008 +0000 @@ -60,21 +60,6 @@ void fillModel(Model *, long, long, bool, std::vector &, QString); - -/* - - typedef std::vector > DurationValueList; - typedef std::map TimeDurationValueMap; - typedef std::map TypeTimeDurationValueMap; - typedef std::map SourceTypeTimeDurationValueMap; - - void extractStructure(const TimeDurationValueMap &map, bool &sparse, - int &minValueCount, int &maxValueCount); - - void fillModel(SparseOneDimensionalModel *, const TimeDurationValueMap &); - void fillModel(SparseTimeValueModel *, const TimeDurationValueMap &); - void fillModel(EditableDenseThreeDimensionalModel *, const TimeDurationValueMap &); -*/ }; @@ -397,8 +382,6 @@ // If the source signal or feature type is unavailable, the empty // string will do. -// SourceTypeTimeDurationValueMap m; - QString prefixes = QString( " PREFIX event: " " PREFIX tl: " @@ -634,160 +617,8 @@ fillModel(model, ftime, fduration, haveDuration, values, label); } } - - -/* - for (SourceTypeTimeDurationValueMap::const_iterator mi = m.begin(); - mi != m.end(); ++mi) { - - QString source = mi->first; - - for (TypeTimeDurationValueMap::const_iterator ttvi = mi->second.begin(); - ttvi != mi->second.end(); ++ttvi) { - - QString type = ttvi->first; - - // Now we need to work out what sort of model to use for - // this source/type combination. Ultimately we'll - // hopefully be able to map directly from the type to the - // model on the basis of known structures for the types, - // but we also want to be able to handle untyped data - // according to its apparent structure so let's do that - // first. - - bool sparse = false; - int minValueCount = 0, maxValueCount = 0; - - extractStructure(ttvi->second, sparse, minValueCount, maxValueCount); - - cerr << "For source \"" << source.toStdString() << "\", type \"" - << type.toStdString() << "\" we have sparse = " << sparse - << ", min value count = " << minValueCount << ", max = " - << maxValueCount << endl; - - // Model allocations: - // - // Sparse, no values: SparseOneDimensionalModel - // - // Sparse, always 1 value: SparseTimeValueModel - // - // Sparse, > 1 value: No standard model for this. If - // there are always 2 values, perhaps hack it into - // NoteModel for now? Or always use SparseTimeValueModel - // and discard all but the first value. - // - // Dense, no values: Meaningless; no suitable model - // - // Dense, > 0 values: EditableDenseThreeDimensionalModel - // - // These should just be our fallback positions; we want to - // be reading semantic data from the RDF in order to pick - // the right model directly - - enum { SODM, STVM, EDTDM } modelType = SODM; - - if (sparse) { - if (maxValueCount == 0) { - modelType = SODM; - } else if (minValueCount == 1 && maxValueCount == 1) { - modelType = STVM; - } else { - cerr << "WARNING: No suitable model available for sparse data with between " << minValueCount << " and " << maxValueCount << " values" << endl; - modelType = STVM; - } - } else { - if (maxValueCount == 0) { - cerr << "WARNING: Dense data set with no values is not meaningful, skipping" << endl; - continue; - } else { - modelType = EDTDM; - } - } - - //!!! set model name &c - - if (modelType == SODM) { - - SparseOneDimensionalModel *model = - new SparseOneDimensionalModel(m_sampleRate, 1, false); - - fillModel(model, ttvi->second); - models.push_back(model); - - } else if (modelType == STVM) { - - SparseTimeValueModel *model = - new SparseTimeValueModel(m_sampleRate, 1, false); - - fillModel(model, ttvi->second); - models.push_back(model); - - } else { - - EditableDenseThreeDimensionalModel *model = - new EditableDenseThreeDimensionalModel(m_sampleRate, 1, 0, - false); - - fillModel(model, ttvi->second); - models.push_back(model); - } - } - } -*/ } -/* -void -RDFImporterImpl::extractStructure(const TimeDurationValueMap &tvm, - bool &sparse, - int &minValueCount, - int &maxValueCount) -{ - // These are floats intentionally rather than RealTime -- - // see logic for handling rounding error below - float firstTime = 0.f; - float timeStep = 0.f; - bool haveTimeStep = false; - - for (TimeDurationValueMap::const_iterator tvi = tvm.begin(); tvi != tvm.end(); ++tvi) { - - RealTime time = tvi->first; - int valueCount = tvi->second.size(); - - if (tvi == tvm.begin()) { - - minValueCount = valueCount; - maxValueCount = valueCount; - - firstTime = time.toDouble(); - - } else { - - if (valueCount < minValueCount) minValueCount = valueCount; - if (valueCount > maxValueCount) maxValueCount = valueCount; - - if (!haveTimeStep) { - timeStep = time.toDouble() - firstTime; - if (timeStep == 0.f) sparse = true; - haveTimeStep = true; - } else if (!sparse) { - // test whether this time is within - // rounding-error range of being an integer - // multiple of some constant away from the - // first time - float timeAsFloat = time.toDouble(); - int count = int((timeAsFloat - firstTime) / timeStep + 0.5); - float expected = firstTime + (timeStep * count); - if (fabsf(expected - timeAsFloat) > 1e-6) { - cerr << "Event at " << timeAsFloat << " is not evenly spaced -- would expect it to be " << expected << " for a spacing of " << count << " * " << timeStep << endl; - sparse = true; - } - } - } - } -} -*/ - void RDFImporterImpl::fillModel(Model *model, long ftime, @@ -871,61 +702,3 @@ } -/* -void -RDFImporterImpl::fillModel(SparseOneDimensionalModel *model, - const TimeDurationValueMap &tvm) -{ - //!!! labels &c not yet handled - - for (TimeDurationValueMap::const_iterator tvi = tvm.begin(); - tvi != tvm.end(); ++tvi) { - - RealTime time = tvi->first; - long frame = RealTime::realTime2Frame(time, m_sampleRate); - - SparseOneDimensionalModel::Point point(frame); - - model->addPoint(point); - } -} - -void -RDFImporterImpl::fillModel(SparseTimeValueModel *model, - const TimeDurationValueMap &tvm) -{ - //!!! labels &c not yet handled - - for (TimeDurationValueMap::const_iterator tvi = tvm.begin(); - tvi != tvm.end(); ++tvi) { - - RealTime time = tvi->first; - long frame = RealTime::realTime2Frame(time, m_sampleRate); - - float value = 0.f; - if (!tvi->second.empty()) value = *tvi->second.begin()->second; - - SparseTimeValueModel::Point point(frame, value, ""); - - model->addPoint(point); - } -} - -void -RDFImporterImpl::fillModel(EditableDenseThreeDimensionalModel *model, - const TimeDurationValueMap &tvm) -{ - //!!! labels &c not yet handled - - //!!! start time offset not yet handled - - size_t col = 0; - - for (TimeDurationValueMap::const_iterator tvi = tvm.begin(); - tvi != tvm.end(); ++tvi) { - - model->setColumn(col++, tvi->second.second); - } -} - -*/