From: Jérôme Date: Sun, 4 Oct 2020 16:48:23 +0000 (+0200) Subject: Add API for Fillet MultiRadius X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=11dd0ff4fc8c3309ae8b24fd29602110a5446bcb;p=modules%2Fshaper.git Add API for Fillet MultiRadius --- diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp index 0f2f5041c..1a93465ec 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp @@ -23,6 +23,9 @@ #include #include #include +#include +#include +#include static GeomAPI_Shape::ShapeType typeOfSelection( const std::list& theBaseObjects) @@ -164,8 +167,46 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrvalue())); + GeomPointPtr first = anEdge->firstPoint(); + GeomPointPtr last = anEdge->lastPoint(); + double taille = first->distance(last); + ListOfShape aPoints; + std::set aContexts; + for (int anIndex = 0; anIndex < myarraypointradiusbypoint->size(); ++anIndex) { + AttributeSelectionPtr aSelection = myarraypointradiusbypoint->value(anIndex); + GeomShapePtr aShape = aSelection->value(); + ResultPtr aContext = aSelection->context(); + aContexts.insert(aContext->shape()); + + if (!aShape.get()) { + aShape = aContext->shape(); + } + aPoints.push_back(aShape); + } + std::list::const_iterator aRowsRadiusIter = theRadius.begin(); + ModelAPI_AttributeTables::Value aVal; + aVal.myDouble = 0.0; + myvaluescurv()->setValue(aVal, 0, 0 ); + aVal.myDouble = aRowsRadiusIter->value(); + myvaluescurv()->setValue(aVal, 0, 1 ); + aRowsRadiusIter++; + int aRowIndex = 1; + ListOfShape::const_iterator aPointsIt = aPoints.begin(); + for (; aPointsIt != aPoints.end(); ++aPointsIt, aRowsRadiusIter++) { + std::shared_ptr aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt); + double res = (aPnt->distance(first) / taille); + aVal.myDouble = res; + myvaluescurv()->setValue(aVal, aRowIndex, 0 ); + aVal.myDouble = aRowsRadiusIter->value(); + myvaluescurv()->setValue(aVal, aRowIndex, 1 ); + aRowIndex++; + } + aVal.myDouble = 1.0; + myvaluescurv()->setValue(aVal, aRowIndex, 0 ); + aVal.myDouble = aRowsRadiusIter->value(); + myvaluescurv()->setValue(aVal, aRowIndex, 1 ); execIfBaseNotEmpty(); } } @@ -180,9 +221,18 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrsetSize( thepointCurvCood.size(), 2 ); + std::list::const_iterator aRowsCoodIter = thepointCurvCood.begin(); + std::list::const_iterator aRowsRadiusIter = theRadius.begin(); + for(; aRowsCoodIter != thepointCurvCood.end(); aRowsCoodIter++, aRowsRadiusIter++, aRowIndex++) { + ModelAPI_AttributeTables::Value aVal; + aVal.myDouble = aRowsCoodIter->value(); + myvaluescurv()->setValue(aVal, aRowIndex, 0 ); + aVal.myDouble = aRowsRadiusIter->value(); + myvaluescurv()->setValue(aVal, aRowIndex, 1 ); + } execIfBaseNotEmpty(); } } @@ -201,6 +251,7 @@ void FeaturesAPI_Fillet2D::setBase(const std::list& theB void FeaturesAPI_Fillet2D::setRadius(const ModelHighAPI_Double& theRadius) { + std::cout << "FeaturesAPI_Fillet2D::setRadius" << std::endl; fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_SINGLE_RADIUS(), mycreationMethod); fillAttribute(theRadius, myradius); @@ -210,6 +261,7 @@ void FeaturesAPI_Fillet2D::setRadius(const ModelHighAPI_Double& theRadius) void FeaturesAPI_Fillet2D::setRadius(const ModelHighAPI_Double& theRadius1, const ModelHighAPI_Double& theRadius2) { + std::cout << "FeaturesAPI_Fillet2D::setRadius CREATION_METHOD_VARYING_RADIUS" << std::endl; fillAttribute(FeaturesPlugin_Fillet::CREATION_METHOD_VARYING_RADIUS(), mycreationMethod); fillAttribute(theRadius1, mystartRadius); fillAttribute(theRadius2, myendRadius); @@ -235,19 +287,39 @@ void FeaturesAPI_Fillet2D::dump(ModelHighAPI_Dumper& theDumper) const if( aBase->string(FeaturesPlugin_Fillet::CREATION_METHOD_MULTIPLES_RADIUSES())->value() == FeaturesPlugin_Fillet::CREATION_METHOD_BY_POINTS() ) { - /*AttributeSelectionListPtr anAttrPoint = + AttributeSelectionListPtr anAttrPoint = aBase->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); - AttributeDoubleArrayPtr anAttrRadius = - aBase->realArray(FeaturesPlugin_Fillet::ARRAY_RADIUS_BY_POINTS()); - theDumper << aBase << " = model.addFilletMultiRadiusBypoint(" << aDocName << ", " << anAttrEdgeSelec; - theDumper << ", " << anAttrPoint << ", " << anAttrRadius; + AttributeTablesPtr anAttrTable = + aBase->tables(FeaturesPlugin_Fillet::VALUES_ID()); + theDumper << aBase << " = model.addFillet(" << aDocName << ", " << anAttrEdgeSelec; + theDumper << ", " << anAttrPoint << ", "; + theDumper<<", ["; + for(int aRow = 0; aRow < myvalues()->rows(); aRow++) { + if (aRow != 0) + theDumper<<", "; + theDumper<value(aRow, 1).myDouble; + } + theDumper<<"]"; + }else{ - AttributeSelectionListPtr anAttrPoint = - aBase->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_CURV()); - AttributeDoubleArrayPtr anAttrRadius = - aBase->realArray(FeaturesPlugin_Fillet::ARRAY_RADIUS_BY_CURV()); - theDumper << aBase << " = model.addFilletMultiRadiusByCurv(" << aDocName << ", " << anAttrEdgeSelec; - theDumper << ", " << anAttrPoint << ", " << anAttrRadius;*/ + AttributeTablesPtr anAttrTable = + aBase->tables(FeaturesPlugin_Fillet::VALUES_CURV_ID()); + theDumper << aBase << " = model.addFillet(" << aDocName << ", " << anAttrEdgeSelec; + theDumper << ", "; + theDumper<<"["; + for(int aRow = 1; aRow < myvalues()->rows()-1; aRow++) { + if (aRow != 1) + theDumper<<", "; + theDumper<value(aRow, 0).myDouble; + } + theDumper<<"],"; + theDumper<<"["; + for(int aRow = 0; aRow < myvalues()->rows(); aRow++) { + if (aRow != 0) + theDumper<<", "; + theDumper<value(aRow, 1).myDouble; + } + theDumper<<"]"; } }else { theDumper << aBase << " = model.addFillet(" << aDocName << ", " << anAttrObjects; @@ -303,7 +375,7 @@ FilletPtr addFillet(const std::shared_ptr& thePart, return aFillet; } -FilletPtr addFilletMultiRadiusBypoint(const std::shared_ptr& thePart, +FilletPtr addFillet(const std::shared_ptr& thePart, const ModelHighAPI_Selection & theedgeselected, const std::list& thepoint, const std::list& theRadius, @@ -321,7 +393,7 @@ FilletPtr addFilletMultiRadiusBypoint(const std::shared_ptr& return aFillet; } -FilletPtr addFilletMultiRadiusByCurv(const std::shared_ptr& thePart, +FilletPtr addFillet(const std::shared_ptr& thePart, const ModelHighAPI_Selection & theedgeselected, const std::list& thepointCurvCood, const std::list& theRadius, diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.h b/src/FeaturesAPI/FeaturesAPI_Fillet.h index 2d66f7d6f..258d6e8ee 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.h +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.h @@ -148,7 +148,7 @@ public: FEATURESAPI_EXPORT virtual ~FeaturesAPI_Fillet2D(); - INTERFACE_8(FeaturesPlugin_Fillet::ID(), + INTERFACE_10(FeaturesPlugin_Fillet::ID(), creationMethod, FeaturesPlugin_Fillet::CREATION_METHOD(), ModelAPI_AttributeString, /** Creation method */, @@ -164,6 +164,12 @@ public: arraypointradiusbypoint, FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList, /** Base objects */, + myvalues, FeaturesPlugin_Fillet::VALUES_ID(), + ModelAPI_AttributeTables, + /** table for methode multi-radiuses by point */, + myvaluescurv, FeaturesPlugin_Fillet::VALUES_CURV_ID(), + ModelAPI_AttributeTables, + /** table for methode multi-radiuses by curviliean coodinate */, radius, FeaturesPlugin_Fillet::RADIUS_ID(), ModelAPI_AttributeDouble, /** Value of the fixed radius fillet */, @@ -207,7 +213,7 @@ FilletPtr addFillet(const std::shared_ptr& thePart, /// \ingroup CPPHighAPI /// \brief Create Fillet feature. FEATURESAPI_EXPORT -FilletPtr addFilletMultiRadiusBypoint(const std::shared_ptr& thePart, +FilletPtr addFillet(const std::shared_ptr& thePart, const ModelHighAPI_Selection & theedgeselected, const std::list& thepoint, const std::list& theRadius, @@ -217,10 +223,10 @@ FilletPtr addFilletMultiRadiusBypoint(const std::shared_ptr& /// \ingroup CPPHighAPI /// \brief Create Fillet feature. FEATURESAPI_EXPORT -FilletPtr addFilletMultiRadiusByCurv(const std::shared_ptr& thePart, - const ModelHighAPI_Selection & theedgeselected, - const std::list& thepointCurvCood, - const std::list& theRadius, - const bool keepSubResults= false); +FilletPtr addFillet( const std::shared_ptr& thePart, + const ModelHighAPI_Selection & theedgeselected, + const std::list& thepointCurvCood, + const std::list& theRadius, + const bool keepSubResults= false); #endif // FeaturesAPI_Fillet_H_ diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp index 3c9f3e3ad..701d5cd65 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp @@ -158,6 +158,11 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), myLastRowValue.push_back("2"); } + if(myTypeMethodeBypoint) + myDataTbl->hideColumn(1); + else + myDataTbl->hideColumn(0); + QStringList aHeaders; aHeaders << "Point";