From 3b77d2b2fac421e72a29f255b1cf753a28b6d8e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me?= Date: Thu, 12 Nov 2020 11:05:56 +0100 Subject: [PATCH] Clean sources --- src/FeaturesAPI/FeaturesAPI.i | 2 - src/FeaturesPlugin/CMakeLists.txt | 34 +---- src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp | 116 +++--------------- src/FeaturesPlugin/FeaturesPlugin_Fillet.h | 47 ------- src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp | 10 -- .../FeaturesPlugin_VersionedChFi.cpp | 20 +-- src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts | 4 - src/FeaturesPlugin/fillet_widget.xml | 49 +------- src/FeaturesPlugin/plugin-Features.xml | 4 +- src/GeomAlgoAPI/CMakeLists.txt | 4 - src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h | 42 +++++++ src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp | 64 ---------- src/GeomAlgoAPI/GeomAlgoAPI_Fillet.h | 23 ---- src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp | 100 +-------------- src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h | 15 +-- src/Model/Model_Objects.cpp | 21 ++-- src/Model/Model_Objects.h | 10 +- src/Model/Model_ResultBody.cpp | 70 +---------- src/Model/Model_ResultBody.h | 19 +-- src/ModelAPI/CMakeLists.txt | 8 +- src/ModelAPI/ModelAPI_Feature.h | 5 - src/ModelAPI/ModelAPI_ResultBody.h | 17 --- .../ModuleBase_WidgetSelectionFilter.cpp | 1 + src/PythonAPI/model/exchange/__init__.py | 2 +- 24 files changed, 93 insertions(+), 594 deletions(-) create mode 100644 src/GeomAlgoAPI/GeomAlgoAPI_BasicProperties.h diff --git a/src/FeaturesAPI/FeaturesAPI.i b/src/FeaturesAPI/FeaturesAPI.i index c5c0c28de..b76fd2dc4 100644 --- a/src/FeaturesAPI/FeaturesAPI.i +++ b/src/FeaturesAPI/FeaturesAPI.i @@ -42,8 +42,6 @@ %feature("kwargs") addCommon; %feature("kwargs") addCut; %feature("kwargs") addFillet; -%feature("kwargs") addFilletMultiRadiusBypoint; -%feature("kwargs") addFilletMultiRadiusByCurv; %feature("kwargs") addFuse; %feature("kwargs") addIntersection; %feature("kwargs") addMultiRotation; diff --git a/src/FeaturesPlugin/CMakeLists.txt b/src/FeaturesPlugin/CMakeLists.txt index 5c3ecc45c..c93c66a17 100644 --- a/src/FeaturesPlugin/CMakeLists.txt +++ b/src/FeaturesPlugin/CMakeLists.txt @@ -19,16 +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 FeaturesPlugin.h @@ -76,12 +66,6 @@ SET(PROJECT_HEADERS FeaturesPlugin_ImportResult.h FeaturesPlugin_Defeaturing.h FeaturesPlugin_VersionedChFi.h - FeaturesPlugin_WidgetCreator.h - FeaturesPlugin_WidgetFilletMultiRadiuses.h -) - -SET(PROJECT_MOC_HEADERS - FeaturesPlugin_WidgetFilletMultiRadiuses.h ) SET(PROJECT_SOURCES @@ -129,8 +113,6 @@ SET(PROJECT_SOURCES FeaturesPlugin_ImportResult.cpp FeaturesPlugin_Defeaturing.cpp FeaturesPlugin_VersionedChFi.cpp - FeaturesPlugin_WidgetCreator.cpp - FeaturesPlugin_WidgetFilletMultiRadiuses.cpp ) SET(XML_RESOURCES @@ -175,12 +157,6 @@ SET(TEXT_RESOURCES FeaturesPlugin_msg_ru.ts ) -# sources / moc wrappings -QT_WRAP_MOC(PROJECT_AUTOMOC ${PROJECT_MOC_HEADERS}) - -#QT5_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES}) - -SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES}) SOURCE_GROUP ("XML Files" FILES ${XML_RESOURCES}) SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES}) @@ -190,7 +166,6 @@ INCLUDE_DIRECTORIES( ../GeomAPI ../GeomAlgoAPI ../GeomValidators - ../ModuleBase ../Events ../Config ${OpenCASCADE_INCLUDE_DIR} @@ -207,12 +182,7 @@ SET(PROJECT_LIBRARIES ) ADD_DEFINITIONS(-DFEATURESPLUGIN_EXPORTS) -ADD_LIBRARY(FeaturesPlugin MODULE - ${PROJECT_SOURCES} - ${PROJECT_HEADERS} - ${XML_RESOURCES} - ${TEXT_RESOURCES} - ${PROJECT_AUTOMOC}) +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}) @@ -712,4 +682,6 @@ ADD_UNIT_TESTS(TestExtrusion.py TestFillet1D_Wire_3.py TestFillet1D_Wire_4.py TestFillet1D_Wire_5.py + Test19931.py + Test20027.py ) diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index 79292632e..c8c5bf0d5 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -22,9 +22,6 @@ #include #include #include -#include -#include - #include #include @@ -33,16 +30,6 @@ #include #include -#include -#include - -#include -#include -#include -#include -#include -#include - // Extract edges from the list static ListOfShape extractEdges(const ListOfShape& theShapes) @@ -62,29 +49,12 @@ FeaturesPlugin_Fillet::FeaturesPlugin_Fillet() void FeaturesPlugin_Fillet::initAttributes() { data()->addAttribute(CREATION_METHOD(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(CREATION_METHOD_MULTIPLES_RADIUSES(), ModelAPI_AttributeString::typeId()); - AttributePtr aSelectionList = data()->addAttribute(OBJECT_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(START_RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); data()->addAttribute(END_RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); - data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId()); - data()->addAttribute(VALUES_CURV_ID(), ModelAPI_AttributeTables::typeId()); - data()->addAttribute(EDGE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId()); - - data()->addAttribute(ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList::typeId()); - - data()->addAttribute(CREATION_METHOD_BY_POINTS(), ModelAPI_AttributeString::typeId()); - data()->addAttribute(CREATION_METHOD_BY_CURVILEAR_ABSCISSA(), ModelAPI_AttributeString::typeId()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END_RADIUS_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), ARRAY_POINT_RADIUS_BY_POINTS()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUES_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), VALUES_CURV_ID()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_MULTIPLES_RADIUSES()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_BY_CURVILEAR_ABSCISSA()); - ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CREATION_METHOD_BY_POINTS()); initVersion(aSelectionList); } @@ -94,20 +64,6 @@ AttributePtr FeaturesPlugin_Fillet::objectsAttribute() return attribute(OBJECT_LIST_ID()); } -void FeaturesPlugin_Fillet::attributeChanged(const std::string& theID) -{ - if (theID == EDGE_SELECTED_ID() - && string(CREATION_METHOD())->value() == CREATION_METHOD_MULTIPLES_RADIUSES()) { - - AttributeSelectionPtr anEdges = - std::dynamic_pointer_cast(attribute(EDGE_SELECTED_ID())); - AttributeSelectionListPtr array = selectionList(OBJECT_LIST_ID()); - if(array->isInitialized()) - array->clear(); - array->append(anEdges->namingName() ); - } -} - const std::string& FeaturesPlugin_Fillet::modifiedShapePrefix() const { static const std::string& THE_PREFIX("Fillet"); @@ -118,65 +74,31 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the const ListOfShape& theEdges) { AttributeStringPtr aCreationMethod = string(CREATION_METHOD()); - std::string anError; - - if (!aCreationMethod){ - setError(anError); + if (!aCreationMethod) return GeomMakeShapePtr(); + + bool isFixedRadius = aCreationMethod->value() == CREATION_METHOD_SINGLE_RADIUS(); + double aRadius1 = 0.0, aRadius2 = 0.0; + if (isFixedRadius) + aRadius1 = real(RADIUS_ID())->value(); + else { + aRadius1 = real(START_RADIUS_ID())->value(); + aRadius2 = real(END_RADIUS_ID())->value(); } - + + // Perform fillet operation std::shared_ptr aFilletBuilder; - - ListOfShape aFilletEdges = extractEdges(theEdges); + std::string anError; - std::cout << "coucou aCreationMethod->value() = " << aCreationMethod->value()<< std::endl; - if ( aCreationMethod->value() == CREATION_METHOD_MULTIPLES_RADIUSES() ) - { - - std::list coodCurv; - std::list radiuses; - AttributeTablesPtr aTablesAttr; - - if( string(CREATION_METHOD_MULTIPLES_RADIUSES())->value() == CREATION_METHOD_BY_POINTS() ) - { - aTablesAttr = tables(VALUES_ID()); - - }else{ - aTablesAttr = tables(VALUES_CURV_ID()); - } - - int aRows = aTablesAttr->rows(); - ModelAPI_AttributeTables::Value aVal; - for (int k = 0; k < aRows; k++) { - aVal = aTablesAttr->value(k, 0); - coodCurv.push_back(aVal.myDouble); - aVal = aTablesAttr->value(k, 1); - radiuses.push_back(aVal.myDouble); - } - - aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, coodCurv,radiuses)); - - }else - { - bool isFixedRadius = aCreationMethod->value() == CREATION_METHOD_SINGLE_RADIUS(); - double aRadius1 = 0.0, aRadius2 = 0.0; - if (isFixedRadius) - aRadius1 = real(RADIUS_ID())->value(); - else { - aRadius1 = real(START_RADIUS_ID())->value(); - aRadius2 = real(END_RADIUS_ID())->value(); - } - - if (isFixedRadius) - aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1)); - else - aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1, aRadius2)); - } + ListOfShape aFilletEdges = extractEdges(theEdges); + if (isFixedRadius) + aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1)); + else + aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, aRadius1, aRadius2)); if (GeomAlgoAPI_Tools::AlgoError::isAlgorithmFailed(aFilletBuilder, getKind(), anError)) { - setError(anError); - return GeomMakeShapePtr(); + setError(anError); + return GeomMakeShapePtr(); } return aFilletBuilder; } - diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h index ff7f2774d..2c1460b95 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h @@ -61,30 +61,6 @@ public: return MY_VARYING_RADIUS; } - inline static const std::string CREATION_METHOD_MULTIPLES_RADIUSES() - { - static std::string MY_METHOD_MULTIPLES_RADIUSES("multiple_radiuses"); - return MY_METHOD_MULTIPLES_RADIUSES; - } - - inline static const std::string CREATION_METHOD_BY_POINTS() - { - static std::string MY_CREATION_METHOD_BY_POINTS("by_point_method"); - return MY_CREATION_METHOD_BY_POINTS; - } - - inline static const std::string ARRAY_POINT_RADIUS_BY_POINTS() - { - static std::string MY_ARRAY_POINT_RADIUS_BY_POINTS("array_point_radius_by_point"); - return MY_ARRAY_POINT_RADIUS_BY_POINTS; - } - - inline static const std::string CREATION_METHOD_BY_CURVILEAR_ABSCISSA() - { - static std::string MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA("by_curvilinear_abscissa_methode"); - return MY_CREATION_METHOD_BY_CURVILEAR_ABSCISSA; - } - /// Attribute name of main objects. inline static const std::string& OBJECT_LIST_ID() { @@ -99,27 +75,6 @@ public: return MY_START_RADIUS_ID; } - /// Attribute name of edge selected. - inline static const std::string& EDGE_SELECTED_ID() - { - static const std::string MY_EDGE_SELECTED_ID("edge_selected"); - return MY_EDGE_SELECTED_ID; - } - - /// attribute name of list of tables that contain deafult values (row 0) and the custom values - inline static const std::string& VALUES_ID() - { - static const std::string MY_VALUES_ID("values"); - return MY_VALUES_ID; - } - - /// attribute name of list of tables that contain deafult values (row 0) and the custom values - inline static const std::string& VALUES_CURV_ID() - { - static const std::string MY_VALUES_ID("values_curv"); - return MY_VALUES_ID; - } - /// Attribute name of end radius. inline static const std::string& END_RADIUS_ID() { @@ -136,8 +91,6 @@ public: /// Request for initialization of data model of the feature: adding all attributes. FEATURESPLUGIN_EXPORT virtual void initAttributes(); - FEATURESPLUGIN_EXPORT void attributeChanged(const std::string& theID); - /// Use plugin manager for features creation. FeaturesPlugin_Fillet(); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp index e68b35d69..0d49dfe08 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Plugin.cpp @@ -55,10 +55,6 @@ #include #include -#include - -#include "FeaturesPlugin_WidgetCreator.h" - #include #include @@ -70,13 +66,7 @@ static FeaturesPlugin_Plugin* MY_FEATURES_INSTANCE = new FeaturesPlugin_Plugin() FeaturesPlugin_Plugin::FeaturesPlugin_Plugin() { - - WidgetCreatorFactoryPtr aWidgetCreatorFactory = ModuleBase_WidgetCreatorFactory::get(); - aWidgetCreatorFactory->registerCreator( - std::shared_ptr(new FeaturesPlugin_WidgetCreator())); - SessionPtr aMgr = ModelAPI_Session::get(); - ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); aFactory->registerValidator("FeaturesPlugin_ValidatorTransform", new FeaturesPlugin_ValidatorTransform); diff --git a/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp b/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp index 7738cf1fe..7dfa2e339 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_VersionedChFi.cpp @@ -27,7 +27,6 @@ #include -#include static const std::string CHAMFERFILLET_VERSION_1("v9.5"); @@ -82,7 +81,6 @@ void FeaturesPlugin_VersionedChFi::execute() anOriginalSolids.push_back(aSolid); anEdges.insert(anEdges.end(), aSubs.begin(), aSubs.end()); - } // Build results of the operaion. @@ -127,28 +125,14 @@ bool FeaturesPlugin_VersionedChFi::processAttribute(const AttributePtr& theAttri if (aContext.get()) { ResultBodyPtr aCtxOwner = ModelAPI_Tools::bodyOwner(aContext); if (aCtxOwner && aCtxOwner->shape()->shapeType() == GeomAPI_Shape::COMPSOLID) - { aContext = aCtxOwner; - } aParent = aContext->shape(); if (!aParent) return false; // store full shape hierarchy for the corresponding version only - if (anObject->shapeType() <= GeomAPI_Shape::SOLID) - { - ListOfShape anEdges; - collectSubs(aParent, anEdges, GeomAPI_Shape::EDGE); - for (ListOfShape::iterator anIt = anEdges.begin(); anIt != anEdges.end(); ++anIt) { - theObjects.addObject(*anIt); - theObjects.addParent(*anIt, aParent); - } - }else - { - theObjects.addObject(anObject); - theObjects.addParent(anObject, aParent); - } - + theObjects.addObject(anObject); + theObjects.addParent(anObject, aParent); if (isStoreFullHierarchy) ModelAPI_Tools::fillShapeHierarchy(aParent, aContext, theObjects); } else { // get it from a feature diff --git a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts index aeebd768d..6f821a2e2 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts +++ b/src/FeaturesPlugin/FeaturesPlugin_msg_fr.ts @@ -924,10 +924,6 @@ Fillet:main_objects - - Faces, edges or/and solids - Faces, arêtes ou/et solides - Faces or/and edges Faces ou/et arêtes diff --git a/src/FeaturesPlugin/fillet_widget.xml b/src/FeaturesPlugin/fillet_widget.xml index 1ba6e708f..7abb4a5df 100644 --- a/src/FeaturesPlugin/fillet_widget.xml +++ b/src/FeaturesPlugin/fillet_widget.xml @@ -5,10 +5,10 @@ tooltip="Fillet with fixed radius" icon="icons/Features/fillet_fixed_radius.png"> @@ -51,50 +51,5 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/FeaturesPlugin/plugin-Features.xml b/src/FeaturesPlugin/plugin-Features.xml index 74b60d59a..08c08b775 100644 --- a/src/FeaturesPlugin/plugin-Features.xml +++ b/src/FeaturesPlugin/plugin-Features.xml @@ -126,7 +126,7 @@ + icon="icons/Features/fillet.png" auto_preview="true" helpfile="filletFeature.html"> + icon="icons/Features/fusion_faces.png" auto_preview="true" helpfile="fuseFeatureFaces.html"> +#include +#include + +/// Run chamfer operation with two distances or with a distance and an angle . + /// \param theShape the shape + /// \param theTolerance tolerance desirated + /// \param theLength lenght calculated + /// \param theSurfArea Surface Area calculated + /// \param theVolume Volume calculated + /// \param theError error +GEOMALGOAPI_EXPORT +bool GetBasicProperties( const std::shared_ptr& theShape, + const Standard_Real theTolerance, + Standard_Real& theLength, + Standard_Real& theSurfArea, + Standard_Real& theVolume, + std::string& theError); + +#endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp index f1241dd36..1fc2b871f 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp @@ -21,8 +21,6 @@ #include #include -#include -#include //================================================================================================= GeomAlgoAPI_Fillet::GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid, @@ -43,17 +41,6 @@ GeomAlgoAPI_Fillet::GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid, build(theBaseSolid, theFilletEdges, theStartRadius, theEndRadius); } -//================================================================================================= -GeomAlgoAPI_Fillet::GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid, - const ListOfShape& theFilletEdges, - const std::list& theCurvCoord, - const std::list& theRadiuses) -{ - if (theRadiuses.size()== 0 ) - return; - build(theBaseSolid, theFilletEdges,theCurvCoord, theRadiuses); -} - //================================================================================================= void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid, const ListOfShape& theFilletEdges, @@ -97,54 +84,3 @@ void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid, setShape(aShape); setDone(true); } - -//================================================================================================= -void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid, - const ListOfShape& theFilletEdges, - const std::list& theCurvCoord, - const std::list& theRadiuses) -{ - if (!theBaseSolid || theFilletEdges.empty() || theRadiuses.size() == 0) - return; - - // create fillet builder - BRepFilletAPI_MakeFillet* aFilletBuilder = - new BRepFilletAPI_MakeFillet(theBaseSolid->impl()); - setImpl(aFilletBuilder); - setBuilderType(OCCT_BRepBuilderAPI_MakeShape); - - // assign filleting edges - for (ListOfShape::const_iterator anIt = theFilletEdges.begin(); - anIt != theFilletEdges.end(); ++anIt) { - if ((*anIt)->isEdge()) - aFilletBuilder->Add( (*anIt)->impl() ); - } - - TColgp_Array1OfPnt2d array(1, theRadiuses.size()); - - int i = 1; - std::list::const_iterator itCurv = theCurvCoord.begin(); - std::list::const_iterator itRadius = theRadiuses.begin(); - - for( ; itCurv != theCurvCoord.end(); ++itCurv, ++itRadius ) - { - array.SetValue(i, gp_Pnt2d( (*itCurv) , (*itRadius))); - i++; - } - // assign fillet radii for each contour of filleting edges - int aNbContours = aFilletBuilder->NbContours(); - for (int ind = 1; ind <= aNbContours; ++ind) { - aFilletBuilder->SetRadius(array, ind, 1); - } - - // build and get result - aFilletBuilder->Build(); - if (!aFilletBuilder->IsDone()) - return; - TopoDS_Shape aResult = GeomAlgoAPI_DFLoader::refineResult(aFilletBuilder->Shape()); - - std::shared_ptr aShape(new GeomAPI_Shape()); - aShape->setImpl(new TopoDS_Shape(aResult)); - setShape(aShape); - setDone(true); -} \ No newline at end of file diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.h b/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.h index 175a88717..f986933df 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.h @@ -24,7 +24,6 @@ #include #include -#include /// \class GeomAlgoAPI_Fillet /// \ingroup DataAlgo @@ -49,16 +48,6 @@ public: const ListOfShape& theFilletEdges, const double theStartRadius, const double theEndRadius); - - /// Run fillet operation with variable radius. - /// \param theBaseSolid a changing solid - /// \param theFilletEdges list of edges the fillet is performed on - /// \param theRadiuses theradius of the fillet - GEOMALGOAPI_EXPORT GeomAlgoAPI_Fillet(const GeomShapePtr& theBaseSolid, - const ListOfShape& theFilletEdges, - const std::list& theCurvCoord, - const std::list& theRadiuses); - private: /// Perform fillet operation. @@ -71,18 +60,6 @@ private: const ListOfShape& theFilletEdges, const double theStartRadius, const double theEndRadius = -1.0); - - /// Perform fillet operation. - /// If theEndRadius is less than 0., the fixed radius fillet will be built. - /// \param theBaseSolid a changing solid - /// \param theFilletEdges list of edges the fillet is performed on - /// \param theCurvCoord the coordinate of a point defines a relative parameter on the edge - /// \param theRadiuses the corresponding value of the radius, and the radius evolves - // between the first and last vertices of the contour of index - void build(const GeomShapePtr& theBaseSolid, - const ListOfShape& theFilletEdges, - const std::list& theCurvCoord, - const std::list& theRadiuses); }; #endif diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp index 9e20ba201..3a824f106 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.cpp @@ -54,36 +54,22 @@ #include #include #include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include #include // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC - -// ---------------------------------------------------------------------------- - std::shared_ptr STEPImport(const std::string& theFileName, const std::string& theFormatName, - const bool anScalInterUnits, std::string& theError) { - TopoDS_Shape aResShape; // Set "C" numeric locale to save numbers correctly // Kernel_Utils::Localizer loc; - + STEPControl_Reader aReader; //VSR: 16/09/09: Convert to METERS @@ -103,7 +89,7 @@ std::shared_ptr STEPImport(const std::string& theFileName, if (status == IFSelect_RetDone) { // Regard or not the model units - if (!anScalInterUnits) { + if (theFormatName == "STEP_SCALE") { // set UnitFlag to units from file TColStd_SequenceOfAsciiString anUnitLengthNames; TColStd_SequenceOfAsciiString anUnitAngleNames; @@ -208,83 +194,3 @@ std::shared_ptr STEPImport(const std::string& theFileName, aGeomShape->setImpl(new TopoDS_Shape(aResShape)); return aGeomShape; } - - -std::shared_ptr STEPImportAttributs(const std::string& theFileName, - std::shared_ptr theResultBody, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor, - std::map< std::wstring, std::list> &theMaterialShape, - std::string& theError) -{ - - STEPControl_Reader aReader; - std::shared_ptr aGeomShape(new GeomAPI_Shape); - //VSR: 16/09/09: Convert to METERS - Interface_Static::SetCVal("xstep.cascade.unit","M"); - Interface_Static::SetIVal("read.step.ideas", 1); - Interface_Static::SetIVal("read.step.nonmanifold", 1); - - try { - OCC_CATCH_SIGNALS; - - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.c_str()); - - if (status == IFSelect_RetDone) { - - // Regard or not the model units - if (!anScalInterUnits) { - // set UnitFlag to units from file - TColStd_SequenceOfAsciiString anUnitLengthNames; - TColStd_SequenceOfAsciiString anUnitAngleNames; - TColStd_SequenceOfAsciiString anUnitSolidAngleNames; - aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames); - if (anUnitLengthNames.Length() > 0) { - TCollection_AsciiString aLenUnits = anUnitLengthNames.First(); - if (aLenUnits == "millimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "MM"); - else if (aLenUnits == "centimetre") - Interface_Static::SetCVal("xstep.cascade.unit", "CM"); - else if (aLenUnits == "metre" || aLenUnits.IsEmpty()) - Interface_Static::SetCVal("xstep.cascade.unit", "M"); - else if (aLenUnits == "INCH") - Interface_Static::SetCVal("xstep.cascade.unit", "INCH"); - else { - theError = "The file contains not supported units."; - aGeomShape->setImpl(new TopoDS_Shape()); - return aGeomShape; - } - // TODO (for other units than mm, cm, m or inch) - //else if (aLenUnits == "") - // Interface_Static::SetCVal("xstep.cascade.unit", "???"); - } - } - else { - //cout<<"need re-scale a model"<setImpl(new TopoDS_Shape()); - return aGeomShape; - } - - STEPCAFControl_Reader cafreader; - cafreader.SetColorMode(true); - cafreader.SetNameMode(true); - cafreader.SetMatMode(true); - - if(cafreader.ReadFile(theFileName.c_str()) != IFSelect_RetDone) { - theError = "Wrong format of the imported file. Can't import file."; - std::shared_ptr aGeomShape(new GeomAPI_Shape); - aGeomShape->setImpl(new TopoDS_Shape()); - return aGeomShape; - } - - return readAttributes(cafreader,theResultBody,anMaterials, theMaterialShape, "STEP-XCAF"); - } - diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h index 9433a0a70..470791a3b 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h @@ -23,26 +23,13 @@ #include #include -#include - -#include +#include /// Implementation of the import STEP files algorithms GEOMALGOAPI_EXPORT std::shared_ptr STEPImport(const std::string& theFileName, const std::string& theFormatName, - const bool anScalInterUnits, std::string& theError); -/// Implementation of the import STEP files algorithms with Attributs (Name, Color, Materials) -GEOMALGOAPI_EXPORT -std::shared_ptr STEPImportAttributs(const std::string& theFileName, - std::shared_ptr theResultBody, - const bool anScalInterUnits, - const bool anMaterials, - const bool anColor, - std::map< std::wstring, std::list> &theMaterialShape, - std::string& theError); - #endif /* GEOMALGOAPI_STEPIMPORT_H_ */ diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 63380e3e2..2c32988e2 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -1226,8 +1226,7 @@ bool Model_Objects::hasCustomName(DataPtr theFeatureData, void Model_Objects::storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, - const int theResultIndex, - const std::wstring& theNameShape) + const int theResultIndex) { theResult->init(); theResult->setDoc(myDoc); @@ -1241,15 +1240,11 @@ void Model_Objects::storeResult(std::shared_ptr theFeatureData, theResult->data()->setName(L""); } else { std::wstringstream aName; - if( theNameShape != L"" ){ - aName << theNameShape; - }else{ - aName << aNewName; - // if there are several results (issue #899: any number of result), - // add unique prefix starting from second - if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) - aName << "_" << theResultIndex + 1; - } + aName << aNewName; + // if there are several results (issue #899: any number of result), + // add unique prefix starting from second + if (theResultIndex > 0 || theResult->groupName() == ModelAPI_ResultBody::group()) + aName << "_" << theResultIndex + 1; aNewName = aName.str(); } theResult->data()->setName(aNewName); @@ -1274,7 +1269,7 @@ std::shared_ptr Model_Objects::createConstruction( } std::shared_ptr Model_Objects::createBody( - const std::shared_ptr& theFeatureData, const int theIndex,const std::wstring& theNameShape ) + const std::shared_ptr& theFeatureData, const int theIndex) { TDF_Label aLab = resultLabel(theFeatureData, theIndex); TDataStd_Comment::Set(aLab, ModelAPI_ResultBody::group().c_str()); @@ -1285,7 +1280,7 @@ std::shared_ptr Model_Objects::createBody( } if (!aResult.get()) { aResult = std::shared_ptr(new Model_ResultBody); - storeResult(theFeatureData, aResult, theIndex,theNameShape); + storeResult(theFeatureData, aResult, theIndex); } return aResult; } diff --git a/src/Model/Model_Objects.h b/src/Model/Model_Objects.h index fe3811543..c929be8ce 100644 --- a/src/Model/Model_Objects.h +++ b/src/Model/Model_Objects.h @@ -124,8 +124,7 @@ class Model_Objects const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a body result std::shared_ptr createBody( - const std::shared_ptr& theFeatureData, const int theIndex = 0, - const std::wstring& theNameShape = L""); + const std::shared_ptr& theFeatureData, const int theIndex = 0); /// Creates a part result std::shared_ptr createPart( const std::shared_ptr& theFeatureData, const int theIndex = 0); @@ -220,13 +219,12 @@ class Model_Objects //! Initializes the data fields of the feature void initData(ObjectPtr theObj, TDF_Label theLab, const int theTag); - - //! Allows to store the result in the data tree of the document + + //! Allows to store the result in the data tree of the document //! (attaches 'data' of result to tree) void storeResult(std::shared_ptr theFeatureData, std::shared_ptr theResult, - const int theResultIndex = 0, - const std::wstring& theNameShape = L""); + const int theResultIndex = 0); //! returns the label of result by index; creates this label if it was not created before TDF_Label resultLabel(const std::shared_ptr& theFeatureData, diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 74b932c81..7d6918c6a 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -30,8 +30,6 @@ #include #include #include -#include -#include #include #include @@ -235,54 +233,6 @@ void Model_ResultBody::updateConcealment() } } -void Model_ResultBody::addShapeColor( const std::wstring& theName,std::vector& color) { - - if( myColorsShape.find(theName) == myColorsShape.end()) - myColorsShape[ theName ] = color; -} - -std::wstring Model_ResultBody::addShapeName(std::shared_ptr theshape,const std::wstring& theName ){ - - int indice = 1; - std::wstringstream aName; - aName << theName; - while(myNamesShape.find(aName.str()) != myNamesShape.end() ){ - aName.str(L""); - aName << theName << L"__" << indice; - indice++; - } - myNamesShape[ aName.str() ] = theshape; - - return aName.str(); -} - -std::wstring Model_ResultBody::findShapeName(std::shared_ptr theshape){ - - TopoDS_Shape aShape = theshape->impl(); - for (std::map< std::wstring, std::shared_ptr >::iterator it = myNamesShape.begin(); - it != myNamesShape.end(); - ++it) - { - TopoDS_Shape curSelectedShape = (*it).second->impl(); - if( (aShape.IsSame(curSelectedShape))) { - return (*it).first; - } - - } - return L"material not found" ; -} - - -void Model_ResultBody::setShapeName(std::map< std::wstring, std::shared_ptr > &theshapename, - std::map< std::wstring, std::vector> & theColorsShape) -{ - myNamesShape = theshapename; - myColorsShape = theColorsShape; -} -void Model_ResultBody::clearShapeNameAndColor(){ - myNamesShape.clear(); - myColorsShape.clear(); -} void Model_ResultBody::updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged) { @@ -312,31 +262,13 @@ void Model_ResultBody::updateSubs(const std::shared_ptr& theThisS aShape->setImpl(new TopoDS_Shape(aShapesIter.Value())); ResultBodyPtr aSub; if (mySubs.size() <= aSubIndex) { // it is needed to create a new sub-result - std::wstring thenameshape = L""; - // find shape name read - for (std::map< std::wstring, std::shared_ptr >::iterator it = myNamesShape.begin(); - it != myNamesShape.end(); - ++it) - { - TopoDS_Shape curSelectedShape = (*it).second->impl(); - if( !(aShapesIter.Value().IsSame(curSelectedShape))) continue; - thenameshape = (*it).first; - break; - } - aSub = anObjects->createBody(this->data(), aSubIndex,thenameshape); - //finf color read - std::map< std::wstring, std::vector>::iterator itColor = myColorsShape.find(thenameshape); - if(itColor != myColorsShape.end()){ - ModelAPI_Tools::setColor(aSub,(*itColor).second); - } - aSub->setShapeName(myNamesShape,myColorsShape); + aSub = anObjects->createBody(this->data(), aSubIndex); mySubs.push_back(aSub); mySubsMap[aSub] = int(mySubs.size() - 1); if (isConcealed()) { // for issue #2579 note7 aSub->ModelAPI_ResultBody::setIsConcealed(true); std::dynamic_pointer_cast(aSub)->updateConcealment(); } - } else { // just update shape of this result aSub = mySubs[aSubIndex]; } diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index fe3987642..94e9d9b7c 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -117,7 +117,7 @@ protected: /// Makes a body on the given feature Model_ResultBody(); -/// Updates the sub-bodies if shape of this object is composite-solid + /// Updates the sub-bodies if shape of this object is composite-solid void updateSubs(const std::shared_ptr& theThisShape, const bool theShapeChanged = true); @@ -134,23 +134,6 @@ protected: const std::list& theAllOlds, std::list& theOldForSub); friend class Model_Objects; - - // Add shape Name for read shape in step file - std::wstring addShapeName(std::shared_ptr,const std::wstring& theName) override; - // Add color for shape Name read shape in step file - void addShapeColor( const std::wstring& theName,std::vector& color) override; - // Set the map of name and color read shape in step file - void setShapeName(std::map< std::wstring, std::shared_ptr > &theshapename,std::map< std::wstring, std::vector> & theColorsShape) override; - // find the name of shapp read in step file - std::wstring findShapeName(std::shared_ptr theshape) override; - // Clear the map of name and color read shape in step file - void clearShapeNameAndColor() override; - - // map with the name read in step file and shape - std::map< std::wstring, std::shared_ptr > myNamesShape; - // map with the name contruct and color read - std::map< std::wstring, std::vector> myColorsShape; - }; #endif diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index 7b7876165..dd2f4acd9 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -117,7 +117,7 @@ SET(PROJECT_SOURCES SET(PROJECT_LIBRARIES Config GeomAPI - ${OpenCASCADE_ApplicationFramework_LIBRARIES} + Locale ) SET(CMAKE_SWIG_FLAGS -threads -w325,321,362,383,302,403,451,473) ADD_DEFINITIONS(-DMODELAPI_EXPORTS) @@ -131,10 +131,6 @@ INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/Config ${PROJECT_SOURCE_DIR}/src/GeomAPI ${PROJECT_SOURCE_DIR}/src/GeomAlgoAPI ${PROJECT_SOURCE_DIR}/src/Locale - ${OpenCASCADE_INCLUDE_DIR} - ${OpenCASCADE_DataExchange_LIBRARIES} - ${OpenCASCADE_ModelingAlgorithms_LIBRARIES} - ${OpenCASCADE_ApplicationFramework_LIBRARIES} ) @@ -269,4 +265,6 @@ ADD_UNIT_TESTS(TestConstants.py Test19707.py Test19726.py Test19912.py + Test19932.py + Test19989.py ) diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 811845db2..a700139ec 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -193,11 +193,6 @@ class ModelAPI_Feature : public ModelAPI_Object { return data()->intArray(theID); } - /// Returns the double array attribute by the identifier - inline std::shared_ptr realArray(const std::string& theID) - { - return data()->realArray(theID); - } /// Returns the reference attribute by the identifier inline std::shared_ptr refattr(const std::string& theID) { diff --git a/src/ModelAPI/ModelAPI_ResultBody.h b/src/ModelAPI/ModelAPI_ResultBody.h index 11fdd2421..c88fb08fc 100644 --- a/src/ModelAPI/ModelAPI_ResultBody.h +++ b/src/ModelAPI/ModelAPI_ResultBody.h @@ -24,8 +24,6 @@ #include #include #include -#include -#include class ModelAPI_BodyBuilder; class GeomAlgoAPI_MakeShape; @@ -184,26 +182,11 @@ public: /// Cleans cash related to the already stored elements MODELAPI_EXPORT virtual void cleanCash() = 0; - - // Add shape Name for read shape in step file - MODELAPI_EXPORT virtual std::wstring addShapeName(std::shared_ptr,const std::wstring& theName) = 0; - // Add color for shape Name read shape in step file - MODELAPI_EXPORT virtual void addShapeColor(const std::wstring& theName,std::vector& color) = 0; - // Set the map of name and color read shape in step file - MODELAPI_EXPORT virtual void setShapeName(std::map< std::wstring, std::shared_ptr > &theshapename, - std::map< std::wstring, std::vector> & theColorsShape) = 0; - // Clear the map of name and color read shape in step file - MODELAPI_EXPORT virtual void clearShapeNameAndColor() = 0; - // find the name of shapp read in step file - MODELAPI_EXPORT virtual std::wstring findShapeName(std::shared_ptr theshape) = 0; - protected: /// Default constructor accessible only from Model_Objects MODELAPI_EXPORT ModelAPI_ResultBody(); - - }; //! Pointer on feature object diff --git a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp index 33bb8470c..4184e2999 100644 --- a/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp +++ b/src/ModuleBase/ModuleBase_WidgetSelectionFilter.cpp @@ -178,6 +178,7 @@ ModuleBase_FilterItem::ModuleBase_FilterItem( connect(aWidget, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), theParent, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*))); connect(aWidget, SIGNAL(objectUpdated()), theParent, SLOT(onObjectUpdated())); + aWidget->enableFocusProcessing(); } aLayout->addWidget(aParamsWgt); } diff --git a/src/PythonAPI/model/exchange/__init__.py b/src/PythonAPI/model/exchange/__init__.py index 84b62bcc3..a37fdd678 100644 --- a/src/PythonAPI/model/exchange/__init__.py +++ b/src/PythonAPI/model/exchange/__init__.py @@ -19,7 +19,7 @@ """Package for Exchange plugin for the Parametric Geometry API of the Modeler. """ -from ExchangeAPI import addImport, addImportStep, exportToFile, exportToXAO, exportToSTL +from ExchangeAPI import addImport, exportToFile, exportToXAO from ExchangeAPI import exportPart, importPart from .tools import * -- 2.39.2