mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-26 17:30:35 +05:00
0022362: EDF SMESH: Quadrangle (mapping) algorithm: enforced vertices
+ void GetBarycentricCoords( const gp_XY& point, + const gp_XY& t0, const gp_XY& t1, const gp_XY& t2, + double & bc0, double & bc1);
This commit is contained in:
parent
9858978294
commit
b8f19ad031
@ -26,6 +26,11 @@
|
||||
//
|
||||
#include "SMESH_Block.hxx"
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "SMESH_MeshAlgos.hxx"
|
||||
|
||||
#include <BRepAdaptor_Curve.hxx>
|
||||
#include <BRepAdaptor_Curve2d.hxx>
|
||||
#include <BRepAdaptor_Surface.hxx>
|
||||
@ -56,10 +61,7 @@
|
||||
#include <math_Matrix.hxx>
|
||||
#include <math_Vector.hxx>
|
||||
|
||||
#include "SMDS_MeshNode.hxx"
|
||||
#include "SMDS_MeshVolume.hxx"
|
||||
#include "SMDS_VolumeTool.hxx"
|
||||
#include "utilities.h"
|
||||
#include <utilities.h>
|
||||
|
||||
#include <list>
|
||||
#include <limits>
|
||||
@ -309,24 +311,15 @@ gp_XYZ SMESH_Block::TFace::Point( const gp_XYZ& theParams ) const
|
||||
|
||||
namespace
|
||||
{
|
||||
inline
|
||||
bool isPntInTria( const gp_XY& p, const gp_XY& t0, const gp_XY& t1, const gp_XY& t2 )
|
||||
{
|
||||
const double // matrix 2x2
|
||||
T11 = t0.X()-t2.X(), T12 = t1.X()-t2.X(),
|
||||
T21 = t0.Y()-t2.Y(), T22 = t1.Y()-t2.Y();
|
||||
const double Tdet = T11*T22 - T12*T21; // matrix determinant
|
||||
if ( Abs( Tdet ) < std::numeric_limits<double>::min() )
|
||||
return false;
|
||||
// matrix inverse
|
||||
const double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11;
|
||||
// vector
|
||||
const double r11 = p.X()-t2.X(), r12 = p.Y()-t2.Y();
|
||||
// barycentric coordinates: mutiply matrix by vector
|
||||
const double bc0 = (t11 * r11 + t12 * r12)/Tdet;
|
||||
const double bc1 = (t21 * r11 + t22 * r12)/Tdet;
|
||||
double bc0, bc1;
|
||||
SMESH_MeshAlgos::GetBarycentricCoords( p, t0, t1, t2, bc0, bc1 );
|
||||
return ( bc0 >= 0. && bc1 >= 0. && bc0 + bc1 <= 1. );
|
||||
}
|
||||
|
||||
inline
|
||||
bool isPntInQuad( const gp_XY& p,
|
||||
const gp_XY& q0, const gp_XY& q1, const gp_XY& q2, const gp_XY& q3 )
|
||||
{
|
||||
|
@ -1386,6 +1386,39 @@ double SMESH_MeshAlgos::GetDistance( const SMDS_MeshFace* face,
|
||||
return badDistance;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Returns barycentric coordinates of a point within a triangle.
|
||||
* A not returned bc2 = 1. - bc0 - bc1.
|
||||
* The point lies within the triangle if ( bc0 >= 0 && bc1 >= 0 && bc0+bc1 <= 1 )
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
void SMESH_MeshAlgos::GetBarycentricCoords( const gp_XY& p,
|
||||
const gp_XY& t0,
|
||||
const gp_XY& t1,
|
||||
const gp_XY& t2,
|
||||
double & bc0,
|
||||
double & bc1)
|
||||
{
|
||||
const double // matrix 2x2
|
||||
T11 = t0.X()-t2.X(), T12 = t1.X()-t2.X(),
|
||||
T21 = t0.Y()-t2.Y(), T22 = t1.Y()-t2.Y();
|
||||
const double Tdet = T11*T22 - T12*T21; // matrix determinant
|
||||
if ( Abs( Tdet ) < std::numeric_limits<double>::min() )
|
||||
{
|
||||
bc0 = bc1 = 2.;
|
||||
return;
|
||||
}
|
||||
// matrix inverse
|
||||
const double t11 = T22, t12 = -T12, t21 = -T21, t22 = T11;
|
||||
// vector
|
||||
const double r11 = p.X()-t2.X(), r12 = p.Y()-t2.Y();
|
||||
// barycentric coordinates: mutiply matrix by vector
|
||||
bc0 = (t11 * r11 + t12 * r12)/Tdet;
|
||||
bc1 = (t21 * r11 + t22 * r12)/Tdet;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindFaceInSet
|
||||
//purpose : Return a face having linked nodes n1 and n2 and which is
|
||||
|
@ -97,9 +97,16 @@ namespace SMESH_MeshAlgos
|
||||
/*!
|
||||
* \brief Return true if the point is IN or ON of the element
|
||||
*/
|
||||
SMESHUtils_EXPORT bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
|
||||
SMESHUtils_EXPORT
|
||||
bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
|
||||
|
||||
SMESHUtils_EXPORT double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
|
||||
SMESHUtils_EXPORT
|
||||
double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
|
||||
|
||||
SMESHUtils_EXPORT
|
||||
void GetBarycentricCoords( const gp_XY& point,
|
||||
const gp_XY& t0, const gp_XY& t1, const gp_XY& t2,
|
||||
double & bc0, double & bc1);
|
||||
|
||||
/*!
|
||||
* Return a face having linked nodes n1 and n2 and which is
|
||||
@ -107,35 +114,40 @@ namespace SMESH_MeshAlgos
|
||||
* - in elemSet provided that !elemSet.empty()
|
||||
* i1 and i2 optionally returns indices of n1 and n2
|
||||
*/
|
||||
SMESHUtils_EXPORT const SMDS_MeshElement*
|
||||
FindFaceInSet(const SMDS_MeshNode* n1,
|
||||
const SMDS_MeshNode* n2,
|
||||
const TIDSortedElemSet& elemSet,
|
||||
const TIDSortedElemSet& avoidSet,
|
||||
int* i1=0,
|
||||
int* i2=0);
|
||||
SMESHUtils_EXPORT
|
||||
const SMDS_MeshElement* FindFaceInSet(const SMDS_MeshNode* n1,
|
||||
const SMDS_MeshNode* n2,
|
||||
const TIDSortedElemSet& elemSet,
|
||||
const TIDSortedElemSet& avoidSet,
|
||||
int* i1=0,
|
||||
int* i2=0);
|
||||
/*!
|
||||
* \brief Calculate normal of a mesh face
|
||||
*/
|
||||
SMESHUtils_EXPORT bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);
|
||||
SMESHUtils_EXPORT
|
||||
bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);
|
||||
|
||||
/*!
|
||||
* \brief Return nodes common to two elements
|
||||
*/
|
||||
SMESHUtils_EXPORT std::vector< const SMDS_MeshNode*> GetCommonNodes(const SMDS_MeshElement* e1,
|
||||
SMESHUtils_EXPORT
|
||||
std::vector< const SMDS_MeshNode*> GetCommonNodes(const SMDS_MeshElement* e1,
|
||||
const SMDS_MeshElement* e2);
|
||||
|
||||
/*!
|
||||
* \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it
|
||||
*/
|
||||
SMESHUtils_EXPORT SMESH_NodeSearcher* GetNodeSearcher( SMDS_Mesh& mesh );
|
||||
SMESHUtils_EXPORT
|
||||
SMESH_NodeSearcher* GetNodeSearcher( SMDS_Mesh& mesh );
|
||||
|
||||
/*!
|
||||
* \brief Return SMESH_ElementSearcher. The caller is responsible for deleting it
|
||||
*/
|
||||
SMESHUtils_EXPORT SMESH_ElementSearcher* GetElementSearcher( SMDS_Mesh& mesh );
|
||||
SMESHUtils_EXPORT SMESH_ElementSearcher* GetElementSearcher( SMDS_Mesh& mesh,
|
||||
SMDS_ElemIteratorPtr elemIt );
|
||||
SMESHUtils_EXPORT
|
||||
SMESH_ElementSearcher* GetElementSearcher( SMDS_Mesh& mesh );
|
||||
SMESHUtils_EXPORT
|
||||
SMESH_ElementSearcher* GetElementSearcher( SMDS_Mesh& mesh,
|
||||
SMDS_ElemIteratorPtr elemIt );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user