AUXILIARY METHODS
*/
-namespace{
+namespace {
+
+ const double theEps = 1e-100;
+ const double theInf = 1e+100;
inline gp_XYZ gpXYZ(const SMDS_MeshNode* aNode )
{
if ( myMesh == 0 )
return false;
- return GetPoints( myMesh->FindElement( theId ), theRes );
+ const SMDS_MeshElement* anElem = myMesh->FindElement( theId );
+ if ( !anElem || anElem->GetType() != this->GetType() )
+ return false;
+
+ return GetPoints( anElem, theRes );
}
bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem,
{
theRes.clear();
- if ( anElem == 0)
+ if ( anElem == 0 )
return false;
theRes.reserve( anElem->NbNodes() );
return SMDSAbs_Volume;
}
-
+//=======================================================================
/*
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;
- }
- return 0.;
+ return GetPoints( theElementId, P ) ? GetValue(P) : 0.0;
}
double MaxElementLength2D::GetBadRate( double Value, int /*nbNodes*/ ) const
return SMDSAbs_Face;
}
+//=======================================================================
/*
Class : MaxElementLength3D
Description : Functor calculating maximum length of 3D element
return SMDSAbs_Volume;
}
-
+//=======================================================================
/*
Class : MinimumAngle
Description : Functor for calculation of minimum angle
double maxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) );
double half_perimeter = ( aLen[0] + aLen[1] + aLen[2] ) / 2.;
double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) );
- if ( anArea <= Precision::Confusion() )
- return 0.;
+ if ( anArea <= theEps )
+ return theInf;
return alfa * maxLen * half_perimeter / anArea;
}
else if ( nbNodes == 6 ) { // quadratic triangles
double maxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) );
double half_perimeter = ( aLen[0] + aLen[1] + aLen[2] ) / 2.;
double anArea = getArea( P(1), P(3), P(5) );
- if ( anArea <= Precision::Confusion() )
- return 0.;
+ if ( anArea <= theEps )
+ return theInf;
return alfa * maxLen * half_perimeter / anArea;
}
else if( nbNodes == 4 ) { // quadrangle
double C2 = Min( anArea[ 0 ],
Min( anArea[ 1 ],
Min( anArea[ 2 ], anArea[ 3 ] ) ) );
- if ( C2 <= Precision::Confusion() )
- return 0.;
+ if ( C2 <= theEps )
+ return theInf;
return alpha * L * C1 / C2;
}
else if( nbNodes == 8 || nbNodes == 9 ) { // nbNodes==8 - quadratic quadrangle
double C2 = Min( anArea[ 0 ],
Min( anArea[ 1 ],
Min( anArea[ 2 ], anArea[ 3 ] ) ) );
- if ( C2 <= Precision::Confusion() )
- return 0.;
+ if ( C2 <= theEps )
+ return theInf;
return alpha * L * C1 / C2;
}
return 0;
double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) );
double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) );
double L = Min( aLen1, aLen2 ) * 0.5;
- if ( L < Precision::Confusion())
- return 0.;
+ if ( L < theEps )
+ return theInf;
gp_XYZ GI = ( thePnt2 + thePnt1 ) / 2. - theG;
gp_XYZ GJ = ( thePnt3 + thePnt2 ) / 2. - theG;
double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2.;
double JA = 0.25 * ( J1 + J2 + J3 + J4 );
- if ( JA <= Precision::Confusion() )
- return 0.;
+ if ( JA <= theEps )
+ return theInf;
double T1 = fabs( ( J1 - JA ) / JA );
double T2 = fabs( ( J2 - JA ) / JA );
? 0. : fabs( PI2 - v1.Angle( v2 ) );
//BUG SWP12743
- if ( A < Precision::Angular() )
- return 0.;
+ if ( A < theEps )
+ return theInf;
return A * 180. / M_PI;
}
ElementsOnSurface::ElementsOnSurface()
{
- myMesh = 0;
myIds.Clear();
myType = SMDSAbs_All;
mySurf.Nullify();
ElementsOnSurface::~ElementsOnSurface()
{
- myMesh = 0;
}
void ElementsOnSurface::SetMesh( const SMDS_Mesh* theMesh )
{
- if ( myMesh == theMesh )
- return;
- myMesh = theMesh;
- process();
+ myMeshModifTracer.SetMesh( theMesh );
+ if ( myMeshModifTracer.IsMeshModified())
+ process();
}
bool ElementsOnSurface::IsSatisfy( long theElementId )
if ( mySurf.IsNull() )
return;
- if ( myMesh == 0 )
+ if ( !myMeshModifTracer.GetMesh() )
return;
- if ( myType == SMDSAbs_Face || myType == SMDSAbs_All )
- {
- myIds.ReSize( myMesh->NbFaces() );
- SMDS_FaceIteratorPtr anIter = myMesh->facesIterator();
- for(; anIter->more(); )
- process( anIter->next() );
- }
+ myIds.ReSize( myMeshModifTracer.GetMesh()->GetMeshInfo().NbElements( myType ));
- if ( myType == SMDSAbs_Edge || myType == SMDSAbs_All )
- {
- myIds.ReSize( myIds.Extent() + myMesh->NbEdges() );
- SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator();
- for(; anIter->more(); )
- process( anIter->next() );
- }
-
- if ( myType == SMDSAbs_Node )
- {
- myIds.ReSize( myMesh->NbNodes() );
- SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator();
- for(; anIter->more(); )
- process( anIter->next() );
- }
+ SMDS_ElemIteratorPtr anIter = myMeshModifTracer.GetMesh()->elementsIterator( myType );
+ for(; anIter->more(); )
+ process( anIter->next() );
}
void ElementsOnSurface::process( const SMDS_MeshElement* theElemPtr )
if ( !myMesh ) return;
- switch (myType)
- {
- case SMDSAbs_All:
- myIds.ReSize(myMesh->NbEdges() + myMesh->NbFaces() + myMesh->NbVolumes());
- break;
- case SMDSAbs_Node:
- myIds.ReSize(myMesh->NbNodes());
- break;
- case SMDSAbs_Edge:
- myIds.ReSize(myMesh->NbEdges());
- break;
- case SMDSAbs_Face:
- myIds.ReSize(myMesh->NbFaces());
- break;
- case SMDSAbs_Volume:
- myIds.ReSize(myMesh->NbVolumes());
- break;
- default:
- break;
- }
+ myIds.ReSize( myMeshModifTracer.GetMesh()->GetMeshInfo().NbElements( myType ));
myShapesMap.Clear();
addShape(myShape);