Fix CCW ellipse arcs
This commit is contained in:
@@ -472,13 +472,21 @@ void ImpExpDxfWrite::exportEllipseArc(BRepAdaptor_Curve c)
|
||||
gp_Vec v1(m,s);
|
||||
gp_Vec v2(m,e);
|
||||
gp_Vec v3(0,0,1);
|
||||
double a = v3.DotCross(v1,v2);
|
||||
double a = v3.DotCross(v1,v2); // a = v3 dot (v1 cross v2)
|
||||
// relates to "handedness" of 3 vectors
|
||||
// a > 0 ==> v2 is CCW from v1 (righthanded)?
|
||||
// a < 0 ==> v2 is CW from v1 (lefthanded)?
|
||||
|
||||
double startAngle = fmod(f,2.0*M_PI);
|
||||
double startAngle = fmod(f,2.0*M_PI); //revolutions
|
||||
double endAngle = fmod(l,2.0*M_PI);
|
||||
bool dir = (a < 0) ? true: false;
|
||||
bool endIsCW = (a < 0) ? true: false; //if !endIsCW swap(start,end)
|
||||
//not sure if this is a hack or not. seems to make valid arcs.
|
||||
if (!endIsCW) {
|
||||
startAngle = -startAngle;
|
||||
endAngle = -endAngle;
|
||||
}
|
||||
|
||||
WriteEllipse(center, major, minor, rotation, startAngle, endAngle, dir, getLayerName().c_str() );
|
||||
WriteEllipse(center, major, minor, rotation, startAngle, endAngle, endIsCW, getLayerName().c_str());
|
||||
}
|
||||
|
||||
void ImpExpDxfWrite::exportBSpline(BRepAdaptor_Curve c)
|
||||
|
||||
Reference in New Issue
Block a user