]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ConstructionAPI/ConstructionAPI_Plane.cpp
Salome HOME
updated copyright message
[modules/shaper.git] / src / ConstructionAPI / ConstructionAPI_Plane.cpp
index b7de5703c0b882fc8e56067c416ce264c13914ab..ca820343304d953780a6e590abae3ae7ba886566 100644 (file)
@@ -1,8 +1,21 @@
-// Name   : ConstructionAPI_Plane.cpp
-// Purpose: 
+// Copyright (C) 2014-2023  CEA, EDF
+//
+// 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
 //
-// History:
-// 27/05/16 - Sergey POKHODENKO - Creation of the file
 
 #include "ConstructionAPI_Plane.h"
 
@@ -20,11 +33,12 @@ ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feat
 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                              const ModelHighAPI_Selection& theFace,
                                              const ModelHighAPI_Double& theDistance,
-                                             const bool theIsReverse)
+                                             const bool theIsReverse,
+                                             const ModelHighAPI_Integer& theNbCopy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
-    setByFaceAndDistance(theFace, theDistance, theIsReverse);
+    setByFaceAndDistance(theFace, theDistance, theIsReverse, theNbCopy);
   }
 }
 
@@ -86,11 +100,12 @@ ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feat
 ConstructionAPI_Plane::ConstructionAPI_Plane(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                                              const ModelHighAPI_Selection& thePlane,
                                              const ModelHighAPI_Selection& theAxis,
-                                             const ModelHighAPI_Double& theAngle)
+                                             const ModelHighAPI_Double& theAngle,
+                                             const ModelHighAPI_Integer& theNbCopy)
 : ModelHighAPI_Interface(theFeature)
 {
   if(initialize()) {
-    setByRotation(thePlane, theAxis, theAngle);
+    setByRotation(thePlane, theAxis, theAngle, theNbCopy);
   }
 }
 
@@ -102,13 +117,16 @@ ConstructionAPI_Plane::~ConstructionAPI_Plane()
 //==================================================================================================
 void ConstructionAPI_Plane::setByFaceAndDistance(const ModelHighAPI_Selection& theFace,
                                                  const ModelHighAPI_Double& theDistance,
-                                                 const bool theIsReverse)
+                                                 const bool theIsReverse,
+                                                 const ModelHighAPI_Integer& theNbCopy)
 {
   fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
   fillAttribute(theFace, myplane);
-  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER(), mycreationMethodByOtherPlane);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER(),
+                mycreationMethodByOtherPlane);
   fillAttribute(theDistance, mydistance);
   fillAttribute(theIsReverse, myreverse);
+  fillAttribute(theNbCopy, mynbcopy);
 
   execute();
 }
@@ -158,7 +176,8 @@ void ConstructionAPI_Plane::setByLineAndPoint(const ModelHighAPI_Selection& theL
 void ConstructionAPI_Plane::setByTwoParallelPlanes(const ModelHighAPI_Selection& thePlane1,
                                                    const ModelHighAPI_Selection& thePlane2)
 {
-  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES(), mycreationMethod);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES(),
+                mycreationMethod);
   fillAttribute(thePlane1, myplane1);
   fillAttribute(thePlane2, myplane2);
 
@@ -171,7 +190,8 @@ void ConstructionAPI_Plane::setByCoincidentToPoint(const ModelHighAPI_Selection&
 {
   fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
   fillAttribute(thePlane, myplane);
-  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT(), mycreationMethodByOtherPlane);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT(),
+                mycreationMethodByOtherPlane);
   fillAttribute(thePoint, mycoincidentPoint);
 
   execute();
@@ -180,13 +200,16 @@ void ConstructionAPI_Plane::setByCoincidentToPoint(const ModelHighAPI_Selection&
 //==================================================================================================
 void ConstructionAPI_Plane::setByRotation(const ModelHighAPI_Selection& thePlane,
                                           const ModelHighAPI_Selection& theAxis,
-                                          const ModelHighAPI_Double& theAngle)
+                                          const ModelHighAPI_Double& theAngle,
+                                          const ModelHighAPI_Integer& theNbCopy)
 {
   fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE(), mycreationMethod);
   fillAttribute(thePlane, myplane);
-  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_ROTATION(), mycreationMethodByOtherPlane);
+  fillAttribute(ConstructionPlugin_Plane::CREATION_METHOD_BY_ROTATION(),
+                mycreationMethodByOtherPlane);
   fillAttribute(theAxis, myaxis);
   fillAttribute(theAngle, myangle);
+  fillAttribute(theNbCopy, mynbcopy);
 
   execute();
 }
@@ -199,7 +222,8 @@ void ConstructionAPI_Plane::dump(ModelHighAPI_Dumper& theDumper) const
 
   theDumper << aBase << " = model.addPlane(" << aDocName;
 
-  std::string aCreationMethod = aBase->string(ConstructionPlugin_Plane::CREATION_METHOD())->value();
+  std::string aCreationMethod =
+    aBase->string(ConstructionPlugin_Plane::CREATION_METHOD())->value();
 
   if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_GENERAL_EQUATION()) {
     AttributeDoublePtr anAttrA = aBase->real(ConstructionPlugin_Plane::A());
@@ -217,7 +241,8 @@ void ConstructionAPI_Plane::dump(ModelHighAPI_Dumper& theDumper) const
   } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_LINE_AND_POINT()) {
     AttributeSelectionPtr anAttrLine = aBase->selection(ConstructionPlugin_Plane::LINE());
     AttributeSelectionPtr anAttrPoint = aBase->selection(ConstructionPlugin_Plane::POINT());
-    AttributeBooleanPtr anAttrPerpendicular = aBase->boolean(ConstructionPlugin_Plane::PERPENDICULAR());
+    AttributeBooleanPtr anAttrPerpendicular =
+      aBase->boolean(ConstructionPlugin_Plane::PERPENDICULAR());
 
     theDumper << ", " << anAttrLine << ", " << anAttrPoint << ", " << anAttrPerpendicular;
   } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE()) {
@@ -225,22 +250,32 @@ void ConstructionAPI_Plane::dump(ModelHighAPI_Dumper& theDumper) const
 
     std::string aCreationMethodOption =
         aBase->string(ConstructionPlugin_Plane::CREATION_METHOD_BY_OTHER_PLANE_OPTION())->value();
-    if(aCreationMethodOption == ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER()) {
+    if(aCreationMethodOption ==
+       ConstructionPlugin_Plane::CREATION_METHOD_BY_DISTANCE_FROM_OTHER()) {
       AttributeDoublePtr anAttrDistance = aBase->real(ConstructionPlugin_Plane::DISTANCE());
       AttributeBooleanPtr anAttrReverse = aBase->boolean(ConstructionPlugin_Plane::REVERSE());
+      AttributeIntegerPtr anAttrNbCopy = aBase->integer(ConstructionPlugin_Plane::NB_COPIES());
 
       theDumper << ", " << anAttrPlane << ", " << anAttrDistance << ", " << anAttrReverse;
-    } else if(aCreationMethodOption == ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT()) {
-      AttributeSelectionPtr anAttrPoint = aBase->selection(ConstructionPlugin_Plane::COINCIDENT_POINT());
+      if(anAttrNbCopy.get() && anAttrNbCopy->value() > 1)
+        theDumper << ", " << anAttrNbCopy;
+    } else if(aCreationMethodOption ==
+              ConstructionPlugin_Plane::CREATION_METHOD_BY_COINCIDENT_TO_POINT()) {
+      AttributeSelectionPtr anAttrPoint =
+        aBase->selection(ConstructionPlugin_Plane::COINCIDENT_POINT());
 
       theDumper << ", " << anAttrPlane << ", " << anAttrPoint;
     } else if(aCreationMethodOption == ConstructionPlugin_Plane::CREATION_METHOD_BY_ROTATION()) {
       AttributeSelectionPtr anAttrAxis = aBase->selection(ConstructionPlugin_Plane::AXIS());
       AttributeDoublePtr anAttrAngle = aBase->real(ConstructionPlugin_Plane::ANGLE());
+      AttributeIntegerPtr anAttrNbCopy = aBase->integer(ConstructionPlugin_Plane::NB_COPIES());
 
       theDumper << ", " << anAttrPlane << ", " << anAttrAxis << ", " << anAttrAngle;
+      if (anAttrNbCopy.get() && anAttrNbCopy->value() > 1)
+         theDumper << ", " << anAttrNbCopy;
     }
-  } else if(aCreationMethod == ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES()) {
+  } else if(aCreationMethod ==
+            ConstructionPlugin_Plane::CREATION_METHOD_BY_TWO_PARALLEL_PLANES()) {
     AttributeSelectionPtr anAttrPlane1 = aBase->selection(ConstructionPlugin_Plane::PLANE1());
     AttributeSelectionPtr anAttrPlane2 = aBase->selection(ConstructionPlugin_Plane::PLANE2());
 
@@ -254,11 +289,13 @@ void ConstructionAPI_Plane::dump(ModelHighAPI_Dumper& theDumper) const
 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const ModelHighAPI_Selection& theFace,
                   const ModelHighAPI_Double& theDistance,
-                  const bool theIsReverse)
+                  const bool theIsReverse,
+                  const ModelHighAPI_Integer& theNbCopies)
 {
   // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
-  return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance, theIsReverse));
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, theFace, theDistance,
+                                            theIsReverse, theNbCopies));
 }
 
 //==================================================================================================
@@ -309,9 +346,10 @@ PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
 PlanePtr addPlane(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const ModelHighAPI_Selection& thePlane,
                   const ModelHighAPI_Selection& theAxis,
-                  const ModelHighAPI_Double& theAngle)
+                  const ModelHighAPI_Double& theAngle,
+                  const ModelHighAPI_Integer& theNbCopies)
 {
   // TODO(spo): check that thePart is not empty
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Plane::ID());
-  return PlanePtr(new ConstructionAPI_Plane(aFeature, thePlane, theAxis, theAngle));
+  return PlanePtr(new ConstructionAPI_Plane(aFeature, thePlane, theAxis, theAngle, theNbCopies));
 }