Salome HOME
updated copyright message
[modules/shaper.git] / src / PrimitivesAPI / PrimitivesAPI_Cylinder.cpp
index 42c10aed1f8f4ea718893bccf57f4646b2321705..36666e63264665dcd043dc69cfb9f21418e6431c 100644 (file)
@@ -1,8 +1,21 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        PrimitivesAPI_Cylinder.h
-// Created:     12 Jan 2017
-// Author:      Clarisse Genrault (CEA)
+// Copyright (C) 2014-2023  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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 
 #include "PrimitivesAPI_Cylinder.h"
 
@@ -27,7 +40,8 @@ PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Fe
 {
   if (initialize()) {
     fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER(), creationMethod());
-    setObjects(theBasePoint, theAxis);
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
     setSizes(theRadius, theHeight);
   }
 }
@@ -43,20 +57,17 @@ PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Fe
 {
   if (initialize()) {
     fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION(), creationMethod());
-    setObjects(theBasePoint, theAxis);
+    fillAttribute(theBasePoint, basePoint());
+    fillAttribute(theAxis, axis());
+    fillAttribute(theAngle, angle());
     setSizes(theRadius, theHeight);
-    setAngle(theAngle);
   }
 }
 
 //==================================================================================================
-void PrimitivesAPI_Cylinder::setObjects(const ModelHighAPI_Selection& theBasePoint,
-                                        const ModelHighAPI_Selection& theAxis)
+PrimitivesAPI_Cylinder::~PrimitivesAPI_Cylinder()
 {
-  fillAttribute(theBasePoint, basePoint());
-  fillAttribute(theAxis, axis());
 
-  execute();
 }
 
 //==================================================================================================
@@ -65,15 +76,6 @@ void PrimitivesAPI_Cylinder::setSizes(const ModelHighAPI_Double& theRadius,
 {
   fillAttribute(theRadius, radius());
   fillAttribute(theHeight, height());
-
-  execute();
-}
-
-//==================================================================================================
-void PrimitivesAPI_Cylinder::setAngle(const ModelHighAPI_Double& theAngle)
-{
-  fillAttribute(theAngle, angle());
-
   execute();
 }
 
@@ -85,17 +87,18 @@ void PrimitivesAPI_Cylinder::dump(ModelHighAPI_Dumper& theDumper) const
 
   theDumper << aBase << " = model.addCylinder(" << aDocName;
 
-  std::string aCreationMethod = aBase->string(PrimitivesPlugin_Cylinder::CREATION_METHOD())->value();
-  
   AttributeSelectionPtr anAttrBasePoint =
     aBase->selection(PrimitivesPlugin_Cylinder::BASE_POINT_ID());
   AttributeSelectionPtr anAttrAxis = aBase->selection(PrimitivesPlugin_Cylinder::AXIS_ID());
+  theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
+
   AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Cylinder::RADIUS_ID());
   AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cylinder::HEIGHT_ID());
-  
-  theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
   theDumper << ", " << anAttrRadius << ", " << anAttrHeight;
-  
+
+  std::string aCreationMethod =
+    aBase->string(PrimitivesPlugin_Cylinder::CREATION_METHOD())->value();
+
   if (aCreationMethod == PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION()) {
     AttributeDoublePtr anAttrAngle = aBase->real(PrimitivesPlugin_Cylinder::ANGLE_ID());
     theDumper << ", " << anAttrAngle;
@@ -109,12 +112,11 @@ CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Selection& theBasePoint,
                         const ModelHighAPI_Selection& theAxis,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight,
-                        const ModelHighAPI_Double& theAngle)
+                        const ModelHighAPI_Double& theHeight)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
-                                                theRadius, theHeight, theAngle));
+                                                theRadius, theHeight));
 }
 
 //==================================================================================================
@@ -122,34 +124,35 @@ CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Selection& theBasePoint,
                         const ModelHighAPI_Selection& theAxis,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight)
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle)
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
-                                                theRadius, theHeight));
+                                                theRadius, theHeight, theAngle));
 }
 
 //==================================================================================================
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight,
-                        const ModelHighAPI_Double& theAngle)
+                        const ModelHighAPI_Double& theHeight)
 {
+  ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin");
+  ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ");
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
-  ModelHighAPI_Selection aBasePoint("VERT", "Origin");
-  ModelHighAPI_Selection anAxis("EDGE", "OZ");
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
-                                                theRadius, theHeight, theAngle));
+                                                theRadius, theHeight));
 }
 
 //==================================================================================================
 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
                         const ModelHighAPI_Double& theRadius,
-                        const ModelHighAPI_Double& theHeight)
+                        const ModelHighAPI_Double& theHeight,
+                        const ModelHighAPI_Double& theAngle)
 {
+  ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin");
+  ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ");
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
-  ModelHighAPI_Selection aBasePoint("VERT", "Origin");
-  ModelHighAPI_Selection anAxis("EDGE", "OZ");
   return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
-                                                theRadius, theHeight));
-}
\ No newline at end of file
+                                                theRadius, theHeight, theAngle));
+}