[cig-commits] [commit] master: Add [] operator to sweeps (d819944)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed Oct 8 17:06:36 PDT 2014
Repository : https://github.com/geodynamics/vc
On branch : master
Link : https://github.com/geodynamics/vc/compare/23464fca3efa2b6ad7ee0ce8f60c225b18b49741...e4325192ad1118379f46ba66899cb98143d09e04
>---------------------------------------------------------------
commit d819944f600d568b6a57f967da1fa6ce13cdd667
Author: Eric Heien <emheien at ucdavis.edu>
Date: Wed Oct 8 00:12:40 2014 -0700
Add [] operator to sweeps
>---------------------------------------------------------------
d819944f600d568b6a57f967da1fa6ce13cdd667
quakelib/src/QuakeLibIO.cpp | 1 +
quakelib/src/QuakeLibIO.h | 15 +++++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/quakelib/src/QuakeLibIO.cpp b/quakelib/src/QuakeLibIO.cpp
index 332ddbf..9e8a2d2 100644
--- a/quakelib/src/QuakeLibIO.cpp
+++ b/quakelib/src/QuakeLibIO.cpp
@@ -2790,6 +2790,7 @@ int quakelib::ModelEventSet::read_file_ascii(const std::string &event_file_name,
unsigned int num_rec_sweeps = new_event.getNumRecordedSweeps();
new_sweeps.read_ascii(sweep_file, num_rec_sweeps);
new_event.setSweeps(new_sweeps);
+
if (!event_file.eof() && !sweep_file.eof()) _events.push_back(new_event);
}
diff --git a/quakelib/src/QuakeLibIO.h b/quakelib/src/QuakeLibIO.h
index d17fff9..a31bea3 100644
--- a/quakelib/src/QuakeLibIO.h
+++ b/quakelib/src/QuakeLibIO.h
@@ -704,6 +704,18 @@ namespace quakelib {
void read_ascii(std::istream &in_stream, const unsigned int num_records);
void write_ascii(std::ostream &out_stream) const;
+ SweepData &operator[](const unsigned int ind) throw(std::out_of_range) {
+ if (ind >= _sweeps.size()) throw std::out_of_range("ModelSweeps[]");
+
+ return _sweeps[ind];
+ };
+
+ const SweepData &operator[](const unsigned int ind) const throw(std::out_of_range) {
+ if (ind >= _sweeps.size()) throw std::out_of_range("ModelSweeps[]");
+
+ return _sweeps[ind];
+ };
+
friend std::ostream &operator<<(std::ostream &os, const ModelSweeps &ms);
};
@@ -838,8 +850,7 @@ namespace quakelib {
//! Also calculate relevant values related to these sweeps.
void setSweeps(const ModelSweeps &sweeps) {
ModelSweeps::iterator it;
- double moment = 0
- ;
+ double moment = 0;
_sweeps = sweeps;
_total_slip.clear();
More information about the CIG-COMMITS
mailing list