mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
0032931: Modeling Algorithms - Crash in ChFi3d_IsInFront when no face was found
The ChFi3d_IsInFront code is currently not handling all the combinations correctly. For example, if `if(fd1->IndexOfS2() == fd2->IndexOfS2())` is true, it can happen that the `TopoDS::Face(DStr.Shape(fd1->Index(jf1)))` returns a Face with entity == NULL. The subsequent usage of this NULL face in `BRep_Tool::Parameters( Vtx, face )` will then cause a segfault. While the best approach would be to identify the implementation bug in the algorithm behind PChFi3d_IsInFron, a check + exception is used instead because the actual algorithm is not known. Signed-off-by: Charlemagne Lasse <charlemagnelasse@gmail.com>
This commit is contained in:
committed by
smoskvin
parent
fd29020f87
commit
19a49b8e74
@@ -819,10 +819,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS1() == fd2->IndexOfS1()) {
|
||||
jf1 = 1; jf2 = 1;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation. This would raise problems
|
||||
@@ -840,10 +843,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS2() == fd2->IndexOfS1()) {
|
||||
jf1 = 2; jf2 = 1;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation. This would raise problems
|
||||
@@ -873,10 +879,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS1() == fd2->IndexOfS2()) {
|
||||
jf1 = 1; jf2 = 2;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation.
|
||||
@@ -906,10 +915,13 @@ Standard_Boolean ChFi3d_IsInFront(TopOpeBRepDS_DataStructure& DStr,
|
||||
if(fd1->IndexOfS2() == fd2->IndexOfS2()) {
|
||||
jf1 = 2; jf2 = 2;
|
||||
face = TopoDS::Face(DStr.Shape(fd1->Index(jf1)));
|
||||
if (face.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL face");
|
||||
OrSave1 = cd1->Orientation(jf1);
|
||||
Or = OrFace1 = face.Orientation();
|
||||
OrSave2 = cd2->Orientation(jf2);
|
||||
OrFace2 = DStr.Shape(fd2->Index(jf2)).Orientation();
|
||||
const TopoDS_Shape& shape2 = DStr.Shape(fd2->Index(jf2));
|
||||
if (shape2.IsNull()) throw Standard_NullObject("ChFi3d_IsInFront : Trying to check orientation of NULL shape");
|
||||
OrFace2 = shape2.Orientation();
|
||||
visavis = Standard_True;
|
||||
sameside = ChFi3d::SameSide(Or,OrSave1,OrSave2,OrFace1,OrFace2);
|
||||
// The parameters of the other side are not used for orientation.
|
||||
|
Reference in New Issue
Block a user