#include "SMDS_MeshElement.hxx"
#include "SMDS_MeshNode.hxx"
#include "SMDS_FacePosition.hxx"
+#include "SMDS_VolumeTool.hxx"
+#include "SMDS_VolumeOfNodes.hxx"
#include <TopExp.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include "utilities.h"
#include "Utils_ExceptHandlers.hxx"
+//modified by NIZNHY-PKV Wed Nov 17 15:31:58 2004 f
+#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
//=============================================================================
/*!
StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D()
{
MESSAGE("StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D");
+ for (int i = 0; i < 6; i++)
+ StdMeshers_Quadrangle_2D::QuadDelete(_quads[i]);
}
//=============================================================================
{
Unexpect aCatch(SalomeException);
MESSAGE("StdMeshers_Hexa_3D::Compute");
-
- bool isOk = false;
+ //bool isOk = false;
SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
- SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
+ //SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape);
//const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS();
// 0. - shape and face mesh verification
for (int i = 0; i < 6; i++)
{
- TopoDS_Shape aShape = meshFaces[i]->GetSubShape();
- SMESH_Algo *algo = _gen->GetAlgo(aMesh, aShape);
- string algoName = algo->GetName();
- if (algoName != "Quadrangle_2D")
- {
- // *** delete _quads
- SCRUTE(algoName);
-// ASSERT(0);
- return false;
- }
- StdMeshers_Quadrangle_2D *quadAlgo =
- dynamic_cast < StdMeshers_Quadrangle_2D * >(algo);
- ASSERT(quadAlgo);
- try
- {
- _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aShape);
- // *** to delete after usage
- }
- catch(SALOME_Exception & S_ex)
- {
- // *** delete _quads
- // *** throw exception
-// ASSERT(0);
- return false;
- }
-
- // 0.2.1 - number of points on the opposite edges must be the same
- if (_quads[i]->nbPts[0] != _quads[i]->nbPts[2] ||
- _quads[i]->nbPts[1] != _quads[i]->nbPts[3])
- {
- MESSAGE("different number of points on the opposite edges of face " << i);
-// ASSERT(0);
- return false;
- }
+ TopoDS_Shape aFace = meshFaces[i]->GetSubShape();
+ SMESH_Algo *algo = _gen->GetAlgo(aMesh, aFace);
+ string algoName = algo->GetName();
+ bool isAllQuad = false;
+ if (algoName == "Quadrangle_2D") {
+ SMESHDS_SubMesh * sm = meshDS->MeshElements( aFace );
+ if ( sm ) {
+ isAllQuad = true;
+ SMDS_ElemIteratorPtr eIt = sm->GetElements();
+ while ( isAllQuad && eIt->more() )
+ isAllQuad = ( eIt->next()->NbNodes() == 4 );
+ }
+ }
+ if ( ! isAllQuad ) {
+ //modified by NIZNHY-PKV Wed Nov 17 15:31:37 2004 f
+ bool bIsOk;
+ //
+ bIsOk=ComputePentahedralMesh(aMesh, aShape);
+ if (bIsOk) {
+ return true;
+ }
+ //modified by NIZNHY-PKV Wed Nov 17 15:31:42 2004 t
+ SCRUTE(algoName);
+ // ASSERT(0);
+ return false;
+ }
+ StdMeshers_Quadrangle_2D *quadAlgo =
+ dynamic_cast < StdMeshers_Quadrangle_2D * >(algo);
+ ASSERT(quadAlgo);
+ try
+ {
+ _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aFace);
+ // *** to delete after usage
+ }
+ catch(SALOME_Exception & S_ex)
+ {
+ // *** delete _quads
+ // *** throw exception
+ // ASSERT(0);
+ return false;
+ }
+
+ // 0.2.1 - number of points on the opposite edges must be the same
+ if (_quads[i]->nbPts[0] != _quads[i]->nbPts[2] ||
+ _quads[i]->nbPts[1] != _quads[i]->nbPts[3])
+ {
+ MESSAGE("different number of points on the opposite edges of face " << i);
+ // ASSERT(0);
+ return false;
+ }
}
// 1. - identify faces and vertices of the "cube"
int nbz = _cube.quad_Y0->nbPts[0];
if (cy0.a1 != 0.) nbz = _cube.quad_Y0->nbPts[1];
-// int nbx = _cube.quad_Y0->nbPts[0];
-// int nby = _cube.quad_Y0->nbPts[1];
-// int nbz;
-// if (cx0.a1 != 0)
-// nbz = _cube.quad_X0->nbPts[1];
-// else
-// nbz = _cube.quad_X0->nbPts[0];
- //SCRUTE(nbx);
- //SCRUTE(nby);
- //SCRUTE(nbz);
+
int i1, j1, nbxyz = nbx * nby * nbz;
Point3DStruct *np = new Point3DStruct[nbxyz];
// - compute the point 3D
// - store the point 3D in SMESHDS, store its ID in 3D structure
- TopoDS_Shell aShell;
- TopExp_Explorer exp(aShape, TopAbs_SHELL);
- if (exp.More())
- {
- aShell = TopoDS::Shell(exp.Current());
- }
- else
- {
- MESSAGE("no shell...");
- ASSERT(0);
- }
+ int shapeID = meshDS->ShapeToIndex( aShape );
Pt3 p000, p001, p010, p011, p100, p101, p110, p111;
Pt3 px00, px01, px10, px11;
SMDS_MeshNode * node = meshDS->AddNode(X[0], X[1], X[2]);
np[ijk].node = node;
- //meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape));
- meshDS->SetNodeInVolume(node, aShell);
+ meshDS->SetNodeInVolume(node, shapeID);
}
}
}
+ // 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;
int n7 = (k + 1) * nbx * nby + (j + 1) * nbx + i + 1;
int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i;
-// MESSAGE(" "<<n1<<" "<<n2<<" "<<n3<<" "<<n4<<" "<<n5<<" "<<n6<<" "<<n7<<" "<<n8);
- //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);
-
- 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);
-
- // *** 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);
-
- }
-
+ 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);
+
+ meshDS->SetMeshElementOnShape(elt, shapeID);
+ }
+ }
+ if ( np ) delete [] np;
//MESSAGE("End of StdMeshers_Hexa_3D::Compute()");
return true;
}
{
return hyp.LoadFrom( load );
}
+
+//modified by NIZNHY-PKV Wed Nov 17 15:34:13 2004 f
+///////////////////////////////////////////////////////////////////////////////
+//ZZ
+//#include <stdio.h>
+
+//=======================================================================
+//function : ComputePentahedralMesh
+//purpose :
+//=======================================================================
+bool ComputePentahedralMesh(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape)
+{
+ //printf(" ComputePentahedralMesh HERE\n");
+ //
+ bool bOK;
+ //int iErr;
+ StdMeshers_Penta_3D anAlgo;
+ //
+ bOK=anAlgo.Compute(aMesh, aShape);
+ /*
+ iErr=anAlgo.ErrorStatus();
+
+ if (iErr) {
+ printf(" *** Error# %d\n", iErr);
+ }
+ else {
+ printf(" *** No errors# %d\n", iErr);
+ }
+ */
+ return bOK;
+}
+