Salome HOME
Fix for the "0021861: EDF 2226 : Documentation of numeric functor option in split...
authorana <ana@opencascade.com>
Thu, 1 Nov 2012 11:39:48 +0000 (11:39 +0000)
committerana <ana@opencascade.com>
Thu, 1 Nov 2012 11:39:48 +0000 (11:39 +0000)
src/Controls/SMESH_Controls.cxx
src/Controls/SMESH_ControlsDef.hxx
src/SMESH/SMESH_MeshEditor.cxx
src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx
src/SMESHGUI/SMESH_msg_en.ts
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_MeshEditor_i.cxx
src/SMESH_SWIG/smeshDC.py

index 2fe0e08891904acfef1deea8223a59c85781cad5..6b400350d09daae940b87994fc36ecec6be6ac76 100644 (file)
@@ -429,59 +429,56 @@ SMDSAbs_ElementType Volume::GetType() const
   Class       : MaxElementLength2D
   Description : Functor calculating maximum length of 2D element
 */
+double MaxElementLength2D::GetValue( const TSequenceOfXYZ& P )
+{
+  if(P.size() == 0)
+    return 0.;
+  double aVal = 0;
+  int len = P.size();
+  if( len == 3 ) { // triangles
+    double L1 = getDistance(P( 1 ),P( 2 ));
+    double L2 = getDistance(P( 2 ),P( 3 ));
+    double L3 = getDistance(P( 3 ),P( 1 ));
+    aVal = Max(L1,Max(L2,L3));
+  }
+  else if( len == 4 ) { // quadrangles
+    double L1 = getDistance(P( 1 ),P( 2 ));
+    double L2 = getDistance(P( 2 ),P( 3 ));
+    double L3 = getDistance(P( 3 ),P( 4 ));
+    double L4 = getDistance(P( 4 ),P( 1 ));
+    double D1 = getDistance(P( 1 ),P( 3 ));
+    double D2 = getDistance(P( 2 ),P( 4 ));
+    aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(D1,D2));
+  }
+  else if( len == 6 ) { // quadratic triangles
+    double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
+    double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
+    double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 1 ));
+    aVal = Max(L1,Max(L2,L3));
+  }
+  else if( len == 8 || len == 9 ) { // quadratic quadrangles
+    double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
+    double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
+    double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 7 ));
+    double L4 = getDistance(P( 7 ),P( 8 )) + getDistance(P( 8 ),P( 1 ));
+    double D1 = getDistance(P( 1 ),P( 5 ));
+    double D2 = getDistance(P( 3 ),P( 7 ));
+    aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(D1,D2));
+  }
+
+  if( myPrecision >= 0 )
+  {
+    double prec = pow( 10., (double)myPrecision );
+    aVal = floor( aVal * prec + 0.5 ) / prec;
+  }
+  return aVal;
+}
 
 double MaxElementLength2D::GetValue( long theElementId )
 {
   TSequenceOfXYZ P;
-  if( GetPoints( theElementId, P ) ) {
-    double aVal = 0;
-    const SMDS_MeshElement* aElem = myMesh->FindElement( theElementId );
-    SMDSAbs_ElementType aType = aElem->GetType();
-    int len = P.size();
-    switch( aType ) {
-    case SMDSAbs_Face:
-      if( len == 3 ) { // triangles
-        double L1 = getDistance(P( 1 ),P( 2 ));
-        double L2 = getDistance(P( 2 ),P( 3 ));
-        double L3 = getDistance(P( 3 ),P( 1 ));
-        aVal = Max(L1,Max(L2,L3));
-        break;
-      }
-      else if( len == 4 ) { // quadrangles
-        double L1 = getDistance(P( 1 ),P( 2 ));
-        double L2 = getDistance(P( 2 ),P( 3 ));
-        double L3 = getDistance(P( 3 ),P( 4 ));
-        double L4 = getDistance(P( 4 ),P( 1 ));
-        double D1 = getDistance(P( 1 ),P( 3 ));
-        double D2 = getDistance(P( 2 ),P( 4 ));
-        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(D1,D2));
-        break;
-      }
-      else if( len == 6 ) { // quadratic triangles
-        double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
-        double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
-        double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 1 ));
-        aVal = Max(L1,Max(L2,L3));
-        break;
-      }
-      else if( len == 8 || len == 9 ) { // quadratic quadrangles
-        double L1 = getDistance(P( 1 ),P( 2 )) + getDistance(P( 2 ),P( 3 ));
-        double L2 = getDistance(P( 3 ),P( 4 )) + getDistance(P( 4 ),P( 5 ));
-        double L3 = getDistance(P( 5 ),P( 6 )) + getDistance(P( 6 ),P( 7 ));
-        double L4 = getDistance(P( 7 ),P( 8 )) + getDistance(P( 8 ),P( 1 ));
-        double D1 = getDistance(P( 1 ),P( 5 ));
-        double D2 = getDistance(P( 3 ),P( 7 ));
-        aVal = Max(Max(Max(L1,L2),Max(L3,L4)),Max(D1,D2));
-        break;
-      }
-    }
-
-    if( myPrecision >= 0 )
-    {
-      double prec = pow( 10., (double)myPrecision );
-      aVal = floor( aVal * prec + 0.5 ) / prec;
-    }
-    return aVal;
+  if( GetPoints( theElementId, P ) && myMesh->FindElement( theElementId )->GetType() == SMDSAbs_Face) {
+    GetValue(P);
   }
   return 0.;
 }
index 81e7ba1cd6f83a748cb64cd7d3dd4174a7752d24..587f5b6d609bf79b6c09b933764aaaf81758953b 100644 (file)
@@ -162,6 +162,7 @@ namespace SMESH{
     class SMESHCONTROLS_EXPORT MaxElementLength2D: public virtual NumericalFunctor{
     public:
       virtual double GetValue( long theElementId );
+      virtual double GetValue( const TSequenceOfXYZ& P );
       virtual double GetBadRate( double Value, int nbNodes ) const;
       virtual SMDSAbs_ElementType GetType() const;
     };
index c7eb286003290d5f27e0455a7ca55c30a893c7ff..7691b580d381b8188c95dfa35ef761d445a8dbd4 100644 (file)
@@ -1267,7 +1267,8 @@ bool SMESH_MeshEditor::QuadToTri (TIDSortedElemSet &                   theElems,
     if( !elem->IsQuadratic() ) {
 
       // split liner quadrangle
-
+      // for MaxElementLength2D functor we return minimum diagonal for splitting,
+      // because aBadRate1=2*len(diagonal 1-3); aBadRate2=2*len(diagonal 2-4)
       if ( aBadRate1 <= aBadRate2 ) {
         // tr1 + tr2 is better
         newElem1 = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] );
@@ -1401,7 +1402,8 @@ int SMESH_MeshEditor::BestSplit (const SMDS_MeshElement*              theQuad,
     SMDS_FaceOfNodes tr3 ( aNodes[1], aNodes[2], aNodes[3] );
     SMDS_FaceOfNodes tr4 ( aNodes[3], aNodes[0], aNodes[1] );
     aBadRate2 = getBadRate( &tr3, theCrit ) + getBadRate( &tr4, theCrit );
-
+    // for MaxElementLength2D functor we return minimum diagonal for splitting,
+    // because aBadRate1=2*len(diagonal 1-3); aBadRate2=2*len(diagonal 2-4)
     if (aBadRate1 <= aBadRate2) // tr1 + tr2 is better
       return 1; // diagonal 1-3
 
index b6aa6c3e2e34abc60f335fc596e7435a52e36bc6..b87346e6313b43ff68d03ad5c241183776a06c21 100755 (executable)
@@ -225,7 +225,7 @@ QWidget* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool
   myComboBoxFunctor->addItem(tr("ASPECTRATIO_ELEMENTS"));
   myComboBoxFunctor->addItem(tr("MINIMUMANGLE_ELEMENTS"));
   myComboBoxFunctor->addItem(tr("SKEW_ELEMENTS"));
-  myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
+  //myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
   //myComboBoxFunctor->addItem(tr("LENGTH2D_EDGES")); // for existing elements only
   //myComboBoxFunctor->addItem(tr("MULTI2D_BORDERS")); // for existing elements only
   myComboBoxFunctor->setCurrentIndex(0);
@@ -362,6 +362,8 @@ SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor()
     aNF = aFilterMgr->CreateLength2D();
   else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS"))
     aNF = aFilterMgr->CreateMultiConnection2D();
+  else if (myComboBoxFunctor->currentText() == tr("MIN_DIAG_ELEMENTS"))
+    aNF = aFilterMgr->CreateMaxElementLength2D();
   else;
 
   return aNF._retn();
@@ -1153,7 +1155,8 @@ SMESHGUI_UnionOfTrianglesDlg
 {
   setWindowTitle(tr("CAPTION"));
 
-  myComboBoxFunctor->setEnabled(true);
+  myComboBoxFunctor->setEnabled(true);  
+  myComboBoxFunctor->addItem(tr("AREA_ELEMENTS"));
   myComboBoxFunctor->addItem(tr("WARP_ELEMENTS")); // for quadrangles only
   myComboBoxFunctor->addItem(tr("TAPER_ELEMENTS")); // for quadrangles only
 
@@ -1240,6 +1243,8 @@ SMESHGUI_CuttingOfQuadsDlg
 
   myCriterionGrp->show();
   myChoiceWidget->show();
+  myComboBoxFunctor->insertItem(0, tr("MIN_DIAG_ELEMENTS"));
+  myComboBoxFunctor->setCurrentIndex(0);
   myComboBoxFunctor->setEnabled(false);
 
   connect(myPreviewChk,      SIGNAL(stateChanged(int)),    this, SLOT(onPreviewChk()));
index 868b81c7ddbf4343b992ba722402247eb78d3c7a..fa507c549c5055c7dfcd84cfa3300f4e1b291344 100644 (file)
         <source>AREA_ELEMENTS</source>
         <translation>Area</translation>
     </message>
+    <message>
+        <source>MIN_DIAG_ELEMENTS</source>
+        <translation>Minimum diagonal</translation>
+    </message>
     <message>
         <source>ASPECTRATIO_3D_ELEMENTS</source>
         <translation>Aspect Ratio 3D</translation>
index 43c0a524e3a1d19f788757bf9317d5ee80636960..e62d2bc657478b4327bf4c43964977ea71a54647 100644 (file)
@@ -2125,6 +2125,17 @@ void _pyMeshEditor::Process( const Handle(_pyCommand)& theCommand)
       theCommand->SetArg( 3, face );
   }
 
+  if(method == "QuadToTri" || method == "QuadToTriObject")\r
+  {\r
+    int crit_arg = theCommand->GetNbArgs();\r
+    _AString crit = theCommand->GetArg(crit_arg);\r
+    if(crit.Search("MaxElementLength2D") != -1)\r
+    {\r
+      theCommand->SetArg(crit_arg, "");\r
+      isPyMeshMethod = true;\r
+    }\r
+  }
+
   if ( isPyMeshMethod )
   {
     theCommand->SetObject( myMesh );
index d4274dc57dfd6ce5f733526434a5c0fc33efccc1..2d3f5b88831641f040fa6a505dfba9ea990e6738 100644 (file)
@@ -1546,7 +1546,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array &   IDsOfE
     dynamic_cast<SMESH::NumericalFunctor_i*>( SMESH_Gen_i::GetServant( Criterion ).in() );
   SMESH::Controls::NumericalFunctorPtr aCrit;
   if ( !aNumericalFunctor )
-    aCrit.reset( new SMESH::Controls::AspectRatio() );
+    aCrit.reset( new SMESH::Controls::MaxElementLength2D() );
   else
     aCrit = aNumericalFunctor->GetNumericalFunctor();
 
index 87d32ec81e4abe9bb7e1f4da4ca04b6854db2da7..6f2b63e7993b7ea25010f7988de5383188ea0102 100644 (file)
@@ -2682,23 +2682,33 @@ class Mesh:
         return self.editor.TriToQuadObject(theObject, self.smeshpyD.GetFunctor(theCriterion), MaxAngle)
 
     ## Splits quadrangles into triangles.
+    #
+    #  If @a theCriterion is None, quadrangles will be split by the smallest diagonal.
+    #
     #  @param IDsOfElements the faces to be splitted.
     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
     #  @return TRUE in case of success, FALSE otherwise.
     #  @ingroup l2_modif_cutquadr
-    def QuadToTri (self, IDsOfElements, theCriterion):
+    def QuadToTri (self, IDsOfElements, theCriterion = None):
         if IDsOfElements == []:
             IDsOfElements = self.GetElementsId()
+        if theCriterion is None:
+            theCriterion = FT_MaxElementLength2D
         return self.editor.QuadToTri(IDsOfElements, self.smeshpyD.GetFunctor(theCriterion))
 
     ## Splits quadrangles into triangles.
+    #
+    #  If @a theCriterion is None, quadrangles will be split by the smallest diagonal.
+    #
     #  @param theObject  the object from which the list of elements is taken, this is mesh, submesh or group
     #  @param theCriterion   FT_...; used to choose a diagonal for splitting.
     #  @return TRUE in case of success, FALSE otherwise.
     #  @ingroup l2_modif_cutquadr
-    def QuadToTriObject (self, theObject, theCriterion):
+    def QuadToTriObject (self, theObject, theCriterion = None):
         if ( isinstance( theObject, Mesh )):
             theObject = theObject.GetMesh()
+        if theCriterion is None:
+            theCriterion = FT_MaxElementLength2D
         return self.editor.QuadToTriObject(theObject, self.smeshpyD.GetFunctor(theCriterion))
 
     ## Splits quadrangles into triangles.