Well, it is evident that scal1 and scal2 are used to decide whether to use the current edge E as is, or whether it has to be reversed. This decision is based on the orientation of all previous edges, and that is the part I don't understand.
Two points (PP1 and PP2) are selected on the curve of the current edge, and these points are then successively transformed by parameters derived from all previous edges:
for (rang=i;rang>ideb;rang--) {
Transform(WithRotation, PP1,
Pos->Value(rang), Axe->Value(rang),
Pos->Value(rang-1), Axe->Value(rang-1), PP1);
Transform(WithRotation, PP2,
Pos->Value(rang), Axe->Value(rang),
Pos->Value(rang-1), Axe->Value(rang-1), PP2);
}
And I have no idea what the reasoning behind this computation might be. But it is crucial to decide which road to take:
1. Use the signed values of scal1 and scal2, and adapt only scalmax:
Standard_Real scalmax=-Precision::Infinite();
2. Use only the absolute values of scal1 and scal2:
scal1 = Abs(N1.Dot(Ns));
scal2 = Abs(N2.Dot(Ns));
(no additional include necessary for this!)
When I have the time, I will try both ways, and see what happens.
And yes, Pete, I have various test cases, both for the access violation and the incorrect orientations, but these cases surfaced in our product environment, and it would take too much time for me to reformulate them in purely OCC terms.
Regards, Kris.