0026202: Wrong result of chamfer on cylindrical surface: wrong value of chord
[occt.git] / src / ChFiKPart / ChFiKPart_ComputeData_ChPlnCyl.cxx
index 2e409ef..700e2c8 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
 // by the Free Software Foundation, with special exception defined in the file
 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
 // distribution for complete text of the license and disclaimer of any warranty.
@@ -131,7 +131,9 @@ Standard_Boolean ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr,
     Rad = Cyl.Radius()- Dis1;
     if ( Abs(Rad) <= Precision::Confusion() ) pointu = Standard_True;
     if(Rad < 0 ) {
+#ifdef OCCT_DEBUG
       cout<<"the chamfer can't pass"<<endl;
+#endif
       return Standard_False;
     }
   }
@@ -351,15 +353,11 @@ Standard_Boolean ChFiKPart_MakeChamfer(TopOpeBRepDS_DataStructure& DStr,
   gp_Ax3 AxCyl = Cyl.Position();
   // OrCyl is the point on axis of cylinder in the plane normal to the
   // axis containing OrSpine
-  gp_Pnt Loc = AxCyl.Location();
-  gp_Vec LocSp(Loc, OrSpine);
-  gp_XYZ temp = AxCyl.Direction().XYZ();
-  temp = temp.Multiplied(LocSp.XYZ().Multiplied(temp) );
-  OrCyl.SetXYZ( (Loc.XYZ()).Added(temp) );
-//  gp_XYZ temp = AxCyl.Direction().XYZ();
-//  temp = temp.Multiplied( OrSpine.XYZ().Multiplied(temp) );
-//  OrCyl.SetXYZ( (AxCyl.Location().XYZ()).Added(temp) );
-
+  // Project <OrSpine> onto <AxCyl>
+  gp_XYZ AxLoc = AxCyl.Location().XYZ(); //aLine.Location().XYZ();
+  gp_XYZ AxDir = AxCyl.Direction().XYZ();
+  Standard_Real Parameter = (OrSpine.XYZ() - AxLoc) * AxDir;
+  OrCyl.SetXYZ( AxLoc + Parameter * AxDir );
  
   //construction of POnPln
   gp_Vec VecTranslPln,tmp;