X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_CompositeHexa_3D.cxx;h=57bf3eaca3582a795d5f003fd42c7aec40a65a02;hb=831ca6c828271732e46fba73b196d423482535ae;hp=4c5269eb6b5e2985572654c677a32e811c7c76ea;hpb=256994070c8e15b6785935722a7d06e6a49c8035;p=modules%2Fsmesh.git
diff --git a/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx b/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx
index 4c5269eb6..57bf3eaca 100644
--- a/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx
+++ b/src/StdMeshers/StdMeshers_CompositeHexa_3D.cxx
@@ -62,9 +62,7 @@
#ifdef _DEBUG_
// #define DEB_FACES
// #define DEB_GRID
-// #define DUMP_VERT(msg,V) \
-// { TopoDS_Vertex v = V; gp_Pnt p = BRep_Tool::Pnt(v); \
-// cout << msg << "( "<< p.X()<<", "<
& faces, EBoxSides id) const;
//!< Reverse edges in order to have the bottom edge going along axes of the unit box
- void ReverseEdges(/*int e1, int e2*/);
+ void ReverseEdges();
bool IsComplex() const { return !myChildren.empty(); }
@@ -179,6 +179,9 @@ public: //** Loading and access to mesh **//
//!< Load nodes of a mesh
bool LoadGrid( SMESH_Mesh& mesh );
+ //!< Computes normalized parameters of nodes of myGrid
+ void ComputeIJK( int i1, int i2, double v3 );
+
//!< Return number of segments on the hirizontal sides
int GetNbHoriSegments(SMESH_Mesh& mesh, bool withBrothers=false) const;
@@ -194,6 +197,9 @@ public: //** Loading and access to mesh **//
//!< Return node coordinates by its position
gp_XYZ GetXYZ(int iHori, int iVert) const;
+ //!< Return normalized parameters of nodes within the unitary cube
+ gp_XYZ& GetIJK(int iCol, int iRow) { return myIJK[ myIndexer( iCol, iRow )]; }
+
public: //** Access to member fields **//
//!< Return i-th face side (0 myGrid;
+ vector myIJK; // normalized parameters of nodes
SMESH_ComputeErrorPtr myError;
@@ -369,7 +376,7 @@ namespace
*/
//================================================================================
- void getInternalEdges( SMESH_Mesh& mesh,
+ bool getInternalEdges( SMESH_Mesh& mesh,
const TopoDS_Shape& shape,
const TopTools_MapOfShape& cornerVV,
TopTools_MapOfShape& internEE)
@@ -379,11 +386,12 @@ namespace
TopExp::MapShapes( shape, TopAbs_FACE, subFF );
TopoDS_Vertex VV[2];
- TopTools_MapOfShape subChecked;
+ TopTools_MapOfShape subChecked/*, ridgeEE*/;
TopTools_MapIteratorOfMapOfShape vIt( cornerVV );
for ( ; vIt.More(); vIt.Next() )
{
TopoDS_Shape V0 = vIt.Key();
+ // walk from one corner VERTEX to another along ridge EDGEs
PShapeIteratorPtr riIt = SMESH_MesherHelper::GetAncestors( V0, mesh, TopAbs_EDGE );
while ( const TopoDS_Shape* riE = riIt->next() )
{
@@ -405,7 +413,7 @@ namespace
{
if ( E->IsSame( ridgeE ) || !subEE.Contains( *E ) || !subChecked.Add( *E ))
continue;
- // look for FACEs sharing E and ridgeE
+ // look for FACEs sharing both E and ridgeE
PShapeIteratorPtr fIt = SMESH_MesherHelper::GetAncestors( *E, mesh, TopAbs_FACE );
while ( const TopoDS_Shape* F = fIt->next() )
{
@@ -422,12 +430,12 @@ namespace
break;
}
}
- // look for the next ridge EDGE
+ // look for the next ridge EDGE ending at V1
if ( nextRidgeE.IsNull() )
{
eIt = SMESH_MesherHelper::GetAncestors( V1, mesh, TopAbs_EDGE );
while ( const TopoDS_Shape* E = eIt->next() )
- if ( !ridgeE.IsSame( *E ) && !internEE.Contains( *E ) )
+ if ( !ridgeE.IsSame( *E ) && !internEE.Contains( *E ) && subEE.Contains( *E ))
{
nextRidgeE = *E;
break;
@@ -436,11 +444,13 @@ namespace
ridgeE = TopoDS::Edge( nextRidgeE );
V0 = V1;
+ if ( ridgeE.IsNull() )
+ return false;
} // check EDGEs around the last VERTEX of ridgeE
} // loop on ridge EDGEs around a corner VERTEX
} // loop on on corner VERTEXes
- return;
+ return true;
} // getInternalEdges()
} // namespace
@@ -463,9 +473,10 @@ bool StdMeshers_CompositeHexa_3D::findBoxFaces( const TopoDS_Shape& shape,
TopTools_MapOfShape cornerVertices;
getBlockCorners( mesh, shape, cornerVertices );
if ( cornerVertices.Extent() != 8 )
- return false;
+ return error( COMPERR_BAD_INPUT_MESH, "Can't find 8 corners of a block by 2D mesh" );
TopTools_MapOfShape internalEdges;
- getInternalEdges( mesh, shape, cornerVertices, internalEdges );
+ if ( !getInternalEdges( mesh, shape, cornerVertices, internalEdges ))
+ return error( COMPERR_BAD_INPUT_MESH, "2D mesh is not suitable for i,j,k hexa meshing" );
list< _QuadFaceGrid >::iterator boxFace;
TopExp_Explorer exp;
@@ -588,6 +599,14 @@ bool StdMeshers_CompositeHexa_3D::Compute(SMESH_Mesh& theMesh,
if ( !fRight ->LoadGrid( theMesh )) return error( fRight ->GetError() );
if ( !fTop ->LoadGrid( theMesh )) return error( fTop ->GetError() );
+ // compute normalized parameters of nodes on sides (PAL23189)
+ fBottom->ComputeIJK( COO_X, COO_Y, /*z=*/0. );
+ fBack ->ComputeIJK( COO_X, COO_Z, /*y=*/1. );
+ fLeft ->ComputeIJK( COO_Y, COO_Z, /*x=*/0. );
+ fFront ->ComputeIJK( COO_X, COO_Z, /*y=*/0. );
+ fRight ->ComputeIJK( COO_Y, COO_Z, /*x=*/1. );
+ fTop ->ComputeIJK( COO_X, COO_Y, /*z=*/1. );
+
int x, xSize = fBottom->GetNbHoriSegments(theMesh) + 1, X = xSize - 1;
int y, ySize = fBottom->GetNbVertSegments(theMesh) + 1, Y = ySize - 1;
int z, zSize = fFront ->GetNbVertSegments(theMesh) + 1, Z = zSize - 1;
@@ -643,13 +662,14 @@ bool StdMeshers_CompositeHexa_3D::Compute(SMESH_Mesh& theMesh,
pointsOnShapes[ SMESH_Block::ID_V011 ] = fTop->GetXYZ( 0, Y );
pointsOnShapes[ SMESH_Block::ID_V111 ] = fTop->GetXYZ( X, Y );
+ gp_XYZ params; // normalized parameters of an internal node within the unit box
+
for ( x = 1; x < xSize-1; ++x )
{
- gp_XYZ params; // normalized parameters of internal node within a unit box
- params.SetCoord( 1, x / double(X) );
+ const double rX = x / double(X);
for ( y = 1; y < ySize-1; ++y )
{
- params.SetCoord( 2, y / double(Y) );
+ const double rY = y / double(Y);
// column to fill during z loop
vector< const SMDS_MeshNode* >& column = columns[ colIndex( x, y )];
// points projections on horizontal edges
@@ -666,14 +686,28 @@ bool StdMeshers_CompositeHexa_3D::Compute(SMESH_Mesh& theMesh,
pointsOnShapes[ SMESH_Block::ID_Fxy1 ] = fTop ->GetXYZ( x, y );
for ( z = 1; z < zSize-1; ++z ) // z loop
{
- params.SetCoord( 3, z / double(Z) );
+ // compute normalized parameters of an internal node within the unit box
+ const double rZ = z / double(Z);
+ const gp_XYZ& pBo = fBottom->GetIJK( x, y );
+ const gp_XYZ& pTo = fTop ->GetIJK( x, y );
+ const gp_XYZ& pFr = fFront ->GetIJK( x, z );
+ const gp_XYZ& pBa = fBack ->GetIJK( x, z );
+ const gp_XYZ& pLe = fLeft ->GetIJK( y, z );
+ const gp_XYZ& pRi = fRight ->GetIJK( y, z );
+ params.SetCoord( 1, 0.5 * ( pBo.X() * ( 1. - rZ ) + pTo.X() * rZ +
+ pFr.X() * ( 1. - rY ) + pBa.X() * rY ));
+ params.SetCoord( 2, 0.5 * ( pBo.Y() * ( 1. - rZ ) + pTo.Y() * rZ +
+ pLe.Y() * ( 1. - rX ) + pRi.Y() * rX ));
+ params.SetCoord( 3, 0.5 * ( pFr.Z() * ( 1. - rY ) + pBa.Z() * rY +
+ pLe.Z() * ( 1. - rX ) + pRi.Z() * rX ));
+
// point projections on vertical edges
- pointsOnShapes[ SMESH_Block::ID_E00z ] = fFront->GetXYZ( 0, z );
- pointsOnShapes[ SMESH_Block::ID_E10z ] = fFront->GetXYZ( X, z );
- pointsOnShapes[ SMESH_Block::ID_E01z ] = fBack->GetXYZ( 0, z );
+ pointsOnShapes[ SMESH_Block::ID_E00z ] = fFront->GetXYZ( 0, z );
+ pointsOnShapes[ SMESH_Block::ID_E10z ] = fFront->GetXYZ( X, z );
+ pointsOnShapes[ SMESH_Block::ID_E01z ] = fBack->GetXYZ( 0, z );
pointsOnShapes[ SMESH_Block::ID_E11z ] = fBack->GetXYZ( X, z );
// point projections on vertical faces
- pointsOnShapes[ SMESH_Block::ID_Fx0z ] = fFront->GetXYZ( x, z );
+ pointsOnShapes[ SMESH_Block::ID_Fx0z ] = fFront->GetXYZ( x, z );
pointsOnShapes[ SMESH_Block::ID_Fx1z ] = fBack ->GetXYZ( x, z );
pointsOnShapes[ SMESH_Block::ID_F0yz ] = fLeft ->GetXYZ( y, z );
pointsOnShapes[ SMESH_Block::ID_F1yz ] = fRight->GetXYZ( y, z );
@@ -1111,10 +1145,10 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
// store the rest nodes row by row
- const SMDS_MeshNode* dummy = mesh.GetMeshDS()->AddNode(0,0,0);
- const SMDS_MeshElement* firstQuad = dummy; // most left face above the last row of found nodes
-
- int nbFoundNodes = myIndexer._xSize;
+ TIDSortedElemSet emptySet, avoidSet;
+ const SMDS_MeshElement* firstQuad = 0; // most left face above the last row of found nodes
+
+ size_t nbFoundNodes = myIndexer._xSize;
while ( nbFoundNodes != myGrid.size() )
{
// first and last nodes of the last filled row of nodes
@@ -1130,8 +1164,6 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
// o---o o o o o
//n1down n2down
//
- TIDSortedElemSet emptySet, avoidSet;
- avoidSet.insert( firstQuad );
firstQuad = SMESH_MeshAlgos::FindFaceInSet( n1down, n2down, emptySet, avoidSet);
while ( firstQuad && !faceSubMesh->Contains( firstQuad )) {
avoidSet.insert( firstQuad );
@@ -1178,13 +1210,60 @@ bool _QuadFaceGrid::LoadGrid( SMESH_Mesh& mesh )
n1down = myGrid[ nbFoundNodes - myIndexer._xSize - 1 ];
n1up = n2up;
}
+ avoidSet.clear(); avoidSet.insert( firstQuad );
}
- mesh.GetMeshDS()->RemoveNode(dummy);
DumpGrid(); // debug
return true;
}
+//================================================================================
+/*!
+ * \brief Fill myIJK with normalized parameters of nodes in myGrid
+ * \param [in] i1 - coordinate index along rows of myGrid
+ * \param [in] i2 - coordinate index along columns of myGrid
+ * \param [in] v3 - value of the constant parameter
+ */
+//================================================================================
+
+void _QuadFaceGrid::ComputeIJK( int i1, int i2, double v3 )
+{
+ gp_XYZ ijk( v3, v3, v3 );
+ myIJK.resize( myIndexer.size(), ijk );
+
+ const size_t nbCol = myIndexer._xSize;
+ const size_t nbRow = myIndexer._ySize;
+
+ vector< double > len( nbRow );
+ len[0] = 0;
+ for ( size_t i = 0; i < nbCol; ++i )
+ {
+ gp_Pnt pPrev = GetXYZ( i, 0 );
+ for ( size_t j = 1; j < nbRow; ++j )
+ {
+ gp_Pnt p = GetXYZ( i, j );
+ len[ j ] = len[ j-1 ] + p.Distance( pPrev );
+ pPrev = p;
+ }
+ for ( size_t j = 0; j < nbRow; ++j )
+ GetIJK( i, j ).SetCoord( i2, len[ j ]/len.back() );
+ }
+
+ len.resize( nbCol );
+ for ( size_t j = 0; j < nbRow; ++j )
+ {
+ gp_Pnt pPrev = GetXYZ( 0, j );
+ for ( size_t i = 1; i < nbCol; ++i )
+ {
+ gp_Pnt p = GetXYZ( i, j );
+ len[ i ] = len[ i-1 ] + p.Distance( pPrev );
+ pPrev = p;
+ }
+ for ( size_t i = 0; i < nbCol; ++i )
+ GetIJK( i, j ).SetCoord( i1, len[ i ]/len.back() );
+ }
+}
+
//================================================================================
/*!
* \brief Find out mutual location of children: find their right and up brothers
@@ -1441,8 +1520,8 @@ const SMDS_MeshNode* _QuadFaceGrid::GetNode(int iHori, int iVert) const
gp_XYZ _QuadFaceGrid::GetXYZ(int iHori, int iVert) const
{
- const SMDS_MeshNode* n = myGrid[ myIndexer( iHori, iVert )];
- return gp_XYZ( n->X(), n->Y(), n->Z() );
+ SMESH_TNodeXYZ xyz = myGrid[ myIndexer( iHori, iVert )];
+ return xyz;
}
//================================================================================