From: lucasjerome Date: Wed, 20 Jan 2021 10:23:29 +0000 (+0100) Subject: Merge from branch CEA_2020_Lot2_1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=660836765158890a6d811c076be7dbbb3821a2e8;p=modules%2Fshaper.git Merge from branch CEA_2020_Lot2_1 --- diff --git a/src/FeaturesAPI/CMakeLists.txt b/src/FeaturesAPI/CMakeLists.txt index c6fbf821c..1f49fe01d 100644 --- a/src/FeaturesAPI/CMakeLists.txt +++ b/src/FeaturesAPI/CMakeLists.txt @@ -32,8 +32,6 @@ SET(PROJECT_HEADERS FeaturesAPI_Fillet.h FeaturesAPI_Intersection.h FeaturesAPI_Measurement.h - FeaturesAPI_GeometryCalculation.h - FeaturesAPI_BoundingBox.h FeaturesAPI_MultiRotation.h FeaturesAPI_MultiTranslation.h FeaturesAPI_Partition.h @@ -53,6 +51,8 @@ SET(PROJECT_HEADERS FeaturesAPI_Copy.h FeaturesAPI_ImportResult.h FeaturesAPI_Defeaturing.h + FeaturesAPI_GeometryCalculation.h + FeaturesAPI_BoundingBox.h ) SET(PROJECT_SOURCES @@ -67,8 +67,6 @@ SET(PROJECT_SOURCES FeaturesAPI_Fillet.cpp FeaturesAPI_Intersection.cpp FeaturesAPI_Measurement.cpp - FeaturesAPI_BoundingBox.cpp - FeaturesAPI_GeometryCalculation.cpp FeaturesAPI_MultiRotation.cpp FeaturesAPI_MultiTranslation.cpp FeaturesAPI_Partition.cpp @@ -88,6 +86,8 @@ SET(PROJECT_SOURCES FeaturesAPI_Copy.cpp FeaturesAPI_ImportResult.cpp FeaturesAPI_Defeaturing.cpp + FeaturesAPI_GeometryCalculation.cpp + FeaturesAPI_BoundingBox.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index 11a7cbcd1..6383bc4a8 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -63,7 +63,6 @@ %shared_ptr(FeaturesAPI_BooleanSmash) %shared_ptr(FeaturesAPI_BooleanFill) %shared_ptr(FeaturesAPI_Chamfer) -%shared_ptr(FeaturesAPI_BoundingBox) %shared_ptr(FeaturesAPI_Extrusion) %shared_ptr(FeaturesAPI_ExtrusionBoolean) %shared_ptr(FeaturesAPI_ExtrusionCut) @@ -93,6 +92,7 @@ %shared_ptr(FeaturesAPI_Copy) %shared_ptr(FeaturesAPI_ImportResult) %shared_ptr(FeaturesAPI_Defeaturing) +%shared_ptr(FeaturesAPI_BoundingBox) %typecheck(SWIG_TYPECHECK_POINTER) std::pair, bool>, const std::pair, bool> & { @@ -212,8 +212,6 @@ %include "FeaturesAPI_Fillet.h" %include "FeaturesAPI_Intersection.h" %include "FeaturesAPI_Measurement.h" -%include "FeaturesAPI_GeometryCalculation.h" -%include "FeaturesAPI_BoundingBox.h" %include "FeaturesAPI_MultiRotation.h" %include "FeaturesAPI_MultiTranslation.h" %include "FeaturesAPI_Partition.h" @@ -232,3 +230,5 @@ %include "FeaturesAPI_RemoveResults.h" %include "FeaturesAPI_Copy.h" %include "FeaturesAPI_ImportResult.h" +%include "FeaturesAPI_GeometryCalculation.h" +%include "FeaturesAPI_BoundingBox.h" diff --git a/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp b/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp index 19191a09b..d72009d39 100644 --- a/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp +++ b/src/FeaturesAPI/FeaturesAPI_BoundingBox.cpp @@ -29,8 +29,8 @@ #include //================================================================================================= -FeaturesAPI_BoundingBox:: - FeaturesAPI_BoundingBox(const std::shared_ptr& theFeature) +FeaturesAPI_BoundingBox::FeaturesAPI_BoundingBox( + const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); @@ -39,11 +39,11 @@ FeaturesAPI_BoundingBox:: //================================================================================================= FeaturesAPI_BoundingBox::FeaturesAPI_BoundingBox( const std::shared_ptr& theFeature, - const ModelHighAPI_Selection& theobject) + const ModelHighAPI_Selection& theObject) :ModelHighAPI_Interface(theFeature) { if (initialize()) { - fillAttribute(theobject, myobjectselected); + fillAttribute(theObject, myobjectSelected); execute(); } } @@ -60,7 +60,7 @@ void FeaturesAPI_BoundingBox::dump(ModelHighAPI_Dumper& theDumper) const const std::string& aDocName = theDumper.name(aBase->document()); AttributeSelectionPtr anAttrObject; - anAttrObject = aBase->selection(FeaturesPlugin_CreateBoundingBox::OBJECTS_LIST_ID()); + anAttrObject = aBase->selection(FeaturesPlugin_CreateBoundingBox::OBJECT_ID()); theDumper << aBase << " = model.getBoundingBox(" << aDocName << ", " << anAttrObject; @@ -69,7 +69,7 @@ void FeaturesAPI_BoundingBox::dump(ModelHighAPI_Dumper& theDumper) const //================================================================================================= BoundingBoxPtr getBoundingBox(const std::shared_ptr& thePart, - const ModelHighAPI_Selection& theobject) + const ModelHighAPI_Selection& theObject) { FeaturePtr aFeature = @@ -77,7 +77,7 @@ BoundingBoxPtr getBoundingBox(const std::shared_ptr& thePart, BoundingBoxPtr aBoundingBox; - aBoundingBox.reset(new FeaturesAPI_BoundingBox(aFeature, theobject)); + aBoundingBox.reset(new FeaturesAPI_BoundingBox(aFeature, theObject)); return aBoundingBox; } diff --git a/src/FeaturesAPI/FeaturesAPI_BoundingBox.h b/src/FeaturesAPI/FeaturesAPI_BoundingBox.h index efa82195b..cc45aa4af 100644 --- a/src/FeaturesAPI/FeaturesAPI_BoundingBox.h +++ b/src/FeaturesAPI/FeaturesAPI_BoundingBox.h @@ -44,16 +44,15 @@ public: FEATURESAPI_EXPORT explicit FeaturesAPI_BoundingBox(const std::shared_ptr& theFeature, - const ModelHighAPI_Selection& theobject); + const ModelHighAPI_Selection& theObject); /// Destructor. FEATURESAPI_EXPORT virtual ~FeaturesAPI_BoundingBox(); - INTERFACE_1(FeaturesPlugin_CreateBoundingBox::ID(), - objectselected, FeaturesPlugin_CreateBoundingBox::OBJECTS_LIST_ID(), - ModelAPI_AttributeSelection, - /** object selected*/) + INTERFACE_1(FeaturesPlugin_CreateBoundingBox::ID(), + objectSelected, FeaturesPlugin_CreateBoundingBox::OBJECT_ID(), + ModelAPI_AttributeSelection, /** object selected*/) /// Dump wrapped feature FEATURESAPI_EXPORT @@ -70,6 +69,6 @@ typedef std::shared_ptr BoundingBoxPtr; /// \param theobject the object selected FEATURESAPI_EXPORT BoundingBoxPtr getBoundingBox(const std::shared_ptr& thePart, - const ModelHighAPI_Selection& theobject); + const ModelHighAPI_Selection& theObject); #endif // FeaturesAPI_BoundingBox_H_ diff --git a/src/FeaturesAPI/FeaturesAPI_swig.h b/src/FeaturesAPI/FeaturesAPI_swig.h index 89d415e98..40ac1c47b 100644 --- a/src/FeaturesAPI/FeaturesAPI_swig.h +++ b/src/FeaturesAPI/FeaturesAPI_swig.h @@ -35,8 +35,6 @@ #include "FeaturesAPI_Fillet.h" #include "FeaturesAPI_Intersection.h" #include "FeaturesAPI_Measurement.h" - #include "FeaturesAPI_GeometryCalculation.h" - #include "FeaturesAPI_BoundingBox.h" #include "FeaturesAPI_MultiRotation.h" #include "FeaturesAPI_MultiTranslation.h" #include "FeaturesAPI_Partition.h" @@ -55,5 +53,7 @@ #include "FeaturesAPI_RemoveResults.h" #include "FeaturesAPI_Copy.h" #include "FeaturesAPI_ImportResult.h" + #include "FeaturesAPI_GeometryCalculation.h" + #include "FeaturesAPI_BoundingBox.h" #endif // FeaturesAPI_swig_H_ diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index ea702997e..852cd5b35 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -19,15 +19,6 @@ INCLUDE(Common) INCLUDE(UnitTest) -INCLUDE(UseQtExt) - -# additional include directories -INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/GeomDataAPI - ${PROJECT_SOURCE_DIR}/src/Locale - ${QT_INCLUDES}) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS(${QT_DEFINITIONS}) SET(PROJECT_HEADERS @@ -69,10 +60,6 @@ SET(PROJECT_HEADERS FeaturesPlugin_Fillet.h FeaturesPlugin_Fillet1D.h FeaturesPlugin_Measurement.h - FeaturesPlugin_GeometryCalculation.h - FeaturesPlugin_BoundingBox.h - FeaturesPlugin_CreateBoundingBox.h - FeaturesPlugin_CommonBoundingBox.h FeaturesPlugin_FusionFaces.h FeaturesPlugin_RemoveResults.h FeaturesPlugin_Chamfer.h @@ -80,6 +67,10 @@ SET(PROJECT_HEADERS FeaturesPlugin_ImportResult.h FeaturesPlugin_Defeaturing.h FeaturesPlugin_VersionedChFi.h + FeaturesPlugin_GeometryCalculation.h + FeaturesPlugin_BoundingBox.h + FeaturesPlugin_CommonBoundingBox.h + FeaturesPlugin_CreateBoundingBox.h ) SET(PROJECT_SOURCES @@ -120,10 +111,6 @@ SET(PROJECT_SOURCES FeaturesPlugin_Fillet.cpp FeaturesPlugin_Fillet1D.cpp FeaturesPlugin_Measurement.cpp - FeaturesPlugin_GeometryCalculation.cpp - FeaturesPlugin_BoundingBox.cpp - FeaturesPlugin_CreateBoundingBox.cpp - FeaturesPlugin_CommonBoundingBox.cpp FeaturesPlugin_FusionFaces.cpp FeaturesPlugin_RemoveResults.cpp FeaturesPlugin_Chamfer.cpp @@ -131,6 +118,10 @@ SET(PROJECT_SOURCES FeaturesPlugin_ImportResult.cpp FeaturesPlugin_Defeaturing.cpp FeaturesPlugin_VersionedChFi.cpp + FeaturesPlugin_GeometryCalculation.cpp + FeaturesPlugin_BoundingBox.cpp + FeaturesPlugin_CommonBoundingBox.cpp + FeaturesPlugin_CreateBoundingBox.cpp ) SET(XML_RESOURCES @@ -162,14 +153,14 @@ SET(XML_RESOURCES fillet_widget.xml fillet1d_widget.xml measurement_widget.xml - geometry_calculation_widget.xml - Bounding_Box_widget.xml - Create_Bounding_Box_widget.xml fusion_faces_widget.xml chamfer_widget.xml copy_widget.xml import_result_widget.xml defeaturing_widget.xml + geometry_calculation_widget.xml + bounding_box_widget.xml + create_bounding_box_widget.xml ) SET(TEXT_RESOURCES @@ -204,11 +195,7 @@ SET(PROJECT_LIBRARIES ) ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS) -ADD_LIBRARY(FeaturesPlugin MODULE - ${PROJECT_SOURCES} - ${PROJECT_HEADERS} - ${XML_RESOURCES} - ${TEXT_RESOURCES}) +ADD_LIBRARY(FeaturesPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES}) TARGET_LINK_LIBRARIES(FeaturesPlugin ${PROJECT_LIBRARIES}) INSTALL(TARGETS FeaturesPlugin DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES}) @@ -708,6 +695,12 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillet1D_Wire_3.py TestFillet1D_Wire_4.py TestFillet1D_Wire_5.py + Test19931.py + Test20027.py + Test20245_1.py + Test20245_2.py + Test20245_3.py + Test20247.py TestGeometryCalculation.py TestBoundingBox.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp index 323c6fa9c..6e30b6f54 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.cpp @@ -45,22 +45,23 @@ FeaturesPlugin_BoundingBox::FeaturesPlugin_BoundingBox() void FeaturesPlugin_BoundingBox::initAttributes() { // attribute for object selected - data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + // attributes for result message and values - data()->addAttribute(X_MIN_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_MIN_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_MIN_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(X_MAX_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_MAX_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_MAX_COOD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(X_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(X_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(CREATEBOX_ID(), ModelAPI_AttributeBoolean::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MIN_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COOD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COORD_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATEBOX_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), RESULT_VALUES_ID()); @@ -94,7 +95,7 @@ void FeaturesPlugin_BoundingBox::execute() //================================================================================================= void FeaturesPlugin_BoundingBox::attributeChanged(const std::string& theID) { - if (theID == OBJECTS_LIST_ID()) { + if (theID == OBJECT_ID()) { if (myCreateFeature.get()) updateBox(); } @@ -109,7 +110,7 @@ AttributePtr FeaturesPlugin_BoundingBox::attributResultValues() //================================================================================================= void FeaturesPlugin_BoundingBox::updateValues() { - AttributeSelectionPtr aSelection = selection(OBJECTS_LIST_ID()); + AttributeSelectionPtr aSelection = selection(OBJECT_ID()); if (aSelection->isInitialized()) { AttributeDoubleArrayPtr aValues = std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); @@ -119,12 +120,14 @@ void FeaturesPlugin_BoundingBox::updateValues() std::stringstream streamxmax; std::stringstream streamymax; std::stringstream streamzmax; + GeomShapePtr aShape; if (aSelection && aSelection->isInitialized()) { aShape = aSelection->value(); if (!aShape && aSelection->context()) aShape = aSelection->context()->shape(); } + if (aShape && !aShape->isEqual(myShape)) { double aXmin, aXmax, aYmin,aYmax,aZmin,aZmax; std::string aError; @@ -135,6 +138,7 @@ void FeaturesPlugin_BoundingBox::updateValues() aZmin,aZmax, aError)) setError("Error in bounding box calculation :" + aError); + myShape = aShape; streamxmin << std::setprecision(14) << aXmin; aValues->setValue(0, aXmin); @@ -148,12 +152,12 @@ void FeaturesPlugin_BoundingBox::updateValues() aValues->setValue(4, aZmin); streamzmax << std::setprecision(14) << aZmax; aValues->setValue(5, aZmax); - string(X_MIN_COOD_ID() )->setValue( "X = " + streamxmin.str() ); - string(Y_MIN_COOD_ID() )->setValue( "Y = " + streamymin.str() ); - string(Z_MIN_COOD_ID() )->setValue( "Z = " + streamzmin.str() ); - string(X_MAX_COOD_ID() )->setValue( "X = " + streamxmax.str() ); - string(Y_MAX_COOD_ID() )->setValue( "Y = " + streamymax.str() ); - string(Z_MAX_COOD_ID() )->setValue( "Z = " + streamzmax.str() ); + string(X_MIN_COORD_ID() )->setValue( "X = " + streamxmin.str() ); + string(Y_MIN_COORD_ID() )->setValue( "Y = " + streamymin.str() ); + string(Z_MIN_COORD_ID() )->setValue( "Z = " + streamzmin.str() ); + string(X_MAX_COORD_ID() )->setValue( "X = " + streamxmax.str() ); + string(Y_MAX_COORD_ID() )->setValue( "Y = " + streamymax.str() ); + string(Z_MAX_COORD_ID() )->setValue( "Z = " + streamzmax.str() ); } } } @@ -173,19 +177,19 @@ void FeaturesPlugin_BoundingBox::createBox() //================================================================================================= void FeaturesPlugin_BoundingBox::updateBox() { - myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(false); - myCreateFeature->selection(FeaturesPlugin_CreateBoundingBox::OBJECTS_LIST_ID()) - ->setValue( selection(OBJECTS_LIST_ID())->context(), - selection(OBJECTS_LIST_ID())->value() ); - - AttributeDoubleArrayPtr aValuesFeatures = - std::dynamic_pointer_cast - (myCreateFeature->attribute(RESULT_VALUES_ID())); - AttributeDoubleArrayPtr aValues = - std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); - for (int anI=0; anI < 6; anI++) - aValuesFeatures->setValue(anI,aValues->value(anI)); - - myCreateFeature->execute(); - myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(true); + myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(false); + myCreateFeature->selection(FeaturesPlugin_CreateBoundingBox::OBJECT_ID()) + ->setValue(selection(OBJECT_ID())->context(), + selection(OBJECT_ID())->value()); + + AttributeDoubleArrayPtr aValuesFeatures = + std::dynamic_pointer_cast + (myCreateFeature->attribute(RESULT_VALUES_ID())); + AttributeDoubleArrayPtr aValues = + std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); + for (int anI=0; anI < 6; anI++) + aValuesFeatures->setValue(anI,aValues->value(anI)); + + myCreateFeature->execute(); + myCreateFeature->boolean(FeaturesPlugin_CreateBoundingBox::COMPUTE_ID())->setValue(true); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h index 509df64e6..ef12a579f 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h +++ b/src/FeaturesPlugin/FeaturesPlugin_BoundingBox.h @@ -29,81 +29,82 @@ class FeaturesPlugin_BoundingBox : public FeaturesPlugin_CommonBoundingBox { public: - inline static const std::string& ID() + /// Bounding box macro kind. + inline static const std::string& ID() { static const std::string MY_ID("BoundingBoxMacro"); return MY_ID; } - /// \return the kind of a feature. - virtual const std::string& getKind() - { - return ID(); - } - /// Attribute name for object selected. - inline static const std::string& OBJECTS_LIST_ID() + inline static const std::string& OBJECT_ID() { - static const std::string MY_OBJECTS_LIST_ID("main_object"); - return MY_OBJECTS_LIST_ID; + static const std::string MY_OBJECT_ID("main_object"); + return MY_OBJECT_ID; } /// Attribute name for x coodinate. - inline static const std::string& X_MIN_COOD_ID() + inline static const std::string& X_MIN_COORD_ID() { - static const std::string MY_X_MIN_COOD_ID("xmincoordinate"); - return MY_X_MIN_COOD_ID; + static const std::string MY_X_MIN_COORD_ID("xmincoordinate"); + return MY_X_MIN_COORD_ID; } /// Attribute name for y coodinate. - inline static const std::string& Y_MIN_COOD_ID() + inline static const std::string& Y_MIN_COORD_ID() { - static const std::string MY_Y_MIN_COOD_ID("ymincoordinate"); - return MY_Y_MIN_COOD_ID; + static const std::string MY_Y_MIN_COORD_ID("ymincoordinate"); + return MY_Y_MIN_COORD_ID; } /// Attribute name for z coodinate. - inline static const std::string& Z_MIN_COOD_ID() + inline static const std::string& Z_MIN_COORD_ID() { - static const std::string MY_Z_MIN_COOD_ID("zmincoordinate"); - return MY_Z_MIN_COOD_ID; + static const std::string MY_Z_MIN_COORD_ID("zmincoordinate"); + return MY_Z_MIN_COORD_ID; } /// Attribute name for x max coodinate. - inline static const std::string& X_MAX_COOD_ID() + inline static const std::string& X_MAX_COORD_ID() { - static const std::string MY_X_MAX_COOD_ID("xmaxcoordinate"); - return MY_X_MAX_COOD_ID; + static const std::string MY_X_MAX_COORD_ID("xmaxcoordinate"); + return MY_X_MAX_COORD_ID; } /// Attribute name for y max coodinate. - inline static const std::string& Y_MAX_COOD_ID() + inline static const std::string& Y_MAX_COORD_ID() { - static const std::string MY_Y_MAX_COOOD_ID("ymaxcoordinate"); - return MY_Y_MAX_COOOD_ID; + static const std::string MY_Y_MAX_COORD_ID("ymaxcoordinate"); + return MY_Y_MAX_COORD_ID; } /// Attribute name for z max coodinate. - inline static const std::string& Z_MAX_COOD_ID() + inline static const std::string& Z_MAX_COORD_ID() { - static const std::string MY_Z_MAX_COOD_ID("zmaxcoordinate"); - return MY_Z_MAX_COOD_ID; + static const std::string MY_Z_MAX_COORD_ID("zmaxcoordinate"); + return MY_Z_MAX_COORD_ID; } - /// Attribute name for checkbox create box. + /// Attribute name for checkbox create box. inline static const std::string& CREATEBOX_ID() { static const std::string MY_CREATEBOX_ID("createbox"); return MY_CREATEBOX_ID; } - /// Attribute name for values of result. + /// Attribute name for values of result. inline static const std::string& RESULT_VALUES_ID() { static const std::string MY_RESULT_VALUES_ID("result_values"); return MY_RESULT_VALUES_ID; } + /// \return the kind of a feature. + virtual const std::string& getKind() + { + return ID(); + } + /// Performs the algorithm and stores results it in the data structure. FEATURESPLUGIN_EXPORT virtual void execute(); @@ -120,7 +121,7 @@ public: /// Use plugin manager for features creation FeaturesPlugin_BoundingBox(); - private: +private: /// Return Attribut values of result. virtual AttributePtr attributResultValues(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp index 63047c5b8..9a3784aa8 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.cpp @@ -113,4 +113,3 @@ void FeaturesPlugin_CommonBoundingBox::loadNamingDS(std::shared_ptrgenerated((*it).second, (*it).first); } } - diff --git a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h index 9bd2d79e2..c28392d47 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CommonBoundingBox.h @@ -37,14 +37,13 @@ class FeaturesPlugin_CommonBoundingBox : public ModelAPI_Feature { public: - /// Performs the algorithm and stores results it in the data structure. FEATURESPLUGIN_EXPORT virtual void execute(){}; /// Return Attribut values of result. virtual AttributePtr attributResultValues() = 0; - protected: +protected: FeaturesPlugin_CommonBoundingBox() {} /// Create box with two points diff --git a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp b/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp index 9baee5543..f59d98b94 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.cpp @@ -45,36 +45,36 @@ FeaturesPlugin_CreateBoundingBox::FeaturesPlugin_CreateBoundingBox() void FeaturesPlugin_CreateBoundingBox::initAttributes() { // attribute for object selected - data()->addAttribute(OBJECTS_LIST_ID(), ModelAPI_AttributeSelection::typeId()); + data()->addAttribute(OBJECT_ID(), ModelAPI_AttributeSelection::typeId()); + // attributes for result message and values - data()->addAttribute(X_MIN_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_MIN_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_MIN_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(X_MAX_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Y_MAX_COOD_ID(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(Z_MAX_COOD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(X_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_MIN_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(X_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Y_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(Z_MAX_COORD_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(COMPUTE_ID(), ModelAPI_AttributeBoolean::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MIN_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COOD_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COOD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MIN_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), X_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Y_MAX_COORD_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), Z_MAX_COORD_ID()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), COMPUTE_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECTS_LIST_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), OBJECT_ID()); data()->addAttribute(RESULT_VALUES_ID(), ModelAPI_AttributeDoubleArray::typeId()); data()->realArray(RESULT_VALUES_ID())->setSize(6); data()->boolean(COMPUTE_ID())->setValue(true); - } //================================================================================================= void FeaturesPlugin_CreateBoundingBox::execute() { - updateValues(); - createBoxByTwoPoints(); + updateValues(); + createBoxByTwoPoints(); } //================================================================================================= @@ -85,7 +85,7 @@ void FeaturesPlugin_CreateBoundingBox::attributeChanged(const std::string& theID //================================================================================================= void FeaturesPlugin_CreateBoundingBox::updateValues() { - AttributeSelectionPtr aSelection = selection(OBJECTS_LIST_ID()); + AttributeSelectionPtr aSelection = selection(OBJECT_ID()); AttributeDoubleArrayPtr aValues = std::dynamic_pointer_cast(attribute(RESULT_VALUES_ID())); @@ -96,12 +96,14 @@ void FeaturesPlugin_CreateBoundingBox::updateValues() std::stringstream streamxmax; std::stringstream streamymax; std::stringstream streamzmax; + GeomShapePtr aShape; if (aSelection && aSelection->isInitialized()) { aShape = aSelection->value(); if (!aShape && aSelection->context()) aShape = aSelection->context()->shape(); } + AttributeBooleanPtr anIsCompute = boolean(COMPUTE_ID()); if (!anIsCompute->value()) { myShape = aShape; @@ -139,12 +141,13 @@ void FeaturesPlugin_CreateBoundingBox::updateValues() streamzmin << std::setprecision(14) << aValues->value(4); streamzmax << std::setprecision(14) << aValues->value(5); } - string(X_MIN_COOD_ID() )->setValue( "X = " + streamxmin.str() ); - string(Y_MIN_COOD_ID() )->setValue( "Y = " + streamymin.str() ); - string(Z_MIN_COOD_ID() )->setValue( "Z = " + streamzmin.str() ); - string(X_MAX_COOD_ID() )->setValue( "X = " + streamxmax.str() ); - string(Y_MAX_COOD_ID() )->setValue( "Y = " + streamymax.str() ); - string(Z_MAX_COOD_ID() )->setValue( "Z = " + streamzmax.str() ); + + string(X_MIN_COORD_ID() )->setValue( "X = " + streamxmin.str() ); + string(Y_MIN_COORD_ID() )->setValue( "Y = " + streamymin.str() ); + string(Z_MIN_COORD_ID() )->setValue( "Z = " + streamzmin.str() ); + string(X_MAX_COORD_ID() )->setValue( "X = " + streamxmax.str() ); + string(Y_MAX_COORD_ID() )->setValue( "Y = " + streamymax.str() ); + string(Z_MAX_COORD_ID() )->setValue( "Z = " + streamzmax.str() ); } } diff --git a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h b/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h index fd942b9f4..6884ac0db 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h +++ b/src/FeaturesPlugin/FeaturesPlugin_CreateBoundingBox.h @@ -29,65 +29,60 @@ class FeaturesPlugin_CreateBoundingBox : public FeaturesPlugin_CommonBoundingBox { public: - inline static const std::string& ID() + /// Bounding box kind. + inline static const std::string& ID() { static const std::string MY_ID("BoundingBox"); return MY_ID; } - /// \return the kind of a feature. - virtual const std::string& getKind() - { - return ID(); - } - /// Attribute name for object selected. - inline static const std::string& OBJECTS_LIST_ID() + inline static const std::string& OBJECT_ID() { - static const std::string MY_OBJECTS_LIST_ID("main_object"); - return MY_OBJECTS_LIST_ID; + static const std::string MY_OBJECT_ID("main_object"); + return MY_OBJECT_ID; } /// Attribute name for x coodinate. - inline static const std::string& X_MIN_COOD_ID() + inline static const std::string& X_MIN_COORD_ID() { - static const std::string MY_X_MIN_COOD_ID("xmincoordinate"); - return MY_X_MIN_COOD_ID; + static const std::string MY_X_MIN_COORD_ID("xmincoordinate"); + return MY_X_MIN_COORD_ID; } /// Attribute name for y coodinate. - inline static const std::string& Y_MIN_COOD_ID() + inline static const std::string& Y_MIN_COORD_ID() { - static const std::string MY_Y_MIN_COOD_ID("ymincoordinate"); - return MY_Y_MIN_COOD_ID; + static const std::string MY_Y_MIN_COORD_ID("ymincoordinate"); + return MY_Y_MIN_COORD_ID; } /// Attribute name for z coodinate. - inline static const std::string& Z_MIN_COOD_ID() + inline static const std::string& Z_MIN_COORD_ID() { - static const std::string MY_Z_MIN_COOD_ID("zmincoordinate"); - return MY_Z_MIN_COOD_ID; + static const std::string MY_Z_MIN_COORD_ID("zmincoordinate"); + return MY_Z_MIN_COORD_ID; } - /// Attribute name for x max coodinate. - inline static const std::string& X_MAX_COOD_ID() + /// Attribute name for x max coodinate. + inline static const std::string& X_MAX_COORD_ID() { - static const std::string MY_X_MAX_COOD_ID("xmaxcoordinate"); - return MY_X_MAX_COOD_ID; + static const std::string MY_X_MAX_COORD_ID("xmaxcoordinate"); + return MY_X_MAX_COORD_ID; } /// Attribute name for y max coodinate. - inline static const std::string& Y_MAX_COOD_ID() + inline static const std::string& Y_MAX_COORD_ID() { - static const std::string MY_Y_MAX_COOOD_ID("ymaxcoordinate"); - return MY_Y_MAX_COOOD_ID; + static const std::string MY_Y_MAX_COORD_ID("ymaxcoordinate"); + return MY_Y_MAX_COORD_ID; } /// Attribute name for z max coodinate. - inline static const std::string& Z_MAX_COOD_ID() + inline static const std::string& Z_MAX_COORD_ID() { - static const std::string MY_Z_MAX_COOD_ID("zmaxcoordinate"); - return MY_Z_MAX_COOD_ID; + static const std::string MY_Z_MAX_COORD_ID("zmaxcoordinate"); + return MY_Z_MAX_COORD_ID; } /// Attribute name for values of result. @@ -104,6 +99,12 @@ public: return MY_COMPUTE_ID; } + /// \return the kind of a feature. + virtual const std::string& getKind() + { + return ID(); + } + /// Performs the algorithm and stores results it in the data structure. FEATURESPLUGIN_EXPORT virtual void execute(); @@ -120,7 +121,7 @@ public: /// Use plugin manager for features creation FeaturesPlugin_CreateBoundingBox(); - private: +private: /// Update values displayed. void updateValues(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index 8aeaee966..d716716d2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -24,18 +24,18 @@ #include #include #include +#include #include +#include #include #include #include #include #include #include +#include #include #include -#include -#include -#include #include #include #include @@ -189,12 +189,7 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID) } else if (theFeatureID == FeaturesPlugin_Fillet1D::ID()) { return FeaturePtr(new FeaturesPlugin_Fillet1D); } else if (theFeatureID == FeaturesPlugin_Measurement::ID()) { - } else if (theFeatureID == FeaturesPlugin_GeometryCalculation::ID()) { - return FeaturePtr(new FeaturesPlugin_GeometryCalculation); - } else if (theFeatureID == FeaturesPlugin_BoundingBox::ID()) { - return FeaturePtr(new FeaturesPlugin_BoundingBox); - } else if (theFeatureID == FeaturesPlugin_CreateBoundingBox::ID()) { - return FeaturePtr(new FeaturesPlugin_CreateBoundingBox); + return FeaturePtr(new FeaturesPlugin_Measurement); } else if (theFeatureID == FeaturesPlugin_RemoveResults::ID()) { return FeaturePtr(new FeaturesPlugin_RemoveResults); } else if (theFeatureID == FeaturesPlugin_Chamfer::ID()) { @@ -205,6 +200,12 @@ FeaturePtr FeaturesPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new FeaturesPlugin_ImportResult); } else if (theFeatureID == FeaturesPlugin_Defeaturing::ID()) { return FeaturePtr(new FeaturesPlugin_Defeaturing); + } else if (theFeatureID == FeaturesPlugin_GeometryCalculation::ID()) { + return FeaturePtr(new FeaturesPlugin_GeometryCalculation); + } else if (theFeatureID == FeaturesPlugin_BoundingBox::ID()) { + return FeaturePtr(new FeaturesPlugin_BoundingBox); + } else if (theFeatureID == FeaturesPlugin_CreateBoundingBox::ID()) { + return FeaturePtr(new FeaturesPlugin_CreateBoundingBox); } diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts index 46fd40148..725c925ce 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts @@ -115,14 +115,6 @@ Angular Copy Copie angulaire - - Bounding box - Boite englobante - - - Geometry calculation - Calcul de la géométrie - Linear copy Copie linéaire @@ -131,6 +123,14 @@ Measurement Mesure + + Geometry calculation + Calcul de la géométrie + + + Bounding box + Boîte englobante + Placement Placement @@ -148,30 +148,31 @@ Translation - + BoundingBox BoundingBox - Boite englobante + Boîte englobante Create box - Créer la boite + Créer la boîte BoundingBoxMacro BoundingBox - Boite englobante + Boîte englobante Create box - Créer la boite + Créer la boîte + Chamfer @@ -553,8 +554,8 @@ Extrusion:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -727,8 +728,8 @@ ExtrusionCut:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -911,8 +912,8 @@ ExtrusionFuse:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -1716,8 +1717,8 @@ Revolution:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -1897,8 +1898,8 @@ RevolutionCut:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -2059,8 +2060,8 @@ RevolutionFuse:sketch - Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edge/vertices. Extrusion will be filled by it. - Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arête / sommets. L'extrusion sera remplie par elle. + Select:<br /> 1. Planar face of non-sketch object or a plane. Sketch creation will be started.<br /> 2. An existing sketch face or contour. Extrusion will be filled by it.<br /> 3. An existing result shape of kind: wires/edges/vertices. Extrusion will be filled by it. + Sélectionnez : <br /> 1. Face plane d'un objet non esquissé ou d'un plan. La création de l'esquisse sera lancée. <br /> 2. Une face ou un contour d'esquisse existant. L'extrusion sera remplie par elle. <br /> 3. Une forme de résultat existante de type: contours / arêtes / sommets. L'extrusion sera remplie par elle. @@ -4358,73 +4359,7 @@ Pas pour la direction angulaire - - - BoundingBoxMacro - - Bounding box - Boîte englobante - - - - BoundingBoxMacro:main_object - - Object - Objet - - - - BoundingBoxMacro:createbox - - Create box - Créer la boite - - - - BoundingBox - - Bounding box - Boîte englobante - - - - BoundingBox:main_object - - Object - Objet - - - - - GeometryCalculation - - Geometry calculation - Calcul de la géometrie - - - - GeometryCalculation:main_object - - Object - Objet - - - - GeometryCalculation - - Length = - Longueur = - - - Area = - Surface = - - - Volume = - Volume = - - LinearCopy @@ -4552,6 +4487,74 @@ + + + BoundingBoxMacro + + Bounding box + Boîte englobante + + + + BoundingBoxMacro:main_object + + Object + Objet + + + + BoundingBoxMacro:createbox + + Create box + Créer la boîte + + + + BoundingBox + + Bounding box + Boîte englobante + + + + BoundingBox:main_object + + Object + Objet + + + + + + GeometryCalculation + + Geometry calculation + Calcul de la géometrie + + + + GeometryCalculation:main_object + + Object + Objet + + + + GeometryCalculation + + Length = + Longueur = + + + Area = + Surface = + + + Volume = + Volume = + + + Measurement diff --git a/src/FeaturesPlugin/bounding_box_widget.xml b/src/FeaturesPlugin/bounding_box_widget.xml new file mode 100644 index 000000000..199c2a111 --- /dev/null +++ b/src/FeaturesPlugin/bounding_box_widget.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + diff --git a/src/FeaturesPlugin/create_bounding_box_widget.xml b/src/FeaturesPlugin/create_bounding_box_widget.xml new file mode 100644 index 000000000..39e494f92 --- /dev/null +++ b/src/FeaturesPlugin/create_bounding_box_widget.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/src/FeaturesPlugin/doc/FeaturesPlugin.rst b/src/FeaturesPlugin/doc/FeaturesPlugin.rst index 5304756f4..18c839db8 100644 --- a/src/FeaturesPlugin/doc/FeaturesPlugin.rst +++ b/src/FeaturesPlugin/doc/FeaturesPlugin.rst @@ -12,6 +12,7 @@ Features plug-in provides a set of common topological operations. It implements booleanOperations.rst angularCopyFeature.rst + boundingBoxFeature.rst chamferFeature.rst copyFeature.rst defeaturingFeature.rst @@ -21,11 +22,10 @@ Features plug-in provides a set of common topological operations. It implements fillet1dFeature.rst filletFeature.rst fuseFeatureFaces.rst + geometryCalculationFeature.rst importResultFeature.rst linearCopyFeature.rst measurementFeature.rst - geometryCalculationFeature.rst - boundingBoxFeature.rst pipeFeature.rst placementFeature.rst recoverFeature.rst diff --git a/src/FeaturesPlugin/doc/TUI_BoundingBoxFeature.rst b/src/FeaturesPlugin/doc/TUI_BoundingBoxFeature.rst deleted file mode 100644 index 6a9497253..000000000 --- a/src/FeaturesPlugin/doc/TUI_BoundingBoxFeature.rst +++ /dev/null @@ -1,11 +0,0 @@ - - .. _tui_create_Bounding_Box: - -Create bounding box -=================== - -.. literalinclude:: examples/createBoundingBox.py - :linenos: - :language: python - -:download:`Download this script ` diff --git a/src/FeaturesPlugin/doc/TUI_boundingBoxFeature.rst b/src/FeaturesPlugin/doc/TUI_boundingBoxFeature.rst new file mode 100644 index 000000000..bb73b2234 --- /dev/null +++ b/src/FeaturesPlugin/doc/TUI_boundingBoxFeature.rst @@ -0,0 +1,11 @@ + + .. _tui_create_Bounding_Box: + +Create bounding box +=================== + +.. literalinclude:: examples/create_bounding_box.py + :linenos: + :language: python + +:download:`Download this script ` diff --git a/src/FeaturesPlugin/doc/boundingBoxFeature.rst b/src/FeaturesPlugin/doc/boundingBoxFeature.rst index 3cab6c3db..9a1222d73 100644 --- a/src/FeaturesPlugin/doc/boundingBoxFeature.rst +++ b/src/FeaturesPlugin/doc/boundingBoxFeature.rst @@ -43,9 +43,9 @@ Result Result of **Bounding box** where **Create box** is checked. -.. figure:: images/BoundinBoxResult.png +.. figure:: images/BoundingBoxResult.png :align: center Object selected -**See Also** a sample TUI Script of :ref:`tui_create_Bounding_Box` operation. \ No newline at end of file +**See Also** a sample TUI Script of :ref:`tui_create_Bounding_Box` operation. diff --git a/src/FeaturesPlugin/doc/examples/createBoundingBox.py b/src/FeaturesPlugin/doc/examples/createBoundingBox.py deleted file mode 100644 index 69143fe8d..000000000 --- a/src/FeaturesPlugin/doc/examples/createBoundingBox.py +++ /dev/null @@ -1,13 +0,0 @@ -from salome.shaper import model -import os - -model.begin() -file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","screw.step") -partSet = model.moduleDocument() -Part_1 = model.addPart(partSet) -Part_1_doc = Part_1.document() -Import_1 = model.addImport(Part_1_doc,file_path) -### Create BoundingBox -BoundingBox_1 = model.getBoundingBox(Part_1_doc, model.selection("SOLID", "screw_1")) -model.do() -model.end() diff --git a/src/FeaturesPlugin/doc/examples/create_bounding_box.py b/src/FeaturesPlugin/doc/examples/create_bounding_box.py new file mode 100644 index 000000000..d904006ae --- /dev/null +++ b/src/FeaturesPlugin/doc/examples/create_bounding_box.py @@ -0,0 +1,13 @@ +from salome.shaper import model +import os + +model.begin() +file_path = os.path.join(os.getenv("DATA_DIR"),"Shapes","Step","screw.step") +partSet = model.moduleDocument() +Part_1 = model.addPart(partSet) +Part_1_doc = Part_1.document() +Import_1 = model.addImport(Part_1_doc,file_path) +model.do() +### Create BoundingBox +BoundingBox_1 = model.getBoundingBox(Part_1_doc, model.selection("SOLID", "screw_1")) +model.end() diff --git a/src/FeaturesPlugin/doc/images/BoundinBoxResult.png b/src/FeaturesPlugin/doc/images/BoundinBoxResult.png deleted file mode 100644 index 89eb1278d..000000000 Binary files a/src/FeaturesPlugin/doc/images/BoundinBoxResult.png and /dev/null differ diff --git a/src/FeaturesPlugin/doc/images/BoundingBoxResult.png b/src/FeaturesPlugin/doc/images/BoundingBoxResult.png new file mode 100644 index 000000000..89eb1278d Binary files /dev/null and b/src/FeaturesPlugin/doc/images/BoundingBoxResult.png differ diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 64379ac67..5819ea208 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -134,7 +134,7 @@ + icon="icons/Features/fusion_faces.png" auto_preview="true" helpfile="fuseFeatureFaces.html"> - - + icon="icons/Features/bounding.png" helpfile="boundingBoxFeature.html"> + - + icon="icons/Features/bounding.png" helpfile="boundingBoxFeature.html" internal="1"> + diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 8e55582d9..49b0d1fbf 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -33,8 +33,6 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Prism.h GeomAlgoAPI_Revolution.h GeomAlgoAPI_Boolean.h - GeomAlgoAPI_GeometryCalculation.h - GeomAlgoAPI_BoundingBox.h GeomAlgoAPI_ThroughAll.h GeomAlgoAPI_Rotation.h GeomAlgoAPI_Translation.h @@ -88,6 +86,8 @@ SET(PROJECT_HEADERS GeomAlgoAPI_Projection.h GeomAlgoAPI_Chamfer.h GeomAlgoAPI_Defeaturing.h + GeomAlgoAPI_GeometryCalculation.h + GeomAlgoAPI_BoundingBox.h ) SET(PROJECT_SOURCES @@ -100,8 +100,6 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Prism.cpp GeomAlgoAPI_Revolution.cpp GeomAlgoAPI_Boolean.cpp - GeomAlgoAPI_GeometryCalculation.cpp - GeomAlgoAPI_BoundingBox.cpp GeomAlgoAPI_ThroughAll.cpp GeomAlgoAPI_Rotation.cpp GeomAlgoAPI_Translation.cpp @@ -155,6 +153,8 @@ SET(PROJECT_SOURCES GeomAlgoAPI_Projection.cpp GeomAlgoAPI_Chamfer.cpp GeomAlgoAPI_Defeaturing.cpp + GeomAlgoAPI_GeometryCalculation.cpp + GeomAlgoAPI_BoundingBox.cpp ) SET(PROJECT_LIBRARIES diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.cpp index c27199700..856b2eb4d 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.cpp @@ -42,46 +42,46 @@ #include /** - * This function constructs and returns modified shape from the original one - * for singular cases. It is used for the method GetMinDistanceSingular. - * - * \param theShape the original shape - * \param theModifiedShape output parameter. The modified shape. - * \param theAddDist output parameter. The added distance for modified shape. - * \retval true if the shape is modified; false otherwise. - * - * \internal - */ - Standard_Boolean ModifyShape(const TopoDS_Shape &theShape, - TopoDS_Shape &theModifiedShape, - Standard_Real &theAddDist) - { - TopExp_Explorer anExp; - int nbf = 0; - - theAddDist = 0.; - theModifiedShape.Nullify(); - - for ( anExp.Init( theShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { - nbf++; - theModifiedShape = anExp.Current(); +* This function constructs and returns modified shape from the original one +* for singular cases. It is used for the method GetMinDistanceSingular. +* +* \param theShape the original shape +* \param theModifiedShape output parameter. The modified shape. +* \param theAddDist output parameter. The added distance for modified shape. +* \retval true if the shape is modified; false otherwise. +* +* \internal +*/ +Standard_Boolean ModifyShape(const TopoDS_Shape &theShape, + TopoDS_Shape &theModifiedShape, + Standard_Real &theAddDist) +{ + TopExp_Explorer anExp; + int nbf = 0; + + theAddDist = 0.; + theModifiedShape.Nullify(); + + for ( anExp.Init( theShape, TopAbs_FACE ); anExp.More(); anExp.Next() ) { + nbf++; + theModifiedShape = anExp.Current(); + } + if(nbf==1) { + TopoDS_Shape sh = theShape; + while(sh.ShapeType()==TopAbs_COMPOUND) { + TopoDS_Iterator it(sh); + sh = it.Value(); } - if(nbf==1) { - TopoDS_Shape sh = theShape; - while(sh.ShapeType()==TopAbs_COMPOUND) { - TopoDS_Iterator it(sh); - sh = it.Value(); - } - Handle(Geom_Surface) S = BRep_Tool::Surface(TopoDS::Face(theModifiedShape)); - if( S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || - S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) || - S->IsUPeriodic()) { - const Standard_Boolean isShell = - (sh.ShapeType()==TopAbs_SHELL || sh.ShapeType()==TopAbs_FACE); - - if ( !isShell && S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) ) { - Handle(Geom_SphericalSurface) SS = Handle(Geom_SphericalSurface)::DownCast(S); - gp_Pnt PC = SS->Location(); + Handle(Geom_Surface) S = BRep_Tool::Surface(TopoDS::Face(theModifiedShape)); + if(S->IsKind(STANDARD_TYPE(Geom_SphericalSurface)) || + S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) || + S->IsUPeriodic()) { + const Standard_Boolean isShell = + (sh.ShapeType()==TopAbs_SHELL || sh.ShapeType()==TopAbs_FACE); + + if (!isShell && S->IsKind(STANDARD_TYPE(Geom_SphericalSurface))) { + Handle(Geom_SphericalSurface) SS = Handle(Geom_SphericalSurface)::DownCast(S); + gp_Pnt PC = SS->Location(); BRep_Builder B; TopoDS_Vertex V; B.MakeVertex(V,PC,1.e-7); @@ -89,7 +89,7 @@ theAddDist = SS->Radius(); return Standard_True; } - if ( !isShell && S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface)) ) { + if (!isShell && S->IsKind(STANDARD_TYPE(Geom_ToroidalSurface))) { Handle(Geom_ToroidalSurface) TS = Handle(Geom_ToroidalSurface)::DownCast(S); gp_Ax3 ax3 = TS->Position(); Handle(Geom_Circle) C = new Geom_Circle(ax3.Ax2(),TS->MajorRadius()); @@ -150,11 +150,11 @@ } //======================================================================= -//function : GetMinDistanceSingular +// function : GetMinDistanceSingular //======================================================================= double GetMinDistanceSingular(const TopoDS_Shape& aSh1, const TopoDS_Shape& aSh2, - gp_Pnt& Ptmp1, gp_Pnt& Ptmp2) + gp_Pnt& Ptmp1, gp_Pnt& Ptmp2) { TopoDS_Shape tmpSh1; TopoDS_Shape tmpSh2; @@ -187,25 +187,25 @@ double GetMinDistanceSingular(const TopoDS_Shape& aSh1, else { gp_Dir aDir(gp_Vec(PMin1,PMin2)); if( MinDist > (AddDist1+AddDist2) ) { - Ptmp1 = gp_Pnt( PMin1.X() + aDir.X()*AddDist1, - PMin1.Y() + aDir.Y()*AddDist1, - PMin1.Z() + aDir.Z()*AddDist1 ); - Ptmp2 = gp_Pnt( PMin2.X() - aDir.X()*AddDist2, - PMin2.Y() - aDir.Y()*AddDist2, - PMin2.Z() - aDir.Z()*AddDist2 ); + Ptmp1 = gp_Pnt(PMin1.X() + aDir.X()*AddDist1, + PMin1.Y() + aDir.Y()*AddDist1, + PMin1.Z() + aDir.Z()*AddDist1); + Ptmp2 = gp_Pnt(PMin2.X() - aDir.X()*AddDist2, + PMin2.Y() - aDir.Y()*AddDist2, + PMin2.Z() - aDir.Z()*AddDist2); return (MinDist - AddDist1 - AddDist2); } else { if( AddDist1 > 0 ) { - Ptmp1 = gp_Pnt( PMin1.X() + aDir.X()*AddDist1, - PMin1.Y() + aDir.Y()*AddDist1, - PMin1.Z() + aDir.Z()*AddDist1 ); + Ptmp1 = gp_Pnt(PMin1.X() + aDir.X()*AddDist1, + PMin1.Y() + aDir.Y()*AddDist1, + PMin1.Z() + aDir.Z()*AddDist1); Ptmp2 = Ptmp1; } else { - Ptmp2 = gp_Pnt( PMin2.X() - aDir.X()*AddDist2, - PMin2.Y() - aDir.Y()*AddDist2, - PMin2.Z() - aDir.Z()*AddDist2 ); + Ptmp2 = gp_Pnt(PMin2.X() - aDir.X()*AddDist2, + PMin2.Y() - aDir.Y()*AddDist2, + PMin2.Z() - aDir.Z()*AddDist2); Ptmp1 = Ptmp2; } } @@ -217,8 +217,8 @@ double GetMinDistanceSingular(const TopoDS_Shape& aSh1, return -2.0; } -//function : GetMinDistance -//purpose : +//======================================================================= +// function : GetMinDistance //======================================================================= Standard_Real GetMinDistance(const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2, @@ -276,13 +276,13 @@ Standard_Real GetMinDistance(const TopoDS_Shape& theShape1, } //======================================================================= -//PreciseBoundingBox +// function : PreciseBoundingBox //======================================================================= Standard_Boolean PreciseBoundingBox (const TopoDS_Shape &theShape, Bnd_Box &theBox) { - if ( theBox.IsVoid() ) BRepBndLib::Add( theShape, theBox ); - if ( theBox.IsVoid() ) return Standard_False; + if (theBox.IsVoid()) BRepBndLib::Add( theShape, theBox ); + if (theBox.IsVoid()) return Standard_False; Standard_Real aBound[6]; theBox.Get(aBound[0], aBound[2], aBound[4], aBound[1], aBound[3], aBound[5]); @@ -342,14 +342,13 @@ Standard_Boolean PreciseBoundingBox } //================================================================================================= -bool GetBoundingBox( const std::shared_ptr& theShape, - const bool thePrecise, - Standard_Real& theXmin,Standard_Real& theXmax, - Standard_Real& theYmin,Standard_Real& theYmax, - Standard_Real& theZmin,Standard_Real& theZmax, - std::string& theError) +bool GetBoundingBox(const std::shared_ptr& theShape, + const bool thePrecise, + Standard_Real& theXmin,Standard_Real& theXmax, + Standard_Real& theYmin,Standard_Real& theYmax, + Standard_Real& theZmin,Standard_Real& theZmax, + std::string& theError) { - #ifdef _DEBUG std::cout << "GetBoundingBox " << std::endl; #endif @@ -360,9 +359,9 @@ bool GetBoundingBox( const std::shared_ptr& theShape, } TopoDS_Shape aShape = theShape->impl(); + //Compute the parameters Bnd_Box B; - try { OCC_CATCH_SIGNALS; BRepBuilderAPI_Copy aCopyTool (aShape); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.h b/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.h index be6e548b6..010c3a30b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_BoundingBox.h @@ -35,11 +35,11 @@ /// \param theZmax Z max of the box /// \param theError error GEOMALGOAPI_EXPORT -bool GetBoundingBox( const std::shared_ptr& theShape, - const bool thePrecise, - Standard_Real& theXmin,Standard_Real& theXmax, - Standard_Real& theYmin,Standard_Real& theYmax, - Standard_Real& theZmin,Standard_Real& theZmax, - std::string& theError); +bool GetBoundingBox(const std::shared_ptr& theShape, + const bool thePrecise, + Standard_Real& theXmin,Standard_Real& theXmax, + Standard_Real& theYmin,Standard_Real& theYmax, + Standard_Real& theZmin,Standard_Real& theZmax, + std::string& theError); #endif