Commit eca69e6a authored by Mathieu Giraud's avatar Mathieu Giraud

core/segment.cpp: codeFromBoxes(), show, when relevant, parts before first box and after last box

parent 8f4a3f8b
......@@ -195,17 +195,30 @@ string codeFromBoxes(vector <AlignBox*> boxes, string sequence)
string code = "";
int n = boxes.size();
bool first = !(boxes[0]->CoverFirstPos());
bool last = !(boxes[n-1]->CoverLastPos());
for (int i=0; i<n; i++) {
for (int i=0; i<=n; i++) {
if (i>0 && (i<n || last)) {
code += " " + string_of_int(boxes[i-1]->del_right) + "/";
}
if ((i>0 && i<n) || (i==0 && first) || (i==n && last)) {
// From box_left->end + 1 to box_right->start - 1, both positions included
int left = i>0 ? boxes[i-1]->end + 1 : 0;
int right = i<n ? boxes[i]->start - 1: sequence.length();
if (i>0) {
code += " " + string_of_int(boxes[i-1]->del_right) + "/"
// From box_left->end + 1 to box_right->start - 1, both positions included
+ sequence.substr(boxes[i-1]->end + 1, boxes[i]->start - boxes[i-1]->end - 1)
+ "/" + string_of_int(boxes[i]->del_left) + " " ;
code += sequence.substr(left, right-left+1);
}
code += boxes[i]->ref_label ;
if (i<n && (i>0 || first)) {
code += "/" + string_of_int(boxes[i]->del_left) + " " ;
}
if (i<n) {
code += boxes[i]->ref_label ;
}
}
return code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment