#include "SMESH_MeshEditor.hxx"
#include "SMESH_subMesh.hxx"
#include "SMESH_subMeshEventListener.hxx"
+#include "SMESH_Comment.hxx"
#include <BRepTools.hxx>
#include <BRepTools_WireExplorer.hxx>
//purpose :
//=======================================================================
StdMeshers_Penta_3D::StdMeshers_Penta_3D()
-: myErrorStatus(1)
+: myErrorStatus(SMESH_ComputeError::New())
{
myTol3D=0.1;
myWallNodesMaps.resize( SMESH_Block::NbFaces() );
StdMeshers_Penta_3D::~StdMeshers_Penta_3D()
{
- if ( myTool )
- delete myTool;
}
//=======================================================================
{
MESSAGE("StdMeshers_Penta_3D::Compute()");
//
- myErrorStatus=0;
- //
bool bOK=false;
//
myShape=aShape;
SetMesh(aMesh);
//
CheckData();
- if (myErrorStatus){
+ if (!myErrorStatus->IsOK()) {
return bOK;
}
- myTool = new SMESH_MesherHelper(aMesh);
+ SMESH_MesherHelper helper(aMesh);
+ myTool = &helper;
myCreateQuadratic = myTool->IsQuadraticSubMesh(aShape);
//
MakeBlock();
- if (myErrorStatus){
- delete myTool; myTool = 0;
+ if (!myErrorStatus->IsOK()) {
return bOK;
}
//
ClearMeshOnFxy1();
- if (myErrorStatus) {
- delete myTool; myTool = 0;
+ if (!myErrorStatus->IsOK()) {
return bOK;
}
//
MakeNodes();
- if (myErrorStatus){
- delete myTool; myTool = 0;
+ if (!myErrorStatus->IsOK()) {
return bOK;
}
//
MakeConnectingMap();
//
MakeMeshOnFxy1();
- if (myErrorStatus) {
- delete myTool; myTool = 0;
+ if (!myErrorStatus->IsOK()) {
return bOK;
}
//
MakeVolumeMesh();
//
- delete myTool; myTool = 0;
return !bOK;
}
//=======================================================================
void StdMeshers_Penta_3D::MakeNodes()
{
- myErrorStatus=0;
- //
const int aNbSIDs=9;
int i, j, k, ij, iNbN, aNodeID, aSize, iErr;
double aX, aY, aZ;
if (iErr) {
MESSAGE("StdMeshers_Penta_3D::MakeNodes()," <<
"SMESHBlock: ComputeParameters operation failed");
- myErrorStatus=101; // SMESHBlock: ComputeParameters operation failed
+ myErrorStatus=myBlock.GetError();
return;
}
aTNode.SetNormCoord(aCoords);
TopoDS::Edge( myBlock.Shape( baseEdgeID[ i ] )),
pMesh->GetMeshDS());
if ( !ok ) {
- myErrorStatus = i + 1;
- MESSAGE(" Cant LoadIJNodes() from a wall face " << myErrorStatus );
+ myErrorStatus->myName = COMPERR_BAD_INPUT_MESH;
+ myErrorStatus->myComment = SMESH_Comment() <<
+ "Can't find regular quadrangle mesh on a side face #" <<
+ pMesh->GetMeshDS()->ShapeToIndex( myBlock.Shape( wallFaceID[ i ]));
return;
}
}
//
// suporting shape ID
ShapeSupportID(bIsUpperLayer, aBNSSID, aSSID);
- if (myErrorStatus) {
+ if (!myErrorStatus->IsOK()) {
MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
return;
}
meshDS->SetNodeOnFace((SMDS_MeshNode*)n, topfaceID, aP.X(), aP.Y());
}
}
- if (myErrorStatus) {
+ if (!myErrorStatus->IsOK()) {
MESSAGE("StdMeshers_Penta_3D::MakeNodes() ");
return;
}
const int z,
StdMeshers_TNode& aTN)
{
- myErrorStatus=0;
- //
double aX, aY, aZ, aD, aTol2, minD;
gp_Pnt aP1, aP2;
//
//=======================================================================
void StdMeshers_Penta_3D::MakeVolumeMesh()
{
- myErrorStatus=0;
- //
int i, j, ij, ik, i1, i2, aSSID;
//
SMESH_Mesh* pMesh = GetMesh();
continue;
aID0 = pNode->GetID();
aJ[k] = GetIndexOnLayer(aID0);
- if (myErrorStatus) {
+ if (!myErrorStatus->IsOK()) {
MESSAGE("StdMeshers_Penta_3D::MakeVolumeMesh");
return;
}
//=======================================================================
void StdMeshers_Penta_3D::MakeMeshOnFxy1()
{
- myErrorStatus=0;
- //
int aID0, aJ, aLevel, ij, aNbNodes, k;
//
SMDS_NodeIteratorPtr itn;
k = aNbNodes-1; // reverse a face
aItNodes = pE0->nodesIterator();
while (aItNodes->more()) {
- //const SMDS_MeshElement* pNode = aItNodes->next();
const SMDS_MeshNode* pNode =
static_cast<const SMDS_MeshNode*> (aItNodes->next());
if(myTool->IsMedium(pNode))
continue;
aID0 = pNode->GetID();
aJ = GetIndexOnLayer(aID0);
- if (myErrorStatus) {
+ if (!myErrorStatus->IsOK()) {
MESSAGE("StdMeshers_Penta_3D::MakeMeshOnFxy1() ");
return;
}
//=======================================================================
void StdMeshers_Penta_3D::ClearMeshOnFxy1()
{
- myErrorStatus=0;
- //
SMESH_subMesh* aSubMesh;
SMESH_Mesh* pMesh=GetMesh();
//
//=======================================================================
int StdMeshers_Penta_3D::GetIndexOnLayer(const int aID)
{
- myErrorStatus=0;
- //
int j=-1;
StdMeshers_IteratorOfDataMapOfIntegerInteger aMapIt;
//
aMapIt=myConnectingMap.find(aID);
if (aMapIt==myConnectingMap.end()) {
- myErrorStatus=200;
+ myErrorStatus->myName = 200;
+ myErrorStatus->myComment = "Internal error of StdMeshers_Penta_3D";
return j;
}
j=(*aMapIt).second;
const gp_XYZ& aParams,
StdMeshers_TNode& aTN)
{
- myErrorStatus=0;
- //
- // int iErr;
double aX, aY, aZ;
//
gp_Pnt aP;
const SMESH_Block::TShapeID aBNSSID,
SMESH_Block::TShapeID& aSSID)
{
- myErrorStatus=0;
- //
switch (aBNSSID) {
case SMESH_Block::ID_V000:
aSSID=(bIsUpperLayer) ? SMESH_Block::ID_V001 : SMESH_Block::ID_E00z;
break;
default:
aSSID=SMESH_Block::ID_NONE;
- myErrorStatus=10; // Can not find supporting shape ID
+ myErrorStatus->myName=10; // Can not find supporting shape ID
+ myErrorStatus->myComment = "Internal error of StdMeshers_Penta_3D";
break;
}
return;
//=======================================================================
void StdMeshers_Penta_3D::MakeBlock()
{
- myErrorStatus=0;
- //
bool bFound;
int i, j, iNbEV, iNbE, iErr, iCnt, iNbNodes, iNbF;
//
}
}
if (!isOK) {
- myErrorStatus=5; // more than one face has triangulation
+ myErrorStatus->myName=5; // more than one face has triangulation
+ myErrorStatus->myComment="Incorrect input mesh";
return;
}
}
iNbE = aME.Extent();
if (iNbE!= NB_WALL_FACES ){
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
- myErrorStatus=7; // too few edges are in base face aFTr
+ myErrorStatus->myName=7; // too few edges are in base face aFTr
+ myErrorStatus->myComment=SMESH_Comment("Not a quadrilateral face #")
+ <<pMesh->GetMeshDS()->ShapeToIndex( aFTr )<<": "<<iNbE<<" edges" ;
return;
}
const TopoDS_Edge& aE1=TopoDS::Edge(aME(1));
iNbEV=aMEV.Extent();
if (iNbEV!=3){
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
- myErrorStatus=7; // too few edges meet in base vertex
+ myErrorStatus->myName=7; // too few edges meet in base vertex
+ myErrorStatus->myComment=SMESH_Comment("3 edges must share vertex #")
+ <<pMesh->GetMeshDS()->ShapeToIndex( aV000 )<<" but there are "<<iNbEV<<" edges";
return;
}
//
//
if (!bFound) {
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
- myErrorStatus=8; // can not find reper V001
+ myErrorStatus->myName=8; // can not find reper V001
+ myErrorStatus->myComment=SMESH_Comment("Can't find opposite vertex for vertex #")
+ <<pMesh->GetMeshDS()->ShapeToIndex( aV000 );
return;
}
//DEB
iNbE=aME.Extent();
if (iNbE!=1) {
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
- myErrorStatus=9; // number of shells in source shape !=1
+ myErrorStatus->myName=9; // number of shells in source shape !=1
+ myErrorStatus->myComment=SMESH_Comment("Unexpected nb of shells ")<<iNbE;
return;
}
//
iErr = myBlock.ErrorStatus();
if (iErr) {
MESSAGE("StdMeshers_Penta_3D::MakeBlock() ");
- myErrorStatus=100; // SMESHBlock: Load operation failed
+ myErrorStatus=myBlock.GetError(); // SMESHBlock: Load operation failed
return;
}
}
//=======================================================================
void StdMeshers_Penta_3D::CheckData()
{
- myErrorStatus=0;
- //
int i, iNb;
int iNbEx[]={8, 12, 6};
//
//
if (myShape.IsNull()){
MESSAGE("StdMeshers_Penta_3D::CheckData() ");
- myErrorStatus=2; // null shape
+ myErrorStatus->myName=2; // null shape
+ myErrorStatus->myComment="Null shape";
return;
}
//
aST=myShape.ShapeType();
if (!(aST==TopAbs_SOLID || aST==TopAbs_SHELL)) {
MESSAGE("StdMeshers_Penta_3D::CheckData() ");
- myErrorStatus=3; // not compatible type of shape
+ myErrorStatus->myName=3; // not compatible type of shape
+ myErrorStatus->myComment=SMESH_Comment("Wrong shape type (TopAbs_ShapeEnum) ")<<aST;
return;
}
//
iNb=aM.Extent();
if (iNb!=iNbEx[i]){
MESSAGE("StdMeshers_Penta_3D::CheckData() ");
- myErrorStatus=4; // number of subshape is not compatible
+ myErrorStatus->myName=4; // number of subshape is not compatible
+ myErrorStatus->myComment="Wrong number of subshapes of a block";
return;
}
}
return myErrorStatus;
}
+//================================================================================
+/*!
+ * \brief Return problem description
+ */
+//================================================================================
+
+SMESH_ComputeErrorPtr StdMeshers_SMESHBlock::GetError() const
+{
+ SMESH_ComputeErrorPtr err = SMESH_ComputeError::New();
+ string & text = err->myComment;
+ switch ( myErrorStatus ) {
+ case 2:
+ 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;
+ }
+ if (!text.empty())
+ err->myName = myErrorStatus;
+ return err;
+}
+
//=======================================================================
//function : Load
//purpose :
myShapeIDMap.Clear();
bOk = myTBlock.LoadBlockShapes(myShell, theV000, theV001, myShapeIDMap);
if (!bOk) {
- myErrorStatus=2;
+ myErrorStatus=6;
return;
}
}
}
}
if (!bOk) {
- myErrorStatus=4; // problems with point computation
+ myErrorStatus=5; // problems with point computation
return;
}
aP3D.SetXYZ(aXYZ);