@@ -60,7 +60,7 @@ void ScanPath::load_segment_scan_path(std::string scan_path_file)
6060 {
6161 // Check to make sure the segment isn't the first, if it is, throw an
6262 // exception (the first segment must be a point in the spec).
63- ASSERT_THROW (_segment_list. size () > 0 ,
63+ ASSERT_THROW (_segment_list_length > 0 ,
6464 " Error: Scan paths must begin with a 'point' segment." );
6565 }
6666 else if (split_line[0 ] == " 1" )
@@ -85,10 +85,10 @@ void ScanPath::load_segment_scan_path(std::string scan_path_file)
8585 // Set the velocity and end time
8686 if (segment_type == ScanPathSegmentType::point)
8787 {
88- if (_segment_list. size () > 0 )
88+ if (_segment_list_length > 0 )
8989 {
90- segment.end_time =
91- _segment_list. back (). end_time + std::stod (split_line[5 ]);
90+ segment.end_time = _segment_list[_segment_list_length - 1 ]. end_time +
91+ std::stod (split_line[5 ]);
9292 }
9393 else
9494 {
@@ -98,12 +98,14 @@ void ScanPath::load_segment_scan_path(std::string scan_path_file)
9898 else
9999 {
100100 double velocity = std::stod (split_line[5 ]);
101- double line_length =
102- segment. end_point . distance ( _segment_list. back () .end_point );
103- segment.end_time =
104- _segment_list. back (). end_time + std::abs (line_length / velocity);
101+ double line_length = segment. end_point . distance (
102+ _segment_list[_segment_list_length - 1 ] .end_point );
103+ segment.end_time = _segment_list[_segment_list_length - 1 ]. end_time +
104+ std::abs (line_length / velocity);
105105 }
106- _segment_list.push_back (segment);
106+ if (_segment_list_length == MAX_NUMBER_OF_SEGMENTS)
107+ Kokkos::abort (" too many segmnets" );
108+ _segment_list[_segment_list_length++] = segment;
107109 data_index++;
108110 }
109111 file.close ();
@@ -138,7 +140,9 @@ void ScanPath::load_event_series_scan_path(std::string scan_path_file)
138140 segment.power_modifier = last_power;
139141 last_power = std::stod (split_line[4 ]);
140142
141- _segment_list.push_back (segment);
143+ if (_segment_list_length == MAX_NUMBER_OF_SEGMENTS)
144+ Kokkos::abort (" too many segmnets" );
145+ _segment_list[_segment_list_length++] = segment;
142146 }
143147}
144148
@@ -169,7 +173,7 @@ dealii::Point<3> ScanPath::value(double const &time) const
169173{
170174 // If the current time is after the scan path data is over, return a point
171175 // that is (presumably) out of the domain.
172- if (time > _segment_list. back () .end_time )
176+ if (time > _segment_list[_segment_list_length - 1 ] .end_time )
173177 {
174178 dealii::Point<3 > out_of_domain_point (std::numeric_limits<double >::lowest (),
175179 std::numeric_limits<double >::lowest (),
@@ -196,7 +200,7 @@ double ScanPath::get_power_modifier(double const &time) const
196200{
197201 // If the current time is after the scan path data is over, set the power to
198202 // zero.
199- if (time > _segment_list. back () .end_time )
203+ if (time > _segment_list[_segment_list_length - 1 ] .end_time )
200204 return 0.0 ;
201205
202206 // Get to the correct segment
@@ -209,7 +213,7 @@ double ScanPath::get_power_modifier(double const &time) const
209213
210214std::vector<ScanPathSegment> ScanPath::get_segment_list () const
211215{
212- return _segment_list;
216+ return {& _segment_list[ 0 ], &_segment_list[ 0 ] + _segment_list_length} ;
213217}
214218
215219} // namespace adamantine
0 commit comments