Added some try catch

This commit is contained in:
gdd 2011-09-07 12:05:48 +00:00
parent acd45e23fa
commit 5eca4e749b

View File

@ -249,14 +249,14 @@ bool GEOMImpl_IAdvancedOperations::MakeGroups(Handle(GEOM_Object) theShape, int
gp_Trsf aTrsfInv = aTrsf.Inverted(); gp_Trsf aTrsfInv = aTrsf.Inverted();
int expectedGroups = 0; // int expectedGroups = 0;
if (shapeType == TSHAPE_BASIC) // if (shapeType == TSHAPE_BASIC)
if (Abs(theR2+theW2-theR1-theW1) <= Precision::Approximation()) // if (Abs(theR2+theW2-theR1-theW1) <= Precision::Approximation())
expectedGroups = 10; // expectedGroups = 10;
else // else
expectedGroups = 11; // expectedGroups = 11;
else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET) // else if (shapeType == TSHAPE_CHAMFER || shapeType == TSHAPE_FILLET)
expectedGroups = 12; // expectedGroups = 12;
double aR1Ext = theR1 + theW1; double aR1Ext = theR1 + theW1;
double aR2Ext = theR2 + theW2; double aR2Ext = theR2 + theW2;
@ -634,7 +634,12 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
Handle(GEOM_Object) wire_t, wire_t2, face_t, face_t2; Handle(GEOM_Object) wire_t, wire_t2, face_t, face_t2;
Handle(GEOM_Object) chan_racc; Handle(GEOM_Object) chan_racc;
Handle(GEOM_Object) vi1, vi2; Handle(GEOM_Object) vi1, vi2;
Handle(GEOM_Object) Te3;
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
Handle(GEOM_Object) Vector_Z = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1); Handle(GEOM_Object) Vector_Z = myBasicOperations->MakeVectorDXDYDZ(0, 0, 1);
Vector_Z->GetLastFunction()->SetDescription(""); Vector_Z->GetLastFunction()->SetDescription("");
@ -744,35 +749,18 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
} }
} }
Handle(GEOM_Object) edge_e1, edge_e2; Handle(GEOM_Object) edge_e1, edge_e2;
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1); edge_e1 = myBasicOperations->MakeLineTwoPnt(ve1, vi1);
if (edge_e1.IsNull()) { if (edge_e1.IsNull()) {
SetErrorCode("Edge 1 could not be built"); SetErrorCode("Edge 1 could not be built");
return false; return false;
} }
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return false;
}
try {
#if OCC_VERSION_LARGE > 0x06010000
OCC_CATCH_SIGNALS;
#endif
edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2); edge_e2 = myBasicOperations->MakeLineTwoPnt(ve2, vi2);
if (edge_e2.IsNull()) { if (edge_e2.IsNull()) {
SetErrorCode("Edge 2 could not be built"); SetErrorCode("Edge 2 could not be built");
return false; return false;
} }
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return false;
}
edge_e1->GetLastFunction()->SetDescription(""); edge_e1->GetLastFunction()->SetDescription("");
edge_e2->GetLastFunction()->SetDescription(""); edge_e2->GetLastFunction()->SetDescription("");
@ -1027,14 +1015,14 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
if (!isNormal) if (!isNormal)
theTools->Append(face_t2); theTools->Append(face_t2);
Handle(GEOM_Object) Te3 = myBooleanOperations->MakePartition Te3 = myBooleanOperations->MakePartition
(partitionShapes, theTools, theKeepInside, theRemoveInside, (partitionShapes, theTools, theKeepInside, theRemoveInside,
TopAbs_SOLID, false, theMaterials, 0, false); TopAbs_SOLID, false, theMaterials, 0, false);
if (Te3.IsNull()) { if (Te3.IsNull()) {
SetErrorCode("Impossible to build partition of TShape"); SetErrorCode("Impossible to build partition of TShape");
// Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes); // Handle(GEOM_Object) aCompound = myShapesOperations->MakeCompound(theShapes);
// TopoDS_Shape aCompoundShape = aCompound->GetValue(); // TopoDS_Shape aCompoundShape = aCompound->GetValue();
// theShape->GetLastFunction()->SetValue(aCompoundShape); // theShape->GetLastFunction()->SetValue(aCompoundShape);
return false; return false;
} }
Te3->GetLastFunction()->SetDescription(""); Te3->GetLastFunction()->SetDescription("");
@ -1047,6 +1035,11 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(Handle(GEOM_Object) t
} }
TopoDS_Shape aShape = Te3->GetValue(); TopoDS_Shape aShape = Te3->GetValue();
theShape->GetLastFunction()->SetValue(aShape); theShape->GetLastFunction()->SetValue(aShape);
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return false;
}
SetErrorCode(OK); SetErrorCode(OK);
return true; return true;
@ -1176,18 +1169,18 @@ GEOMImpl_IAdvancedOperations::MakePipeTShape(double theR1, double theW1, double
SetErrorCode("TShape driver failed"); SetErrorCode("TShape driver failed");
return NULL; return NULL;
} }
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
if (theHexMesh) { if (theHexMesh) {
if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) if (!MakePipeTShapePartition(aShape, theR1, theW1, theL1, theR2, theW2, theL2))
return NULL; return NULL;
if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2)) if (!MakePipeTShapeMirrorAndGlue(aShape, theR1, theW1, theL1, theR2, theW2, theL2))
return NULL; return NULL;
} }
} catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) aSeq = new TColStd_HSequenceOfTransient;
aSeq->Append(aShape); aSeq->Append(aShape);