| 1095 | } |
| 1096 | |
| 1097 | void rebuildTwoIndexSegment( |
| 1098 | ClipperLib::Path::size_type start_index, |
| 1099 | ClipperLib::Path::size_type end_index, |
| 1100 | bool sequence_increasing, |
| 1101 | const ClipperLib::Path& polygon, |
| 1102 | const PolyMap& polymap, |
| 1103 | PathObject* object) |
| 1104 | { |
| 1105 | Q_UNUSED(sequence_increasing); // only used in Q_ASSERT. |
| 1106 | |
| 1107 | PathCoordInfo start_info = polymap.value(polygon.at(start_index)); |
| 1108 | PathCoordInfo end_info = polymap.value(polygon.at(end_index)); |
| 1109 | const PathObject* original = end_info.first->path; |
| 1110 | |
| 1111 | bool coords_increasing; |
| 1112 | bool is_curve; |
| 1113 | int coord_index; |
| 1114 | if (start_info.second->index == end_info.second->index) |
| 1115 | { |
| 1116 | coord_index = end_info.second->index; |
| 1117 | bool found = checkSegmentMatch(original, coord_index, polygon, start_index, end_index, coords_increasing, is_curve); |
| 1118 | if (!found) |
| 1119 | { |
| 1120 | object->getCoordinateRef(object->getCoordinateCount() - 1).setCurveStart(false); |
| 1121 | rebuildCoordinate(end_index, polygon, polymap, object); |
| 1122 | return; |
| 1123 | } |
| 1124 | Q_ASSERT(coords_increasing == sequence_increasing); |
| 1125 | } |
| 1126 | else |
| 1127 | { |
| 1128 | coord_index = end_info.second->index; |
| 1129 | bool found = checkSegmentMatch(original, coord_index, polygon, start_index, end_index, coords_increasing, is_curve); |
| 1130 | if (!found) |
| 1131 | { |
| 1132 | coord_index = start_info.second->index; |
| 1133 | found = checkSegmentMatch(original, coord_index, polygon, start_index, end_index, coords_increasing, is_curve); |
| 1134 | if (!found) |
| 1135 | { |
| 1136 | object->getCoordinateRef(object->getCoordinateCount() - 1).setCurveStart(false); |
| 1137 | rebuildCoordinate(end_index, polygon, polymap, object); |
| 1138 | return; |
| 1139 | } |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | if (!is_curve) |
| 1144 | object->getCoordinateRef(object->getCoordinateCount() - 1).setCurveStart(false); |
| 1145 | |
| 1146 | if (coords_increasing) |
| 1147 | { |
| 1148 | object->addCoordinate(resetCoordinate(original->getCoordinate(coord_index + 1))); |
| 1149 | if (is_curve) |
| 1150 | { |
| 1151 | object->addCoordinate(original->getCoordinate(coord_index + 2)); |
| 1152 | object->addCoordinate(resetCoordinate(original->getCoordinate(coord_index + 3))); |
| 1153 | } |
| 1154 | } |
no test coverage detected