]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add a new mode for the box (the following)
authorClarisse Genrault <cgenrault@is231796.intra.cea.fr>
Wed, 15 Apr 2020 16:26:09 +0000 (18:26 +0200)
committerClarisse Genrault <cgenrault@is231796.intra.cea.fr>
Wed, 15 Apr 2020 16:26:09 +0000 (18:26 +0200)
src/PrimitivesAPI/PrimitivesAPI_Box.cpp
src/PrimitivesAPI/PrimitivesAPI_Box.h
src/PrimitivesPlugin/doc/images/Box_ptAndDims.png [new file with mode: 0644]
src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png [new file with mode: 0644]

index c65330b3113fba6d08a17e56ff5231081d0698c8..0a69550bb19457d2e45043e7f311f17aa0b39bcc 100644 (file)
@@ -51,9 +51,31 @@ PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& th
 }
 
 //==================================================================================================
-PrimitivesAPI_Box::~PrimitivesAPI_Box()
+PrimitivesAPI_Box::PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                                     const ModelHighAPI_Double& theOx,
+                                     const ModelHighAPI_Double& theOy,
+                                     const ModelHighAPI_Double& theOz,
+                                     const ModelHighAPI_Double& theHalfX,
+                                     const ModelHighAPI_Double& theHalfY,
+                                     const ModelHighAPI_Double& theHalfZ)
+: ModelHighAPI_Interface(theFeature)
 {
+  if (initialize())
+  {
+    fillAttribute(PrimitivesPlugin_Box::CREATION_METHOD_BY_ONE_POINT_AND_DIMS(), creationMethod());
+    fillAttribute(theOx, ox());
+    fillAttribute(theOy, oy());
+    fillAttribute(theOz, oz());
+    fillAttribute(theHalfX, halfdx());
+    fillAttribute(theHalfY, halfdy());
+    fillAttribute(theHalfZ, halfdz());
+    execute();
+  }
+}
 
+//==================================================================================================
+PrimitivesAPI_Box::~PrimitivesAPI_Box()
+{
 }
 
 //==================================================================================================
@@ -80,6 +102,30 @@ void PrimitivesAPI_Box::setPoints(const ModelHighAPI_Selection& theFirstPoint,
   execute();
 }
 
+//==================================================================================================
+void PrimitivesAPI_Box::setOrigin(const ModelHighAPI_Double& theOx,
+                                  const ModelHighAPI_Double& theOy,
+                                  const ModelHighAPI_Double& theOz)
+{
+  fillAttribute(theOx, ox());
+  fillAttribute(theOy, oy());
+  fillAttribute(theOz, oz());
+
+  execute();
+}
+
+//==================================================================================================
+void PrimitivesAPI_Box::setHalfLengths(const ModelHighAPI_Double& theHalfLengthX,
+                                       const ModelHighAPI_Double& theHalfLengthY,
+                                       const ModelHighAPI_Double& theHalfLengthZ)
+{
+  fillAttribute(theHalfLengthX, halfdx());
+  fillAttribute(theHalfLengthY, halfdy());
+  fillAttribute(theHalfLengthZ, halfdz());
+
+  execute();
+}
+
 //==================================================================================================
 void PrimitivesAPI_Box::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -101,6 +147,16 @@ void PrimitivesAPI_Box::dump(ModelHighAPI_Dumper& theDumper) const
     AttributeSelectionPtr anAttrSecondPnt =
       aBase->selection(PrimitivesPlugin_Box::POINT_SECOND_ID());
     theDumper << ", " << anAttrFirstPnt << ", " << anAttrSecondPnt;
+  } else if (aCreationMethod == PrimitivesPlugin_Box::CREATION_METHOD_BY_ONE_POINT_AND_DIMS()) {
+    AttributeDoublePtr anAttrOx = aBase->real(PrimitivesPlugin_Box::OX_ID());
+    AttributeDoublePtr anAttrOy = aBase->real(PrimitivesPlugin_Box::OY_ID());
+    AttributeDoublePtr anAttrOz = aBase->real(PrimitivesPlugin_Box::OZ_ID());
+    AttributeDoublePtr anAttrHalfLengthX = aBase->real(PrimitivesPlugin_Box::HALF_DX_ID());
+    AttributeDoublePtr anAttrHalfLengthY = aBase->real(PrimitivesPlugin_Box::HALF_DY_ID());
+    AttributeDoublePtr anAttrHalfLengthZ = aBase->real(PrimitivesPlugin_Box::HALF_DZ_ID());
+    theDumper << ", " << anAttrOx << ", " << anAttrOy << ", " << anAttrOz;
+    theDumper << ", " << anAttrHalfLengthX << ", " << anAttrHalfLengthY;
+    theDumper << ", " << anAttrHalfLengthZ;
   }
 
   theDumper << ")" << std::endl;
@@ -123,4 +179,18 @@ BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
   return BoxPtr(new PrimitivesAPI_Box(aFeature, theFirstPoint, theSecondPoint));
+}
+
+//==================================================================================================
+BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
+              const ModelHighAPI_Double& theOx,
+              const ModelHighAPI_Double& theOy,
+              const ModelHighAPI_Double& theOz,
+              const ModelHighAPI_Double& theHalfLengthX,
+              const ModelHighAPI_Double& theHalfLengthY,
+              const ModelHighAPI_Double& theHalfLengthZ)
+{
+  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Box::ID());
+  return BoxPtr(new PrimitivesAPI_Box(aFeature, theOx, theOy, theOz, theHalfLengthX,
+                                      theHalfLengthY, theHalfLengthZ));
 }
\ No newline at end of file
index c590a205289490d395964ff866f378f890a57e41..969d746325bcdbbdbf5cc8d4a3fd7c1366c12588 100644 (file)
@@ -51,13 +51,21 @@ public:
   PRIMITIVESAPI_EXPORT
   explicit PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
                              const ModelHighAPI_Selection& theFirstPoint,
-                             const ModelHighAPI_Selection& theSecondPoint);
+                             const ModelHighAPI_Selection& theSecondPoint);/// Constructor with values.
+  PRIMITIVESAPI_EXPORT
+  explicit PrimitivesAPI_Box(const std::shared_ptr<ModelAPI_Feature>& theFeature,
+                             const ModelHighAPI_Double& theOx,
+                             const ModelHighAPI_Double& theOy,
+                             const ModelHighAPI_Double& theOz,
+                             const ModelHighAPI_Double& theHalfX,
+                             const ModelHighAPI_Double& theHalfY,
+                             const ModelHighAPI_Double& theHalfZ);
 
   /// Destructor.
   PRIMITIVESAPI_EXPORT
   virtual ~PrimitivesAPI_Box();
 
-  INTERFACE_6(PrimitivesPlugin_Box::ID(),
+  INTERFACE_12(PrimitivesPlugin_Box::ID(),
              creationMethod, PrimitivesPlugin_Box::CREATION_METHOD(),
              ModelAPI_AttributeString, /** Creation method */,
              dx, PrimitivesPlugin_Box::DX_ID(),
@@ -69,7 +77,19 @@ public:
              firstPoint, PrimitivesPlugin_Box::POINT_FIRST_ID(),
              ModelAPI_AttributeSelection, /** First point */,
              secondPoint, PrimitivesPlugin_Box::POINT_SECOND_ID(),
-             ModelAPI_AttributeSelection, /** Second point */)
+             ModelAPI_AttributeSelection, /** Second point */,
+             ox, PrimitivesPlugin_Box::OX_ID(),
+             ModelAPI_AttributeDouble, /** X coordinate for origin*/,
+             oy, PrimitivesPlugin_Box::OY_ID(),
+             ModelAPI_AttributeDouble, /** Y coordinate for origin*/,
+             oz, PrimitivesPlugin_Box::OZ_ID(),
+             ModelAPI_AttributeDouble, /** Z coordinate for origin*/,
+             halfdx, PrimitivesPlugin_Box::HALF_DX_ID(),
+             ModelAPI_AttributeDouble, /** Half length in X*/,
+             halfdy, PrimitivesPlugin_Box::HALF_DY_ID(),
+             ModelAPI_AttributeDouble, /** Half length in Y*/,
+             halfdz, PrimitivesPlugin_Box::HALF_DZ_ID(),
+             ModelAPI_AttributeDouble, /** Half length in Z*/)
 
   /// Set dimensions
   PRIMITIVESAPI_EXPORT
@@ -82,6 +102,18 @@ public:
   void setPoints(const ModelHighAPI_Selection& theFirstPoint,
                  const ModelHighAPI_Selection& theSecondPoint);
 
+  /// Set origin point
+  PRIMITIVESAPI_EXPORT
+  void setOrigin(const ModelHighAPI_Double& theOx,
+                 const ModelHighAPI_Double& theOy,
+                 const ModelHighAPI_Double& theOz);
+
+  /// Set half lengths
+  PRIMITIVESAPI_EXPORT
+  void setHalfLengths(const ModelHighAPI_Double& theHalfLengthX,
+                      const ModelHighAPI_Double& theHalfLengthY,
+                      const ModelHighAPI_Double& theHalfLengthZ);
+
   /// Dump wrapped feature
   PRIMITIVESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -105,4 +137,15 @@ BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
               const ModelHighAPI_Selection& theFirstPoint,
               const ModelHighAPI_Selection& theSecondPoint);
 
+/// \ingroup CPPHighAPI
+/// \brief Create primitive Box feature.
+PRIMITIVESAPI_EXPORT
+BoxPtr addBox(const std::shared_ptr<ModelAPI_Document>& thePart,
+              const ModelHighAPI_Double& theOx,
+              const ModelHighAPI_Double& theOy,
+              const ModelHighAPI_Double& theOz,
+              const ModelHighAPI_Double& theHalfLengthX,
+              const ModelHighAPI_Double& theHalfLengthY,
+              const ModelHighAPI_Double& theHalfLengthZ);
+
 #endif // PRIMITIVESAPI_BOX_H_
\ No newline at end of file
diff --git a/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png b/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png
new file mode 100644 (file)
index 0000000..3fedaf7
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/Box_ptAndDims.png differ
diff --git a/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png b/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png
new file mode 100644 (file)
index 0000000..db199ea
Binary files /dev/null and b/src/PrimitivesPlugin/doc/images/box_pt_dxyz_32x32.png differ