mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2024-12-28 18:30:35 +05:00
0022360: EDF SMESH: Body Fitting algorithm: incorporate edges
Treat tangent transition at the 1st link node
This commit is contained in:
parent
004510cb7d
commit
790cad1c40
@ -54,6 +54,8 @@
|
|||||||
#include <Geom2d_BSplineCurve.hxx>
|
#include <Geom2d_BSplineCurve.hxx>
|
||||||
#include <Geom2d_BezierCurve.hxx>
|
#include <Geom2d_BezierCurve.hxx>
|
||||||
#include <Geom2d_TrimmedCurve.hxx>
|
#include <Geom2d_TrimmedCurve.hxx>
|
||||||
|
#include <GeomAPI_ProjectPointOnSurf.hxx>
|
||||||
|
#include <GeomLib.hxx>
|
||||||
#include <Geom_BSplineCurve.hxx>
|
#include <Geom_BSplineCurve.hxx>
|
||||||
#include <Geom_BSplineSurface.hxx>
|
#include <Geom_BSplineSurface.hxx>
|
||||||
#include <Geom_BezierCurve.hxx>
|
#include <Geom_BezierCurve.hxx>
|
||||||
@ -289,6 +291,8 @@ namespace
|
|||||||
list< E_IntersectPoint > _edgeIntP; // intersections with EDGEs
|
list< E_IntersectPoint > _edgeIntP; // intersections with EDGEs
|
||||||
TopTools_IndexedMapOfShape _shapes;
|
TopTools_IndexedMapOfShape _shapes;
|
||||||
|
|
||||||
|
SMESH_MesherHelper* _helper;
|
||||||
|
|
||||||
size_t CellIndex( size_t i, size_t j, size_t k ) const
|
size_t CellIndex( size_t i, size_t j, size_t k ) const
|
||||||
{
|
{
|
||||||
return i + j*(_coords[0].size()-1) + k*(_coords[0].size()-1)*(_coords[1].size()-1);
|
return i + j*(_coords[0].size()-1) + k*(_coords[0].size()-1)*(_coords[1].size()-1);
|
||||||
@ -603,7 +607,7 @@ namespace
|
|||||||
bool findChain( _Node* n1, _Node* n2, _Face& quad, vector<_Node*>& chainNodes );
|
bool findChain( _Node* n1, _Node* n2, _Face& quad, vector<_Node*>& chainNodes );
|
||||||
bool closePolygon( _Face* polygon, vector<_Node*>& chainNodes ) const;
|
bool closePolygon( _Face* polygon, vector<_Node*>& chainNodes ) const;
|
||||||
int addElements(SMESH_MesherHelper& helper);
|
int addElements(SMESH_MesherHelper& helper);
|
||||||
bool is1stNodeOut( int iLink ) const;
|
bool is1stNodeOut( _Link& link ) const;
|
||||||
bool isInHole() const;
|
bool isInHole() const;
|
||||||
bool checkPolyhedronSize() const;
|
bool checkPolyhedronSize() const;
|
||||||
bool addHexa ();
|
bool addHexa ();
|
||||||
@ -1618,7 +1622,11 @@ namespace
|
|||||||
switch ( link._intNodes[i].FaceIntPnt()->_transition ) {
|
switch ( link._intNodes[i].FaceIntPnt()->_transition ) {
|
||||||
case Trans_OUT: isOut = true; break;
|
case Trans_OUT: isOut = true; break;
|
||||||
case Trans_IN : isOut = false; break;
|
case Trans_IN : isOut = false; break;
|
||||||
default:; // isOut remains the same
|
default:
|
||||||
|
if ( !link._intNodes[i].Node() && i == 0 )
|
||||||
|
isOut = is1stNodeOut( link );
|
||||||
|
else
|
||||||
|
; // isOut remains the same
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1703,7 +1711,10 @@ namespace
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: // inside a hex
|
} // switch( nbFacets )
|
||||||
|
|
||||||
|
if ( nbFacets == 0 ||
|
||||||
|
_grid->_shapes( _edgeIntPnts[ iP ]->_shapeID ).ShapeType() == TopAbs_VERTEX )
|
||||||
{
|
{
|
||||||
equalNode = FindEqualNode( _vertexNodes, _edgeIntPnts[ iP ], tol2 );
|
equalNode = FindEqualNode( _vertexNodes, _edgeIntPnts[ iP ], tol2 );
|
||||||
if ( equalNode ) {
|
if ( equalNode ) {
|
||||||
@ -1714,8 +1725,6 @@ namespace
|
|||||||
++_nbIntNodes;
|
++_nbIntNodes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // switch( nbFacets )
|
|
||||||
|
|
||||||
} // loop on _edgeIntPnts
|
} // loop on _edgeIntPnts
|
||||||
}
|
}
|
||||||
else if ( 3 < _nbCornerNodes && _nbCornerNodes < 8 ) // _nbIntNodes == 0
|
else if ( 3 < _nbCornerNodes && _nbCornerNodes < 8 ) // _nbIntNodes == 0
|
||||||
@ -2401,9 +2410,11 @@ namespace
|
|||||||
if ( iDirZ == 0 )
|
if ( iDirZ == 0 )
|
||||||
{
|
{
|
||||||
ip._point = p1;
|
ip._point = p1;
|
||||||
|
ip._shapeID = _grid->_shapes.Add( v1 );
|
||||||
_grid->_edgeIntP.push_back( ip );
|
_grid->_edgeIntP.push_back( ip );
|
||||||
if ( !addIntersection( _grid->_edgeIntP.back(), hexes, ijk, d000 ))
|
if ( !addIntersection( _grid->_edgeIntP.back(), hexes, ijk, d000 ))
|
||||||
_grid->_edgeIntP.pop_back();
|
_grid->_edgeIntP.pop_back();
|
||||||
|
ip._shapeID = edgeID;
|
||||||
}
|
}
|
||||||
for ( int iP = 2; iP <= discret.NbPoints(); ++iP )
|
for ( int iP = 2; iP <= discret.NbPoints(); ++iP )
|
||||||
{
|
{
|
||||||
@ -2446,6 +2457,7 @@ namespace
|
|||||||
// add the 2nd vertex point to a hexahedron
|
// add the 2nd vertex point to a hexahedron
|
||||||
if ( iDirZ == 0 )
|
if ( iDirZ == 0 )
|
||||||
{
|
{
|
||||||
|
ip._shapeID = _grid->_shapes.Add( v2 );
|
||||||
ip._point = p1;
|
ip._point = p1;
|
||||||
_grid->ComputeUVW( p1, ip._uvw );
|
_grid->ComputeUVW( p1, ip._uvw );
|
||||||
locateValue( ijk[iDirX], ip._uvw[iDirX], _grid->_coords[iDirX], dIJK[iDirX], tol );
|
locateValue( ijk[iDirX], ip._uvw[iDirX], _grid->_coords[iDirX], dIJK[iDirX], tol );
|
||||||
@ -2454,6 +2466,7 @@ namespace
|
|||||||
_grid->_edgeIntP.push_back( ip );
|
_grid->_edgeIntP.push_back( ip );
|
||||||
if ( !addIntersection( _grid->_edgeIntP.back(), hexes, ijk, d000 ))
|
if ( !addIntersection( _grid->_edgeIntP.back(), hexes, ijk, d000 ))
|
||||||
_grid->_edgeIntP.pop_back();
|
_grid->_edgeIntP.pop_back();
|
||||||
|
ip._shapeID = edgeID;
|
||||||
}
|
}
|
||||||
} // loop on 3 grid directions
|
} // loop on 3 grid directions
|
||||||
} // loop on EDGEs
|
} // loop on EDGEs
|
||||||
@ -2709,46 +2722,86 @@ namespace
|
|||||||
/*!
|
/*!
|
||||||
* \brief Checks transition at the 1st node of a link
|
* \brief Checks transition at the 1st node of a link
|
||||||
*/
|
*/
|
||||||
bool Hexahedron::is1stNodeOut( int iLink ) const
|
bool Hexahedron::is1stNodeOut( _Link& link /*int iLink*/ ) const
|
||||||
{
|
{
|
||||||
if ( !_hexLinks[ iLink ]._nodes[0]->Node() ) // no node
|
// new version is for the case: tangent transition at the 1st node
|
||||||
return true;
|
bool isOut = false;
|
||||||
if ( !_hexLinks[ iLink ]._nodes[0]->_intPoint ) // no intersection with geometry
|
if ( link._intNodes.size() > 1 )
|
||||||
return false;
|
{
|
||||||
switch ( _hexLinks[ iLink ]._nodes[0]->FaceIntPnt()->_transition ) {
|
// check transition at the next intersection
|
||||||
case Trans_OUT: return true;
|
switch ( link._intNodes[1].FaceIntPnt()->_transition ) {
|
||||||
case Trans_IN : return false;
|
case Trans_OUT: return false;
|
||||||
|
case Trans_IN : return true;
|
||||||
default: ; // tangent transition
|
default: ; // tangent transition
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
gp_Pnt p1 = link._nodes[0]->Point();
|
||||||
|
gp_Pnt p2 = link._nodes[1]->Point();
|
||||||
|
gp_Pnt testPnt = 0.8 * p1.XYZ() + 0.2 * p2.XYZ();
|
||||||
|
|
||||||
// ijk of a GridLine corresponding to the link
|
TGeomID faceID = link._intNodes[0]._intPoint->_faceIDs[0];
|
||||||
int iDir = iLink / 4;
|
const TopoDS_Face& face = TopoDS::Face( _grid->_shapes( faceID ));
|
||||||
int indSub = iLink % 4;
|
TopLoc_Location loc;
|
||||||
LineIndexer li = _grid->GetLineIndexer( iDir );
|
GeomAPI_ProjectPointOnSurf& proj =
|
||||||
li.SetIJK( _i,_j,_k );
|
_grid->_helper->GetProjector( face, loc, 0.1*_grid->_tol );
|
||||||
size_t lineIndex[4] = { li.LineIndex (),
|
testPnt.Transform( loc );
|
||||||
li.LineIndex10(),
|
proj.Perform( testPnt );
|
||||||
li.LineIndex01(),
|
if ( proj.IsDone() &&
|
||||||
li.LineIndex11() };
|
proj.NbPoints() > 0 &&
|
||||||
GridLine& line = _grid->_lines[ iDir ][ lineIndex[ indSub ]];
|
proj.LowerDistance() > _grid->_tol )
|
||||||
|
|
||||||
// analyze transition of previous ip
|
|
||||||
bool isOut = true;
|
|
||||||
multiset< F_IntersectPoint >::const_iterator ip = line._intPoints.begin();
|
|
||||||
for ( ; ip != line._intPoints.end(); ++ip )
|
|
||||||
{
|
{
|
||||||
if ( &(*ip) == _hexLinks[ iLink ]._nodes[0]->_intPoint )
|
Quantity_Parameter u,v;
|
||||||
break;
|
proj.LowerDistanceParameters( u,v );
|
||||||
switch ( ip->_transition ) {
|
gp_Dir normal;
|
||||||
case Trans_OUT: isOut = true;
|
if ( GeomLib::NormEstim( BRep_Tool::Surface( face, loc ),
|
||||||
case Trans_IN : isOut = false;
|
gp_Pnt2d( u,v ),
|
||||||
default:;
|
0.1*_grid->_tol,
|
||||||
|
normal ) < 3 )
|
||||||
|
{
|
||||||
|
if ( face.Orientation() == TopAbs_REVERSED )
|
||||||
|
normal.Reverse();
|
||||||
|
gp_Vec v( proj.NearestPoint(), testPnt );
|
||||||
|
return v * normal > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef _DEBUG_
|
// if ( !_hexLinks[ iLink ]._nodes[0]->Node() ) // no node
|
||||||
if ( ip == line._intPoints.end() )
|
// return true;
|
||||||
cout << "BUG: Wrong GridLine. IKJ = ( "<< _i << " " << _j << " " << _k << " )" << endl;
|
// if ( !_hexLinks[ iLink ]._nodes[0]->_intPoint ) // no intersection with geometry
|
||||||
#endif
|
// return false;
|
||||||
|
// switch ( _hexLinks[ iLink ]._nodes[0]->FaceIntPnt()->_transition ) {
|
||||||
|
// case Trans_OUT: return true;
|
||||||
|
// case Trans_IN : return false;
|
||||||
|
// default: ; // tangent transition
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // ijk of a GridLine corresponding to the link
|
||||||
|
// int iDir = iLink / 4;
|
||||||
|
// int indSub = iLink % 4;
|
||||||
|
// LineIndexer li = _grid->GetLineIndexer( iDir );
|
||||||
|
// li.SetIJK( _i,_j,_k );
|
||||||
|
// size_t lineIndex[4] = { li.LineIndex (),
|
||||||
|
// li.LineIndex10(),
|
||||||
|
// li.LineIndex01(),
|
||||||
|
// li.LineIndex11() };
|
||||||
|
// GridLine& line = _grid->_lines[ iDir ][ lineIndex[ indSub ]];
|
||||||
|
|
||||||
|
// // analyze transition of previous ip
|
||||||
|
// bool isOut = true;
|
||||||
|
// multiset< F_IntersectPoint >::const_iterator ip = line._intPoints.begin();
|
||||||
|
// for ( ; ip != line._intPoints.end(); ++ip )
|
||||||
|
// {
|
||||||
|
// if ( &(*ip) == _hexLinks[ iLink ]._nodes[0]->_intPoint )
|
||||||
|
// break;
|
||||||
|
// switch ( ip->_transition ) {
|
||||||
|
// case Trans_OUT: isOut = true;
|
||||||
|
// case Trans_IN : isOut = false;
|
||||||
|
// default:;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// #ifdef _DEBUG_
|
||||||
|
// if ( ip == line._intPoints.end() )
|
||||||
|
// cout << "BUG: Wrong GridLine. IKJ = ( "<< _i << " " << _j << " " << _k << " )" << endl;
|
||||||
|
// #endif
|
||||||
return isOut;
|
return isOut;
|
||||||
}
|
}
|
||||||
//================================================================================
|
//================================================================================
|
||||||
@ -3166,6 +3219,7 @@ bool StdMeshers_Cartesian_3D::Compute(SMESH_Mesh & theMesh,
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Grid grid;
|
Grid grid;
|
||||||
|
grid._helper = &helper;
|
||||||
|
|
||||||
vector< TopoDS_Shape > faceVec;
|
vector< TopoDS_Shape > faceVec;
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user