From f6497472ab8bd0388358d7a35f858e39522ef30b Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 21 Jan 2005 13:12:53 +0000 Subject: [PATCH] PAL7358. Take care of orientation when creating volumes --- src/StdMeshers/StdMeshers_Hexa_3D.cxx | 87 +++++++++++++----------- src/StdMeshers/StdMeshers_Penta_3D.cxx | 94 ++++++++++++++++++-------- 2 files changed, 113 insertions(+), 68 deletions(-) diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.cxx b/src/StdMeshers/StdMeshers_Hexa_3D.cxx index f80cd53cb..1eea74196 100644 --- a/src/StdMeshers/StdMeshers_Hexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_Hexa_3D.cxx @@ -37,6 +37,8 @@ using namespace std; #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_FacePosition.hxx" +#include "SMDS_VolumeTool.hxx" +#include "SMDS_VolumeOfNodes.hxx" #include #include @@ -56,7 +58,7 @@ using namespace std; #include "Utils_ExceptHandlers.hxx" //modified by NIZNHY-PKV Wed Nov 17 15:31:58 2004 f -#include +#include "StdMeshers_Penta_3D.hxx" static bool ComputePentahedralMesh(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); //modified by NIZNHY-PKV Wed Nov 17 15:32:00 2004 t @@ -701,11 +703,34 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, } } + // find orientation of furute volumes according to MED convention + vector< bool > forward( nbx * nby ); + SMDS_VolumeTool vTool; + for (int i = 0; i < nbx - 1; i++) + for (int j = 0; j < nby - 1; j++) + { + int n1 = j * nbx + i; + int n2 = j * nbx + i + 1; + int n3 = (j + 1) * nbx + i + 1; + int n4 = (j + 1) * nbx + i; + int n5 = nbx * nby + j * nbx + i; + int n6 = nbx * nby + j * nbx + i + 1; + int n7 = nbx * nby + (j + 1) * nbx + i + 1; + int n8 = nbx * nby + (j + 1) * nbx + i; + + SMDS_VolumeOfNodes tmpVol (np[n1].node,np[n2].node,np[n3].node,np[n4].node, + np[n5].node,np[n6].node,np[n7].node,np[n8].node); + vTool.Set( &tmpVol ); + forward[ n1 ] = vTool.IsForward(); + } + //2.1 - for each node of the cube (less 3 *1 Faces): // - store hexahedron in SMESHDS MESSAGE("Storing hexahedron into the DS"); for (int i = 0; i < nbx - 1; i++) for (int j = 0; j < nby - 1; j++) + { + bool isForw = forward.at( j * nbx + i ); for (int k = 0; k < nbz - 1; k++) { int n1 = k * nbx * nby + j * nbx + i; @@ -717,46 +742,32 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, int n7 = (k + 1) * nbx * nby + (j + 1) * nbx + i + 1; int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i; -// MESSAGE(" "<AddVolume(np[n1].node, - np[n2].node, - np[n3].node, - np[n4].node, - np[n5].node, - np[n6].node, - np[n7].node, - np[n8].node); - ; - meshDS->SetMeshElementOnShape(elt, aShell); + SMDS_MeshVolume * elt; + if ( isForw ) + elt = meshDS->AddVolume(np[n1].node, + np[n2].node, + np[n3].node, + np[n4].node, + np[n5].node, + np[n6].node, + np[n7].node, + np[n8].node); + else + elt = meshDS->AddVolume(np[n1].node, + np[n4].node, + np[n3].node, + np[n2].node, + np[n5].node, + np[n8].node, + np[n7].node, + np[n6].node); - // *** 5 tetrahedres ... verifier orientations, - // mettre en coherence &vec quadrangles-> triangles - // choisir afficher 1 parmi edges, face et volumes -// int tetra1 = meshDS->AddVolume(np[n1].nodeId, -// np[n2].nodeId, -// np[n4].nodeId, -// np[n5].nodeId); -// int tetra2 = meshDS->AddVolume(np[n2].nodeId, -// np[n3].nodeId, -// np[n4].nodeId, -// np[n7].nodeId); -// int tetra3 = meshDS->AddVolume(np[n5].nodeId, -// np[n6].nodeId, -// np[n7].nodeId, -// np[n2].nodeId); -// int tetra4 = meshDS->AddVolume(np[n5].nodeId, -// np[n7].nodeId, -// np[n8].nodeId, -// np[n4].nodeId); -// int tetra5 = meshDS->AddVolume(np[n5].nodeId, -// np[n7].nodeId, -// np[n2].nodeId, -// np[n4].nodeId); + meshDS->SetMeshElementOnShape(elt, aShell); - } + } + } + if ( np ) delete [] np; //MESSAGE("End of StdMeshers_Hexa_3D::Compute()"); return true; } diff --git a/src/StdMeshers/StdMeshers_Penta_3D.cxx b/src/StdMeshers/StdMeshers_Penta_3D.cxx index 30362f4b9..90dbd5de6 100644 --- a/src/StdMeshers/StdMeshers_Penta_3D.cxx +++ b/src/StdMeshers/StdMeshers_Penta_3D.cxx @@ -24,35 +24,36 @@ // File : StdMeshers_Penta_3D.cxx // Module : SMESH -using namespace std; - -#include - -#include - -#include +#include "StdMeshers_Penta_3D.hxx" #include "utilities.h" #include "Utils_ExceptHandlers.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_VolumeOfNodes.hxx" +#include "SMDS_VolumeTool.hxx" +#include "SMESHDS_SubMesh.hxx" +#include "SMESH_Mesh.hxx" +#include "SMESH_subMesh.hxx" + +#include #include -#include #include -#include -#include -#include - -#include +#include +#include #include +#include #include -#include -#include #include -#include -#include -#include -#include +#include #include +#include +#include + +#include +#include + +using namespace std; typedef map < int, int, less >::iterator \ StdMeshers_IteratorOfDataMapOfIntegerInteger; @@ -380,11 +381,12 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS, { myErrorStatus=0; // - double aX, aY, aZ, aD, aTol2; + double aX, aY, aZ, aD, aTol2, minD; gp_Pnt aP1, aP2; // SMESH_Mesh* pMesh=GetMesh(); aTol2=myTol3D*myTol3D; + minD = 1.e100; SMDS_MeshNode* pNode=NULL; // myBlock.Point(aParams, aS, aP1); @@ -399,18 +401,20 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS, aP2.SetCoord(aX, aY, aZ); aD=(double)aP1.SquareDistance(aP2); //printf("** D=%lf ", aD, aTol2); - if (aDAddVolume(aN[0], aN[1], aN[2], - aN[3], aN[4], aN[5]); + if ( forward ) + aV = meshDS->AddVolume(aN[0], aN[1], aN[2], + aN[3], aN[4], aN[5]); + else + aV = meshDS->AddVolume(aN[0], aN[2], aN[1], + aN[3], aN[5], aN[4]); break; case 4: - aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3], - aN[4], aN[5], aN[6], aN[7]); + if ( forward ) + aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3], + aN[4], aN[5], aN[6], aN[7]); + else + aV = meshDS->AddVolume(aN[0], aN[3], aN[2], aN[1], + aN[4], aN[7], aN[6], aN[5]); break; default: continue; -- 2.39.2