| 167 | m_lineSegmentIndexes->resize(psl->count()); |
| 168 | |
| 169 | foreach (const auto &segment, *psl) { |
| 170 | PointSegment *ps = segment; |
| 171 | bool isMetric = ps->isMetric(); |
| 172 | ps->convertToMetric(); |
| 173 | |
| 174 | end = ps->point(); |
| 175 | endAxes = ps->axes(); |
| 176 | |
| 177 | // start is null for the first iteration. |
| 178 | if (start != NULL) { |
| 179 | // Expand arc for graphics. |
| 180 | if (ps->isArc()) { |
| 181 | QList<QVector3D> points = |
| 182 | GcodePreprocessorUtils::generatePointsAlongArcBDring( |
| 183 | ps->plane(), *start, *end, |
| 184 | *ps->center(), ps->isClockwise(), ps->getRadius(), |
| 185 | minArcLength, arcPrecision, arcDegreeMode, ps->getArcTurns()); |
| 186 | |
| 187 | // Create line segments from points. |
| 188 | int segments = points.length(); |
| 189 | if (segments > 0) { |
| 190 | double rotation = (Util::nAssign(startAxes->x()) - Util::nAssign(endAxes->x())); |
| 191 | double segmentRotation = rotation / segments; |
| 192 | |
| 193 | QVector3D startPoint = *start; |
| 194 | foreach (QVector3D nextPoint, points) { |
| 195 | if (nextPoint == startPoint) continue; |
| 196 | if (!Util::nIsNaN(m_axesRotationVectors[RotationAxisA])) |
| 197 | endRotation.rotate(segmentRotation, m_axesRotationVectors[RotationAxisA]); |
| 198 | |
| 199 | ls = new LineSegment(startRotation * startPoint, |
| 200 | endRotation * nextPoint, lineIndex); |
| 201 | ls->setIsArc(ps->isArc()); |
| 202 | ls->setIsClockwise(ps->isClockwise()); |
| 203 | ls->setPlane(ps->plane()); |
| 204 | ls->setIsFastTraverse(ps->isFastTraverse()); |
| 205 | ls->setIsZMovement(ps->isZMovement()); |
| 206 | ls->setIsMetric(isMetric); |
| 207 | ls->setIsAbsolute(ps->isAbsolute()); |
| 208 | ls->setSpeed(ps->getSpeed()); |
| 209 | ls->setSpindleSpeed(ps->getSpindleSpeed()); |
| 210 | ls->setDwell(ps->getDwell()); |
| 211 | ls->setModelStart(startPoint); |
| 212 | ls->setModelEnd(nextPoint); |
| 213 | ls->setAxesStart(*startAxes); |
| 214 | ls->setAxesEnd(*endAxes); |
| 215 | ls->setIndex(index++); |
| 216 | |
| 217 | this->updateViewBounds(ls->getEnd()); |
| 218 | this->updateModelBounds(nextPoint); |
| 219 | |
| 220 | m_lineSegments->append(ls); |
| 221 | (*m_lineSegmentIndexes)[ps->getLineNumber()].append(m_lineSegments->count() - 1); |
| 222 | |
| 223 | startPoint = nextPoint; |
| 224 | startRotation = endRotation; |
| 225 | } |
| 226 | lineIndex++; |
no test coverage detected