X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FStdMeshers%2FStdMeshers_Penta_3D.cxx;h=20f1ff59d51a6c77758e4bbb66e03a30fc098a0c;hp=93bb7fd5c8560e8cb764f34b65f559ac94d06d9b;hb=38a77c4a9810f4715212368ac53315689ba9150f;hpb=0635c9fc80f67d1e5dc0e94ec85f487286a92070 diff --git a/src/StdMeshers/StdMeshers_Penta_3D.cxx b/src/StdMeshers/StdMeshers_Penta_3D.cxx index 93bb7fd5c..20f1ff59d 100644 --- a/src/StdMeshers/StdMeshers_Penta_3D.cxx +++ b/src/StdMeshers/StdMeshers_Penta_3D.cxx @@ -1,24 +1,25 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE // -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SMESH StdMeshers_Penta_3D implementaion of SMESH idl descriptions // File : StdMeshers_Penta_3D.cxx // Module : SMESH @@ -33,11 +34,12 @@ #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeTool.hxx" #include "SMESHDS_SubMesh.hxx" +#include "SMESH_Comment.hxx" #include "SMESH_Mesh.hxx" -#include "SMESH_MeshEditor.hxx" +#include "SMESH_MeshAlgos.hxx" +#include "SMESH_MesherHelper.hxx" #include "SMESH_subMesh.hxx" #include "SMESH_subMeshEventListener.hxx" -#include "SMESH_Comment.hxx" #include #include @@ -46,6 +48,8 @@ #include #include #include +#include +#include #include #include #include @@ -67,7 +71,7 @@ enum { NB_WALL_FACES = 4 }; //purpose : //======================================================================= StdMeshers_Penta_3D::StdMeshers_Penta_3D() -: myErrorStatus(SMESH_ComputeError::New()) + : myErrorStatus(SMESH_ComputeError::New()) { myTol3D=0.1; myWallNodesMaps.resize( SMESH_Block::NbFaces() ); @@ -89,7 +93,7 @@ StdMeshers_Penta_3D::~StdMeshers_Penta_3D() //purpose : //======================================================================= bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape) + const TopoDS_Shape& aShape) { MESSAGE("StdMeshers_Penta_3D::Compute()"); // @@ -103,10 +107,6 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh, return bOK; } - SMESH_MesherHelper helper(aMesh); - myTool = &helper; - myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape); - // MakeBlock(); if (!myErrorStatus->IsOK()) { @@ -117,6 +117,12 @@ bool StdMeshers_Penta_3D::Compute(SMESH_Mesh& aMesh, if (!myErrorStatus->IsOK()) { return bOK; } + + // now unnecessary faces removed, we can load medium nodes + SMESH_MesherHelper helper(aMesh); + myTool = &helper; + myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape); + // MakeNodes(); if (!myErrorStatus->IsOK()) { @@ -230,7 +236,7 @@ void StdMeshers_Penta_3D::MakeNodes() // if ( SMESH_Block::IsEdgeID (aSID)) { const SMDS_EdgePosition* epos = - static_cast(aNode->GetPosition().get()); + static_cast(aNode->GetPosition()); myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords ); } else { @@ -258,11 +264,11 @@ void StdMeshers_Penta_3D::MakeNodes() SMESH_Block::TShapeID wallFaceID[ NB_WALL_FACES ] = { SMESH_Block::ID_Fx0z, SMESH_Block::ID_Fx1z, SMESH_Block::ID_F0yz, SMESH_Block::ID_F1yz - }; + }; SMESH_Block::TShapeID baseEdgeID[ NB_WALL_FACES ] = { SMESH_Block::ID_Ex00, SMESH_Block::ID_Ex10, SMESH_Block::ID_E0y0, SMESH_Block::ID_E1y0 - }; + }; for ( i = 0; i < NB_WALL_FACES ; ++i ) { int fIndex = SMESH_Block::ShapeIndex( wallFaceID[ i ]); bool ok = LoadIJNodes (myWallNodesMaps[ fIndex ], @@ -420,7 +426,7 @@ void StdMeshers_Penta_3D::MakeNodes() ShapeSupportID(bIsUpperLayer, aBNSSID, aSSID); if (!myErrorStatus->IsOK()) { MESSAGE("StdMeshers_Penta_3D::MakeNodes() "); - return; + return; } // aTN.SetShapeSupportID(aSSID); @@ -428,13 +434,13 @@ void StdMeshers_Penta_3D::MakeNodes() aTN.SetBaseNodeID(iBNID); // if (aSSID!=SMESH_Block::ID_NONE){ - // try to find the node - const TopoDS_Shape& aS=myBlock.Shape((int)aSSID); - FindNodeOnShape(aS, aCoords, i, aTN); + // try to find the node + const TopoDS_Shape& aS=myBlock.Shape((int)aSSID); + FindNodeOnShape(aS, aCoords, i, aTN); } else{ - // create node and get it id - CreateNode (bIsUpperLayer, aCoords, aTN); + // create node and get its id + CreateNode (bIsUpperLayer, aCoords, aTN); // if ( bIsUpperLayer ) { const SMDS_MeshNode* n = aTN.Node(); @@ -467,39 +473,12 @@ void StdMeshers_Penta_3D::MakeNodes() } if (!myErrorStatus->IsOK()) { MESSAGE("StdMeshers_Penta_3D::MakeNodes() "); - return; + return; } // myTNodes[ij]=aTN; } } - //DEB - /* - { - int iSSID, iBNID, aID; - // - for (i=0; iGetID(); - aX=aNode->X(); - aY=aNode->Y(); - aZ=aNode->Z(); - printf("*** j:%d BNID#%d iSSID:%d ID:%d { %lf %lf %lf }, { %lf %lf %lf }\n", - j, iBNID, iSSID, aID, aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aX, aY, aZ); - } - } - } - */ - //DEB t } @@ -509,9 +488,9 @@ void StdMeshers_Penta_3D::MakeNodes() //======================================================================= void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS, - const gp_XYZ& aParams, + const gp_XYZ& aParams, const int z, - StdMeshers_TNode& aTN) + StdMeshers_TNode& aTN) { double aX, aY, aZ, aD, aTol2, minD; gp_Pnt aP1, aP2; @@ -630,16 +609,16 @@ double StdMeshers_Penta_3D::SetHorizEdgeXYZ(const gp_XYZ& aBase } else { // this variant is better for other cases -// SMESH_MesherHelper helper( *GetMesh() ); -// const TopoDS_Edge & edge = TopoDS::Edge( myBlock.Shape( edgeVec[ TOP ])); -// double u1 = helper.GetNodeU( edge, n1 ); -// double u2 = helper.GetNodeU( edge, n2 ); -// double u = ( 1. - r ) * u1 + r * u2; -// gp_XYZ topNodeParams; -// myBlock.Block().EdgeParameters( edgeVec[ TOP ], u, topNodeParams ); -// myBlock.Block().EdgePoint( edgeVec[ TOP ], -// topNodeParams, -// myShapeXYZ[ edgeVec[ TOP ]]); + // SMESH_MesherHelper helper( *GetMesh() ); + // const TopoDS_Edge & edge = TopoDS::Edge( myBlock.Shape( edgeVec[ TOP ])); + // double u1 = helper.GetNodeU( edge, n1 ); + // double u2 = helper.GetNodeU( edge, n2 ); + // double u = ( 1. - r ) * u1 + r * u2; + // gp_XYZ topNodeParams; + // myBlock.Block().EdgeParameters( edgeVec[ TOP ], u, topNodeParams ); + // myBlock.Block().EdgePoint( edgeVec[ TOP ], + // topNodeParams, + // myShapeXYZ[ edgeVec[ TOP ]]); } // base edge @@ -671,8 +650,8 @@ void StdMeshers_Penta_3D::MakeVolumeMesh() const StdMeshers_TNode& aTN = myTNodes[ij]; aSSID=aTN.ShapeSupportID(); if (aSSID==SMESH_Block::ID_NONE) { - SMDS_MeshNode* aNode = (SMDS_MeshNode*)aTN.Node(); - meshDS->SetNodeInVolume(aNode, shapeID); + SMDS_MeshNode* aNode = (SMDS_MeshNode*)aTN.Node(); + meshDS->SetNodeInVolume(aNode, shapeID); } } } @@ -698,22 +677,16 @@ void StdMeshers_Penta_3D::MakeVolumeMesh() if ( aN.size() < nbFaceNodes * 2 ) aN.resize( nbFaceNodes * 2 ); // - k=0; - aItNodes=pE0->nodesIterator(); - while (aItNodes->more()) { - //const SMDS_MeshElement* pNode = aItNodes->next(); - const SMDS_MeshNode* pNode = - static_cast (aItNodes->next()); - if(myTool->IsMedium(pNode)) - continue; + for ( k=0; kGetNode(k); +// if(myTool->IsMedium(pNode)) +// continue; aID0 = pNode->GetID(); aJ[k] = GetIndexOnLayer(aID0); if (!myErrorStatus->IsOK()) { MESSAGE("StdMeshers_Penta_3D::MakeVolumeMesh"); - return; + return; } - // - ++k; } // bool forward = true; @@ -721,15 +694,15 @@ void StdMeshers_Penta_3D::MakeVolumeMesh() i1=i; i2=i+1; for(j=0; jGetMeshDS(); @@ -820,7 +791,7 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1() itn = aSM0->GetNodes(); aNbNodes = aSM0->NbNodes(); //printf("** aNbNodes=%d\n", aNbNodes); - + myTool->SetSubShape( aFxy1 ); // to set medium nodes to aFxy1 // // set elements on aFxy1 vector aNodes1; @@ -849,7 +820,7 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1() aJ = GetIndexOnLayer(aID0); if (!myErrorStatus->IsOK()) { MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() "); - return; + return; } // ij = aLevel*myJSize + aJ; @@ -861,16 +832,17 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1() SMDS_MeshFace * face = 0; switch ( aNbNodes ) { case 3: - face = faceHelper.AddFace(aNodes1[0], aNodes1[1], aNodes1[2]); + face = myTool->AddFace(aNodes1[0], aNodes1[1], aNodes1[2]); break; case 4: - face = faceHelper.AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]); + face = myTool->AddFace(aNodes1[0], aNodes1[1], aNodes1[2], aNodes1[3]); break; default: continue; } meshDS->SetMeshElementOnShape(face, aFxy1); } + myTool->SetSubShape( myShape ); // update compute state of top face submesh aSubMesh1->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); @@ -878,7 +850,8 @@ void StdMeshers_Penta_3D::MakeMeshOnFxy1() // assure that mesh on the top face will be cleaned when it is cleaned // on the bottom face SMESH_subMesh* volSM = pMesh->GetSubMesh( myTool->GetSubShape() ); - volSM->SetEventListener( new SMESH_subMeshEventListener(true), + volSM->SetEventListener( new SMESH_subMeshEventListener(true, // deletable by SMESH_subMesh + "StdMeshers_Penta_3D"), SMESH_subMeshEventListenerData::MakeData( aSubMesh1 ), aSubMesh0 ); // translate CLEAN event of aSubMesh0 to aSubMesh1 } @@ -937,8 +910,8 @@ void StdMeshers_Penta_3D::MakeConnectingMap() //purpose : //======================================================================= void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer, - const gp_XYZ& aParams, - StdMeshers_TNode& aTN) + const gp_XYZ& aParams, + StdMeshers_TNode& aTN) { double aX, aY, aZ; // @@ -947,15 +920,15 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer, SMDS_MeshNode* pNode=NULL; aTN.SetNode(pNode); // -// if (bIsUpperLayer) { -// // point on face Fxy1 -// const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_Fxy1); -// myBlock.Point(aParams, aS, aP); -// } -// else { -// // point inside solid -// myBlock.Point(aParams, aP); -// } + // if (bIsUpperLayer) { + // // point on face Fxy1 + // const TopoDS_Shape& aS=myBlock.Shape(SMESH_Block::ID_Fxy1); + // myBlock.Point(aParams, aS, aP); + // } + // else { + // // point inside solid + // myBlock.Point(aParams, aP); + // } if (bIsUpperLayer) { double u = aParams.X(), v = aParams.Y(); double u1 = ( 1. - u ), v1 = ( 1. - v ); @@ -973,11 +946,11 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer, SMESH_Block::ShellPoint( aParams, myShapeXYZ, aP.ChangeCoord() ); } // -// iErr=myBlock.ErrorStatus(); -// if (iErr) { -// myErrorStatus=12; // can not find the node point; -// return; -// } + // iErr=myBlock.ErrorStatus(); + // if (iErr) { + // myErrorStatus=12; // can not find the node point; + // return; + // } // aX=aP.X(); aY=aP.Y(); aZ=aP.Z(); // @@ -985,7 +958,7 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer, SMESHDS_Mesh* pMeshDS = pMesh->GetMeshDS(); // pNode = pMeshDS->AddNode(aX, aY, aZ); - + aTN.SetNode(pNode); } @@ -994,42 +967,42 @@ void StdMeshers_Penta_3D::CreateNode(const bool bIsUpperLayer, //purpose : //======================================================================= void StdMeshers_Penta_3D::ShapeSupportID(const bool bIsUpperLayer, - const SMESH_Block::TShapeID aBNSSID, - SMESH_Block::TShapeID& aSSID) + const SMESH_Block::TShapeID aBNSSID, + SMESH_Block::TShapeID& aSSID) { switch (aBNSSID) { - case SMESH_Block::ID_V000: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V001 : SMESH_Block::ID_E00z; - break; - case SMESH_Block::ID_V100: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V101 : SMESH_Block::ID_E10z; - break; - case SMESH_Block::ID_V110: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V111 : SMESH_Block::ID_E11z; - break; - case SMESH_Block::ID_V010: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V011 : SMESH_Block::ID_E01z; - break; - case SMESH_Block::ID_Ex00: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex01 : SMESH_Block::ID_Fx0z; - break; - case SMESH_Block::ID_Ex10: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex11 : SMESH_Block::ID_Fx1z; - break; - case SMESH_Block::ID_E0y0: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E0y1 : SMESH_Block::ID_F0yz; - break; - case SMESH_Block::ID_E1y0: - aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E1y1 : SMESH_Block::ID_F1yz; - break; - case SMESH_Block::ID_Fxy0: - aSSID=SMESH_Block::ID_NONE;//(bIsUpperLayer) ? Shape_ID_Fxy1 : Shape_ID_NONE; - break; - default: - aSSID=SMESH_Block::ID_NONE; - myErrorStatus->myName=10; // Can not find supporting shape ID - myErrorStatus->myComment = "Internal error of StdMeshers_Penta_3D"; - break; + case SMESH_Block::ID_V000: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V001 : SMESH_Block::ID_E00z; + break; + case SMESH_Block::ID_V100: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V101 : SMESH_Block::ID_E10z; + break; + case SMESH_Block::ID_V110: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V111 : SMESH_Block::ID_E11z; + break; + case SMESH_Block::ID_V010: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V011 : SMESH_Block::ID_E01z; + break; + case SMESH_Block::ID_Ex00: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex01 : SMESH_Block::ID_Fx0z; + break; + case SMESH_Block::ID_Ex10: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_Ex11 : SMESH_Block::ID_Fx1z; + break; + case SMESH_Block::ID_E0y0: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E0y1 : SMESH_Block::ID_F0yz; + break; + case SMESH_Block::ID_E1y0: + aSSID=(bIsUpperLayer) ? SMESH_Block::ID_E1y1 : SMESH_Block::ID_F1yz; + break; + case SMESH_Block::ID_Fxy0: + aSSID=SMESH_Block::ID_NONE;//(bIsUpperLayer) ? Shape_ID_Fxy1 : Shape_ID_NONE; + break; + default: + aSSID=SMESH_Block::ID_NONE; + myErrorStatus->myName=10; // Can not find supporting shape ID + myErrorStatus->myComment = "Internal error of StdMeshers_Penta_3D"; + break; } return; } @@ -1066,25 +1039,25 @@ void StdMeshers_Penta_3D::MakeBlock() const SMDS_MeshElement * pElement = itf->next(); aElementType = pElement->GetType(); if (aElementType==SMDSAbs_Face) { - iNbNodes = pElement->NbNodes(); - if ( iNbNodes==3 || (myCreateQuadratic && iNbNodes==6) ) { - aFTr = aF; - ++iCnt; - if (iCnt>1) { - // \begin{E.A.} - // The current algorithm fails if there is more that one - // face wich contains triangles ... - // In that case, replace return by break to try another - // method (coded in "if (iCnt != 1) { ... }") - // + iNbNodes = pElement->NbNodes(); + if ( iNbNodes==3 || (pElement->IsQuadratic() && iNbNodes==6) ) { + aFTr = aF; + ++iCnt; + if (iCnt>1) { + // \begin{E.A.} + // The current algorithm fails if there is more that one + // face wich contains triangles ... + // In that case, replace return by break to try another + // method (coded in "if (iCnt != 1) { ... }") + // // MESSAGE("StdMeshers_Penta_3D::MakeBlock() "); - // myErrorStatus=5; // more than one face has triangulation - // return; - break; - // \end{E.A.} - } - break; // next face - } + // myErrorStatus=5; // more than one face has triangulation + // return; + break; + // \end{E.A.} + } + break; // next face + } } } } @@ -1153,85 +1126,85 @@ void StdMeshers_Penta_3D::MakeBlock() int has_only_quad_f6 = 1; // for (i=1; i<=iNbF; ++i) { - int ok = 1; - const TopoDS_Shape& aF = aM(i); - SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF); - SMESHDS_SubMesh *aSM = aSubMesh->GetSubMeshDS(); - SMDS_ElemIteratorPtr itf = aSM->GetElements(); - while(itf->more()) { - const SMDS_MeshElement * pElement = itf->next(); - aElementType = pElement->GetType(); - if (aElementType==SMDSAbs_Face) { - iNbNodes = pElement->NbNodes(); - if ( iNbNodes!=4 ) { - ok = 0; - break ; - } - } - } - if (i==1) has_only_quad_f1 = ok ; - if (i==2) has_only_quad_f2 = ok ; - if (i==3) has_only_quad_f3 = ok ; - if (i==4) has_only_quad_f4 = ok ; - if (i==5) has_only_quad_f5 = ok ; - if (i==6) has_only_quad_f6 = ok ; + int ok = 1; + const TopoDS_Shape& aF = aM(i); + SMESH_subMesh *aSubMesh = pMesh->GetSubMeshContaining(aF); + SMESHDS_SubMesh *aSM = aSubMesh->GetSubMeshDS(); + SMDS_ElemIteratorPtr itf = aSM->GetElements(); + while(itf->more()) { + const SMDS_MeshElement * pElement = itf->next(); + aElementType = pElement->GetType(); + if (aElementType==SMDSAbs_Face) { + iNbNodes = pElement->NbNodes(); + if ( iNbNodes!=4 ) { + ok = 0; + break ; + } + } + } + if (i==1) has_only_quad_f1 = ok ; + if (i==2) has_only_quad_f2 = ok ; + if (i==3) has_only_quad_f3 = ok ; + if (i==4) has_only_quad_f4 = ok ; + if (i==5) has_only_quad_f5 = ok ; + if (i==6) has_only_quad_f6 = ok ; } // TopTools_IndexedMapOfShape aE; TopExp::MapShapes(myShape, TopAbs_EDGE, aE); int iNbE = aE.Extent(); if (iNbE == 12) { - // - int nb_e01 = pMesh->GetSubMeshContaining(aE(1))->GetSubMeshDS()->NbElements(); - int nb_e02 = pMesh->GetSubMeshContaining(aE(2))->GetSubMeshDS()->NbElements(); - int nb_e03 = pMesh->GetSubMeshContaining(aE(3))->GetSubMeshDS()->NbElements(); - int nb_e04 = pMesh->GetSubMeshContaining(aE(4))->GetSubMeshDS()->NbElements(); - int nb_e05 = pMesh->GetSubMeshContaining(aE(5))->GetSubMeshDS()->NbElements(); - int nb_e06 = pMesh->GetSubMeshContaining(aE(6))->GetSubMeshDS()->NbElements(); - int nb_e07 = pMesh->GetSubMeshContaining(aE(7))->GetSubMeshDS()->NbElements(); - int nb_e08 = pMesh->GetSubMeshContaining(aE(8))->GetSubMeshDS()->NbElements(); - int nb_e09 = pMesh->GetSubMeshContaining(aE(9))->GetSubMeshDS()->NbElements(); - int nb_e10 = pMesh->GetSubMeshContaining(aE(10))->GetSubMeshDS()->NbElements(); - int nb_e11 = pMesh->GetSubMeshContaining(aE(11))->GetSubMeshDS()->NbElements(); - int nb_e12 = pMesh->GetSubMeshContaining(aE(12))->GetSubMeshDS()->NbElements(); - // - int nb_ok = 0 ; - // - if ( (nb_e01==nb_e03) && (nb_e03==nb_e05) && (nb_e05==nb_e07) ) { - if ( has_only_quad_f1 && has_only_quad_f2 && has_only_quad_f3 && has_only_quad_f4 ) { - if ( (nb_e09==nb_e10) && (nb_e08==nb_e06) && (nb_e11==nb_e12) && (nb_e04==nb_e02) ) { - if (nb_f5==nb_f6) { - nb_ok += 1; - aFTr = aM(5); - } - } - } - } - if ( (nb_e02==nb_e04) && (nb_e04==nb_e06) && (nb_e06==nb_e08) ) { - if ( has_only_quad_f1 && has_only_quad_f2 && has_only_quad_f5 && has_only_quad_f6 ) { - if ( (nb_e01==nb_e03) && (nb_e10==nb_e12) && (nb_e05==nb_e07) && (nb_e09==nb_e11) ) { - if (nb_f3==nb_f4) { - nb_ok += 1; - aFTr = aM(3); - } - } - } - } - if ( (nb_e09==nb_e10) && (nb_e10==nb_e11) && (nb_e11==nb_e12) ) { - if ( has_only_quad_f3 && has_only_quad_f4 && has_only_quad_f5 && has_only_quad_f6 ) { - if ( (nb_e01==nb_e05) && (nb_e02==nb_e06) && (nb_e03==nb_e07) && (nb_e04==nb_e08) ) { - if (nb_f1==nb_f2) { - nb_ok += 1; - aFTr = aM(1); - } - } - } - } - // - if ( nb_ok == 1 ) { - isOK = 1; - } - // + // + int nb_e01 = pMesh->GetSubMeshContaining(aE(1))->GetSubMeshDS()->NbElements(); + int nb_e02 = pMesh->GetSubMeshContaining(aE(2))->GetSubMeshDS()->NbElements(); + int nb_e03 = pMesh->GetSubMeshContaining(aE(3))->GetSubMeshDS()->NbElements(); + int nb_e04 = pMesh->GetSubMeshContaining(aE(4))->GetSubMeshDS()->NbElements(); + int nb_e05 = pMesh->GetSubMeshContaining(aE(5))->GetSubMeshDS()->NbElements(); + int nb_e06 = pMesh->GetSubMeshContaining(aE(6))->GetSubMeshDS()->NbElements(); + int nb_e07 = pMesh->GetSubMeshContaining(aE(7))->GetSubMeshDS()->NbElements(); + int nb_e08 = pMesh->GetSubMeshContaining(aE(8))->GetSubMeshDS()->NbElements(); + int nb_e09 = pMesh->GetSubMeshContaining(aE(9))->GetSubMeshDS()->NbElements(); + int nb_e10 = pMesh->GetSubMeshContaining(aE(10))->GetSubMeshDS()->NbElements(); + int nb_e11 = pMesh->GetSubMeshContaining(aE(11))->GetSubMeshDS()->NbElements(); + int nb_e12 = pMesh->GetSubMeshContaining(aE(12))->GetSubMeshDS()->NbElements(); + // + int nb_ok = 0 ; + // + if ( (nb_e01==nb_e03) && (nb_e03==nb_e05) && (nb_e05==nb_e07) ) { + if ( has_only_quad_f1 && has_only_quad_f2 && has_only_quad_f3 && has_only_quad_f4 ) { + if ( (nb_e09==nb_e10) && (nb_e08==nb_e06) && (nb_e11==nb_e12) && (nb_e04==nb_e02) ) { + if (nb_f5==nb_f6) { + nb_ok += 1; + aFTr = aM(5); + } + } + } + } + if ( (nb_e02==nb_e04) && (nb_e04==nb_e06) && (nb_e06==nb_e08) ) { + if ( has_only_quad_f1 && has_only_quad_f2 && has_only_quad_f5 && has_only_quad_f6 ) { + if ( (nb_e01==nb_e03) && (nb_e10==nb_e12) && (nb_e05==nb_e07) && (nb_e09==nb_e11) ) { + if (nb_f3==nb_f4) { + nb_ok += 1; + aFTr = aM(3); + } + } + } + } + if ( (nb_e09==nb_e10) && (nb_e10==nb_e11) && (nb_e11==nb_e12) ) { + if ( has_only_quad_f3 && has_only_quad_f4 && has_only_quad_f5 && has_only_quad_f6 ) { + if ( (nb_e01==nb_e05) && (nb_e02==nb_e06) && (nb_e03==nb_e07) && (nb_e04==nb_e08) ) { + if (nb_f1==nb_f2) { + nb_ok += 1; + aFTr = aM(1); + } + } + } + } + // + if ( nb_ok == 1 ) { + isOK = 1; + } + // } } if (!isOK) { @@ -1284,11 +1257,11 @@ void StdMeshers_Penta_3D::MakeBlock() const TopoDS_Edge& aE=TopoDS::Edge(aEx); TopExp::Vertices(aE, aV[0], aV[1]); for (i=0; i<2; ++i) { - if (!aV[i].IsSame(aV000)) { - aV001=aV[i]; - bFound=!bFound; - break; - } + if (!aV[i].IsSame(aV000)) { + aV001=aV[i]; + bFound=!bFound; + break; + } } } } @@ -1365,8 +1338,8 @@ void StdMeshers_Penta_3D::CheckData() iNb=aM.Extent(); if (iNb!=iNbEx[i]){ MESSAGE("StdMeshers_Penta_3D::CheckData() "); - myErrorStatus->myName=4; // number of subshape is not compatible - myErrorStatus->myComment="Wrong number of subshapes of a block"; + myErrorStatus->myName=4; // number of sub-shape is not compatible + myErrorStatus->myComment="Wrong number of sub-shapes of a block"; return; } } @@ -1432,7 +1405,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, SMESHDS_SubMesh* smVft = theMesh->MeshElements( vft ); if (!smFace || !smb || !smt || !sm1 || !sm2 || !smVfb || !smVlb || !smVft ) { MESSAGE( "NULL submesh " <NbNodes() != smt->NbNodes() || sm1->NbNodes() != sm2->NbNodes() ) { @@ -1453,13 +1426,13 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, int nf = sm1->NbNodes()*smb->NbNodes() - n3*n4; if( nf != smFace->NbNodes() ) { MESSAGE( "Wrong nb face nodes: " << - sm1->NbNodes()<<" "<NbNodes()<<" "<NbNodes()); + sm1->NbNodes()<<" "<NbNodes()<<" "<NbNodes()); return false; } } else { MESSAGE( "Wrong nb face nodes: " << - sm1->NbNodes()<<" "<NbNodes()<<" "<NbNodes()); + sm1->NbNodes()<<" "<NbNodes()<<" "<NbNodes()); return false; } } @@ -1494,7 +1467,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, if(myTool->IsMedium(node)) continue; const SMDS_EdgePosition* pos = - dynamic_cast( node->GetPosition().get() ); + dynamic_cast( node->GetPosition() ); if ( !pos ) { return false; } @@ -1517,7 +1490,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, if(myTool->IsMedium(node)) continue; const SMDS_EdgePosition* pos = - dynamic_cast( node->GetPosition().get() ); + dynamic_cast( node->GetPosition() ); if ( !pos ) { return false; } @@ -1561,7 +1534,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, const SMDS_MeshElement* face = 0; do { // look for a face by 2 nodes - face = SMESH_MeshEditor::FindFaceInSet( n1, n2, allFaces, foundFaces ); + face = SMESH_MeshAlgos::FindFaceInSet( n1, n2, allFaces, foundFaces ); if ( face ) { int nbFaceNodes = face->NbNodes(); if ( (!myCreateQuadratic && nbFaceNodes>4) || @@ -1594,7 +1567,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, } } else if ( (nbFaceNodes==3 || (myCreateQuadratic && nbFaceNodes==6) ) && - n3 == par_nVec_1->second[ row ] ) { + n3 == par_nVec_1->second[ row ] ) { n1 = n3; } else { @@ -1678,7 +1651,7 @@ SMESH_ComputeErrorPtr StdMeshers_SMESHBlock::GetError() const case 3: text = "Internal error of StdMeshers_Penta_3D"; break; case 4: text = "Can't compute normalized parameters of a point inside a block"; break; case 5: text = "Can't compute coordinates by normalized parameters inside a block"; break; - case 6: text = "Can't detect block subshapes. Not a block?"; break; + case 6: text = "Can't detect block sub-shapes. Not a block?"; break; } if (!text.empty()) err->myName = myErrorStatus; @@ -1701,8 +1674,8 @@ void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell) //purpose : //======================================================================= void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell, - const TopoDS_Vertex& theV000, - const TopoDS_Vertex& theV001) + const TopoDS_Vertex& theV000, + const TopoDS_Vertex& theV001) { myErrorStatus=0; // @@ -1723,7 +1696,7 @@ void StdMeshers_SMESHBlock::Load(const TopoDS_Shell& theShell, //purpose : //======================================================================= void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt, - gp_XYZ& theXYZ) + gp_XYZ& theXYZ) { ComputeParameters(thePnt, myShell, theXYZ); } @@ -1733,7 +1706,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt, //purpose : //======================================================================= void StdMeshers_SMESHBlock::ComputeParameters(const gp_Pnt& thePnt, - const TopoDS_Shape& theShape, + const TopoDS_Shape& theShape, gp_XYZ& theXYZ) { myErrorStatus=0; @@ -1771,7 +1744,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU, return; } if ( SMESH_Block::IsEdgeID( aID )) - bOk = myTBlock.EdgeParameters( aID, theU, theXYZ ); + bOk = myTBlock.EdgeParameters( aID, theU, theXYZ ); if (!bOk) { myErrorStatus=4; // problems with computation Parameters return; @@ -1782,8 +1755,7 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU, //function : Point //purpose : //======================================================================= - void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams, - gp_Pnt& aP3D) +void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams, gp_Pnt& aP3D) { TopoDS_Shape aS; // @@ -1794,9 +1766,9 @@ void StdMeshers_SMESHBlock::ComputeParameters(const double& theU, //function : Point //purpose : //======================================================================= - void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams, - const TopoDS_Shape& theShape, - gp_Pnt& aP3D) +void StdMeshers_SMESHBlock::Point(const gp_XYZ& theParams, + const TopoDS_Shape& theShape, + gp_Pnt& aP3D) { myErrorStatus = 0; // @@ -1882,3 +1854,112 @@ const TopoDS_Shape& StdMeshers_SMESHBlock::Shape(const int theID) } +//======================================================================= +//function : Evaluate +//purpose : +//======================================================================= +bool StdMeshers_Penta_3D::Evaluate(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + MapShapeNbElems& aResMap) +{ + MESSAGE("StdMeshers_Penta_3D::Evaluate()"); + + // find face contains only triangles + vector < SMESH_subMesh * >meshFaces; + TopTools_SequenceOfShape aFaces; + int NumBase = 0, i = 0; + for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) { + i++; + aFaces.Append(exp.Current()); + SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current()); + meshFaces.push_back(aSubMesh); + MapShapeNbElemsItr anIt = aResMap.find(meshFaces[i]); + if( anIt == aResMap.end() ) { + NumBase = 0; + break; + } + std::vector aVec = (*anIt).second; + int nbtri = Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]); + int nbqua = Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]); + if( nbtri>0 && nbqua==0 ) { + NumBase = i; + } + } + + if(NumBase==0) { + std::vector aResVec(SMDSEntity_Last); + for(int i=SMDSEntity_Node; imyName = COMPERR_ALGO_FAILED; + myErrorStatus->myComment = "Submesh can not be evaluated"; + return false; + } + + // find number of 1d elems for base face + int nb1d = 0; + TopTools_MapOfShape Edges1; + for (TopExp_Explorer exp(aFaces.Value(NumBase), TopAbs_EDGE); exp.More(); exp.Next()) { + Edges1.Add(exp.Current()); + SMESH_subMesh *sm = aMesh.GetSubMesh(exp.Current()); + if( sm ) { + MapShapeNbElemsItr anIt = aResMap.find(sm); + if( anIt == aResMap.end() ) continue; + std::vector aVec = (*anIt).second; + nb1d += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]); + } + } + // find face opposite to base face + int OppNum = 0; + for(i=1; i<=6; i++) { + if(i==NumBase) continue; + bool IsOpposite = true; + for(TopExp_Explorer exp(aFaces.Value(i), TopAbs_EDGE); exp.More(); exp.Next()) { + if( Edges1.Contains(exp.Current()) ) { + IsOpposite = false; + break; + } + } + if(IsOpposite) { + OppNum = i; + break; + } + } + // find number of 2d elems on side faces + int nb2d = 0; + for(i=1; i<=6; i++) { + if( i==OppNum || i==NumBase ) continue; + MapShapeNbElemsItr anIt = aResMap.find( meshFaces[i-1] ); + if( anIt == aResMap.end() ) continue; + std::vector aVec = (*anIt).second; + nb2d += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]); + } + + MapShapeNbElemsItr anIt = aResMap.find( meshFaces[NumBase-1] ); + std::vector aVec = (*anIt).second; + int nb2d_face0 = Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]); + int nb0d_face0 = aVec[SMDSEntity_Node]; + + anIt = aResMap.find( meshFaces[OppNum-1] ); + for(i=SMDSEntity_Node; i aResVec(SMDSEntity_Last); + for(int i=SMDSEntity_Node; i