From: Clarisse Genrault Date: Fri, 27 Jan 2017 07:52:37 +0000 (+0100) Subject: Deleting the option of "Scale" feature from dimensions in X, in Y and in Z. X-Git-Tag: V_2.7.0~302^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f12d4f220bde1f12a1c92f68e2cb27336fce8de;p=modules%2Fshaper.git Deleting the option of "Scale" feature from dimensions in X, in Y and in Z. --- diff --git a/src/FeaturesAPI/FeaturesAPI_Scale.cpp b/src/FeaturesAPI/FeaturesAPI_Scale.cpp index e80f3b4cf..d402713bc 100644 --- a/src/FeaturesAPI/FeaturesAPI_Scale.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Scale.cpp @@ -30,22 +30,6 @@ FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr& th } } -//================================================================================================== -FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr& theFeature, - const std::list& 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& thePart, { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Scale::ID()); return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, theScaleFactor)); -} - -//================================================================================================== -ScalePtr addScale(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theCenterPoint, - const ModelHighAPI_Double& theScaleFactorX, - const ModelHighAPI_Double& theScaleFactorY, - const ModelHighAPI_Double& theScaleFactorZ) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Scale::ID()); - return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, - theScaleFactorX, theScaleFactorY, theScaleFactorZ)); } \ No newline at end of file diff --git a/src/FeaturesAPI/FeaturesAPI_Scale.h b/src/FeaturesAPI/FeaturesAPI_Scale.h index d53ff1777..137763c62 100644 --- a/src/FeaturesAPI/FeaturesAPI_Scale.h +++ b/src/FeaturesAPI/FeaturesAPI_Scale.h @@ -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& theFeature, - const std::list& 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& thePart, const ModelHighAPI_Selection& theCenterPoint, const ModelHighAPI_Double& theScaleFactor); -/// \ingroup CPPHighAPI -/// \brief Create Scale feature. -FEATURESAPI_EXPORT -ScalePtr addScale(const std::shared_ptr& thePart, - const std::list& 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 diff --git a/src/FeaturesAPI/Test/APIParam_Scale.py b/src/FeaturesAPI/Test/APIParam_Scale.py index f0a33e077..ea6895052 100644 --- a/src/FeaturesAPI/Test/APIParam_Scale.py +++ b/src/FeaturesAPI/Test/APIParam_Scale.py @@ -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 diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp index ee82f611d..e216dc452 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.cpp @@ -14,6 +14,8 @@ #include #include +#include + //================================================================================================= 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(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 aTrsf(new GeomAPI_Trsf()); - //aTrsf->setSymmetry(anAxis); + aTrsf->setScale(aCenterPoint, aScaleFactor); ResultPartPtr anOrigin = std::dynamic_pointer_cast(*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 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 anObjectAttr = - anObjectsSelList->value(anObjectsIndex); - std::shared_ptr 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 aCenterPoint; - std::shared_ptr 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::iterator aContext = aContextes.begin(); - for(ListOfShape::iterator anObjectsIt = anObjects.begin(); anObjectsIt != anObjects.end(); - anObjectsIt++, aContext++) { - std::shared_ptr aBaseShape = *anObjectsIt; - bool isPart = (*aContext)->groupName() == ModelAPI_ResultPart::group(); - - // Setting result. - if (isPart) { - std::shared_ptr aTrsf(new GeomAPI_Trsf()); - //aTrsf->setSymmetry(anAxis); - ResultPartPtr anOrigin = std::dynamic_pointer_cast(*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 theResultBody, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Scale.h b/src/FeaturesPlugin/FeaturesPlugin_Scale.h index 71bf032a2..9c01fb670 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Scale.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Scale.h @@ -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 theResultBody, diff --git a/src/FeaturesPlugin/scale_widget.xml b/src/FeaturesPlugin/scale_widget.xml index 3f6f8122d..45ffe043c 100644 --- a/src/FeaturesPlugin/scale_widget.xml +++ b/src/FeaturesPlugin/scale_widget.xml @@ -1,76 +1,27 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/src/GeomAPI/GeomAPI_Trsf.cpp b/src/GeomAPI/GeomAPI_Trsf.cpp index 21a972872..627459963 100644 --- a/src/GeomAPI/GeomAPI_Trsf.cpp +++ b/src/GeomAPI/GeomAPI_Trsf.cpp @@ -13,10 +13,13 @@ #include #include +#include #include #define MY_TRSF implPtr() +#include + //================================================================================================= GeomAPI_Trsf::GeomAPI_Trsf() : GeomAPI_Interface(new gp_Trsf()) @@ -73,3 +76,10 @@ void GeomAPI_Trsf::setSymmetry(const std::shared_ptr thePlane) { MY_TRSF->SetMirror(thePlane->impl()); } + +//================================================================================================= +void GeomAPI_Trsf::setScale(const std::shared_ptr theCenterPoint, + const double theScaleFactor) +{ + MY_TRSF->SetScale(theCenterPoint->impl(), theScaleFactor); +} diff --git a/src/GeomAPI/GeomAPI_Trsf.h b/src/GeomAPI/GeomAPI_Trsf.h index 9f7a7f811..ede05133e 100644 --- a/src/GeomAPI/GeomAPI_Trsf.h +++ b/src/GeomAPI/GeomAPI_Trsf.h @@ -73,6 +73,13 @@ class GeomAPI_Trsf : public GeomAPI_Interface * \param[in] thePlane symmetry plane. */ GEOMAPI_EXPORT void setSymmetry(const std::shared_ptr 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 theCenterPoint, + const double theScaleFactor); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp index bfdd1d0a4..28484c4d4 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Scale.cpp @@ -7,34 +7,18 @@ #include "GeomAlgoAPI_Scale.h" #include -#include +#include //================================================================================================= GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr theSourceShape, std::shared_ptr theCenterPoint, double theScaleFactor) { - myMethodType = BY_FACTOR; mySourceShape = theSourceShape; myCenterPoint = theCenterPoint; myScaleFactor = theScaleFactor; } -//================================================================================================= -GeomAlgoAPI_Scale::GeomAlgoAPI_Scale(std::shared_ptr theSourceShape, - std::shared_ptr 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_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(); - - // 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(); - - 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 aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aResult)); - setShape(aShape); - setDone(true); -} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Scale.h b/src/GeomAlgoAPI/GeomAlgoAPI_Scale.h index 3fcb1c486..b78a84f09 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Scale.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Scale.h @@ -18,12 +18,6 @@ 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 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 theSourceShape, - std::shared_ptr 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 mySourceShape; /// Shape to be moved. std::shared_ptr 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 diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index faba77138..b10e028ab 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -329,32 +329,6 @@ namespace GeomAlgoAPI_ShapeAPI return aScaleAlgo.shape(); } - //=============================================================================================== - std::shared_ptr GeomAlgoAPI_ShapeAPI::makeScale( - std::shared_ptr theSourceShape, - std::shared_ptr 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 GeomAlgoAPI_ShapeAPI::makeConeSegment( const double theRMin1, const double theRMax1, diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index 2f478373b..bbabbf902 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -133,19 +133,6 @@ public: std::shared_ptr 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 makeScale( - std::shared_ptr theSourceShape, - std::shared_ptr 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 diff --git a/src/GeomAlgoAPI/Test/TestAPI_Scale.py b/src/GeomAlgoAPI/Test/TestAPI_Scale.py index a60134807..791a9c047 100644 --- a/src/GeomAlgoAPI/Test/TestAPI_Scale.py +++ b/src/GeomAlgoAPI/Test/TestAPI_Scale.py @@ -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()