X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Prism_3D.cxx;h=4d818a4682668419cbfde9c19887dc023b15ed91;hb=c10193fae6b80027ca1d44e7c7778a97ff7f9f01;hp=70a6fc5d43eda9caf942f8b69cbba1238b75e2bc;hpb=0b587a208b6b3156254b62b639b3a56c0f369678;p=modules%2Fsmesh.git diff --git a/src/StdMeshers/StdMeshers_Prism_3D.cxx b/src/StdMeshers/StdMeshers_Prism_3D.cxx index 70a6fc5d4..4d818a468 100644 --- a/src/StdMeshers/StdMeshers_Prism_3D.cxx +++ b/src/StdMeshers/StdMeshers_Prism_3D.cxx @@ -38,17 +38,17 @@ #include "utilities.h" -#include -#include -#include #include #include #include +#include +#include #include +#include using namespace std; -#define RETURN_BAD_RESULT(msg) { MESSAGE(msg); return false; } +#define RETURN_BAD_RESULT(msg) { MESSAGE(")-: Error: " << msg); return false; } #define gpXYZ(n) gp_XYZ(n->X(),n->Y(),n->Z()) #define SHOWYXZ(msg, xyz) // {\ // gp_Pnt p (xyz); \ @@ -185,7 +185,7 @@ bool StdMeshers_Prism_3D::CheckHypothesis(SMESH_Mesh& a SMESH_Hypothesis::Hypothesis_Status& aStatus) { // Check shape geometry - +/* PAL16229 aStatus = SMESH_Hypothesis::HYP_BAD_GEOMETRY; // find not quadrangle faces @@ -216,7 +216,7 @@ bool StdMeshers_Prism_3D::CheckHypothesis(SMESH_Mesh& a if ( nbFace != nbEdge + 2 ) RETURN_BAD_RESULT("Bad nb of faces: " << nbFace << " but must be " << nbEdge + 2); } - +*/ // no hypothesis aStatus = SMESH_Hypothesis::HYP_OK; return true; @@ -275,18 +275,16 @@ bool StdMeshers_Prism_3D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theSh TNodeColumn& column = bot_column->second; // bottom node parameters and coords - gp_XYZ botParams = tBotNode.GetParams(); myShapeXYZ[ ID_BOT_FACE ] = tBotNode.GetCoords(); + gp_XYZ botParams = tBotNode.GetParams(); // compute top node parameters - gp_XYZ topParams; myShapeXYZ[ ID_TOP_FACE ] = gpXYZ( column.back() ); - if ( column.size() < 3 ) { // only top and bottom nodes in columns - topParams = botParams; - } - else { + gp_XYZ topParams = botParams; + topParams.SetZ( 1 ); + if ( column.size() > 2 ) { gp_Pnt topCoords = myShapeXYZ[ ID_TOP_FACE ]; - if ( !myBlock.ComputeParameters( topCoords, topParams, ID_TOP_FACE )) + if ( !myBlock.ComputeParameters( topCoords, topParams, ID_TOP_FACE, topParams )) return error(TCom("Can't compute normalized parameters ") << "for node " << column.back()->GetID() << " on the face #"<< column.back()->GetPosition()->GetShapeId() ); @@ -318,6 +316,10 @@ bool StdMeshers_Prism_3D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theSh if ( !SMESH_Block::ShellPoint( params, myShapeXYZ, coords )) return error("Can't compute coordinates by normalized parameters"); + SHOWYXZ("TOPFacePoint ",myShapeXYZ[ ID_TOP_FACE]); + SHOWYXZ("BOT Node "<< tBotNode.myNode->GetID(),gpXYZ(tBotNode.myNode)); + SHOWYXZ("ShellPoint ",coords); + // create a node node = meshDS->AddNode( coords.X(), coords.Y(), coords.Z() ); meshDS->SetNodeInVolume( node, volumeID ); @@ -381,12 +383,44 @@ void StdMeshers_Prism_3D::AddPrisms( vector & columns, int shapeID = helper->GetSubShapeID(); int nbNodes = columns.size(); + int nbZ = columns[0]->size(); + if ( nbZ < 2 ) return; + + // find out orientation + bool isForward = true; + SMDS_VolumeTool vTool; + int z = 1; + switch ( nbNodes ) { + case 3: { + const SMDS_MeshNode* botNodes[3] = { (*columns[0])[z-1], + (*columns[1])[z-1], + (*columns[2])[z-1] }; + const SMDS_MeshNode* topNodes[3] = { (*columns[0])[z], + (*columns[1])[z], + (*columns[2])[z] }; + SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], + topNodes[0], topNodes[1], topNodes[2]); + vTool.Set( &tmpVol ); + isForward = vTool.IsForward(); + break; + } + case 4: { + const SMDS_MeshNode* botNodes[4] = { (*columns[0])[z-1], (*columns[1])[z-1], + (*columns[2])[z-1], (*columns[3])[z-1] }; + const SMDS_MeshNode* topNodes[4] = { (*columns[0])[z], (*columns[1])[z], + (*columns[2])[z], (*columns[3])[z] }; + SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], botNodes[3], + topNodes[0], topNodes[1], topNodes[2], topNodes[3]); + vTool.Set( &tmpVol ); + isForward = vTool.IsForward(); + break; + } + } // vertical loop on columns - for ( int z = 1; z < columns[0]->size(); ++z) + for ( z = 1; z < nbZ; ++z ) { SMDS_MeshElement* vol = 0; - SMDS_VolumeTool vTool; switch ( nbNodes ) { case 3: { @@ -396,11 +430,7 @@ void StdMeshers_Prism_3D::AddPrisms( vector & columns, const SMDS_MeshNode* topNodes[3] = { (*columns[0])[z], (*columns[1])[z], (*columns[2])[z] }; - // assure good orientation - SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], - topNodes[0], topNodes[1], topNodes[2]); - vTool.Set( &tmpVol ); - if ( vTool.IsForward() ) + if ( isForward ) vol = helper->AddVolume( botNodes[0], botNodes[1], botNodes[2], topNodes[0], topNodes[1], topNodes[2]); else @@ -413,11 +443,7 @@ void StdMeshers_Prism_3D::AddPrisms( vector & columns, (*columns[2])[z-1], (*columns[3])[z-1] }; const SMDS_MeshNode* topNodes[4] = { (*columns[0])[z], (*columns[1])[z], (*columns[2])[z], (*columns[3])[z] }; - // assure good orientation - SMDS_VolumeOfNodes tmpVol ( botNodes[0], botNodes[1], botNodes[2], botNodes[3], - topNodes[0], topNodes[1], topNodes[2], topNodes[3]); - vTool.Set( &tmpVol ); - if ( vTool.IsForward() ) + if ( isForward ) vol = helper->AddVolume( botNodes[0], botNodes[1], botNodes[2], botNodes[3], topNodes[0], topNodes[1], topNodes[2], topNodes[3]); else @@ -511,6 +537,7 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top() // Fill myBotToColumnMap int zSize = myBlock.VerticalSize(); + TNode prevTNode; TNodeNodeMap::iterator bN_tN = n2nMap.begin(); for ( ; bN_tN != n2nMap.end(); ++bN_tN ) { @@ -520,10 +547,16 @@ bool StdMeshers_Prism_3D::assocOrProjBottom2Top() continue; // wall columns are contained in myBlock // compute bottom node params TNode bN( botNode ); - if ( zSize > 2 ) - if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(), ID_BOT_FACE )) - return error(TCom("Can't compute normalized parameters ") - << "for node " << botNode->GetID() << " on the face #"<< botSM->GetId() ); + if ( zSize > 2 ) { + gp_XYZ paramHint(-1,-1,-1); + if ( prevTNode.IsNeighbor( bN )) + paramHint = prevTNode.GetParams(); + if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(), + ID_BOT_FACE, paramHint )) + return error(TCom("Can't compute normalized parameters for node ") + << botNode->GetID() << " on the face #"<< botSM->GetId() ); + prevTNode = bN; + } // create node column TNode2ColumnMap::iterator bN_col = myBotToColumnMap.insert( make_pair ( bN, TNodeColumn() )).first; @@ -561,6 +594,7 @@ bool StdMeshers_Prism_3D::projectBottomToTop() // Fill myBotToColumnMap int zSize = myBlock.VerticalSize(); + TNode prevTNode; SMDS_NodeIteratorPtr nIt = botSMDS->GetNodes(); while ( nIt->more() ) { @@ -569,15 +603,20 @@ bool StdMeshers_Prism_3D::projectBottomToTop() continue; // strange // compute bottom node params TNode bN( botNode ); - if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(), ID_BOT_FACE )) - return error(TCom("Can't compute normalized parameters ") - << "for node " << botNode->GetID() << " on the face #"<< botSM->GetId() ); + gp_XYZ paramHint(-1,-1,-1); + if ( prevTNode.IsNeighbor( bN )) + paramHint = prevTNode.GetParams(); + if ( !myBlock.ComputeParameters( bN.GetCoords(), bN.ChangeParams(), + ID_BOT_FACE, paramHint )) + return error(TCom("Can't compute normalized parameters for node ") + << botNode->GetID() << " on the face #"<< botSM->GetId() ); + prevTNode = bN; // compute top node coords gp_XYZ topXYZ; gp_XY topUV; if ( !myBlock.FacePoint( ID_TOP_FACE, bN.GetParams(), topXYZ ) || !myBlock.FaceUV ( ID_TOP_FACE, bN.GetParams(), topUV )) - return error(TCom("Can't compute coordinates ") - << "by normalized parameters on the face #"<< topSM->GetId() ); + return error(TCom("Can't compute coordinates " + "by normalized parameters on the face #")<< topSM->GetId() ); SMDS_MeshNode * topNode = meshDS->AddNode( topXYZ.X(),topXYZ.Y(),topXYZ.Z() ); meshDS->SetNodeOnFace( topNode, topFaceID, topUV.X(), topUV.Y() ); // create node column @@ -679,6 +718,23 @@ bool StdMeshers_Prism_3D::setFaceAndEdgesXYZ( const int faceID, const gp_XYZ& pa return true; } +//================================================================================ +/*! + * \brief Return true if this node and other one belong to one face + */ +//================================================================================ + +bool TNode::IsNeighbor( const TNode& other ) const +{ + if ( !other.myNode || !myNode ) return false; + + SMDS_ElemIteratorPtr fIt = other.myNode->GetInverseElementIterator(SMDSAbs_Face); + while ( fIt->more() ) + if ( fIt->next()->GetNodeIndex( myNode ) >= 0 ) + return true; + return false; +} + //================================================================================ /*! * \brief Constructor. Initialization is needed @@ -819,11 +875,11 @@ bool StdMeshers_PrismAsBlock::Init(SMESH_MesherHelper* helper, // detect bad cases if ( nbNotQuad > 0 && nbNotQuad != 2 ) return error(COMPERR_BAD_SHAPE, - TCom("More than 2 not quadrilateral faces ") + TCom("More than 2 not quadrilateral faces: ") < 2 ) return error(COMPERR_BAD_INPUT_MESH, - TCom("More than 2 faces meshed with not quadrangle elements ") + TCom("More than 2 faces with not quadrangle elements: ") <