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.;
}
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);
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();
{
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
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()));
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.