PAL7358. Take care of orientation when creating volumes

This commit is contained in:
eap 2005-01-21 13:12:53 +00:00
parent c21a157b9d
commit f6497472ab
2 changed files with 115 additions and 70 deletions

View File

@ -37,6 +37,8 @@ using namespace std;
#include "SMDS_MeshElement.hxx" #include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx" #include "SMDS_MeshNode.hxx"
#include "SMDS_FacePosition.hxx" #include "SMDS_FacePosition.hxx"
#include "SMDS_VolumeTool.hxx"
#include "SMDS_VolumeOfNodes.hxx"
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx> #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
@ -56,7 +58,7 @@ using namespace std;
#include "Utils_ExceptHandlers.hxx" #include "Utils_ExceptHandlers.hxx"
//modified by NIZNHY-PKV Wed Nov 17 15:31:58 2004 f //modified by NIZNHY-PKV Wed Nov 17 15:31:58 2004 f
#include <StdMeshers_Penta_3D.hxx> #include "StdMeshers_Penta_3D.hxx"
static bool ComputePentahedralMesh(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); static bool ComputePentahedralMesh(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape);
//modified by NIZNHY-PKV Wed Nov 17 15:32:00 2004 t //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): //2.1 - for each node of the cube (less 3 *1 Faces):
// - store hexahedron in SMESHDS // - store hexahedron in SMESHDS
MESSAGE("Storing hexahedron into the DS"); MESSAGE("Storing hexahedron into the DS");
for (int i = 0; i < nbx - 1; i++) for (int i = 0; i < nbx - 1; i++)
for (int j = 0; j < nby - 1; j++) for (int j = 0; j < nby - 1; j++)
{
bool isForw = forward.at( j * nbx + i );
for (int k = 0; k < nbz - 1; k++) for (int k = 0; k < nbz - 1; k++)
{ {
int n1 = k * nbx * nby + j * nbx + i; 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 n7 = (k + 1) * nbx * nby + (j + 1) * nbx + i + 1;
int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i; int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i;
// MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8); SMDS_MeshVolume * elt;
//MESSAGE(" "<<np[n1].nodeId<<" "<<np[n2].nodeId<<" "<<np[n3].nodeId<<" "<<np[n4].nodeId<<" "<<np[n5].nodeId<<" "<<np[n6].nodeId<<" "<<np[n7].nodeId<<" "<<np[n8].nodeId); 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);
SMDS_MeshVolume * 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);
;
meshDS->SetMeshElementOnShape(elt, aShell); meshDS->SetMeshElementOnShape(elt, aShell);
// *** 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);
}
}
}
if ( np ) delete [] np;
//MESSAGE("End of StdMeshers_Hexa_3D::Compute()"); //MESSAGE("End of StdMeshers_Hexa_3D::Compute()");
return true; return true;
} }

View File

@ -24,35 +24,36 @@
// File : StdMeshers_Penta_3D.cxx // File : StdMeshers_Penta_3D.cxx
// Module : SMESH // Module : SMESH
using namespace std; #include "StdMeshers_Penta_3D.hxx"
#include <StdMeshers_Penta_3D.hxx>
#include <stdio.h>
#include <algorithm>
#include "utilities.h" #include "utilities.h"
#include "Utils_ExceptHandlers.hxx" #include "Utils_ExceptHandlers.hxx"
#include <TopAbs_ShapeEnum.hxx> #include "SMDS_MeshElement.hxx"
#include <TopTools_IndexedMapOfShape.hxx> #include "SMDS_VolumeOfNodes.hxx"
#include <TopExp.hxx> #include "SMDS_VolumeTool.hxx"
#include <SMESH_Mesh.hxx> #include "SMESHDS_SubMesh.hxx"
#include <SMESH_subMesh.hxx> #include "SMESH_Mesh.hxx"
#include <SMESHDS_SubMesh.hxx> #include "SMESH_subMesh.hxx"
#include <SMDS_MeshElement.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <gp_Pnt.hxx>
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <TopAbs_ShapeEnum.hxx>
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shell.hxx> #include <TopoDS_Shell.hxx>
#include <TopoDS_Vertex.hxx>
#include <gp_Pnt.hxx>
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef map < int, int, less<int> >::iterator \ typedef map < int, int, less<int> >::iterator \
StdMeshers_IteratorOfDataMapOfIntegerInteger; StdMeshers_IteratorOfDataMapOfIntegerInteger;
@ -380,11 +381,12 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
{ {
myErrorStatus=0; myErrorStatus=0;
// //
double aX, aY, aZ, aD, aTol2; double aX, aY, aZ, aD, aTol2, minD;
gp_Pnt aP1, aP2; gp_Pnt aP1, aP2;
// //
SMESH_Mesh* pMesh=GetMesh(); SMESH_Mesh* pMesh=GetMesh();
aTol2=myTol3D*myTol3D; aTol2=myTol3D*myTol3D;
minD = 1.e100;
SMDS_MeshNode* pNode=NULL; SMDS_MeshNode* pNode=NULL;
// //
myBlock.Point(aParams, aS, aP1); myBlock.Point(aParams, aS, aP1);
@ -399,18 +401,20 @@ void StdMeshers_Penta_3D::FindNodeOnShape(const TopoDS_Shape& aS,
aP2.SetCoord(aX, aY, aZ); aP2.SetCoord(aX, aY, aZ);
aD=(double)aP1.SquareDistance(aP2); aD=(double)aP1.SquareDistance(aP2);
//printf("** D=%lf ", aD, aTol2); //printf("** D=%lf ", aD, aTol2);
if (aD<aTol2) { if (aD < minD) {
pNode=(SMDS_MeshNode*)aNode; pNode=(SMDS_MeshNode*)aNode;
aTN.SetNode(pNode); aTN.SetNode(pNode);
minD = aD;
//printf(" Ok\n"); //printf(" Ok\n");
return; if (aD<aTol2)
return;
} }
} }
// //
//printf(" KO\n"); //printf(" KO\n");
aTN.SetNode(pNode); //aTN.SetNode(pNode);
MESSAGE("StdMeshers_Penta_3D::FindNodeOnShape(), can not find the node"); //MESSAGE("StdMeshers_Penta_3D::FindNodeOnShape(), can not find the node");
myErrorStatus=11; // can not find the node; //myErrorStatus=11; // can not find the node;
} }
//======================================================================= //=======================================================================
@ -482,6 +486,7 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
++k; ++k;
} }
// //
bool forward = true;
for (i=0; i<ik; ++i){ for (i=0; i<ik; ++i){
i1=i; i1=i;
i2=i+1; i2=i+1;
@ -496,16 +501,45 @@ void StdMeshers_Penta_3D::MakeVolumeMesh()
const SMDS_MeshNode* aN2=aTN2.Node(); const SMDS_MeshNode* aN2=aTN2.Node();
aN[j+nbFaceNodes]=aN2; aN[j+nbFaceNodes]=aN2;
} }
// // check if volume orientation will be ok
if ( i == 0 ) {
SMDS_VolumeTool vTool;
switch ( nbFaceNodes ) {
case 3: {
SMDS_VolumeOfNodes tmpVol (aN[0], aN[1], aN[2],
aN[3], aN[4], aN[5]);
vTool.Set( &tmpVol );
break;
}
case 4: {
SMDS_VolumeOfNodes tmpVol(aN[0], aN[1], aN[2], aN[3],
aN[4], aN[5], aN[6], aN[7]);
vTool.Set( &tmpVol );
break;
}
default:
continue;
}
forward = vTool.IsForward();
}
// add volume
SMDS_MeshVolume* aV = 0; SMDS_MeshVolume* aV = 0;
switch ( nbFaceNodes ) { switch ( nbFaceNodes ) {
case 3: case 3:
aV = meshDS->AddVolume(aN[0], aN[1], aN[2], if ( forward )
aN[3], aN[4], aN[5]); 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; break;
case 4: case 4:
aV = meshDS->AddVolume(aN[0], aN[1], aN[2], aN[3], if ( forward )
aN[4], aN[5], aN[6], aN[7]); 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; break;
default: default:
continue; continue;