+//================================================================================
+/*!
+ * \brief Decrease height of a given or adjacent pyramids if height difference
+ * is too large
+ * \param [in] pyram - a pyramid to treat
+ * \param [inout] h2 - pyramid's square height
+ * \return bool - true if the height changes
+ */
+//================================================================================
+
+bool StdMeshers_QuadToTriaAdaptor::DecreaseHeightDifference( const SMDS_MeshElement* thePyram,
+ const double theH2 )
+{
+ const double allowedFactor2 = 2. * 2.;
+
+ bool modif = false;
+ myNodes[0] = thePyram->GetNode( 3 );
+ for ( int i = 0; i < 4; ++i )
+ {
+ myNodes[1] = thePyram->GetNode( i );
+ SMDS_Mesh::GetElementsByNodes( myNodes, myAdjPyrams, SMDSAbs_Volume );
+ myNodes[0] = myNodes[1];
+
+ for ( const SMDS_MeshElement* pyramAdj : myAdjPyrams )
+ {
+ if ( pyramAdj == thePyram )
+ continue;
+ if ( !myPyramHeight2.IsBound( pyramAdj ))
+ continue;
+ double h2Adj = Abs( myPyramHeight2( pyramAdj ));
+ double h2 = Abs( theH2 );
+ if ( h2Adj > h2 )
+ {
+ if ( h2 * allowedFactor2 < h2Adj )
+ {
+ // bind negative value to allow finding pyramids whose height must change
+ myPyramHeight2.Bind( pyramAdj, - h2 * allowedFactor2 );
+ modif = true;
+ }
+ }
+ else
+ {
+ if ( h2Adj * allowedFactor2 < h2 )
+ {
+ // bind negative value to allow finding pyramids whose height must change
+ myPyramHeight2.Bind( thePyram, - h2Adj * allowedFactor2 );
+ modif = true;
+ }
+ }
+ }
+ }
+ return modif;
+}
+
+