0020695: EDF 1076 GEOM: Add a new shape in GEOM: T-shape

- Change Partition operation: MakePartition instead of MakeHalfPartition because result was not a block
- Add exception catch
This commit is contained in:
gdd 2010-04-18 17:03:45 +00:00
parent 9da0aeceb7
commit 307d55f904

View File

@ -1045,89 +1045,89 @@ bool GEOMImpl_IAdvancedOperations::MakePipeTShapePartition(/*std::vector<GEOM_IO
theShapes.push_back(aPlnOXZ); theShapes.push_back(aPlnOXZ);
// Partition // Partition
Handle(GEOM_Object) Part0 = aBooleanOperations->MakeHalfPartition(theShape, face_t); // Handle(GEOM_Object) Part0 = aBooleanOperations->MakeHalfPartition(theShape, face_t);
if (Part0.IsNull()) { // if (Part0.IsNull()) {
std::cerr << "Impossible to build partition between TShape and 1st face" << std::endl; // std::cerr << "Impossible to build partition between TShape and 1st face" << std::endl;
SetErrorCode("Impossible to build partition between TShape and 1st face"); // SetErrorCode("Impossible to build partition between TShape and 1st face");
return false; // return false;
} // }
Part0->GetLastFunction()->SetDescription(""); // Part0->GetLastFunction()->SetDescription("");
//
Handle(GEOM_Object) Te3 ; // Handle(GEOM_Object) Te3 ;
if (isNormal) { // if (isNormal) {
if (Abs(aR1Ext - aR2Ext) <= Precision::Approximation()) { // if (Abs(aR1Ext - aR2Ext) <= Precision::Approximation()) {
std::cerr << "External radius are identical: we do not make partition with plane OXZ" << std::endl; // std::cerr << "External radius are identical: we do not make partition with plane OXZ" << std::endl;
Te3 = aBooleanOperations->MakeHalfPartition(Part0, aPlnOZ); // Te3 = aBooleanOperations->MakeHalfPartition(Part0, aPlnOZ);
} // }
else { // else {
Handle(GEOM_Object) Part1 = aBooleanOperations->MakeHalfPartition(Part0, aPlnOXZ); // Handle(GEOM_Object) Part1 = aBooleanOperations->MakeHalfPartition(Part0, aPlnOXZ);
if (Part1.IsNull()) { // if (Part1.IsNull()) {
std::cerr << "Impossible to build partition between TShape and plane OXZ" << std::endl; // std::cerr << "Impossible to build partition between TShape and plane OXZ" << std::endl;
SetErrorCode("Impossible to build partition between TShape and plane OXZ"); // SetErrorCode("Impossible to build partition between TShape and plane OXZ");
return false; // return false;
} // }
Part1->GetLastFunction()->SetDescription(""); // Part1->GetLastFunction()->SetDescription("");
Te3 = aBooleanOperations->MakeHalfPartition(Part1, aPlnOZ); // Te3 = aBooleanOperations->MakeHalfPartition(Part1, aPlnOZ);
} // }
if (Te3.IsNull()) { // if (Te3.IsNull()) {
std::cerr << "Impossible to build partition between TShape and plane OZ" << std::endl; // std::cerr << "Impossible to build partition between TShape and plane OZ" << std::endl;
SetErrorCode("Impossible to build partition between TShape and plane OZ"); // SetErrorCode("Impossible to build partition between TShape and plane OZ");
return false; // return false;
} // }
Te3->GetLastFunction()->SetDescription(""); // Te3->GetLastFunction()->SetDescription("");
} // }
else { // else {
if (Abs(aR1Ext - aR2Ext) <= Precision::Approximation()){ // We should never go here // if (Abs(aR1Ext - aR2Ext) <= Precision::Approximation()){ // We should never go here
SetErrorCode("Impossible to build TShape"); // SetErrorCode("Impossible to build TShape");
return false; // return false;
} // }
else { // else {
Handle(GEOM_Object) Part1 = aBooleanOperations->MakeHalfPartition(Part0, aPlnOXZ); // Handle(GEOM_Object) Part1 = aBooleanOperations->MakeHalfPartition(Part0, aPlnOXZ);
if (Part1.IsNull()) { // if (Part1.IsNull()) {
std::cerr << "Impossible to build partition between TShape and plane OXZ" << std::endl; // std::cerr << "Impossible to build partition between TShape and plane OXZ" << std::endl;
SetErrorCode("Impossible to build partition between TShape and plane OXZ"); // SetErrorCode("Impossible to build partition between TShape and plane OXZ");
return false; // return false;
} // }
Part1->GetLastFunction()->SetDescription(""); // Part1->GetLastFunction()->SetDescription("");
Handle(GEOM_Object) Part2 = aBooleanOperations->MakeHalfPartition(Part1, aPlnOZ); // Handle(GEOM_Object) Part2 = aBooleanOperations->MakeHalfPartition(Part1, aPlnOZ);
if (Part2.IsNull()) { // if (Part2.IsNull()) {
std::cerr << "Impossible to build partition between TShape and plane OZ" << std::endl; // std::cerr << "Impossible to build partition between TShape and plane OZ" << std::endl;
SetErrorCode("Impossible to build partition between TShape and plane OZ"); // SetErrorCode("Impossible to build partition between TShape and plane OZ");
return false; // return false;
} // }
Part2->GetLastFunction()->SetDescription(""); // Part2->GetLastFunction()->SetDescription("");
Te3 = aBooleanOperations->MakeHalfPartition(Part2, face_t2); // Te3 = aBooleanOperations->MakeHalfPartition(Part2, face_t2);
if (Te3.IsNull()) { // if (Te3.IsNull()) {
std::cerr << "Impossible to build partition between TShape and 2nd face" << std::endl; // std::cerr << "Impossible to build partition between TShape and 2nd face" << std::endl;
SetErrorCode("Impossible to build partition between TShape and 2nd face"); // SetErrorCode("Impossible to build partition between TShape and 2nd face");
return false; // return false;
} // }
Te3->GetLastFunction()->SetDescription(""); // Te3->GetLastFunction()->SetDescription("");
} // }
} // }
// Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) partitionShapes = new TColStd_HSequenceOfTransient;
// Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) theTools = new TColStd_HSequenceOfTransient;
// Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) theKeepInside = new TColStd_HSequenceOfTransient;
// Handle(TColStd_HSequenceOfTransient) theRemoveInside = new TColStd_HSequenceOfTransient; Handle(TColStd_HSequenceOfTransient) theRemoveInside = new TColStd_HSequenceOfTransient;
// Handle(TColStd_HArray1OfInteger) theMaterials; Handle(TColStd_HArray1OfInteger) theMaterials;
// partitionShapes->Append(theShape); partitionShapes->Append(theShape);
// theTools->Append(aPlnOZ); theTools->Append(aPlnOZ);
// theTools->Append(aPlnOXZ); theTools->Append(aPlnOXZ);
// theTools->Append(face_t); theTools->Append(face_t);
// if (!isNormal) if (!isNormal)
// theTools->Append(face_t2); theTools->Append(face_t2);
//
// Handle(GEOM_Object) Te3 = aBooleanOperations->MakePartition(partitionShapes, theTools, theKeepInside, theRemoveInside, TopAbs_SOLID, false, theMaterials, 0, false); Handle(GEOM_Object) Te3 = aBooleanOperations->MakePartition(partitionShapes, theTools, theKeepInside, theRemoveInside, 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 = aShapesOperations->MakeCompound(theShapes); // Handle(GEOM_Object) aCompound = aShapesOperations->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("");
//
TopoDS_Shape aShape = Te3->GetValue(); TopoDS_Shape aShape = Te3->GetValue();
theShape->GetLastFunction()->SetValue(aShape); theShape->GetLastFunction()->SetValue(aShape);
@ -1639,14 +1639,11 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IAdvancedOperations::MakePipeTShap
catch (Standard_Failure) { catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString()); SetErrorCode(aFail->GetMessageString());
try { return NULL;
aChamfer = aLocalOperations->MakeChamferEdges(aShape, theH, theW, theEdges); }
} if (aChamfer.IsNull()) {
catch (Standard_Failure) { SetErrorCode("Chamfer can not be computed on the given shape with the given parameters");
Handle(Standard_Failure) aFail = Standard_Failure::Caught(); return NULL;
SetErrorCode(aFail->GetMessageString());
return NULL;
}
} }
aChamfer->GetLastFunction()->SetDescription(""); aChamfer->GetLastFunction()->SetDescription("");
@ -1853,8 +1850,14 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IAdvancedOperations::MakePipeTShap
try { try {
aChamfer = aLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges); aChamfer = aLocalOperations->MakeChamferEdges(aShape, theW, theH, theEdges);
} }
catch (...) { catch (Standard_Failure) {
aChamfer = aLocalOperations->MakeChamferEdges(aShape, theH, theW, theEdges); Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
if (aChamfer.IsNull()) {
SetErrorCode("Chamfer can not be computed on the given shape with the given parameters");
return NULL;
} }
aChamfer->GetLastFunction()->SetDescription(""); aChamfer->GetLastFunction()->SetDescription("");
@ -2040,8 +2043,20 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IAdvancedOperations::MakePipeTShap
if (theHexMesh && nbEdgesInFillet == 1) if (theHexMesh && nbEdgesInFillet == 1)
break; break;
} }
Handle(GEOM_Object) aFillet = aLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); Handle(GEOM_Object) aFillet;
try {
aFillet = aLocalOperations->MakeFilletEdges(aShape, theRF, theEdges);
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
if (aFillet.IsNull()) {
SetErrorCode("Fillet can not be computed on the given shape with the given parameters");
return NULL;
}
aFillet->GetLastFunction()->SetDescription(""); aFillet->GetLastFunction()->SetDescription("");
TopoDS_Shape aFilletShape = aFillet->GetValue(); TopoDS_Shape aFilletShape = aFillet->GetValue();
@ -2229,8 +2244,20 @@ Handle(TColStd_HSequenceOfTransient) GEOMImpl_IAdvancedOperations::MakePipeTShap
if (theHexMesh && nbEdgesInFillet == 1) if (theHexMesh && nbEdgesInFillet == 1)
break; break;
} }
Handle(GEOM_Object) aFillet = aLocalOperations->MakeFilletEdges(aShape, theRF, theEdges); Handle(GEOM_Object) aFillet;
try {
aFillet = aLocalOperations->MakeFilletEdges(aShape, theRF, theEdges);
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
if (aFillet.IsNull()) {
SetErrorCode("Fillet can not be computed on the given shape with the given parameters");
return NULL;
}
aFillet->GetLastFunction()->SetDescription(""); aFillet->GetLastFunction()->SetDescription("");
TopoDS_Shape aFilletShape = aFillet->GetValue(); TopoDS_Shape aFilletShape = aFillet->GetValue();