@@ -76,21 +76,23 @@ void JumpDistanceSegmentation::perform_segmentation(
76
76
segments.push_back (current_segment);
77
77
78
78
// Check if last and first segments belongs to the same segment
79
- slg::Segment2D first_segment = segments.front ();
80
- slg::Segment2D last_segment = segments.back ();
81
- // Check if the point belong to the same segment or we have to discard it.
82
- // Remember that the points are radially sorted.
83
- if (!is_jump_between (last_segment, first_segment)) {
84
- last_segment.merge (first_segment);
85
- // Insert the last segment as the first one
86
- segments[0 ] = last_segment;
87
- // And remove the last one
88
- segments.pop_back ();
89
- } else {
90
- // Fix the prior segment of the first segment
91
- segments.front ().set_prior_segment (last_segment.last_point ());
92
- // Fix the next segment of the last segment
93
- segments.back ().set_next_segment (first_segment.first_point ());
79
+ if (segments.size () > 1 ) {
80
+ slg::Segment2D first_segment = segments.front ();
81
+ slg::Segment2D last_segment = segments.back ();
82
+ // Check if the point belong to the same segment or we have to discard it.
83
+ // Remember that the points are radially sorted.
84
+ if (!is_jump_between (last_segment, first_segment)) {
85
+ last_segment.merge (first_segment);
86
+ // Insert the last segment as the first one
87
+ segments[0 ] = last_segment;
88
+ // And remove the last one
89
+ segments.pop_back ();
90
+ } else {
91
+ // Fix the prior segment of the first segment
92
+ segments.front ().set_prior_segment (last_segment.last_point ());
93
+ // Fix the next segment of the last segment
94
+ segments.back ().set_next_segment (first_segment.first_point ());
95
+ }
94
96
}
95
97
}
96
98
0 commit comments