Salome HOME
Deleting the option of "Scale" feature from dimensions in X, in Y and in Z.
authorClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 27 Jan 2017 07:52:37 +0000 (08:52 +0100)
committerClarisse Genrault <clarisse.genrault@cea.fr>
Fri, 27 Jan 2017 07:52:37 +0000 (08:52 +0100)
13 files changed:
src/FeaturesAPI/FeaturesAPI_Scale.cpp
src/FeaturesAPI/FeaturesAPI_Scale.h
src/FeaturesAPI/Test/APIParam_Scale.py
src/FeaturesPlugin/FeaturesPlugin_Scale.cpp
src/FeaturesPlugin/FeaturesPlugin_Scale.h
src/FeaturesPlugin/scale_widget.xml
src/GeomAPI/GeomAPI_Trsf.cpp
src/GeomAPI/GeomAPI_Trsf.h
src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Scale.h
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp
src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h
src/GeomAlgoAPI/Test/TestAPI_Scale.py

index e80f3b4cfaf84fc1afd49207f8cdfbc9b27f5ec7..d402713bc1e5729f84132de2da9a2e11cbeb0e25 100644 (file)
@@ -30,22 +30,6 @@ FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& th
   }
 }
 
-//==================================================================================================
-FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                                     const std::list<ModelHighAPI_Selection>& theMainObjects,
-                                     const ModelHighAPI_Selection& theCenterPoint,
-                                     const ModelHighAPI_Double& theScaleFactorX,
-                                     const ModelHighAPI_Double& theScaleFactorY,
-                                     const ModelHighAPI_Double& theScaleFactorZ)
-: ModelHighAPI_Interface(theFeature)
-{
-  if (initialize()) {
-    fillAttribute(theMainObjects, mainObjects());
-    fillAttribute(theCenterPoint, centerPoint());
-    setDimensions(theScaleFactorX, theScaleFactorY, theScaleFactorZ);
-  }
-}
-
 //==================================================================================================
 FeaturesAPI_Scale::~FeaturesAPI_Scale()
 {
@@ -68,23 +52,10 @@ void FeaturesAPI_Scale::setCenterPoint(const ModelHighAPI_Selection& theCenterPo
 //==================================================================================================
 void FeaturesAPI_Scale::setScaleFactor(const ModelHighAPI_Double& theScaleFactor)
 {
-  fillAttribute(FeaturesPlugin_Scale::CREATION_METHOD_BY_FACTOR(), creationMethod());
   fillAttribute(theScaleFactor, scaleFactor());
   execute();
 }
 
-//==================================================================================================
-void FeaturesAPI_Scale::setDimensions(const ModelHighAPI_Double& theScaleFactorX,
-                                      const ModelHighAPI_Double& theScaleFactorY,
-                                      const ModelHighAPI_Double& theScaleFactorZ)
-{
-  fillAttribute(FeaturesPlugin_Scale::CREATION_METHOD_BY_DIMENSIONS(), creationMethod());
-  fillAttribute(theScaleFactorX, scaleFactorX());
-  fillAttribute(theScaleFactorY, scaleFactorY());
-  fillAttribute(theScaleFactorZ, scaleFactorZ());
-  execute();
-}
-
 //==================================================================================================
 void FeaturesAPI_Scale::dump(ModelHighAPI_Dumper& theDumper) const
 {
@@ -99,23 +70,9 @@ void FeaturesAPI_Scale::dump(ModelHighAPI_Dumper& theDumper) const
     aBase->selection(FeaturesPlugin_Scale::CENTER_POINT_ID());
   theDumper << " , " << anAttrPoint;
 
-  std::string aCreationMethod =
-    aBase->string(FeaturesPlugin_Scale::CREATION_METHOD())->value();
-
-  if (aCreationMethod == FeaturesPlugin_Scale::CREATION_METHOD_BY_FACTOR()) {
-    AttributeDoublePtr anAttrScaleFactor =
+  AttributeDoublePtr anAttrScaleFactor =
       aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_ID());
     theDumper << ", " << anAttrScaleFactor;
-  } else if (aCreationMethod == FeaturesPlugin_Scale::CREATION_METHOD_BY_DIMENSIONS()) {
-    AttributeDoublePtr anAttrScaleFactorX =
-      aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_X_ID());
-    AttributeDoublePtr anAttrScaleFactorY =
-      aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_Y_ID());
-    AttributeDoublePtr anAttrScaleFactorZ =
-      aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID());
-    theDumper << ", " << anAttrScaleFactorX << " , " << anAttrScaleFactorY;
-    theDumper << ", " << anAttrScaleFactorZ;
-  }
 
   theDumper << ")" << std::endl;
 }
@@ -128,17 +85,4 @@ ScalePtr addScale(const std::shared_ptr<ModelAPI_Document>& thePart,
 {
   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Scale::ID());
   return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, theScaleFactor));
-}
-
-//==================================================================================================
-ScalePtr addScale(const std::shared_ptr<ModelAPI_Document>& thePart,
-                  const std::list<ModelHighAPI_Selection>& theMainObjects,
-                  const ModelHighAPI_Selection& theCenterPoint,
-                  const ModelHighAPI_Double& theScaleFactorX,
-                  const ModelHighAPI_Double& theScaleFactorY,
-                  const ModelHighAPI_Double& theScaleFactorZ)
-{
-  std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Scale::ID());
-  return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint,
-                  theScaleFactorX, theScaleFactorY, theScaleFactorZ));
 }
\ No newline at end of file
index d53ff17771979f765042b716a35cb5bd095c2550..137763c62e642ee5972d9aebb82e51e17f399779 100644 (file)
@@ -35,34 +35,17 @@ public:
                              const ModelHighAPI_Selection& theCenterPoint,
                              const ModelHighAPI_Double& theScaleFactor);
 
-  /// Constructor with values.
-  FEATURESAPI_EXPORT
-  explicit FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& theFeature,
-                             const std::list<ModelHighAPI_Selection>& theMainObjects,
-                             const ModelHighAPI_Selection& theCenterPoint,
-                             const ModelHighAPI_Double& theScaleFactorX,
-                             const ModelHighAPI_Double& theScaleFactorY,
-                             const ModelHighAPI_Double& theScaleFactorZ);
-
   /// Destructor.
   FEATURESAPI_EXPORT
   virtual ~FeaturesAPI_Scale();
 
-  INTERFACE_7(FeaturesPlugin_Scale::ID(),
-              creationMethod, FeaturesPlugin_Scale::CREATION_METHOD(),
-              ModelAPI_AttributeString, /** Creation method */,
+  INTERFACE_3(FeaturesPlugin_Scale::ID(),
               mainObjects, FeaturesPlugin_Scale::OBJECTS_LIST_ID(),
               ModelAPI_AttributeSelectionList, /** Main objects */,
               centerPoint, FeaturesPlugin_Scale::CENTER_POINT_ID(),
               ModelAPI_AttributeSelection, /** Center point */,
               scaleFactor, FeaturesPlugin_Scale::SCALE_FACTOR_ID(),
-              ModelAPI_AttributeDouble, /** Scale factor */,
-              scaleFactorX, FeaturesPlugin_Scale::SCALE_FACTOR_X_ID(),
-              ModelAPI_AttributeDouble, /** Scale factor in X */,
-              scaleFactorY, FeaturesPlugin_Scale::SCALE_FACTOR_Y_ID(),
-              ModelAPI_AttributeDouble, /** Scale factor in Y */,
-              scaleFactorZ, FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID(),
-              ModelAPI_AttributeDouble, /** Scale factor in Z */)
+              ModelAPI_AttributeDouble, /** Scale factor */)
 
   /// Set main objects.
   FEATURESAPI_EXPORT
@@ -76,13 +59,6 @@ public:
   FEATURESAPI_EXPORT
   void setScaleFactor(const ModelHighAPI_Double& theScaleFactor);
 
-  /// Modify Creation Method and scale_factor_x, scale_factor_y and scale_factor_z
-  /// attributes of the feature.
-  FEATURESAPI_EXPORT
-  void setDimensions(const ModelHighAPI_Double& theScaleFactorX,
-                     const ModelHighAPI_Double& theScaleFactorY,
-                     const ModelHighAPI_Double& theScaleFactorZ);
-
   /// Dump wrapped feature
   FEATURESAPI_EXPORT
   virtual void dump(ModelHighAPI_Dumper& theDumper) const;
@@ -99,14 +75,4 @@ ScalePtr addScale(const std::shared_ptr<ModelAPI_Document>& thePart,
                   const ModelHighAPI_Selection& theCenterPoint,
                   const ModelHighAPI_Double& theScaleFactor);
 
-/// \ingroup CPPHighAPI
-/// \brief Create Scale feature.
-FEATURESAPI_EXPORT
-ScalePtr addScale(const std::shared_ptr<ModelAPI_Document>& thePart,
-                  const std::list<ModelHighAPI_Selection>& theMainObjects,
-                  const ModelHighAPI_Selection& theCenterPoint,
-                  const ModelHighAPI_Double& theScaleFactorX,
-                  const ModelHighAPI_Double& theScaleFactorY,
-                  const ModelHighAPI_Double& theScaleFactorZ);
-
 #endif // FEATURESAPI_SCALE_H_
\ No newline at end of file
index f0a33e07779151eeab55843bedf69141b1ac0262..ea6895052616427a0425057c46eba9276d9d30bd 100644 (file)
@@ -21,17 +21,10 @@ aSession.finishOperation()
 aSession.startOperation()
 aCenterPoint = model.addPoint(aDocument, 20, 20, 0).result()
 aBox1 =  model.addBox(aDocument, 10, 10, 10)
-aBox2 =  model.addBox(aDocument, 10, 10, 10)
 aSession.finishOperation()
 
 # Perform a symmetry by a point
 aSession.startOperation()
 aScale1 = model.addScale(aDocument, [model.selection("SOLID", "Box_1_1")], aCenterPoint, 2.0).result()
 aSession.finishOperation()
-assert (aScale1 is not None)
-
-# Perform a symmetry by an axis
-aSession.startOperation()
-aScale2 = model.addScale(aDocument, [model.selection("SOLID", "Box_2_1")], aCenterPoint, -0.5, 2, 3.7).result()
-aSession.finishOperation()
-assert (aScale2 is not None)
\ No newline at end of file
+assert (aScale1 is not None)
\ No newline at end of file
index ee82f611d3b9fffcae52f1cdb978b49955db503e..e216dc4527582df3a1114cf2094a9461e0e5e63d 100644 (file)
@@ -14,6 +14,8 @@
 #include <ModelAPI_ResultBody.h>
 #include <ModelAPI_ResultPart.h>
 
+#include <iostream>
+
 //=================================================================================================
 FeaturesPlugin_Scale::FeaturesPlugin_Scale()
 {
@@ -22,9 +24,6 @@ FeaturesPlugin_Scale::FeaturesPlugin_Scale()
 //=================================================================================================
 void FeaturesPlugin_Scale::initAttributes()
 {
-  data()->addAttribute(FeaturesPlugin_Scale::CREATION_METHOD(),
-                       ModelAPI_AttributeString::typeId());
-
   AttributeSelectionListPtr aSelection =
     std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(data()->addAttribute(
     FeaturesPlugin_Scale::OBJECTS_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()));
@@ -34,32 +33,10 @@ void FeaturesPlugin_Scale::initAttributes()
 
   data()->addAttribute(FeaturesPlugin_Scale::SCALE_FACTOR_ID(),
                        ModelAPI_AttributeDouble::typeId());
-
-  data()->addAttribute(FeaturesPlugin_Scale::SCALE_FACTOR_X_ID(),
-                       ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(FeaturesPlugin_Scale::SCALE_FACTOR_Y_ID(),
-                       ModelAPI_AttributeDouble::typeId());
-  data()->addAttribute(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID(),
-                       ModelAPI_AttributeDouble::typeId());
 }
 
 //=================================================================================================
 void FeaturesPlugin_Scale::execute()
-{
-  AttributeStringPtr aMethodTypeAttr = string(FeaturesPlugin_Scale::CREATION_METHOD());
-  std::string aMethodType = aMethodTypeAttr->value();
-
-  if (aMethodType == FeaturesPlugin_Scale::CREATION_METHOD_BY_FACTOR()) {
-    performScaleByFactor();
-  }
-
-  if (aMethodType == FeaturesPlugin_Scale::CREATION_METHOD_BY_DIMENSIONS()) {
-    performScaleByDimensions();
-  }
-}
-
-//=================================================================================================
-void FeaturesPlugin_Scale::performScaleByFactor()
 {
   // Getting objects.
   ListOfShape anObjects;
@@ -109,7 +86,7 @@ void FeaturesPlugin_Scale::performScaleByFactor()
     // Setting result.
     if (isPart) {
       std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      //aTrsf->setSymmetry(anAxis);
+      aTrsf->setScale(aCenterPoint, aScaleFactor);
       ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
       ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
       aResultPart->setTrsf(*aContext, aTrsf);
@@ -152,103 +129,6 @@ void FeaturesPlugin_Scale::performScaleByFactor()
   removeResults(aResultIndex);
 }
 
-//=================================================================================================
-void FeaturesPlugin_Scale::performScaleByDimensions()
-{
-  // Getting objects.
-  ListOfShape anObjects;
-  std::list<ResultPtr> aContextes;
-  AttributeSelectionListPtr anObjectsSelList =
-    selectionList(FeaturesPlugin_Scale::OBJECTS_LIST_ID());
-  if (anObjectsSelList->size() == 0) {
-    return;
-  }
-  for(int anObjectsIndex = 0; anObjectsIndex < anObjectsSelList->size(); anObjectsIndex++) {
-    std::shared_ptr<ModelAPI_AttributeSelection> anObjectAttr =
-      anObjectsSelList->value(anObjectsIndex);
-    std::shared_ptr<GeomAPI_Shape> anObject = anObjectAttr->value();
-    if(!anObject.get()) { // may be for not-activated parts
-      eraseResults();
-      return;
-    }
-    anObjects.push_back(anObject);
-    aContextes.push_back(anObjectAttr->context());
-  }
-
-  // Getting the center point
-  std::shared_ptr<GeomAPI_Pnt> aCenterPoint;
-  std::shared_ptr<ModelAPI_AttributeSelection> anObjRef =
-    selection(FeaturesPlugin_Scale::CENTER_POINT_ID());
-  if (anObjRef.get() != NULL) {
-    GeomShapePtr aShape = anObjRef->value();
-    if (!aShape.get()) {
-      aShape = anObjRef->context()->shape();
-    }
-    if (aShape) {
-      aCenterPoint = GeomAlgoAPI_PointBuilder::point(aShape);
-    }
-  }
-
-  // Getting dimensions
-  double aScaleFactorX = real(FeaturesPlugin_Scale::SCALE_FACTOR_X_ID())->value();
-  double aScaleFactorY = real(FeaturesPlugin_Scale::SCALE_FACTOR_Y_ID())->value();
-  double aScaleFactorZ = real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID())->value();
-
-  // Moving each object.
-  int aResultIndex = 0;
-  std::list<ResultPtr>::iterator aContext = aContextes.begin();
-  for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end();
-        anObjectsIt++, aContext++) {
-    std::shared_ptr<GeomAPI_Shape> aBaseShape = *anObjectsIt;
-    bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group();
-
-    // Setting result.
-    if (isPart) {
-      std::shared_ptr<GeomAPI_Trsf> aTrsf(new GeomAPI_Trsf());
-      //aTrsf->setSymmetry(anAxis);
-      ResultPartPtr anOrigin = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aContext);
-      ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex);
-      aResultPart->setTrsf(*aContext, aTrsf);
-      setResult(aResultPart, aResultIndex);
-    } else {
-      GeomAlgoAPI_Scale aScaleAlgo(aBaseShape, aCenterPoint,
-                                   aScaleFactorX, aScaleFactorY, aScaleFactorZ);
-
-      if (!aScaleAlgo.check()) {
-        setError(aScaleAlgo.getError());
-        return;
-      }
-
-      aScaleAlgo.build();
-
-      // Checking that the algorithm worked properly.
-      if(!aScaleAlgo.isDone()) {
-        static const std::string aFeatureError = "Error: Symmetry algorithm failed.";
-        setError(aFeatureError);
-        break;
-      }
-      if(aScaleAlgo.shape()->isNull()) {
-        static const std::string aShapeError = "Error: Resulting shape is Null.";
-        setError(aShapeError);
-        break;
-      }
-      if(!aScaleAlgo.isValid()) {
-        std::string aFeatureError = "Error: Resulting shape is not valid.";
-        setError(aFeatureError);
-        break;
-      }
-
-      ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex);
-      loadNamingDS(aScaleAlgo, aResultBody, aBaseShape);
-      setResult(aResultBody, aResultIndex);
-    }
-    aResultIndex++;
-  }
-
-  // Remove the rest results if there were produced in the previous pass.
-  removeResults(aResultIndex);
-}
-
 //=================================================================================================
 void FeaturesPlugin_Scale::loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
                                         std::shared_ptr<ModelAPI_ResultBody> theResultBody,
index 71bf032a23a0b9967a5e0f4fbc3fe58afc32d1f7..9c01fb67066e21274303407d2cdb88909b6cc832 100644 (file)
@@ -27,27 +27,6 @@ class FeaturesPlugin_Scale : public ModelAPI_Feature
     return MY_SCALE_ID;
   }
 
-  /// Attribute name for creation method.
-  inline static const std::string& CREATION_METHOD()
-  {
-    static const std::string MY_CREATION_METHOD_ID("CreationMethod");
-    return MY_CREATION_METHOD_ID;
-  }
-
-  /// Attribute name for creation method "ByFactor".
-  inline static const std::string& CREATION_METHOD_BY_FACTOR()
-  {
-    static const std::string MY_CREATION_METHOD_ID("ByFactor");
-    return MY_CREATION_METHOD_ID;
-  }
-
-  /// Attribute name for creation method "ByFactor".
-  inline static const std::string& CREATION_METHOD_BY_DIMENSIONS()
-  {
-    static const std::string MY_CREATION_METHOD_ID("ByDimensions");
-    return MY_CREATION_METHOD_ID;
-  }
-
   /// Attribute name of referenced objects.
   inline static const std::string& OBJECTS_LIST_ID()
   {
@@ -69,27 +48,6 @@ class FeaturesPlugin_Scale : public ModelAPI_Feature
     return MY_SCALE_FACTOR_ID;
   }
 
-  /// Attribute name of scale factor in X.
-  inline static const std::string& SCALE_FACTOR_X_ID()
-  {
-    static const std::string MY_SCALE_FACTOR_X_ID("scale_factor_x");
-    return MY_SCALE_FACTOR_X_ID;
-  }
-
-  /// Attribute name of scale factor in Y.
-  inline static const std::string& SCALE_FACTOR_Y_ID()
-  {
-    static const std::string MY_SCALE_FACTOR_Y_ID("scale_factor_y");
-    return MY_SCALE_FACTOR_Y_ID;
-  }
-
-  /// Attribute name of scale factor in Z.
-  inline static const std::string& SCALE_FACTOR_Z_ID()
-  {
-    static const std::string MY_SCALE_FACTOR_Z_ID("scale_factor_z");
-    return MY_SCALE_FACTOR_Z_ID;
-  }
-
   /// \return the kind of a feature.
   FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
   {
@@ -107,12 +65,6 @@ class FeaturesPlugin_Scale : public ModelAPI_Feature
   FeaturesPlugin_Scale();
 
 private:
-  /// Perform scale using a central point and a value of the scale.
-  void performScaleByFactor();
-
-  /// Perform symmetry using a central point and three dimensions
-  void performScaleByDimensions();
-
   /// Perform the naming
   void loadNamingDS(GeomAlgoAPI_Scale& theScaleAlgo,
                     std::shared_ptr<ModelAPI_ResultBody> theResultBody,
index 3f6f8122d03c4dbab4cae73c8dc61c1d96b8cb8d..45ffe043ca3f34f5d4a925ee134143746fb28fbe 100644 (file)
@@ -1,76 +1,27 @@
 <!-- Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
 
 <source>
-  <toolbox id="CreationMethod">
-    <box id="ByFactor"
-         title="By one common factor for the three directions"
-         icon="icons/Features/scale_factor_32x32.png">
-      <multi_selector id="main_objects"
-                      label="Main objects"
-                      icon=""
-                      tooltip="Select objects"
-                      type_choice="objects"
-                      concealment="true">
-        <validator id="FeaturesPlugin_ValidatorTransform"/>
-      </multi_selector>
-      <shape_selector id="center_point"
-                      icon=""
-                      label="Center point"
-                      tooltip="Select the center point"
-                      shape_types="vertex"
-                      default="">
-        <validator id="GeomValidators_ShapeType" parameters="vertex"/>
-        <validator id="GeomValidators_ConstructionComposite"/>
-      </shape_selector>
-      <doublevalue
-          id="scale_factor"
-          label="Scale factor"
-          step="1."
-          default="2."
-          tooltip="Scale factor">
-      </doublevalue>
-    </box>
-    <box id="ByDimensions"
-         title="Different factors for the three directions"
-         icon="icons/Features/scale_dimensions_32x32.png">
-      <multi_selector id="main_objects"
-                      label="Main objects"
-                      icon=""
-                      tooltip="Select objects"
-                      type_choice="objects"
-                      concealment="true">
-        <validator id="FeaturesPlugin_ValidatorTransform"/>
-      </multi_selector>
-      <shape_selector id="center_point"
-                      icon=""
-                      label="Center point"
-                      tooltip="Select the center point"
-                      shape_types="vertex"
-                      default="">
-        <validator id="GeomValidators_ShapeType" parameters="vertex"/>
-        <validator id="GeomValidators_ConstructionComposite"/>
-      </shape_selector>
-      <doublevalue
-          id="scale_factor_x"
-          label="Scale factor in X"
-          step="1."
-          default="2."
-          tooltip="Scale factor in X">
-      </doublevalue>
-      <doublevalue
-          id="scale_factor_y"
-          label="Scale factor in Y"
-          step="1."
-          default="2."
-          tooltip="Scale factor in Y">
-      </doublevalue>
-      <doublevalue
-          id="scale_factor_z"
-          label="Scale factor in Z"
-          step="1."
-          default="2."
-          tooltip="Scale factor in Z">
-      </doublevalue>
-    </box>
-  </toolbox>
+  <multi_selector id="main_objects"
+                  label="Main objects"
+                  icon=""
+                  tooltip="Select objects"
+                  type_choice="objects"
+                  concealment="true">
+    <validator id="FeaturesPlugin_ValidatorTransform"/>
+  </multi_selector>
+  <shape_selector id="center_point"
+                  icon=""
+                  label="Center point"
+                  tooltip="Select the center point"
+                  shape_types="vertex"
+                  default="">
+    <validator id="GeomValidators_ShapeType" parameters="vertex"/>
+    <validator id="GeomValidators_ConstructionComposite"/>
+  </shape_selector>
+  <doublevalue id="scale_factor"
+               label="Scale factor"
+               step="1."
+               default="2."
+               tooltip="Scale factor">
+  </doublevalue>
 </source>
\ No newline at end of file
index 21a972872bbf2ca3a10d58fc0e14b3f0e66c5eac..6274599632846ba108524e290d1dbd777035545e 100644 (file)
 
 #include <gp_Ax1.hxx>
 #include <gp_Ax2.hxx>
+#include <gp_GTrsf.hxx>
 #include <gp_Trsf.hxx>
 
 #define MY_TRSF implPtr<gp_Trsf>()
 
+#include <iostream>
+
 //=================================================================================================
 GeomAPI_Trsf::GeomAPI_Trsf()
 : GeomAPI_Interface(new gp_Trsf())
@@ -73,3 +76,10 @@ void GeomAPI_Trsf::setSymmetry(const std::shared_ptr<GeomAPI_Ax2> thePlane)
 {
   MY_TRSF->SetMirror(thePlane->impl<gp_Ax2>());
 }
+
+//=================================================================================================
+void GeomAPI_Trsf::setScale(const std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+                            const double theScaleFactor)
+{
+  MY_TRSF->SetScale(theCenterPoint->impl<gp_Pnt>(), theScaleFactor);
+}
index 9f7a7f811e84f1b800c9babd742ff18d108bbdb2..ede05133e45274850df16f6dd5b3e41894827b56 100644 (file)
@@ -73,6 +73,13 @@ class GeomAPI_Trsf : public GeomAPI_Interface
    *  \param[in] thePlane symmetry plane.
    */
   GEOMAPI_EXPORT void setSymmetry(const std::shared_ptr<GeomAPI_Ax2> thePlane);
+  
+  /** \brief Sets a scale transformation using a factor.
+   *  \param[in] theCenterPoint center point.
+   *  \param[in] theScaleFactor scale factor.
+   */
+  GEOMAPI_EXPORT void setScale(const std::shared_ptr<GeomAPI_Pnt> theCenterPoint,
+                               const double theScaleFactor);
 };
 
 #endif
index bfdd1d0a48faf487fb06d3f1fbf2fed360403c6d..28484c4d409b463bd7f6b7c2b199d709c33aee45 100644 (file)
@@ -7,34 +7,18 @@
 #include "GeomAlgoAPI_Scale.h"
 
 #include <BRepBuilderAPI_Transform.hxx>
-#include <BRepBuilderAPI_GTransform.hxx>
+#include <Precision.hxx>
 
 //=================================================================================================
 GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr<GeomAPI_Shape> theSourceShape,
                                      std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
                                      double theScaleFactor)
 {
-  myMethodType = BY_FACTOR;
   mySourceShape = theSourceShape;
   myCenterPoint = theCenterPoint;
   myScaleFactor = theScaleFactor;
 }
 
-//=================================================================================================
-GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr<GeomAPI_Shape> theSourceShape,
-                                     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
-                                     double theScaleFactorX,
-                                     double theScaleFactorY,
-                                     double theScaleFactorZ)
-{
-  myMethodType = BY_DIMENSIONS;
-  mySourceShape = theSourceShape;
-  myCenterPoint = theCenterPoint;
-  myScaleFactorX = theScaleFactorX;
-  myScaleFactorY = theScaleFactorY;
-  myScaleFactorZ = theScaleFactorZ;
-}
-
 //=================================================================================================
 bool GeomAlgoAPI_Scale::check()
 {
@@ -46,57 +30,15 @@ bool GeomAlgoAPI_Scale::check()
     myError = "Scale builder :: center point is invalid.";
     return false;
   }
-  switch (myMethodType) {
-    case BY_FACTOR: {
-      if (fabs(myScaleFactor) < Precision::Confusion()) {
-        myError = "Scale builder :: the scale factor is null.";
-        return false;
-      }
-      return true;
-    }
-    case BY_DIMENSIONS: {
-      if (fabs(myScaleFactorX) < Precision::Confusion()) {
-        myError = "Scale builder :: the scale factor in X is null.";
-        return false;
-      }
-      if (fabs(myScaleFactorY) < Precision::Confusion()) {
-        myError = "Scale builder :: the scale factor in Y is null.";
-        return false;
-      }
-      if (fabs(myScaleFactorZ) < Precision::Confusion()) {
-        myError = "Scale builder :: the scale factor in Z is null.";
-        return false;
-      }
-      return true;
-    }
-    default: {
-      myError = "Scale builder :: method not implemented.";
-      return false;
-    }
+  if (fabs(myScaleFactor) < Precision::Confusion()) {
+    myError = "Scale builder :: the scale factor is null.";
+    return false;
   }
+  return true;
 }
 
 //=================================================================================================
 void GeomAlgoAPI_Scale::build()
-{
-  switch (myMethodType) {
-   case BY_FACTOR : {
-     buildByFactor();
-     break;
-   }
-   case BY_DIMENSIONS : {
-     buildByDimensions();
-     break;
-   }
-   default : {
-     myError = "Scale builder :: method not yet implemented";
-     return;
-   }
-  }
-}
-
-//=================================================================================================
-void GeomAlgoAPI_Scale::buildByFactor()
 {
   const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
   gp_Trsf* aTrsf = new gp_Trsf();
@@ -131,54 +73,3 @@ void GeomAlgoAPI_Scale::buildByFactor()
   setShape(aShape);
   setDone(true);
 }
-
-//=================================================================================================
-void GeomAlgoAPI_Scale::buildByDimensions()
-{
-  const gp_Pnt& aCenterPoint = myCenterPoint->impl<gp_Pnt>();
-
-  // Perform the rotation matrix
-  gp_Mat aMatRot(myScaleFactorX, 0., 0.,
-                 0., myScaleFactorY, 0.,
-                 0., 0., myScaleFactorZ);
-
-  // Perform the tranformation
-  gp_Pnt anOriginPnt(0., 0., 0.);
-  gp_GTrsf aGTrsf;
-  gp_GTrsf aGTrsfP0;
-  gp_GTrsf aGTrsf0P;
-  aGTrsfP0.SetTranslationPart(anOriginPnt.XYZ() - aCenterPoint.XYZ());
-  aGTrsf0P.SetTranslationPart(aCenterPoint.XYZ());
-  aGTrsf.SetVectorialPart(aMatRot);
-  aGTrsf = aGTrsf0P.Multiplied(aGTrsf);
-  aGTrsf = aGTrsf.Multiplied(aGTrsfP0);
-
-  const TopoDS_Shape& aSourceShape = mySourceShape->impl<TopoDS_Shape>();
-
-  if(aSourceShape.IsNull()) {
-    myError = "Scale builder :: source shape does not contain any actual shape.";
-    return;
-  }
-
-  // Transform the shape while copying it.
-  BRepBuilderAPI_GTransform* aBuilder = new BRepBuilderAPI_GTransform(aSourceShape, aGTrsf, true);
-  if(!aBuilder) {
-    myError = "Scale builder :: transform initialization failed.";
-    return;
-  }
-
-  setImpl(aBuilder);
-  setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
-
-  if(!aBuilder->IsDone()) {
-    myError = "Scale builder :: algorithm failed.";
-    return;
-  }
-
-  TopoDS_Shape aResult = aBuilder->Shape();
-
-  std::shared_ptr<GeomAPI_Shape> aShape(new GeomAPI_Shape());
-  aShape->setImpl(new TopoDS_Shape(aResult));
-  setShape(aShape);
-  setDone(true);
-}
index 3fcb1c48671918f18fe8231dca703ff7ec10e054..b78a84f093df34d1546f5f57764c55243f116ddd 100644 (file)
 class GeomAlgoAPI_Scale : public GeomAlgoAPI_MakeShape
 {
 public:
-  /// Type of scale operation
-  enum MethodType {
-    BY_FACTOR,     ///< Scale by factor.
-    BY_DIMENSIONS, ///< Scale by dimensions.
-  };
-
   /// \brief Creates an object which is obtained from current object by performing
   ///        a scale operation by a factor.
   /// \param[in] theSourceShape  the shape to be moved.
@@ -33,19 +27,6 @@ public:
                                        std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
                                        double                         theScaleFactor);
 
-  /// \brief Creates an object which is obtained from current object by performing
-  ///        a scale operation by dimensions.
-  /// \param[in] theSourceShape  the shape to be moved.
-  /// \param[in] theCenterPoint  the center point.
-  /// \param[in] theFactorX      the scale factor in X.
-  /// \param[in] theFactorY      the scale factor in Y.
-  /// \param[in] theFactorZ      the scale factor in Z.
-  GEOMALGOAPI_EXPORT GeomAlgoAPI_Scale(std::shared_ptr<GeomAPI_Shape> theSourceShape,
-                                       std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
-                                       double                         theScaleFactorX,
-                                       double                         theScaleFactorY,
-                                       double                         theScaleFactorZ);
-
   /// Checks if data for the scale transform is OK.
   GEOMALGOAPI_EXPORT bool check();
 
@@ -53,16 +34,9 @@ public:
   GEOMALGOAPI_EXPORT void build();
 
 private:
-  MethodType myMethodType; /// Type of method used.
   std::shared_ptr<GeomAPI_Shape> mySourceShape; /// Shape to be moved.
   std::shared_ptr<GeomAPI_Pnt> myCenterPoint; /// Center point.
   double myScaleFactor; /// Scale factor.
-  double myScaleFactorX; /// Scale factor in X.
-  double myScaleFactorY; /// Scale factor in Y.
-  double myScaleFactorZ; /// Scale factor in Z.
-
-  void buildByFactor();
-  void buildByDimensions();
 };
 
 #endif // GEOMALGOAPI_SCALE_H_
\ No newline at end of file
index faba77138781436e08d0054a31eb6ba9a824cde7..b10e028abeeb62761ca4490884a41c578298b5a5 100644 (file)
@@ -329,32 +329,6 @@ namespace GeomAlgoAPI_ShapeAPI
     return aScaleAlgo.shape();
   }
 
-  //===============================================================================================
-  std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeScale(
-   std::shared_ptr<GeomAPI_Shape> theSourceShape,
-   std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
-   const double                   theScaleFactorX,
-   const double                   theScaleFactorY,
-   const double                   theScaleFactorZ) throw (GeomAlgoAPI_Exception)
-  {
-    GeomAlgoAPI_Scale aScaleAlgo(theSourceShape, theCenterPoint,
-                                 theScaleFactorX, theScaleFactorY, theScaleFactorZ);
-
-    if (!aScaleAlgo.check()) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-
-    aScaleAlgo.build();
-
-    if(!aScaleAlgo.isDone()) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-    if (!aScaleAlgo.checkValid("Scale builder by dimensions")) {
-      throw GeomAlgoAPI_Exception(aScaleAlgo.getError());
-    }
-    return aScaleAlgo.shape();
-  }
-
   //===============================================================================================
   std::shared_ptr<GeomAPI_Shape> GeomAlgoAPI_ShapeAPI::makeConeSegment(
     const double theRMin1, const double theRMax1,
index 2f478373b92b23f98db05a5ef7eb8eb4410dbac4..bbabbf9027dd2653d79f640ef0c3454178219312 100644 (file)
@@ -133,19 +133,6 @@ public:
                      std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
                      const double                   theScaleFactor) throw (GeomAlgoAPI_Exception);
 
-  /// Performs a scale by dimensions.
-  /// \param theSourceShape Shape be scaled
-  /// \param theCenterPoint Point of scale
-  /// \param theScaleFactorX Factor of scale in X
-  /// \param theScaleFactorY Factor of scale in Y
-  /// \param theScaleFactorZ Factor of scale in Z
-  static std::shared_ptr<GeomAPI_Shape> makeScale(
-                     std::shared_ptr<GeomAPI_Shape> theSourceShape,
-                     std::shared_ptr<GeomAPI_Pnt>   theCenterPoint,
-                     const double                   theScaleFactorX,
-                     const double                   theScaleFactorY,
-                     const double                   theScaleFactorZ) throw (GeomAlgoAPI_Exception);
-
   /// Creates a cone segment using standard GDML parameters.
   /// \param theRMin1 Inner radius at base of cone
   /// \param theRMax1 Outer radius at base of cone
index a6013480732a4a4b23b38ac99db412a7a413bf3e..791a9c047d978c0c1c52ade5c3beea6ec7278925 100644 (file)
@@ -11,7 +11,6 @@ from GeomAPI import GeomAPI_Pnt as pnt
 # Create a box
 try :
   box1 = shaperpy.makeBox(10.,10.,10.)
-  box2 = shaperpy.makeBox(10.,10.,10.)
   centerPoint = pnt(20.,20.,0.)
  
 except myExcept, ec:
@@ -23,10 +22,3 @@ try :
  
 except myExcept, ec:
   print ec.what()
-
-# Perfom a scale by dimensions.
-try :
-  scale2 = shaperpy.makeScale(box2,centerPoint, 2, -0.5, 1.3)
-except myExcept, ec:
-  print ec.what()