From: Jérôme Date: Mon, 5 Oct 2020 09:13:42 +0000 (+0200) Subject: Add API python, Project on edge and face for curv method X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c8863238e0adbc812f708e05f913284e606b7e32;p=modules%2Fshaper.git Add API python, Project on edge and face for curv method --- diff --git a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp index 1a93465ec..9d4182788 100644 --- a/src/FeaturesAPI/FeaturesAPI_Fillet.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Fillet.cpp @@ -26,6 +26,7 @@ #include #include #include +#include static GeomAPI_Shape::ShapeType typeOfSelection( const std::list& theBaseObjects) @@ -172,6 +173,9 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptrfirstPoint(); GeomPointPtr last = anEdge->lastPoint(); double taille = first->distance(last); + + std::shared_ptr aCurve(new GeomAPI_Curve(edgeselected()->value())); + ListOfShape aPoints; std::set aContexts; for (int anIndex = 0; anIndex < myarraypointradiusbypoint->size(); ++anIndex) { @@ -196,7 +200,8 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt); - double res = (aPnt->distance(first) / taille); + std::shared_ptr aPntCurv = aCurve->project(aPnt); + double res = (aPntCurv->distance(first) / taille); aVal.myDouble = res; myvaluescurv()->setValue(aVal, aRowIndex, 0 ); aVal.myDouble = aRowsRadiusIter->value(); @@ -250,8 +255,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); @@ -260,8 +264,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); diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp index aafdfacde..e52156a8c 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp @@ -72,6 +72,7 @@ void FeaturesPlugin_Fillet::initAttributes() 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(EDGEFACE_SELECTED_ID(), ModelAPI_AttributeSelection::typeId()); data()->addAttribute(ARRAY_POINT_RADIUS_BY_POINTS(), ModelAPI_AttributeSelectionList::typeId()); @@ -91,7 +92,6 @@ void FeaturesPlugin_Fillet::initAttributes() AttributePtr FeaturesPlugin_Fillet::objectsAttribute() { - return attribute(OBJECT_LIST_ID()); } @@ -103,12 +103,17 @@ void FeaturesPlugin_Fillet::attributeChanged(const std::string& theID) 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() ); - - + + selection( EDGEFACE_SELECTED_ID())->setValue( anEdges->context(), anEdges->value()); + } + else if (theID == EDGEFACE_SELECTED_ID() + && string(CREATION_METHOD())->value() == CREATION_METHOD_MULTIPLES_RADIUSES()) { + + AttributeSelectionPtr anEdges = + std::dynamic_pointer_cast(attribute(EDGEFACE_SELECTED_ID())); + AttributeSelectionListPtr array = selectionList(OBJECT_LIST_ID()); + array->append(anEdges->namingName() ); } } @@ -156,6 +161,7 @@ GeomMakeShapePtr FeaturesPlugin_Fillet::performOperation(const GeomShapePtr& the aVal = aTablesAttr->value(k, 1); radiuses.push_back(aVal.myDouble); } + aFilletBuilder.reset(new GeomAlgoAPI_Fillet(theSolid, aFilletEdges, coodCurv,radiuses)); }else diff --git a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h index ff7f2774d..f06195b02 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_Fillet.h +++ b/src/FeaturesPlugin/FeaturesPlugin_Fillet.h @@ -106,6 +106,13 @@ public: return MY_EDGE_SELECTED_ID; } + /// Attribute name of edge selected. + inline static const std::string& EDGEFACE_SELECTED_ID() + { + static const std::string MY_EDGEFACE_SELECTED_ID("edgeface_selected"); + return MY_EDGEFACE_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() { diff --git a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp index 701d5cd65..5d4b30b37 100644 --- a/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp +++ b/src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -163,7 +164,6 @@ ModuleBase_WidgetSelector(theParent, theWorkshop, theData), myHeaderEditor(0), else myDataTbl->hideColumn(0); - QStringList aHeaders; aHeaders << "Point"; aHeaders << "Curvilinear /n Abscissa"; @@ -320,7 +320,6 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::eventFilter(QObject* theObject, Q //********************************************************************************** bool FeaturesPlugin_WidgetFilletMultiRadiuses::storeValueCustom() { - DataPtr aData = myFeature->data(); AttributeTablesPtr aTablesAttr; @@ -380,7 +379,9 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() GeomPointPtr first = anEdge->firstPoint(); GeomPointPtr last = anEdge->lastPoint(); double taille = first->distance(last); - + + std::shared_ptr aCurve(new GeomAPI_Curve(anEdges->value())); + // Load points AttributeSelectionListPtr aSelectionListAttr = aData->selectionList(FeaturesPlugin_Fillet::ARRAY_POINT_RADIUS_BY_POINTS()); AttributeDoubleArrayPtr aArrayAttr; @@ -406,7 +407,8 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses::restoreValueCustom() for (; aPointsIt != aPoints.end(); ++aPointsIt) { AttributeSelectionPtr attsel = aSelectionListAttr->value(i); std::shared_ptr aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt); - res = (aPnt->distance(first) / taille); + std::shared_ptr aPntCurv = aCurve->project(aPnt); + res = (aPntCurv->distance(first) / taille); QString aName = QString::fromStdWString(attsel->namingName()); QString aRad = findRadius( QString::number(res) ); if ( aValuesSort.find( res ) == aValuesSort.end() ) @@ -639,7 +641,6 @@ bool FeaturesPlugin_WidgetFilletMultiRadiuses:: ModuleBase_ViewerPrsPtr aValue = theValues.first(); aResult = std::dynamic_pointer_cast(aValue->object()); aShape = aValue->shape(); - if ( (aResult.get() || aShape.get() ) && !aSelList->isInList(aResult, aShape)) { aSelList->append(aResult, aShape); onRemoveStep(); diff --git a/src/FeaturesPlugin/fillet_widget.xml b/src/FeaturesPlugin/fillet_widget.xml index d4c6fa624..4601b0388 100644 --- a/src/FeaturesPlugin/fillet_widget.xml +++ b/src/FeaturesPlugin/fillet_widget.xml @@ -76,12 +76,12 @@ title="By curvilinear abscissa" tooltip="Fillet with multiple radiuses by curvilinear abscissa" icon="icons/Features/fillet_multiradius_by_curv.png"> - - + shape_types="edge face"> + diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp index 65f908ded..f1241dd36 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp @@ -129,7 +129,6 @@ void GeomAlgoAPI_Fillet::build(const GeomShapePtr& theBaseSolid, for( ; itCurv != theCurvCoord.end(); ++itCurv, ++itRadius ) { array.SetValue(i, gp_Pnt2d( (*itCurv) , (*itRadius))); - std::cout << "Value lance " << (*itCurv) << " "<< (*itRadius) << std::endl; i++; } // assign fillet radii for each contour of filleting edges