From d9d6904264df238227607220a68dca38c537d8cb Mon Sep 17 00:00:00 2001 From: Clarisse Genrault Date: Wed, 23 Nov 2016 15:34:21 +0100 Subject: [PATCH] Revert "Revert "Add a new method for translation : translation by two points."" This reverts commit 596cc06a3cdc89783d15e893e7da4b6b882fb442. --- src/FeaturesAPI/FeaturesAPI_Translation.cpp | 42 +++++++ src/FeaturesAPI/FeaturesAPI_Translation.h | 34 +++++- src/FeaturesAPI/Test/APIParam_Translation.py | 8 ++ .../FeaturesPlugin_Translation.cpp | 106 ++++++++++++++++++ .../FeaturesPlugin_Translation.h | 24 ++++ src/FeaturesPlugin/extrusion_widget.xml | 30 ++--- .../icons/translation_2pt_32x32.png | Bin 0 -> 873 bytes src/FeaturesPlugin/translation_widget.xml | 31 +++++ src/GeomAPI/GeomAPI_Trsf.cpp | 7 ++ src/GeomAPI/GeomAPI_Trsf.h | 8 ++ src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp | 23 ++++ src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h | 10 ++ src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp | 32 ++++++ src/GeomAlgoAPI/GeomAlgoAPI_Translation.h | 11 ++ src/GeomAlgoAPI/Test/TestAPI_Translation.py | 9 ++ 15 files changed, 355 insertions(+), 20 deletions(-) create mode 100644 src/FeaturesPlugin/icons/translation_2pt_32x32.png diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.cpp b/src/FeaturesAPI/FeaturesAPI_Translation.cpp index bfcd5bdfc..ec05c3cef 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Translation.cpp @@ -46,6 +46,20 @@ 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() { @@ -85,6 +99,17 @@ 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 { @@ -109,6 +134,12 @@ 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; @@ -135,3 +166,14 @@ 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 91f3e7e14..11a7ddf8c 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.h +++ b/src/FeaturesAPI/FeaturesAPI_Translation.h @@ -39,15 +39,22 @@ 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); + 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); /// Destructor. FEATURESAPI_EXPORT virtual ~FeaturesAPI_Translation(); - INTERFACE_7(FeaturesPlugin_Translation::ID(), + INTERFACE_9(FeaturesPlugin_Translation::ID(), creationMethod, FeaturesPlugin_Translation::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, mainObjects, FeaturesPlugin_Translation::OBJECTS_LIST_ID(), @@ -61,7 +68,11 @@ public: dy, FeaturesPlugin_Translation::DY_ID(), ModelAPI_AttributeDouble, /** Dimension in Y */, dz, FeaturesPlugin_Translation::DZ_ID(), - ModelAPI_AttributeDouble, /** Dimension in Z */ + 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 */ ) /// Set main objects. @@ -79,6 +90,11 @@ 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; @@ -104,4 +120,12 @@ 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 53b176781..6795c25b8 100644 --- a/src/FeaturesAPI/Test/APIParam_Translation.py +++ b/src/FeaturesAPI/Test/APIParam_Translation.py @@ -32,4 +32,12 @@ 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 26b70c33b..4bd8aea03 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include //================================================================================================= @@ -46,6 +48,11 @@ 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()); } //================================================================================================= @@ -61,6 +68,10 @@ void FeaturesPlugin_Translation::execute() if (aMethodType == CREATION_METHOD_BY_DIMENSIONS()) { performTranslationByDimensions(); } + + if (aMethodType == CREATION_METHOD_BY_TWO_POINTS()) { + performTranslationByTwoPoints(); + } } //================================================================================================= @@ -241,6 +252,101 @@ 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 2e3cf314b..899a8e0f2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Translation.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Translation.h @@ -49,6 +49,13 @@ 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() { @@ -91,6 +98,20 @@ 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() { @@ -114,6 +135,9 @@ 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 25a388dff..dcb41eb2d 100644 --- a/src/FeaturesPlugin/extrusion_widget.xml +++ b/src/FeaturesPlugin/extrusion_widget.xml @@ -10,21 +10,6 @@ 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 new file mode 100644 index 0000000000000000000000000000000000000000..5e6860737c62103a82c2cfca7742d61882170dea GIT binary patch literal 873 zcmV-v1D5=WP)!+UeidCvd$JTK1&Bp`uf0!Ib11nvneN~GU-&6U6v0TJ*B3=6FOYXD&gn?QdU zqWN$6+JIFisOW)L;h8(a5ZlJv%p4(MC!dK2`p*^5hGL<4vT zxB)xxW-dJI)ma7Tgbtawr9>295m*|z25u9&M9u(*fd&P&e`@0B?3H-n_SEis>-BmI z&A<*|mV$PHXTall8pbPgVQFdq;1G?uiuLwzF!%SG9;c&aR?+}ct@iW2Kwm!aest3N z{d-=rjDG>t?XRtfl-yob`Oz?fNd<^?86{g!Ck#aA5bK@w9&fSh>7)s*bi z%gPG;2?LZA*xZSX{}X_m+~U%%NJ*!oWnR(%EEdZrzuz}9R-IuOHXtPta{!g-QR;NG z#Clgo)nsqO{{a6!K-;7NWM|EIlAg+@L;-#P$?yp@w)0|&00000NkvXXu0mjfi!g=N literal 0 HcmV?d00001 diff --git a/src/FeaturesPlugin/translation_widget.xml b/src/FeaturesPlugin/translation_widget.xml index 1e5556a93..a5b247dc6 100644 --- a/src/FeaturesPlugin/translation_widget.xml +++ b/src/FeaturesPlugin/translation_widget.xml @@ -62,5 +62,36 @@ 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 7983c91e6..322c14b90 100644 --- a/src/GeomAPI/GeomAPI_Trsf.cpp +++ b/src/GeomAPI/GeomAPI_Trsf.cpp @@ -40,6 +40,13 @@ 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 630c36fdd..ed97f4beb 100644 --- a/src/GeomAPI/GeomAPI_Trsf.h +++ b/src/GeomAPI/GeomAPI_Trsf.h @@ -13,6 +13,7 @@ #include class GeomAPI_Ax1; +class GeomAPI_Pnt; /**\class GeomAPI_Trsf * \ingroup DataModel @@ -43,6 +44,13 @@ 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 bd5f6015b..37ecc1296 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.cpp @@ -106,4 +106,27 @@ 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 f5769a35e..5e0ef0ba9 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_ShapeAPI.h @@ -59,6 +59,16 @@ 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 9fee16ebf..574b63d23 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.cpp @@ -36,6 +36,17 @@ 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() { @@ -58,6 +69,21 @@ 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; @@ -80,6 +106,12 @@ 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 91fc03c8f..62252139b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Translation.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Translation.h @@ -47,6 +47,15 @@ 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(); @@ -61,6 +70,8 @@ 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 0d405fbaf..b3933912e 100644 --- a/src/GeomAlgoAPI/Test/TestAPI_Translation.py +++ b/src/GeomAlgoAPI/Test/TestAPI_Translation.py @@ -33,3 +33,12 @@ 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() -- 2.39.2