- if( IsOK1 && !IsOK2 ) {
- // using existed direction
- double tmp = PC.Distance(Pres1)/3.;
- if( height > tmp ) {
- height = tmp;
- PCbest = gp_Pnt( PC.X() + tmpDir.X()*height,
- PC.Y() + tmpDir.Y()*height,
- PC.Z() + tmpDir.Z()*height );
- }
- }
- else if( !IsOK1 && IsOK2 ) {
- // using opposite direction
- IsRev = true;
- double tmp = PC.Distance(Pres2)/3.;
- if( height > tmp ) height = tmp;
- PCbest = gp_Pnt( PC.X() + tmpDir.Reversed().X()*height,
- PC.Y() + tmpDir.Reversed().Y()*height,
- PC.Z() + tmpDir.Reversed().Z()*height );
- }
- else { // IsOK1 && IsOK2
- double tmp1 = PC.Distance(Pres1)/3.;
- double tmp2 = PC.Distance(Pres2)/3.;
- if(tmp1<tmp2) {
- // using existed direction
- if( height > tmp1 ) {
- height = tmp1;
- PCbest = gp_Pnt( PC.X() + tmpDir.X()*height,
- PC.Y() + tmpDir.Y()*height,
- PC.Z() + tmpDir.Z()*height );
- }
- }
- else {
- // using opposite direction
- IsRev = true;
- if( height > tmp2 ) height = tmp2;
- PCbest = gp_Pnt( PC.X() + tmpDir.Reversed().X()*height,
- PC.Y() + tmpDir.Reversed().Y()*height,
- PC.Z() + tmpDir.Reversed().Z()*height );
- }
- }