]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add API python, Project on edge and face for curv method
authorJérôme <jerome.lucas@cesgenslab.fr>
Mon, 5 Oct 2020 09:13:42 +0000 (11:13 +0200)
committerJérôme <jerome.lucas@cesgenslab.fr>
Mon, 5 Oct 2020 09:13:42 +0000 (11:13 +0200)
src/FeaturesAPI/FeaturesAPI_Fillet.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.cpp
src/FeaturesPlugin/FeaturesPlugin_Fillet.h
src/FeaturesPlugin/FeaturesPlugin_WidgetFilletMultiRadiuses.cpp
src/FeaturesPlugin/fillet_widget.xml
src/GeomAlgoAPI/GeomAlgoAPI_Fillet.cpp

index 1a93465ec61e9b41227ea53ed4b14b2cc7581de7..9d41827881318fba4830bceda573497209d10017 100644 (file)
@@ -26,6 +26,7 @@
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Pnt.h>
+#include <GeomAPI_Curve.h>
 
 static GeomAPI_Shape::ShapeType typeOfSelection(
     const std::list<ModelHighAPI_Selection>& theBaseObjects)
@@ -172,6 +173,9 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Featur
     GeomPointPtr first =  anEdge->firstPoint();
     GeomPointPtr last  =  anEdge->lastPoint();
     double taille = first->distance(last);
+
+    std::shared_ptr<GeomAPI_Curve> aCurve(new GeomAPI_Curve(edgeselected()->value()));
+
     ListOfShape aPoints;
     std::set<GeomShapePtr> aContexts;
     for (int anIndex = 0; anIndex < myarraypointradiusbypoint->size(); ++anIndex) {
@@ -196,7 +200,8 @@ FeaturesAPI_Fillet2D::FeaturesAPI_Fillet2D(const std::shared_ptr<ModelAPI_Featur
     ListOfShape::const_iterator aPointsIt = aPoints.begin();
     for (; aPointsIt != aPoints.end(); ++aPointsIt, aRowsRadiusIter++) {
       std::shared_ptr<GeomAPI_Pnt> aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt);
-      double res = (aPnt->distance(first) / taille);
+      std::shared_ptr<GeomAPI_Pnt> 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<ModelHighAPI_Selection>& 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);
index aafdfacde94170494479abceb42b10e015458573..e52156a8c9d6390d57ecc378a11e69d014b00ce9 100644 (file)
@@ -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<ModelAPI_AttributeSelection>(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<ModelAPI_AttributeSelection>(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
index ff7f2774d459b7a300072451692bc106e87520d1..f06195b02d817ab639e8e199ae901d541dc31e50 100644 (file)
@@ -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()
   {
index 701d5cd65cd1a9ddd713de77946a2421a37ebaa1..5d4b30b3750f788027ec559fb2a7c33699d54ef7 100644 (file)
@@ -56,6 +56,7 @@
 #include <GeomAlgoAPI_PointBuilder.h>
 #include <GeomAPI_Edge.h>
 #include <GeomAPI_Pnt.h>
+#include <GeomAPI_Curve.h>
 #include <Locale_Convert.h>
 #include <QStandardItem>
 #include <map>
@@ -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<GeomAPI_Curve> 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<GeomAPI_Pnt> aPnt = GeomAlgoAPI_PointBuilder::point(*aPointsIt);
-      res = (aPnt->distance(first) / taille);
+      std::shared_ptr<GeomAPI_Pnt> 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<ModelAPI_Result>(aValue->object());
   aShape = aValue->shape();
-
   if ( (aResult.get() || aShape.get() ) && !aSelList->isInList(aResult, aShape)) {
     aSelList->append(aResult, aShape);
     onRemoveStep();
index d4c6fa6249ee1432ea762a7da3f2d8b10f45689a..4601b038831a495fb487b732ba194b622b10e7f5 100644 (file)
          title="By curvilinear abscissa"
          tooltip="Fillet with multiple radiuses by curvilinear abscissa"
          icon="icons/Features/fillet_multiradius_by_curv.png">
-          <shape_selector id="edge_selected"
+          <shape_selector id="edgeface_selected"
                         icon="icons/Features/edge.png"
                         label="Start"
                         tooltip="Select edge"
-                        shape_types="edge">
-           <validator id="GeomValidators_ShapeType" parameters="empty,line"/>
+                        shape_types="edge face">
+           <validator id="GeomValidators_ShapeType" parameters="empty,line,face"/>
           </shape_selector>
           <multiradiuscurv-panel id="array_point_radius_by_point"
             filter_points="false">
index 65f908deda7f1ab2d82e7647c3b661733f321c87..f1241dd3627ffc67e279274337d15283b18f4683 100644 (file)
@@ -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