Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
fix potential exception in RPolyline::getLengthTo
- Loading branch information
Showing
with
4 additions
and
1 deletion.
-
+4
−1
src/core/math/RPolyline.cpp
|
@@ -947,13 +947,16 @@ double RPolyline::getLength() const { |
|
|
} |
|
|
|
|
|
double RPolyline::getLengthTo(const RVector& p) const { |
|
|
double ret = 0.0; |
|
|
double ret = -1.0; |
|
|
|
|
|
if (p.equalsFuzzy(getStartPoint())) { |
|
|
return ret; |
|
|
} |
|
|
|
|
|
int segIdx = getClosestSegment(p); |
|
|
if (segIdx<0) { |
|
|
return ret; |
|
|
} |
|
|
|
|
|
for (int i=0; i<segIdx; i++) { |
|
|
double l = getSegmentAt(i)->getLength(); |
|
|