+ static bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);

This commit is contained in:
eap 2010-02-24 12:43:56 +00:00
parent 1ac99281d8
commit a34eac9276
2 changed files with 47 additions and 2 deletions

View File

@ -175,6 +175,37 @@ double SMESH_Algo::EdgeLength(const TopoDS_Edge & E)
return length;
}
//================================================================================
/*!
* \brief Calculate normal of a mesh face
*/
//================================================================================
bool SMESH_Algo::FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized)
{
if ( !F || F->GetType() != SMDSAbs_Face )
return false;
normal.SetCoord(0,0,0);
int nbNodes = F->IsQuadratic() ? F->NbNodes()/2 : F->NbNodes();
for ( int i = 0; i < nbNodes-2; ++i )
{
gp_XYZ p[3];
for ( int n = 0; n < 3; ++n )
{
const SMDS_MeshNode* node = F->GetNode( n );
p[n].SetCoord( node->X(), node->Y(), node->Z() );
}
normal += ( p[0] - p[1] ) ^ ( p[2] - p[1] );
}
double size2 = normal.SquareModulus();
bool ok = ( size2 > numeric_limits<double>::min() * numeric_limits<double>::min());
if ( normalized && ok )
normal /= sqrt( size2 );
return ok;
}
//================================================================================
/*!
* \brief Find out elements orientation on a geometrical face

View File

@ -53,11 +53,20 @@ class SMESHDS_Mesh;
class SMDS_MeshNode;
class SMESH_subMesh;
class SMESH_MesherHelper;
class gp_XYZ;
typedef std::map< SMESH_subMesh*, std::vector<int> > MapShapeNbElems;
// vector must have size corresponding to EntityType_Last from SMDSAbs:
typedef std::map< SMESH_subMesh*, std::vector<int> > MapShapeNbElems;
typedef std::map< SMESH_subMesh*, std::vector<int> >::iterator MapShapeNbElemsItr;
/*!
* \brief Root of all algorithms
*
* Methods of the class are grouped into several parts:
* - main lifecycle methods, like Compute()
* - methods describing features of the algorithm, like NeedShape()
* - methods related to dependencies between sub-meshes imposed by the algorith
* - static utilities, like EdgeLength()
*/
class SMESH_EXPORT SMESH_Algo:public SMESH_Hypothesis
{
public:
@ -281,6 +290,11 @@ public:
*/
static double EdgeLength(const TopoDS_Edge & E);
/*!
* \brief Calculate normal of a mesh face
*/
static bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);
/*!
* \brief Return continuity of two edges
* \param E1 - the 1st edge