From: Clarisse Genrault Date: Wed, 23 Nov 2016 14:22:08 +0000 (+0100) Subject: Revert "Add a new method for translation : translation by two points." X-Git-Tag: V_2.6.0~63^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=596cc06a3cdc89783d15e893e7da4b6b882fb442;p=modules%2Fshaper.git Revert "Add a new method for translation : translation by two points." This reverts commit eed4f101a32c24d5a9be0830f9a7ead06ca159d1. --- diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.cpp b/src/FeaturesAPI/FeaturesAPI_Translation.cpp index ec05c3cef..bfcd5bdfc 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Translation.cpp @@ -46,20 +46,6 @@ FeaturesAPI_Translation::FeaturesAPI_Translation( } } -//================================================================================================== -FeaturesAPI_Translation::FeaturesAPI_Translation( - const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theStartPoint, - const ModelHighAPI_Selection& theEndPoint) -: ModelHighAPI_Interface(theFeature) -{ - if(initialize()) { - fillAttribute(theMainObjects, mymainObjects); - setPoints(theStartPoint, theEndPoint); - } -} - //================================================================================================== FeaturesAPI_Translation::~FeaturesAPI_Translation() { @@ -99,17 +85,6 @@ void FeaturesAPI_Translation::setDimensions(const ModelHighAPI_Double& theDx, execute(); } -//================================================================================================== -void FeaturesAPI_Translation::setPoints(const ModelHighAPI_Selection& theStartPoint, - const ModelHighAPI_Selection& theEndPoint) -{ - fillAttribute(FeaturesPlugin_Translation::CREATION_METHOD_BY_TWO_POINTS(), mycreationMethod); - fillAttribute(theStartPoint, mystartPoint); - fillAttribute(theEndPoint, myendPoint); - - execute(); -} - //================================================================================================== void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const { @@ -134,12 +109,6 @@ void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const AttributeDoublePtr anAttrDy = aBase->real(FeaturesPlugin_Translation::DY_ID()); AttributeDoublePtr anAttrDz = aBase->real(FeaturesPlugin_Translation::DZ_ID()); theDumper << ", " << anAttrDx << ", " << anAttrDy << ", " << anAttrDz; - } else if (aCreationMethod == FeaturesPlugin_Translation::CREATION_METHOD_BY_TWO_POINTS()) { - AttributeSelectionPtr anAttrStartPoint = - aBase->selection(FeaturesPlugin_Translation::START_POINT_ID()); - AttributeSelectionPtr anAttrEndPoint = - aBase->selection(FeaturesPlugin_Translation::END_POINT_ID()); - theDumper << ", " << anAttrStartPoint << ", " << anAttrEndPoint; } theDumper << ")" << std::endl; @@ -166,14 +135,3 @@ TranslationPtr addTranslation(const std::shared_ptr& thePart, std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Translation::ID()); return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, theDx, theDy, theDz)); } - -//================================================================================================== -TranslationPtr addTranslation(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theStartPoint, - const ModelHighAPI_Selection& theEndPoint) -{ - std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Translation::ID()); - return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, - theStartPoint, theEndPoint)); -} diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.h b/src/FeaturesAPI/FeaturesAPI_Translation.h index 11a7ddf8c..91f3e7e14 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.h +++ b/src/FeaturesAPI/FeaturesAPI_Translation.h @@ -39,22 +39,15 @@ public: FEATURESAPI_EXPORT explicit FeaturesAPI_Translation(const std::shared_ptr& theFeature, const std::list& theMainObjects, - const ModelHighAPI_Double& theDx, - const ModelHighAPI_Double& theDy, - const ModelHighAPI_Double& theDz); - - /// Constructor with values. - FEATURESAPI_EXPORT - explicit FeaturesAPI_Translation(const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theStartPoint, - const ModelHighAPI_Selection& theEndPoint); + const ModelHighAPI_Double& theDx, + const ModelHighAPI_Double& theDy, + const ModelHighAPI_Double& theDz); /// Destructor. FEATURESAPI_EXPORT virtual ~FeaturesAPI_Translation(); - INTERFACE_9(FeaturesPlugin_Translation::ID(), + INTERFACE_7(FeaturesPlugin_Translation::ID(), creationMethod, FeaturesPlugin_Translation::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, mainObjects, FeaturesPlugin_Translation::OBJECTS_LIST_ID(), @@ -68,11 +61,7 @@ public: dy, FeaturesPlugin_Translation::DY_ID(), ModelAPI_AttributeDouble, /** Dimension in Y */, dz, FeaturesPlugin_Translation::DZ_ID(), - ModelAPI_AttributeDouble, /** Dimension in Z */, - startPoint, FeaturesPlugin_Translation::START_POINT_ID(), - ModelAPI_AttributeSelection, /** Start point object */, - endPoint, FeaturesPlugin_Translation::END_POINT_ID(), - ModelAPI_AttributeSelection, /** End point object */ + ModelAPI_AttributeDouble, /** Dimension in Z */ ) /// Set main objects. @@ -90,11 +79,6 @@ public: const ModelHighAPI_Double& theDy, const ModelHighAPI_Double& theDz); - /// Modify CreationMethod, start_point, end_point attributes of the feature. - FEATURESAPI_EXPORT - void setPoints(const ModelHighAPI_Selection& theStartPoint, - const ModelHighAPI_Selection& theEndPoint); - /// Dump wrapped feature FEATURESAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; @@ -120,12 +104,4 @@ TranslationPtr addTranslation(const std::shared_ptr& thePart, const ModelHighAPI_Double& theDy, const ModelHighAPI_Double& theDz); -/// \ingroup CPPHighAPI -/// \brief Create Translation feature. -FEATURESAPI_EXPORT -TranslationPtr addTranslation(const std::shared_ptr& thePart, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theStartPoint, - const ModelHighAPI_Selection& theEndPoint); - #endif // FeaturesAPI_Translation_H_ diff --git a/src/FeaturesAPI/Test/APIParam_Translation.py b/src/FeaturesAPI/Test/APIParam_Translation.py index 6795c25b8..53b176781 100644 --- a/src/FeaturesAPI/Test/APIParam_Translation.py +++ b/src/FeaturesAPI/Test/APIParam_Translation.py @@ -32,12 +32,4 @@ assert (aTranslation1 is not None) aSession.startOperation() aTranslation2 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], 10, 10, 10).result() aSession.finishOperation() -assert (aTranslation2 is not None) - -# Perform a translation by two points -aSession.startOperation() -aPoint1 = model.addPoint(aDocument, 0, 0, 0).result() -aPoint2 = model.addPoint(aDocument, 10, 10, 0).result() -aTranslation3 = model.addTranslation(aDocument, [model.selection("SOLID", "Box_1_1")], aPoint1, aPoint2).result() -aSession.finishOperation() assert (aTranslation2 is not None) \ No newline at end of file diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp index 4bd8aea03..26b70c33b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -19,8 +19,6 @@ #include #include -#include - #include //================================================================================================= @@ -48,11 +46,6 @@ void FeaturesPlugin_Translation::initAttributes() ModelAPI_AttributeDouble::typeId()); data()->addAttribute(FeaturesPlugin_Translation::DZ_ID(), ModelAPI_AttributeDouble::typeId()); - - data()->addAttribute(FeaturesPlugin_Translation::START_POINT_ID(), - ModelAPI_AttributeSelection::typeId()); - data()->addAttribute(FeaturesPlugin_Translation::END_POINT_ID(), - ModelAPI_AttributeSelection::typeId()); } //================================================================================================= @@ -68,10 +61,6 @@ void FeaturesPlugin_Translation::execute() if (aMethodType == CREATION_METHOD_BY_DIMENSIONS()) { performTranslationByDimensions(); } - - if (aMethodType == CREATION_METHOD_BY_TWO_POINTS()) { - performTranslationByTwoPoints(); - } } //================================================================================================= @@ -252,101 +241,6 @@ void FeaturesPlugin_Translation::performTranslationByDimensions() removeResults(aResultIndex); } -//================================================================================================= -void FeaturesPlugin_Translation::performTranslationByTwoPoints() -{ - // Getting objects. - ListOfShape anObjects; - std::list aContextes; - AttributeSelectionListPtr anObjectsSelList = - selectionList(FeaturesPlugin_Translation::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 start point and the end point - AttributeSelectionPtr aRef1 = data()->selection(FeaturesPlugin_Translation::START_POINT_ID()); - AttributeSelectionPtr aRef2 = data()->selection(FeaturesPlugin_Translation::END_POINT_ID()); - std::shared_ptr aFirstPoint; - std::shared_ptr aSecondPoint; - if ((aRef1.get() != NULL) && (aRef2.get() != NULL)) { - GeomShapePtr aShape1 = aRef1->value(); - if (!aShape1.get()) //If we can't get the points directly, try getting them from the context - aShape1 = aRef1->context()->shape(); - GeomShapePtr aShape2 = aRef2->value(); - if (!aShape2.get()) - aShape2 = aRef2->context()->shape(); - if (aShape1 && aShape2) { - aFirstPoint = GeomAlgoAPI_PointBuilder::point(aShape1); - aSecondPoint = GeomAlgoAPI_PointBuilder::point(aShape2); - } - } - - // 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->setTranslation(aFirstPoint, aSecondPoint); - ResultPartPtr anOrigin = std::dynamic_pointer_cast(*aContext); - ResultPartPtr aResultPart = document()->copyPart(anOrigin, data(), aResultIndex); - aResultPart->setTrsf(*aContext, aTrsf); - setResult(aResultPart, aResultIndex); - } else { - GeomAlgoAPI_Translation aTranslationAlgo(aBaseShape, aFirstPoint, aSecondPoint); - - if (!aTranslationAlgo.check()) { - setError(aTranslationAlgo.getError()); - return; - } - - aTranslationAlgo.build(); - - // Checking that the algorithm worked properly. - if(!aTranslationAlgo.isDone()) { - static const std::string aFeatureError = "Error: Translation algorithm failed."; - setError(aFeatureError); - break; - } - if(aTranslationAlgo.shape()->isNull()) { - static const std::string aShapeError = "Error: Resulting shape is Null."; - setError(aShapeError); - break; - } - if(!aTranslationAlgo.isValid()) { - std::string aFeatureError = "Error: Resulting shape is not valid."; - setError(aFeatureError); - break; - } - - ResultBodyPtr aResultBody = document()->createBody(data(), aResultIndex); - loadNamingDS(aTranslationAlgo, aResultBody, aBaseShape); - setResult(aResultBody, aResultIndex); - } - aResultIndex++; - } - - // Remove the rest results if there were produced in the previous pass. - removeResults(aResultIndex); -} - //================================================================================================= void FeaturesPlugin_Translation::loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, std::shared_ptr theResultBody, diff --git a/src/FeaturesPlugin/FeaturesPlugin_Translation.h b/src/FeaturesPlugin/FeaturesPlugin_Translation.h index 899a8e0f2..2e3cf314b 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.h @@ -49,13 +49,6 @@ class FeaturesPlugin_Translation : public ModelAPI_Feature return MY_CREATION_METHOD_ID; } - /// Attribute name for creation method "ByTwoPoints". - inline static const std::string& CREATION_METHOD_BY_TWO_POINTS() - { - static const std::string MY_CREATION_METHOD_ID("ByTwoPoints"); - return MY_CREATION_METHOD_ID; - } - /// Attribute name of referenced objects. inline static const std::string& OBJECTS_LIST_ID() { @@ -98,20 +91,6 @@ class FeaturesPlugin_Translation : public ModelAPI_Feature return MY_DZ_ID; } - /// Attribute name of start point. - inline static const std::string& START_POINT_ID() - { - static const std::string MY_START_POINT_ID("start_point"); - return MY_START_POINT_ID; - } - - /// Attribute name of end point. - inline static const std::string& END_POINT_ID() - { - static const std::string MY_END_POINT_ID("end_point"); - return MY_END_POINT_ID; - } - /// \return the kind of a feature. FEATURESPLUGIN_EXPORT virtual const std::string& getKind() { @@ -135,9 +114,6 @@ private: ///Perform the translation using three dimensions X, Y and Z void performTranslationByDimensions(); - ///Perform the translation usind two points - void performTranslationByTwoPoints(); - void loadNamingDS(GeomAlgoAPI_Translation& theTranslationAlgo, std::shared_ptr theResultBody, std::shared_ptr theBaseShape); diff --git a/src/FeaturesPlugin/extrusion_widget.xml b/src/FeaturesPlugin/extrusion_widget.xml index dcb41eb2d..25a388dff 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -10,6 +10,21 @@ shape_types="vertices edges wires faces shells solids compsolids compounds"> + + + + + + - - - - - - diff --git a/src/FeaturesPlugin/icons/translation_2pt_32x32.png b/src/FeaturesPlugin/icons/translation_2pt_32x32.png deleted file mode 100644 index 5e6860737..000000000 Binary files a/src/FeaturesPlugin/icons/translation_2pt_32x32.png and /dev/null differ diff --git a/src/FeaturesPlugin/translation_widget.xml b/src/FeaturesPlugin/translation_widget.xml index a5b247dc6..1e5556a93 100644 --- a/src/FeaturesPlugin/translation_widget.xml +++ b/src/FeaturesPlugin/translation_widget.xml @@ -62,36 +62,5 @@ tooltip="Dimension in Z"> - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/GeomAPI/GeomAPI_Trsf.cpp b/src/GeomAPI/GeomAPI_Trsf.cpp index 322c14b90..7983c91e6 100644 --- a/src/GeomAPI/GeomAPI_Trsf.cpp +++ b/src/GeomAPI/GeomAPI_Trsf.cpp @@ -40,13 +40,6 @@ void GeomAPI_Trsf::setTranslation(const double theDx, const double theDy, const MY_TRSF->SetTranslation(gp_Vec(theDx, theDy, theDz)); } -//================================================================================================= -void GeomAPI_Trsf::setTranslation(const std::shared_ptr theStartPoint, - const std::shared_ptr theEndPoint) -{ - MY_TRSF->SetTranslation(theStartPoint->impl(), theEndPoint->impl()); -} - //================================================================================================= void GeomAPI_Trsf::setRotation(const std::shared_ptr theAxis, const double theAngle) diff --git a/src/GeomAPI/GeomAPI_Trsf.h b/src/GeomAPI/GeomAPI_Trsf.h index ed97f4beb..630c36fdd 100644 --- a/src/GeomAPI/GeomAPI_Trsf.h +++ b/src/GeomAPI/GeomAPI_Trsf.h @@ -13,7 +13,6 @@ #include class GeomAPI_Ax1; -class GeomAPI_Pnt; /**\class GeomAPI_Trsf * \ingroup DataModel @@ -44,13 +43,6 @@ class GeomAPI_Trsf : public GeomAPI_Interface const double theDy, const double theDz); - /** \brief Sets a translation transformation using two points. - * \param[in] theStartPoint Start point of the translation vector. - * \param[in] theEndPoint End point of the translation vector. - */ - GEOMAPI_EXPORT void setTranslation(const std::shared_ptr theStartPoint, - const std::shared_ptr theEndPoint); - /** \brief Sets a rotation transformation. * \param[in] theAxis rotation axis. * \param[in] theAngle rotation angle(in degree). diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp index 37ecc1296..bd5f6015b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -106,27 +106,4 @@ namespace GeomAlgoAPI_ShapeAPI } return aTranslationAlgo.shape(); } - - //========================================================================================================= - std::shared_ptr GeomAlgoAPI_ShapeAPI::makeTranslation( - std::shared_ptr theSourceShape, - std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception) - { - GeomAlgoAPI_Translation aTranslationAlgo(theSourceShape, theStartPoint, theEndPoint); - - if (!aTranslationAlgo.check()) { - throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); - } - - aTranslationAlgo.build(); - - if(!aTranslationAlgo.isDone()) { - throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); - } - if (!aTranslationAlgo.checkValid("Translation builder with two points")) { - throw GeomAlgoAPI_Exception(aTranslationAlgo.getError()); - } - return aTranslationAlgo.shape(); - } } diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h index 5e0ef0ba9..f5769a35e 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -59,16 +59,6 @@ public: const double theDx, const double theDy, const double theDz) throw (GeomAlgoAPI_Exception); - - /// Performs a translation from two points. - /// \param theSourceShape Shape to be moved. - /// \param theStartPoint Movement start point. - /// \param theEndPoint Movement end point. - /// \return a shape - static std::shared_ptr makeTranslation( - std::shared_ptr theSourceShape, - std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) throw (GeomAlgoAPI_Exception); }; } #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp index 574b63d23..9fee16ebf 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp @@ -36,17 +36,6 @@ GeomAlgoAPI_Translation::GeomAlgoAPI_Translation(std::shared_ptr myDz = theDz; } -//================================================================================================= -GeomAlgoAPI_Translation::GeomAlgoAPI_Translation(std::shared_ptr theSourceShape, - std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint) -{ - myMethodType = BY_POINTS; - mySourceShape = theSourceShape; - myStartPoint = theStartPoint; - myEndPoint = theEndPoint; -} - //================================================================================================= bool GeomAlgoAPI_Translation::check() { @@ -69,21 +58,6 @@ bool GeomAlgoAPI_Translation::check() } return true; } - case BY_POINTS: { - if (!myStartPoint) { - myError = "Translation builder :: start point is invalid."; - return false; - } - if (!myEndPoint) { - myError = "Translation builder :: start point is invalid."; - return false; - } - if (!mySourceShape) { - myError = "Translation builder :: source shape is invalid."; - return false; - } - return true; - } default: { myError = "Translation builder :: method not implemented."; return false; @@ -106,12 +80,6 @@ void GeomAlgoAPI_Translation::build() aTrsf->SetTranslation(gp_Vec(myDx, myDy, myDz)); break; } - case BY_POINTS: { - const gp_Pnt& aStartPoint = myStartPoint->impl(); - const gp_Pnt& aEndPoint = myEndPoint->impl(); - aTrsf->SetTranslation(aStartPoint, aEndPoint); - break; - } default: { myError = "Translation builder :: method not supported"; return; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.h b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.h index 62252139b..91fc03c8f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.h @@ -47,15 +47,6 @@ public: double theDy, double theDz); - /// \brief Creates an object which is obtained from current object by moving it along a vector - /// defined by two points. - /// \param[in] theSourceShape the shape to be moved. - /// \param[in] theStartPoint the movement start point. - /// \param[in] theEndPoint the movement end point. - GEOMALGOAPI_EXPORT GeomAlgoAPI_Translation(std::shared_ptr theSourceShape, - std::shared_ptr theStartPoint, - std::shared_ptr theEndPoint); - /// Checks if data for the translation execution is OK. GEOMALGOAPI_EXPORT bool check(); @@ -70,8 +61,6 @@ private: double myDx; /// Movement dimension on X. double myDy; /// Movement dimension on Y. double myDz; /// Movement dimension on Z. - std::shared_ptr myStartPoint; /// Movement start point. - std::shared_ptr myEndPoint; /// Movement end point. }; #endif diff --git a/src/GeomAlgoAPI/Test/TestAPI_Translation.py b/src/GeomAlgoAPI/Test/TestAPI_Translation.py index b3933912e..0d405fbaf 100644 --- a/src/GeomAlgoAPI/Test/TestAPI_Translation.py +++ b/src/GeomAlgoAPI/Test/TestAPI_Translation.py @@ -33,12 +33,3 @@ try : except myExcept, ec: print ec.what() - -# Perfom a translation with two points. -try : - pnt1 = pnt(10.,0.,0.) - pnt2 = pnt(10.,15.,0.) - translation3 = shaperpy.makeTranslation(box,pnt1,pnt2) - -except myExcept, ec: - print ec.what()