Salome HOME
Issue #17924: filter F5 on geometry for faces
[modules/shaper.git] / src / GeomAPI / GeomAPI_Cone.cpp
index e18d4d333e6cb87f05f8ed034a083e00ec945e41..a08a07535e93dc1f9d1cd73961c1ef227e0b03e9 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018-20xx  CEA/DEN, EDF R&D
+// Copyright (C) 2018-2019  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/ or
-// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
 #include <GeomAPI_Cone.h>
@@ -61,11 +60,19 @@ GeomAPI_Cone::GeomAPI_Cone(const std::shared_ptr<GeomAPI_Pnt>& theLocation,
                            const double theSemiAngle,
                            const double theRadius1,
                            const double theRadius2)
-  : GeomAPI_Interface(
-      newCone(theLocation->impl<gp_Pnt>(), theAxis->impl<gp_Dir>(), theSemiAngle, theRadius1)),
-    myRadius1(theRadius1),
+  : myRadius1(theRadius1),
     myRadius2(theRadius2)
 {
+  gp_Pnt aLoc = theLocation->impl<gp_Pnt>();
+  gp_Dir aDir = theAxis->impl<gp_Dir>();
+  if (theRadius1 > theRadius2) {
+    aLoc.ChangeCoord() += aDir.XYZ() * (theRadius1 - theRadius2) / Tan(theSemiAngle);
+    aDir.Reverse();
+    myRadius1 = theRadius2;
+    myRadius2 = theRadius1;
+  }
+
+  setImpl(newCone(aLoc, aDir, theSemiAngle, myRadius1));
 }
 
 //=================================================================================================