77
88namespace shapeworks {
99
10- ParticleSystemEvaluation::ParticleSystemEvaluation (const std::vector<std::string>& _paths) {
11- if (_paths.empty ()) {
10+ // ---------------------------------------------------------------------------
11+ ParticleSystemEvaluation::ParticleSystemEvaluation (const std::vector<std::string>& paths) {
12+ if (paths.empty ()) {
1213 throw std::runtime_error (" No filenames passed to readParticleSystemEvaluation" );
1314 }
1415
15- this -> paths = _paths ;
16- const int N = paths .size ();
16+ paths_ = paths ;
17+ const int N = paths_ .size ();
1718 const int VDimension = 3 ;
1819 assert (N > 0 );
1920
@@ -23,41 +24,44 @@ ParticleSystemEvaluation::ParticleSystemEvaluation(const std::vector<std::string
2324 // huge problem for now because the particle files are quite small)
2425
2526 // Read the first file to find dimensions
26- auto points0 = particles::read_particles_as_vector (paths [0 ]);
27+ auto points0 = particles::read_particles_as_vector (paths_ [0 ]);
2728 const int D = points0.size () * VDimension;
2829
29- P .resize (D, N);
30- P .col (0 ) = Eigen::Map<const Eigen::VectorXd>((double *)points0.data (), D);
30+ matrix_ .resize (D, N);
31+ matrix_ .col (0 ) = Eigen::Map<const Eigen::VectorXd>((double *)points0.data (), D);
3132
3233 for (int i = 1 ; i < N; i++) {
33- auto points = particles::read_particles_as_vector (paths [i]);
34+ auto points = particles::read_particles_as_vector (paths_ [i]);
3435 int count = points.size () * VDimension;
3536 if (count != D) {
3637 throw std::runtime_error (" ParticleSystemEvaluation files must have the same number of particles" );
3738 }
38- P .col (i) = Eigen::Map<const Eigen::VectorXd>((double *)points.data (), D);
39+ matrix_ .col (i) = Eigen::Map<const Eigen::VectorXd>((double *)points.data (), D);
3940 }
4041}
4142
42- ParticleSystemEvaluation::ParticleSystemEvaluation (const Eigen::MatrixXd& matrix) { this ->P = matrix; }
43+ // ---------------------------------------------------------------------------
44+ ParticleSystemEvaluation::ParticleSystemEvaluation (const Eigen::MatrixXd& matrix) { matrix_ = matrix; }
4345
46+ // ---------------------------------------------------------------------------
4447bool ParticleSystemEvaluation::ExactCompare (const ParticleSystemEvaluation& other) const {
45- if (P .rows () != other.P .rows () || P .cols () != other.P .cols ()) {
48+ if (matrix_ .rows () != other.matrix_ .rows () || matrix_ .cols () != other.matrix_ .cols ()) {
4649 std::cerr << " Rows/Columns mismatch\n " ;
4750 return false ;
4851 }
4952 bool same = true ;
50- for (int r = 0 ; r < P .rows (); r++) {
51- for (int c = 0 ; c < P .cols (); c++) {
52- if (!epsEqual (P (r, c), other.P (r, c), 0.001 )) {
53- std::cerr << " (" << r << " ," << c << " ): " << P (r, c) << " vs " << other.P (r, c) << " \n " ;
53+ for (int r = 0 ; r < matrix_ .rows (); r++) {
54+ for (int c = 0 ; c < matrix_ .cols (); c++) {
55+ if (!epsEqual (matrix_ (r, c), other.matrix_ (r, c), 0.001 )) {
56+ std::cerr << " (" << r << " ," << c << " ): " << matrix_ (r, c) << " vs " << other.matrix_ (r, c) << " \n " ;
5457 same = false ;
5558 }
5659 }
5760 }
5861 return same;
5962}
6063
64+ // ---------------------------------------------------------------------------
6165bool ParticleSystemEvaluation::EvaluationCompare (const ParticleSystemEvaluation& other) const {
6266 auto compactness1 = ShapeEvaluation::ComputeFullCompactness (*this );
6367 auto compactness2 = ShapeEvaluation::ComputeFullCompactness (other);
@@ -113,9 +117,12 @@ bool ParticleSystemEvaluation::EvaluationCompare(const ParticleSystemEvaluation&
113117 return good;
114118}
115119
120+ // ---------------------------------------------------------------------------
116121bool ParticleSystemEvaluation::ReadParticleFile (std::string filename, Eigen::VectorXd& points) {
117122 points = particles::read_particles (filename);
118123 return true ;
119124}
120125
126+ // ---------------------------------------------------------------------------
127+
121128} // namespace shapeworks
0 commit comments