mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +03:00
0024964: ThruSections crashes the DRAW.exe
Test case for issue CR24964
This commit is contained in:
@@ -105,7 +105,7 @@
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
static Standard_Real PreciseUpar(const Standard_Real anUpar,
|
static Standard_Real PreciseUpar(const Standard_Real anUpar,
|
||||||
const Handle(Geom_BSplineSurface)& aSurface)
|
const Handle(Geom_BSplineSurface)& aSurface)
|
||||||
{
|
{
|
||||||
Standard_Real Tol = Precision::PConfusion();
|
Standard_Real Tol = Precision::PConfusion();
|
||||||
Standard_Integer i1, i2;
|
Standard_Integer i1, i2;
|
||||||
@@ -126,17 +126,17 @@ static Standard_Real PreciseUpar(const Standard_Real anUpar,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
static Standard_Boolean PerformPlan(const TopoDS_Wire& W,
|
static Standard_Boolean PerformPlan(const TopoDS_Wire& W,
|
||||||
const Standard_Real presPln,
|
const Standard_Real presPln,
|
||||||
TopoDS_Face& theFace)
|
TopoDS_Face& theFace)
|
||||||
{
|
{
|
||||||
Standard_Boolean isDegen = Standard_True;
|
Standard_Boolean isDegen = Standard_True;
|
||||||
TopoDS_Iterator iter(W);
|
TopoDS_Iterator iter(W);
|
||||||
for (; iter.More(); iter.Next())
|
for (; iter.More(); iter.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(iter.Value());
|
const TopoDS_Edge& anEdge = TopoDS::Edge(iter.Value());
|
||||||
if (!BRep_Tool::Degenerated(anEdge))
|
if (!BRep_Tool::Degenerated(anEdge))
|
||||||
isDegen = Standard_False;
|
isDegen = Standard_False;
|
||||||
}
|
}
|
||||||
if (isDegen)
|
if (isDegen)
|
||||||
return Standard_True;
|
return Standard_True;
|
||||||
|
|
||||||
@@ -144,22 +144,22 @@ static Standard_Boolean PerformPlan(const TopoDS_Wire& W,
|
|||||||
if (!W.IsNull()) {
|
if (!W.IsNull()) {
|
||||||
BRepBuilderAPI_FindPlane Searcher( W, presPln );
|
BRepBuilderAPI_FindPlane Searcher( W, presPln );
|
||||||
if (Searcher.Found())
|
if (Searcher.Found())
|
||||||
{
|
{
|
||||||
theFace = BRepBuilderAPI_MakeFace(Searcher.Plane(), W);
|
theFace = BRepBuilderAPI_MakeFace(Searcher.Plane(), W);
|
||||||
Ok = Standard_True;
|
Ok = Standard_True;
|
||||||
}
|
}
|
||||||
else // try to find another surface
|
else // try to find another surface
|
||||||
|
{
|
||||||
|
BRepBuilderAPI_MakeFace MF( W );
|
||||||
|
if (MF.IsDone())
|
||||||
{
|
{
|
||||||
BRepBuilderAPI_MakeFace MF( W );
|
theFace = MF.Face();
|
||||||
if (MF.IsDone())
|
Ok = Standard_True;
|
||||||
{
|
|
||||||
theFace = MF.Face();
|
|
||||||
Ok = Standard_True;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@@ -168,7 +168,7 @@ static Standard_Boolean PerformPlan(const TopoDS_Wire& W,
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
|
||||||
static Standard_Boolean IsSameOriented(const TopoDS_Shape& aFace,
|
static Standard_Boolean IsSameOriented(const TopoDS_Shape& aFace,
|
||||||
const TopoDS_Shape& aShell)
|
const TopoDS_Shape& aShell)
|
||||||
{
|
{
|
||||||
TopExp_Explorer Explo(aFace, TopAbs_EDGE);
|
TopExp_Explorer Explo(aFace, TopAbs_EDGE);
|
||||||
TopoDS_Shape anEdge = Explo.Current();
|
TopoDS_Shape anEdge = Explo.Current();
|
||||||
@@ -180,11 +180,11 @@ static Standard_Boolean IsSameOriented(const TopoDS_Shape& aFace,
|
|||||||
const TopoDS_Shape& AdjacentFace = EFmap.FindFromKey(anEdge).First();
|
const TopoDS_Shape& AdjacentFace = EFmap.FindFromKey(anEdge).First();
|
||||||
TopoDS_Shape theEdge;
|
TopoDS_Shape theEdge;
|
||||||
for (Explo.Init(AdjacentFace, TopAbs_EDGE); Explo.More(); Explo.Next())
|
for (Explo.Init(AdjacentFace, TopAbs_EDGE); Explo.More(); Explo.Next())
|
||||||
{
|
{
|
||||||
theEdge = Explo.Current();
|
theEdge = Explo.Current();
|
||||||
if (theEdge.IsSame(anEdge))
|
if (theEdge.IsSame(anEdge))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TopAbs_Orientation Or2 = theEdge.Orientation();
|
TopAbs_Orientation Or2 = theEdge.Orientation();
|
||||||
if (Or1 == Or2)
|
if (Or1 == Or2)
|
||||||
@@ -198,8 +198,8 @@ static Standard_Boolean IsSameOriented(const TopoDS_Shape& aFace,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, const TopoDS_Wire& wire1,
|
static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, const TopoDS_Wire& wire1,
|
||||||
const TopoDS_Wire& wire2, const Standard_Real presPln,
|
const TopoDS_Wire& wire2, const Standard_Real presPln,
|
||||||
TopoDS_Face& face1, TopoDS_Face& face2)
|
TopoDS_Face& face1, TopoDS_Face& face2)
|
||||||
{
|
{
|
||||||
if (shell.IsNull())
|
if (shell.IsNull())
|
||||||
StdFail_NotDone::Raise("Thrusections is not build");
|
StdFail_NotDone::Raise("Thrusections is not build");
|
||||||
@@ -207,31 +207,31 @@ static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, const TopoDS_Wire& wire1,
|
|||||||
BRep_Builder BB;
|
BRep_Builder BB;
|
||||||
|
|
||||||
if (!B)
|
if (!B)
|
||||||
{
|
{
|
||||||
// It is necessary to close the extremities
|
// It is necessary to close the extremities
|
||||||
B = PerformPlan(wire1, presPln, face1);
|
B = PerformPlan(wire1, presPln, face1);
|
||||||
|
if (B) {
|
||||||
|
B = PerformPlan(wire2, presPln, face2);
|
||||||
if (B) {
|
if (B) {
|
||||||
B = PerformPlan(wire2, presPln, face2);
|
if (!face1.IsNull() && !IsSameOriented( face1, shell ))
|
||||||
if (B) {
|
face1.Reverse();
|
||||||
if (!face1.IsNull() && !IsSameOriented( face1, shell ))
|
if (!face2.IsNull() && !IsSameOriented( face2, shell ))
|
||||||
face1.Reverse();
|
face2.Reverse();
|
||||||
if (!face2.IsNull() && !IsSameOriented( face2, shell ))
|
|
||||||
face2.Reverse();
|
if (!face1.IsNull())
|
||||||
|
BB.Add(shell, face1);
|
||||||
if (!face1.IsNull())
|
if (!face2.IsNull())
|
||||||
BB.Add(shell, face1);
|
BB.Add(shell, face2);
|
||||||
if (!face2.IsNull())
|
|
||||||
BB.Add(shell, face2);
|
shell.Closed(Standard_True);
|
||||||
|
|
||||||
shell.Closed(Standard_True);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TopoDS_Solid solid;
|
TopoDS_Solid solid;
|
||||||
BB.MakeSolid(solid);
|
BB.MakeSolid(solid);
|
||||||
BB.Add(solid, shell);
|
BB.Add(solid, shell);
|
||||||
|
|
||||||
// verify the orientation the solid
|
// verify the orientation the solid
|
||||||
BRepClass3d_SolidClassifier clas3d(solid);
|
BRepClass3d_SolidClassifier clas3d(solid);
|
||||||
clas3d.PerformInfinitePoint(Precision::Confusion());
|
clas3d.PerformInfinitePoint(Precision::Confusion());
|
||||||
@@ -239,7 +239,7 @@ static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, const TopoDS_Wire& wire1,
|
|||||||
BB.MakeSolid(solid);
|
BB.MakeSolid(solid);
|
||||||
TopoDS_Shape aLocalShape = shell.Reversed();
|
TopoDS_Shape aLocalShape = shell.Reversed();
|
||||||
BB.Add(solid, TopoDS::Shell(aLocalShape));
|
BB.Add(solid, TopoDS::Shell(aLocalShape));
|
||||||
// B.Add(solid, TopoDS::Shell(newShell.Reversed()));
|
// B.Add(solid, TopoDS::Shell(newShell.Reversed()));
|
||||||
}
|
}
|
||||||
|
|
||||||
solid.Closed(Standard_True);
|
solid.Closed(Standard_True);
|
||||||
@@ -253,11 +253,11 @@ static TopoDS_Solid MakeSolid(TopoDS_Shell& shell, const TopoDS_Wire& wire1,
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
BRepOffsetAPI_ThruSections::BRepOffsetAPI_ThruSections(const Standard_Boolean isSolid, const Standard_Boolean ruled,
|
BRepOffsetAPI_ThruSections::BRepOffsetAPI_ThruSections(const Standard_Boolean isSolid, const Standard_Boolean ruled,
|
||||||
const Standard_Real pres3d):
|
const Standard_Real pres3d):
|
||||||
myIsSolid(isSolid), myIsRuled(ruled), myPres3d(pres3d)
|
myIsSolid(isSolid), myIsRuled(ruled), myPres3d(pres3d)
|
||||||
{
|
{
|
||||||
myWCheck = Standard_True;
|
myWCheck = Standard_True;
|
||||||
//----------------------------
|
//----------------------------
|
||||||
myParamType = Approx_ChordLength;
|
myParamType = Approx_ChordLength;
|
||||||
myDegMax = 8;
|
myDegMax = 8;
|
||||||
myContinuity = GeomAbs_C2;
|
myContinuity = GeomAbs_C2;
|
||||||
@@ -274,13 +274,13 @@ BRepOffsetAPI_ThruSections::BRepOffsetAPI_ThruSections(const Standard_Boolean is
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
void BRepOffsetAPI_ThruSections::Init(const Standard_Boolean isSolid, const Standard_Boolean ruled,
|
void BRepOffsetAPI_ThruSections::Init(const Standard_Boolean isSolid, const Standard_Boolean ruled,
|
||||||
const Standard_Real pres3d)
|
const Standard_Real pres3d)
|
||||||
{
|
{
|
||||||
myIsSolid = isSolid;
|
myIsSolid = isSolid;
|
||||||
myIsRuled = ruled;
|
myIsRuled = ruled;
|
||||||
myPres3d = pres3d;
|
myPres3d = pres3d;
|
||||||
myWCheck = Standard_True;
|
myWCheck = Standard_True;
|
||||||
//----------------------------
|
//----------------------------
|
||||||
myParamType = Approx_ChordLength;
|
myParamType = Approx_ChordLength;
|
||||||
myDegMax = 6;
|
myDegMax = 6;
|
||||||
myContinuity = GeomAbs_C2;
|
myContinuity = GeomAbs_C2;
|
||||||
@@ -348,39 +348,39 @@ void BRepOffsetAPI_ThruSections::Build()
|
|||||||
Standard_Integer i;
|
Standard_Integer i;
|
||||||
TopExp_Explorer explo;
|
TopExp_Explorer explo;
|
||||||
for (i = 2; i <= myWires.Length()-1; i++)
|
for (i = 2; i <= myWires.Length()-1; i++)
|
||||||
|
{
|
||||||
|
Standard_Boolean wdeg = Standard_True;
|
||||||
|
for (explo.Init(myWires(i), TopAbs_EDGE); explo.More(); explo.Next())
|
||||||
{
|
{
|
||||||
Standard_Boolean wdeg = Standard_True;
|
const TopoDS_Edge& anEdge = TopoDS::Edge(explo.Current());
|
||||||
for (explo.Init(myWires(i), TopAbs_EDGE); explo.More(); explo.Next())
|
wdeg = wdeg && (BRep_Tool::Degenerated(anEdge));
|
||||||
{
|
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(explo.Current());
|
|
||||||
wdeg = wdeg && (BRep_Tool::Degenerated(anEdge));
|
|
||||||
}
|
|
||||||
if (wdeg)
|
|
||||||
Standard_Failure::Raise("Wrong usage of punctual sections");
|
|
||||||
}
|
}
|
||||||
|
if (wdeg)
|
||||||
|
Standard_Failure::Raise("Wrong usage of punctual sections");
|
||||||
|
}
|
||||||
if (myWires.Length() <= 2)
|
if (myWires.Length() <= 2)
|
||||||
{
|
{
|
||||||
Standard_Boolean wdeg = Standard_True;
|
Standard_Boolean wdeg = Standard_True;
|
||||||
for (i = 1; i <= myWires.Length(); i++)
|
for (i = 1; i <= myWires.Length(); i++)
|
||||||
for (explo.Init(myWires(i), TopAbs_EDGE); explo.More(); explo.Next())
|
for (explo.Init(myWires(i), TopAbs_EDGE); explo.More(); explo.Next())
|
||||||
{
|
{
|
||||||
const TopoDS_Edge& anEdge = TopoDS::Edge(explo.Current());
|
const TopoDS_Edge& anEdge = TopoDS::Edge(explo.Current());
|
||||||
wdeg = wdeg && (BRep_Tool::Degenerated(anEdge));
|
wdeg = wdeg && (BRep_Tool::Degenerated(anEdge));
|
||||||
}
|
}
|
||||||
if (wdeg)
|
if (wdeg)
|
||||||
Standard_Failure::Raise("Wrong usage of punctual sections");
|
Standard_Failure::Raise("Wrong usage of punctual sections");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (myWCheck) {
|
if (myWCheck) {
|
||||||
// compute origin and orientation on wires to avoid twisted results
|
// compute origin and orientation on wires to avoid twisted results
|
||||||
// and update wires to have same number of edges
|
// and update wires to have same number of edges
|
||||||
|
|
||||||
// use BRepFill_CompatibleWires
|
// use BRepFill_CompatibleWires
|
||||||
TopTools_SequenceOfShape WorkingSections;
|
TopTools_SequenceOfShape WorkingSections;
|
||||||
WorkingSections.Clear();
|
WorkingSections.Clear();
|
||||||
TopTools_DataMapOfShapeListOfShape WorkingMap;
|
TopTools_DataMapOfShapeListOfShape WorkingMap;
|
||||||
WorkingMap.Clear();
|
WorkingMap.Clear();
|
||||||
|
|
||||||
// Calculate the working sections
|
// Calculate the working sections
|
||||||
BRepFill_CompatibleWires Georges(myWires);
|
BRepFill_CompatibleWires Georges(myWires);
|
||||||
Georges.Perform();
|
Georges.Perform();
|
||||||
@@ -402,7 +402,7 @@ void BRepOffsetAPI_ThruSections::Build()
|
|||||||
}
|
}
|
||||||
// Encode the Regularities
|
// Encode the Regularities
|
||||||
BRepLib::EncodeRegularity(myShape);
|
BRepLib::EncodeRegularity(myShape);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -415,7 +415,7 @@ void BRepOffsetAPI_ThruSections::CreateRuled()
|
|||||||
{
|
{
|
||||||
Standard_Integer nbSects = myWires.Length();
|
Standard_Integer nbSects = myWires.Length();
|
||||||
BRepFill_Generator aGene;
|
BRepFill_Generator aGene;
|
||||||
// for (Standard_Integer i=1; i<=nbSects; i++) {
|
// for (Standard_Integer i=1; i<=nbSects; i++) {
|
||||||
Standard_Integer i;
|
Standard_Integer i;
|
||||||
for (i=1; i<=nbSects; i++) {
|
for (i=1; i<=nbSects; i++) {
|
||||||
aGene.AddWire(TopoDS::Wire(myWires(i)));
|
aGene.AddWire(TopoDS::Wire(myWires(i)));
|
||||||
@@ -434,15 +434,15 @@ void BRepOffsetAPI_ThruSections::CreateRuled()
|
|||||||
BRep_Builder B;
|
BRep_Builder B;
|
||||||
B.MakeSolid(solid);
|
B.MakeSolid(solid);
|
||||||
B.Add(solid, shell);
|
B.Add(solid, shell);
|
||||||
|
|
||||||
// verify the orientation of the solid
|
// verify the orientation of the solid
|
||||||
BRepClass3d_SolidClassifier clas3d(solid);
|
BRepClass3d_SolidClassifier clas3d(solid);
|
||||||
clas3d.PerformInfinitePoint(Precision::Confusion());
|
clas3d.PerformInfinitePoint(Precision::Confusion());
|
||||||
if (clas3d.State() == TopAbs_IN) {
|
if (clas3d.State() == TopAbs_IN) {
|
||||||
B.MakeSolid(solid);
|
B.MakeSolid(solid);
|
||||||
TopoDS_Shape aLocalShape = shell.Reversed();
|
TopoDS_Shape aLocalShape = shell.Reversed();
|
||||||
B.Add(solid, TopoDS::Shell(aLocalShape));
|
B.Add(solid, TopoDS::Shell(aLocalShape));
|
||||||
// B.Add(solid, TopoDS::Shell(shell.Reversed()));
|
// B.Add(solid, TopoDS::Shell(shell.Reversed()));
|
||||||
}
|
}
|
||||||
myShape = solid;
|
myShape = solid;
|
||||||
|
|
||||||
@@ -472,12 +472,12 @@ void BRepOffsetAPI_ThruSections::CreateRuled()
|
|||||||
|
|
||||||
TopTools_IndexedDataMapOfShapeListOfShape MV;
|
TopTools_IndexedDataMapOfShapeListOfShape MV;
|
||||||
TopExp::MapShapesAndAncestors(shell, TopAbs_VERTEX, TopAbs_FACE, MV);
|
TopExp::MapShapesAndAncestors(shell, TopAbs_VERTEX, TopAbs_FACE, MV);
|
||||||
|
|
||||||
for (i=1; i<=nbSects-1; i++) {
|
for (i=1; i<=nbSects-1; i++) {
|
||||||
|
|
||||||
const TopoDS_Wire& wire1 = TopoDS::Wire(myWires(i));
|
const TopoDS_Wire& wire1 = TopoDS::Wire(myWires(i));
|
||||||
const TopoDS_Wire& wire2 = TopoDS::Wire(myWires(i+1));
|
const TopoDS_Wire& wire2 = TopoDS::Wire(myWires(i+1));
|
||||||
|
|
||||||
anExp1.Init(wire1);
|
anExp1.Init(wire1);
|
||||||
anExp2.Init(wire2);
|
anExp2.Init(wire2);
|
||||||
|
|
||||||
@@ -489,51 +489,51 @@ void BRepOffsetAPI_ThruSections::CreateRuled()
|
|||||||
const TopoDS_Shape& edge2 = anExp2.Current();
|
const TopoDS_Shape& edge2 = anExp2.Current();
|
||||||
Standard_Boolean degen1 = BRep_Tool::Degenerated(anExp1.Current());
|
Standard_Boolean degen1 = BRep_Tool::Degenerated(anExp1.Current());
|
||||||
Standard_Boolean degen2 = BRep_Tool::Degenerated(anExp2.Current());
|
Standard_Boolean degen2 = BRep_Tool::Degenerated(anExp2.Current());
|
||||||
|
|
||||||
TopTools_MapOfShape MapFaces;
|
TopTools_MapOfShape MapFaces;
|
||||||
if (degen2){
|
if (degen2){
|
||||||
TopoDS_Vertex Vdegen = TopExp::FirstVertex(TopoDS::Edge(edge2));
|
TopoDS_Vertex Vdegen = TopExp::FirstVertex(TopoDS::Edge(edge2));
|
||||||
for (it.Initialize(MV.FindFromKey(Vdegen)); it.More(); it.Next()) {
|
for (it.Initialize(MV.FindFromKey(Vdegen)); it.More(); it.Next()) {
|
||||||
MapFaces.Add(it.Value());
|
MapFaces.Add(it.Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (it.Initialize(M.FindFromKey(edge2)); it.More(); it.Next()) {
|
for (it.Initialize(M.FindFromKey(edge2)); it.More(); it.Next()) {
|
||||||
MapFaces.Add(it.Value());
|
MapFaces.Add(it.Value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (degen1) {
|
if (degen1) {
|
||||||
TopoDS_Vertex Vdegen = TopExp::FirstVertex(TopoDS::Edge(edge1));
|
TopoDS_Vertex Vdegen = TopExp::FirstVertex(TopoDS::Edge(edge1));
|
||||||
for (it.Initialize(MV.FindFromKey(Vdegen)); it.More(); it.Next()) {
|
for (it.Initialize(MV.FindFromKey(Vdegen)); it.More(); it.Next()) {
|
||||||
const TopoDS_Shape& Face = it.Value();
|
const TopoDS_Shape& Face = it.Value();
|
||||||
if (MapFaces.Contains(Face)) {
|
if (MapFaces.Contains(Face)) {
|
||||||
myGenerated.Bind(edge1, Face);
|
myGenerated.Bind(edge1, Face);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (it.Initialize(M.FindFromKey(edge1)); it.More(); it.Next()) {
|
for (it.Initialize(M.FindFromKey(edge1)); it.More(); it.Next()) {
|
||||||
const TopoDS_Shape& Face = it.Value();
|
const TopoDS_Shape& Face = it.Value();
|
||||||
if (MapFaces.Contains(Face)) {
|
if (MapFaces.Contains(Face)) {
|
||||||
myGenerated.Bind(edge1, Face);
|
myGenerated.Bind(edge1, Face);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!degen1) anExp1.Next();
|
if (!degen1) anExp1.Next();
|
||||||
if (!degen2) anExp2.Next();
|
if (!degen2) anExp2.Next();
|
||||||
|
|
||||||
tantque = anExp1.More() && anExp2.More();
|
tantque = anExp1.More() && anExp2.More();
|
||||||
if (degen1) tantque = anExp2.More();
|
if (degen1) tantque = anExp2.More();
|
||||||
if (degen2) tantque = anExp1.More();
|
if (degen2) tantque = anExp1.More();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
@@ -593,15 +593,15 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
// if the wire is punctual
|
// if the wire is punctual
|
||||||
anExp.Init(TopoDS::Wire(wire));
|
anExp.Init(TopoDS::Wire(wire));
|
||||||
for(j=1; j<=nbEdges; j++) {
|
for(j=1; j<=nbEdges; j++) {
|
||||||
nb++;
|
nb++;
|
||||||
shapes(nb) = anExp.Current();
|
shapes(nb) = anExp.Current();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// otherwise
|
// otherwise
|
||||||
for(anExp.Init(TopoDS::Wire(wire)); anExp.More(); anExp.Next()) {
|
for(anExp.Init(TopoDS::Wire(wire)); anExp.More(); anExp.Next()) {
|
||||||
nb++;
|
nb++;
|
||||||
shapes(nb) = anExp.Current();
|
shapes(nb) = anExp.Current();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -667,17 +667,17 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
|
|
||||||
// make the wire
|
// make the wire
|
||||||
B.MakeWire(W);
|
B.MakeWire(W);
|
||||||
|
|
||||||
// make the missing edges
|
// make the missing edges
|
||||||
Standard_Real f1, f2, l1, l2;
|
Standard_Real f1, f2, l1, l2;
|
||||||
surface->Bounds(f1,l1,f2,l2);
|
surface->Bounds(f1,l1,f2,l2);
|
||||||
|
|
||||||
// --- edge 1
|
// --- edge 1
|
||||||
if ( w1Point ) {
|
if ( w1Point ) {
|
||||||
// copy the degenerated edge
|
// copy the degenerated edge
|
||||||
TopoDS_Shape aLocalShape = shapes(1).EmptyCopied();
|
TopoDS_Shape aLocalShape = shapes(1).EmptyCopied();
|
||||||
edge1 = TopoDS::Edge(aLocalShape);
|
edge1 = TopoDS::Edge(aLocalShape);
|
||||||
// edge1 = TopoDS::Edge(shapes(1).EmptyCopied());
|
// edge1 = TopoDS::Edge(shapes(1).EmptyCopied());
|
||||||
edge1.Orientation(TopAbs_FORWARD);
|
edge1.Orientation(TopAbs_FORWARD);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -692,21 +692,21 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
// store edges of the 1st section
|
// store edges of the 1st section
|
||||||
if (vClosed)
|
if (vClosed)
|
||||||
vcouture(i) = edge1;
|
vcouture(i) = edge1;
|
||||||
|
|
||||||
|
|
||||||
// --- edge 2
|
// --- edge 2
|
||||||
if (vClosed)
|
if (vClosed)
|
||||||
edge2 = TopoDS::Edge(vcouture(i));
|
edge2 = TopoDS::Edge(vcouture(i));
|
||||||
else {
|
else {
|
||||||
if ( w2Point ) {
|
if ( w2Point ) {
|
||||||
// copy of the degenerated edge
|
// copy of the degenerated edge
|
||||||
TopoDS_Shape aLocalShape = shapes(nbSects*nbEdges).EmptyCopied();
|
TopoDS_Shape aLocalShape = shapes(nbSects*nbEdges).EmptyCopied();
|
||||||
edge2 = TopoDS::Edge(aLocalShape);
|
edge2 = TopoDS::Edge(aLocalShape);
|
||||||
// edge2 = TopoDS::Edge(shapes(nbSects*nbEdges).EmptyCopied());
|
// edge2 = TopoDS::Edge(shapes(nbSects*nbEdges).EmptyCopied());
|
||||||
edge2.Orientation(TopAbs_FORWARD);
|
edge2.Orientation(TopAbs_FORWARD);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
B.MakeEdge(edge2, surface->VIso(l2), Precision::Confusion());
|
B.MakeEdge(edge2, surface->VIso(l2), Precision::Confusion());
|
||||||
}
|
}
|
||||||
v2f.Orientation(TopAbs_FORWARD);
|
v2f.Orientation(TopAbs_FORWARD);
|
||||||
B.Add(edge2, v2f);
|
B.Add(edge2, v2f);
|
||||||
@@ -726,7 +726,7 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
B.Add(edge3, v2f);
|
B.Add(edge3, v2f);
|
||||||
B.Range(edge3, f2, l2);
|
B.Range(edge3, f2, l2);
|
||||||
if (uClosed) {
|
if (uClosed) {
|
||||||
couture = edge3;
|
couture = edge3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -755,34 +755,34 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
// set PCurve
|
// set PCurve
|
||||||
if (vClosed) {
|
if (vClosed) {
|
||||||
B.UpdateEdge(edge1,
|
B.UpdateEdge(edge1,
|
||||||
new Geom2d_Line(gp_Pnt2d(0,f2),gp_Dir2d(1,0)),
|
new Geom2d_Line(gp_Pnt2d(0,f2),gp_Dir2d(1,0)),
|
||||||
new Geom2d_Line(gp_Pnt2d(0,l2),gp_Dir2d(1,0)),face,
|
new Geom2d_Line(gp_Pnt2d(0,l2),gp_Dir2d(1,0)),face,
|
||||||
Precision::Confusion());
|
Precision::Confusion());
|
||||||
B.Range(edge1,face,f1,l1);
|
B.Range(edge1,face,f1,l1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
B.UpdateEdge(edge1,new Geom2d_Line(gp_Pnt2d(0,f2),gp_Dir2d(1,0)),face,
|
B.UpdateEdge(edge1,new Geom2d_Line(gp_Pnt2d(0,f2),gp_Dir2d(1,0)),face,
|
||||||
Precision::Confusion());
|
Precision::Confusion());
|
||||||
B.Range(edge1,face,f1,l1);
|
B.Range(edge1,face,f1,l1);
|
||||||
B.UpdateEdge(edge2,new Geom2d_Line(gp_Pnt2d(0,l2),gp_Dir2d(1,0)),face,
|
B.UpdateEdge(edge2,new Geom2d_Line(gp_Pnt2d(0,l2),gp_Dir2d(1,0)),face,
|
||||||
Precision::Confusion());
|
Precision::Confusion());
|
||||||
B.Range(edge2,face,f1,l1);
|
B.Range(edge2,face,f1,l1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( uClosed && nbEdges ==1 ) {
|
if ( uClosed && nbEdges ==1 ) {
|
||||||
B.UpdateEdge(edge3,
|
B.UpdateEdge(edge3,
|
||||||
new Geom2d_Line(gp_Pnt2d(l1,0),gp_Dir2d(0,1)),
|
new Geom2d_Line(gp_Pnt2d(l1,0),gp_Dir2d(0,1)),
|
||||||
new Geom2d_Line(gp_Pnt2d(f1,0),gp_Dir2d(0,1)),face,
|
new Geom2d_Line(gp_Pnt2d(f1,0),gp_Dir2d(0,1)),face,
|
||||||
Precision::Confusion());
|
Precision::Confusion());
|
||||||
B.Range(edge3,face,f2,l2);
|
B.Range(edge3,face,f2,l2);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
B.UpdateEdge(edge3,new Geom2d_Line(gp_Pnt2d(f1,0),gp_Dir2d(0,1)),face,
|
B.UpdateEdge(edge3,new Geom2d_Line(gp_Pnt2d(f1,0),gp_Dir2d(0,1)),face,
|
||||||
Precision::Confusion());
|
Precision::Confusion());
|
||||||
B.Range(edge3,face,f2,l2);
|
B.Range(edge3,face,f2,l2);
|
||||||
B.UpdateEdge(edge4,new Geom2d_Line(gp_Pnt2d(l1,0),gp_Dir2d(0,1)),face,
|
B.UpdateEdge(edge4,new Geom2d_Line(gp_Pnt2d(l1,0),gp_Dir2d(0,1)),face,
|
||||||
Precision::Confusion());
|
Precision::Confusion());
|
||||||
B.Range(edge4,face,f2,l2);
|
B.Range(edge4,face,f2,l2);
|
||||||
}
|
}
|
||||||
B.Add(face,W);
|
B.Add(face,W);
|
||||||
@@ -811,15 +811,15 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
BRep_Builder B;
|
BRep_Builder B;
|
||||||
B.MakeSolid(solid);
|
B.MakeSolid(solid);
|
||||||
B.Add(solid, shell);
|
B.Add(solid, shell);
|
||||||
|
|
||||||
// verify the orientation the solid
|
// verify the orientation the solid
|
||||||
BRepClass3d_SolidClassifier clas3d(solid);
|
BRepClass3d_SolidClassifier clas3d(solid);
|
||||||
clas3d.PerformInfinitePoint(Precision::Confusion());
|
clas3d.PerformInfinitePoint(Precision::Confusion());
|
||||||
if (clas3d.State() == TopAbs_IN) {
|
if (clas3d.State() == TopAbs_IN) {
|
||||||
B.MakeSolid(solid);
|
B.MakeSolid(solid);
|
||||||
TopoDS_Shape aLocalShape = shell.Reversed();
|
TopoDS_Shape aLocalShape = shell.Reversed();
|
||||||
B.Add(solid, TopoDS::Shell(aLocalShape));
|
B.Add(solid, TopoDS::Shell(aLocalShape));
|
||||||
// B.Add(solid, TopoDS::Shell(shell.Reversed()));
|
// B.Add(solid, TopoDS::Shell(shell.Reversed()));
|
||||||
}
|
}
|
||||||
myShape = solid;
|
myShape = solid;
|
||||||
|
|
||||||
@@ -836,7 +836,7 @@ void BRepOffsetAPI_ThruSections::CreateSmoothed()
|
|||||||
myShape = shell;
|
myShape = shell;
|
||||||
Done();
|
Done();
|
||||||
}
|
}
|
||||||
|
|
||||||
TopExp_Explorer ex(myShape,TopAbs_EDGE);
|
TopExp_Explorer ex(myShape,TopAbs_EDGE);
|
||||||
while (ex.More()) {
|
while (ex.More()) {
|
||||||
const TopoDS_Edge& CurE = TopoDS::Edge(ex.Current());
|
const TopoDS_Edge& CurE = TopoDS::Edge(ex.Current());
|
||||||
@@ -924,15 +924,14 @@ static Handle(Geom_BSplineCurve) EdgeToBSpline (const TopoDS_Edge& theEdge)
|
|||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
|
||||||
Handle(Geom_BSplineSurface) BRepOffsetAPI_ThruSections::
|
Handle(Geom_BSplineSurface) BRepOffsetAPI_ThruSections::
|
||||||
TotalSurf(const TopTools_Array1OfShape& shapes,
|
TotalSurf(const TopTools_Array1OfShape& shapes,
|
||||||
const Standard_Integer NbSects,
|
const Standard_Integer NbSects,
|
||||||
const Standard_Integer NbEdges,
|
const Standard_Integer NbEdges,
|
||||||
const Standard_Boolean w1Point,
|
const Standard_Boolean w1Point,
|
||||||
const Standard_Boolean w2Point,
|
const Standard_Boolean w2Point,
|
||||||
const Standard_Boolean vClosed) const
|
const Standard_Boolean vClosed) const
|
||||||
{
|
{
|
||||||
Standard_Integer i,j,jdeb=1,jfin=NbSects;
|
Standard_Integer i,j,jdeb=1,jfin=NbSects;
|
||||||
TopoDS_Edge edge;
|
|
||||||
TopoDS_Vertex vf,vl;
|
TopoDS_Vertex vf,vl;
|
||||||
|
|
||||||
GeomFill_SectionGenerator section;
|
GeomFill_SectionGenerator section;
|
||||||
@@ -943,7 +942,7 @@ Handle(Geom_BSplineSurface) BRepOffsetAPI_ThruSections::
|
|||||||
|
|
||||||
if (w1Point) {
|
if (w1Point) {
|
||||||
jdeb++;
|
jdeb++;
|
||||||
edge = TopoDS::Edge(shapes(1));
|
TopoDS_Edge edge = TopoDS::Edge(shapes(1));
|
||||||
TopExp::Vertices(edge,vl,vf);
|
TopExp::Vertices(edge,vl,vf);
|
||||||
TColgp_Array1OfPnt Extremities(1,2);
|
TColgp_Array1OfPnt Extremities(1,2);
|
||||||
Extremities(1) = BRep_Tool::Pnt(vf);
|
Extremities(1) = BRep_Tool::Pnt(vf);
|
||||||
@@ -979,12 +978,17 @@ Handle(Geom_BSplineSurface) BRepOffsetAPI_ThruSections::
|
|||||||
GeomConvert_CompCurveToBSplineCurve CompBS(curvBS);
|
GeomConvert_CompCurveToBSplineCurve CompBS(curvBS);
|
||||||
|
|
||||||
for (i=2; i<=NbEdges; i++) {
|
for (i=2; i<=NbEdges; i++) {
|
||||||
// read the edge
|
// read the edge
|
||||||
TopoDS_Edge aNextEdge = TopoDS::Edge (shapes((j-1)*NbEdges+i));
|
TopoDS_Edge aNextEdge = TopoDS::Edge (shapes((j-1)*NbEdges+i));
|
||||||
|
Standard_Real aTolV = Precision::Confusion();
|
||||||
|
TopExp::Vertices(aNextEdge,vf,vl);
|
||||||
|
aTolV = Max(aTolV, BRep_Tool::Tolerance(vf));
|
||||||
|
aTolV = Max(aTolV, BRep_Tool::Tolerance(vl));
|
||||||
|
aTolV = Min(aTolV, 1.e-3);
|
||||||
curvBS = EdgeToBSpline (aNextEdge);
|
curvBS = EdgeToBSpline (aNextEdge);
|
||||||
|
|
||||||
// concatenation
|
// concatenation
|
||||||
CompBS.Add(curvBS, Precision::Confusion(), Standard_True, Standard_False, 1);
|
CompBS.Add(curvBS, aTolV, Standard_True, Standard_False, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the final section
|
// return the final section
|
||||||
@@ -993,14 +997,14 @@ Handle(Geom_BSplineSurface) BRepOffsetAPI_ThruSections::
|
|||||||
|
|
||||||
// case of looping sections
|
// case of looping sections
|
||||||
if (j==jdeb && vClosed) {
|
if (j==jdeb && vClosed) {
|
||||||
BS1 = BS;
|
BS1 = BS;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w2Point) {
|
if (w2Point) {
|
||||||
edge = TopoDS::Edge(shapes(NbSects*NbEdges));
|
TopoDS_Edge edge = TopoDS::Edge(shapes(NbSects*NbEdges));
|
||||||
TopExp::Vertices(edge,vl,vf);
|
TopExp::Vertices(edge,vl,vf);
|
||||||
TColgp_Array1OfPnt Extremities(1,2);
|
TColgp_Array1OfPnt Extremities(1,2);
|
||||||
Extremities(1) = BRep_Tool::Pnt(vf);
|
Extremities(1) = BRep_Tool::Pnt(vf);
|
||||||
@@ -1040,13 +1044,13 @@ Handle(Geom_BSplineSurface) BRepOffsetAPI_ThruSections::
|
|||||||
if(anApprox.IsDone()) {
|
if(anApprox.IsDone()) {
|
||||||
surface =
|
surface =
|
||||||
new Geom_BSplineSurface(anApprox.SurfPoles(), anApprox.SurfWeights(),
|
new Geom_BSplineSurface(anApprox.SurfPoles(), anApprox.SurfWeights(),
|
||||||
anApprox.SurfUKnots(), anApprox.SurfVKnots(),
|
anApprox.SurfUKnots(), anApprox.SurfVKnots(),
|
||||||
anApprox.SurfUMults(), anApprox.SurfVMults(),
|
anApprox.SurfUMults(), anApprox.SurfVMults(),
|
||||||
anApprox.UDegree(), anApprox.VDegree());
|
anApprox.UDegree(), anApprox.VDegree());
|
||||||
}
|
}
|
||||||
|
|
||||||
return surface;
|
return surface;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
//=======================================================================
|
||||||
|
27
tests/bugs/modalg_5/bug24964
Normal file
27
tests/bugs/modalg_5/bug24964
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
puts "============"
|
||||||
|
puts "OCC24964"
|
||||||
|
puts "============"
|
||||||
|
puts ""
|
||||||
|
#########################################################################
|
||||||
|
# ThruSections crashes the DRAW.exe
|
||||||
|
#########################################################################
|
||||||
|
|
||||||
|
restore [locate_data_file bug24964_w1.brep] w1
|
||||||
|
restore [locate_data_file bug24964_w2.brep] w2
|
||||||
|
restore [locate_data_file bug24964_w3.brep] w3
|
||||||
|
|
||||||
|
thrusections result 0 0 w1 w2 w3
|
||||||
|
|
||||||
|
set square 163127
|
||||||
|
|
||||||
|
set nb_v_good 30
|
||||||
|
set nb_e_good 45
|
||||||
|
set nb_w_good 15
|
||||||
|
set nb_f_good 15
|
||||||
|
set nb_sh_good 1
|
||||||
|
set nb_sol_good 0
|
||||||
|
set nb_compsol_good 0
|
||||||
|
set nb_compound_good 0
|
||||||
|
set nb_shape_good 106
|
||||||
|
|
||||||
|
set 2dviewer 1
|
Reference in New Issue
Block a user