1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Compare commits

..

4 Commits

Author SHA1 Message Date
akondrat
96d4000f3b 0024909: Modeling Algorithms - SIGSEGV in buildsweep
Update algorithm.
2022-08-18 08:27:03 +03:00
akondrat
4b2a0e8e49 0024909: Modeling Algorithms - SIGSEGV in buildsweep
Update algorithm to preventing regression.
2022-08-09 14:39:38 +03:00
akondrat
abd63556da 0024909: Modeling Algorithms - SIGSEGV in buildsweep
Update Extrema_ExtCC::PrepareParallelResult and Extrema_ExtCC::PrepareResults
2022-08-09 14:39:38 +03:00
asuraven
ca97f1702d 0024909: Modeling Algorithms - SIGSEGV in buildsweep
Change NCollection_DataMap NCollection_IndexedDataMap to avoid undefined behavior in BRepFill_CompatibleWires::SameNumberByPolarMethod()

Correction in BRepFill_PipeShell::Prepare()
2022-08-09 14:39:38 +03:00
10 changed files with 136 additions and 66 deletions

View File

@@ -103,7 +103,7 @@ static Standard_Integer mkvolume (Draw_Interpretor&, Standard_Integer, const c
"-na - disables the approximation of the section curves.\n",
__FILE__, bsection, g);
//
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] [-noapprox] "
theCommands.Add("bopcurves", "use bopcurves F1 F2 [-2d/-2d1/-2d2] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]",
__FILE__, bopcurves, g);
theCommands.Add("mkvolume", "make solids from set of shapes.\nmkvolume r b1 b2 ... [-c] [-ni] [-ai]",
@@ -544,7 +544,7 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
const char** a)
{
if (n<3) {
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] [-noapprox] "
di << "Usage: bopcurves F1 F2 [-2d/-2d1/-2d2] "
"[-p u1 v1 u2 v2 (to add start points] [-v (for extended output)]\n";
return 1;
}
@@ -597,9 +597,6 @@ Standard_Integer bopcurves (Draw_Interpretor& di,
else if (!strcasecmp(a[i],"-2d2")) {
aToApproxC2dOnS2 = Standard_True;
}
else if (!strcasecmp(a[i],"-noapprox")) {
aToApproxC3d = Standard_False;
}
else if (!strcasecmp(a[i],"-p")) {
IntSurf_PntOn2S aPt;
const Standard_Real aU1 = Draw::Atof(a[++i]);

View File

@@ -389,13 +389,13 @@ static void TrimEdge (const TopoDS_Edge& CurrentEdge,
static Standard_Boolean SearchRoot (const TopoDS_Vertex& V,
const TopTools_DataMapOfShapeListOfShape& Map,
TopoDS_Vertex& VRoot)
const TopTools_IndexedDataMapOfShapeListOfShape Map,
TopoDS_Vertex& VRoot)
{
Standard_Boolean trouve = Standard_False;
VRoot.Nullify();
TopTools_DataMapIteratorOfDataMapOfShapeListOfShape it;
for (it.Initialize(Map); it.More(); it.Next()) {
TopTools_IndexedDataMapIteratorOfDataMapOfShapeListOfShape it(Map);
for (; it.More(); it.Next()) {
const TopTools_ListOfShape & List = it.Value();
TopTools_ListIteratorOfListOfShape itL;
Standard_Boolean ilyest = Standard_False;
@@ -445,12 +445,12 @@ static Standard_Boolean SearchVertex (const TopTools_ListOfShape& List,
static Standard_Boolean EdgeIntersectOnWire (const gp_Pnt& P1,
const gp_Pnt& P2,
Standard_Real percent,
const TopTools_DataMapOfShapeListOfShape& Map,
const TopoDS_Wire& W,
TopoDS_Vertex& Vsol,
TopoDS_Wire& newW,
const gp_Pnt& P2,
Standard_Real percent,
const TopTools_IndexedDataMapOfShapeListOfShape& Map,
const TopoDS_Wire& W,
TopoDS_Vertex& Vsol,
TopoDS_Wire& newW,
TopTools_DataMapOfShapeSequenceOfShape& theEdgeNewEdges)
{
@@ -976,7 +976,7 @@ void BRepFill_CompatibleWires::
}
// construction of RMap, map of reports of wire i to wire i-1
TopTools_DataMapOfShapeListOfShape RMap;
TopTools_IndexedDataMapOfShapeListOfShape RMap;
RMap.Clear();
// loop on i
@@ -997,7 +997,10 @@ void BRepFill_CompatibleWires::
// init of RMap for Vi
TopTools_ListOfShape Init;
Init.Clear();
RMap.Bind(Vi,Init);
TopTools_ListOfShape* aShapeList = RMap.ChangeSeek(Vi);
if (!aShapeList)
aShapeList = &RMap(RMap.Add(Vi, Init));
aShapeList->Append(Init);
// it is required to find intersection Vi - wire2
gp_Pnt Pi = BRep_Tool::Pnt(Vi);
@@ -1019,14 +1022,14 @@ void BRepFill_CompatibleWires::
RMap,TopoDS::Wire(myWork(i-1)),
Vsol,newwire,EdgeNewEdges);
if (NewVertex) myWork(i-1) = newwire;
RMap(Vi).Append(Vsol);
RMap.ChangeFromKey(Vi).Append(Vsol);
}
} // loop on ii
} // loop on i
// initialisation of MapVLV, map of correspondences vertex - list of vertices
TopTools_DataMapOfShapeListOfShape MapVLV;
TopTools_IndexedDataMapOfShapeListOfShape MapVLV;
SeqOfVertices(TopoDS::Wire(myWork(ideb)),SeqV);
Standard_Integer SizeMap = SeqV.Length();
MapVLV.Clear();
@@ -1035,13 +1038,16 @@ void BRepFill_CompatibleWires::
TopTools_ListOfShape Init;
Init.Clear();
Init.Append(Vi);
MapVLV.Bind(Vi,Init);
TopTools_ListOfShape* aShapeList = MapVLV.ChangeSeek(Vi);
if (!aShapeList)
aShapeList = &MapVLV(MapVLV.Add(Vi, Init));
aShapeList->Append(Init);
Standard_Integer NbV = 1;
TopoDS_Vertex V0,V1;
V0 = Vi;
Standard_Boolean tantque = SearchRoot(V0,RMap,V1);
while (tantque) {
MapVLV(Vi).Append(V1);
MapVLV.ChangeFromKey(Vi).Append(V1);
NbV++;
// test on NbV required for looping sections
if (V1.IsSame(Vi) || NbV >= myWork.Length()) {
@@ -1076,7 +1082,7 @@ void BRepFill_CompatibleWires::
VRoot.Nullify();
Standard_Boolean intersect = Standard_True;
if (SearchRoot(Vi,MapVLV,VRoot)) {
const TopTools_ListOfShape& LVi = MapVLV(VRoot);
const TopTools_ListOfShape& LVi = MapVLV.FindFromKey(VRoot);
TopoDS_Vertex VonW;
VonW.Nullify();
intersect = (!SearchVertex(LVi,wire2,VonW));
@@ -1102,7 +1108,7 @@ void BRepFill_CompatibleWires::
NewVertex = EdgeIntersectOnWire(Pos->Value(i+1),Pnew,percent,
MapVLV,TopoDS::Wire(myWork(i+1)),
Vsol,newwire,EdgeNewEdges);
MapVLV(VRoot).Append(Vsol);
MapVLV.ChangeFromKey(VRoot).Append(Vsol);
if (NewVertex) myWork(i+1) = newwire;
}
@@ -1129,7 +1135,7 @@ void BRepFill_CompatibleWires::
Standard_Real U2 = BRep_Tool::Parameter(VL,ECur);
BRepAdaptor_Curve Curve(ECur);
gp_Pnt PPs = Curve.Value(0.1*(U1+9*U2));
TopTools_ListIteratorOfListOfShape itF(MapVLV(VF)),itL(MapVLV(VL));
TopTools_ListIteratorOfListOfShape itF(MapVLV.FindFromKey(VF)),itL(MapVLV.FindFromKey(VL));
Standard_Integer rang = ideb;
while (rang < i) {
itF.Next();
@@ -1149,7 +1155,24 @@ void BRepFill_CompatibleWires::
// parse candidate edges
Standard_Real scal1,scal2;
if ( (V1.IsSame(VVF)&&V2.IsSame(VVL)) || (V2.IsSame(VVF)&&V1.IsSame(VVL)) ) {
Standard_Boolean isEqual = (V1.IsSame(VVF) && V2.IsSame(VVL)) || (V2.IsSame(VVF) && V1.IsSame(VVL));
if (!isEqual)
{
itF = (MapVLV.FindFromKey(VF));
itL = (MapVLV.FindFromKey(VL));
rang = ideb - 1;
while (rang < i) {
itF.Next();
itL.Next();
rang++;
}
V1 = TopoDS::Vertex(itF.Value()), V2 = TopoDS::Vertex(itL.Value());
isEqual = (V1.IsSame(VVF) && V2.IsSame(VVL)) || (V2.IsSame(VVF) && V1.IsSame(VVL));
}
if (isEqual) {
Standard_Real U1param = BRep_Tool::Parameter(VVF,E);
Standard_Real U2param = BRep_Tool::Parameter(VVL,E);
BRepAdaptor_Curve CurveE(E);

View File

@@ -1024,11 +1024,13 @@ void BRepFill_PipeShell::Generated(const TopoDS_Shape& theShape,
// place the initial section at the final position
Param.Append(V2);
WSeq.Append(WSeq(ideb));
IndSec.Append(WSeq.Length());
}
else if (ifin>0) {
// place the final section at the initial position
Param.Append(V1);
WSeq.Append(WSeq(ifin));
IndSec.Append(WSeq.Length());
}
else {
// it is necessary to find a medium section to impose by V1 and by V2

View File

@@ -837,7 +837,9 @@ void Extrema_ExtCC::PrepareResults(const Extrema_ExtElC& AlgExt,
if (myIsParallel) {
PrepareParallelResult(Ut11, Ut12, Ut21, Ut22, AlgExt.SquareDistance());
}
else {
if(mypoints.IsEmpty())
{
NbExt = AlgExt.NbExt();
for (i = 1; i <= NbExt; i++) {
// Verification de la validite des parametres
@@ -866,6 +868,8 @@ void Extrema_ExtCC::PrepareResults(const Extrema_ExtElC& AlgExt,
(U2 >= Ut21 - RealEpsilon()) &&
(U2 <= Ut22 + RealEpsilon())) {
Val = AlgExt.SquareDistance(i);
if (mypoints.IsEmpty())
mySqDist.Clear();
mySqDist.Append(Val);
if (!theIsInverse)
{
@@ -911,7 +915,7 @@ void Extrema_ExtCC::PrepareResults(const Extrema_ECC& AlgExt,
{
PrepareParallelResult(Ut11, Ut12, Ut21, Ut22, AlgExt.SquareDistance());
}
else
if(mypoints.IsEmpty())
{
NbExt = AlgExt.NbExt();
for (i = 1; i <= NbExt; i++)
@@ -935,6 +939,8 @@ void Extrema_ExtCC::PrepareResults(const Extrema_ECC& AlgExt,
(U2 >= Ut21 - RealEpsilon()) &&
(U2 <= Ut22 + RealEpsilon()))
{
if(mypoints.IsEmpty())
mySqDist.Clear();
Val = AlgExt.SquareDistance(i);
mySqDist.Append(Val);
P1.SetValues(U, P1.Value());

View File

@@ -23,6 +23,7 @@
#include <NCollection_IndexedDataMap.hxx>
typedef NCollection_IndexedDataMap<TopoDS_Shape,TopTools_ListOfShape,TopTools_ShapeMapHasher> TopTools_IndexedDataMapOfShapeListOfShape;
typedef NCollection_IndexedDataMap<TopoDS_Shape, TopTools_ListOfShape, TopTools_ShapeMapHasher>::Iterator TopTools_IndexedDataMapIteratorOfDataMapOfShapeListOfShape;
#endif

View File

@@ -0,0 +1,22 @@
puts "========"
puts "0024909: Modeling Algorithms - SIGSEGV in buildsweep"
puts "========"
puts ""
pload MODELING
circle c1 0 0 0 40
mkedge e1 c1
wire w1 e1
tcopy w1 Sketch002
tcopy w1 Sketch001
renamevar w1 Sketch
trotate Sketch 0 0 0 0. 1. 0. 90
ttranslate Sketch 0. 0. 75.
trotate Sketch001 0 0 0 0. 1. 0. 90
ttranslate Sketch001 0. 0. -75.
ttranslate Sketch002 50. 0. 0.
mksweep Sketch002
setsweep -CF
addsweep Sketch001
addsweep Sketch
buildsweep Sweep

View File

@@ -0,0 +1,26 @@
puts "========"
puts "0024909: Modeling Algorithms - SIGSEGV in buildsweep"
puts "========"
puts ""
pload MODELING
restore [locate_data_file bug24909_BezCurve.brep] BezCurve
ttranslate BezCurve 0 -8 0
explode BezCurve E
wire Sweep001-0-spine BezCurve_1
mksweep Sweep001-0-spine
setsweep -CF
circle Circle-curve 0 0 0 18
mkedge Circle-edge Circle-curve 0 0
wire Circle Circle-edge
trotate Circle 0 0 0 0.577350269189625731 0.577350269189625731 0.577350269189625731 120
ttranslate Circle 0 -71 203.5
addsweep Circle
circle Circle001-curve 0 0 0 16
mkedge Circle001-edge Circle001-curve 0 0
wire Circle001 Circle001-edge
trotate Circle001 0 0 0 0.577350269189625731 0.577350269189625731 0.577350269189625731 120
ttranslate Circle001 0 -71 203.5
addsweep Circle001
buildsweep Sweep001 -C -S

View File

@@ -0,0 +1,17 @@
puts "========"
puts "0024909: Modeling Algorithms - SIGSEGV in buildsweep"
puts "========"
puts ""
pload MODELING
restore [locate_data_file bug24909_spine.brep]
renamevar bug24909_spine Sweep-0-spine
mksweep Sweep-0-spine
setsweep -CF
restore [locate_data_file bug24909_Sketch.brep]
renamevar bug24909_Sketch Sweep-0-section-00-Sketch
addsweep Sweep-0-section-00-Sketch
restore [locate_data_file bug24909_Sketch001.brep]
renamevar bug24909_Sketch001 Sweep-0-section-01-Sketch001
addsweep Sweep-0-section-01-Sketch001
buildsweep Sweep

View File

@@ -0,0 +1,15 @@
puts "========"
puts "0024909: Modeling Algorithms - SIGSEGV in buildsweep"
puts "========"
puts ""
pload ALL
circle c1 0 0 0 40
mkedge e1 c1
wire w1 e1
line l1 0 0 0 0 0 20
mkedge e2 l1 0 10
wire w2 e2
mksweep w1
addsweep w2
buildsweep sw1

View File

@@ -1,39 +0,0 @@
puts "================================================="
puts "0023860: Bad memory access intersecting two nearly coincident cylindrical faces"
puts "================================================="
puts ""
cylinder c1 1031.3339148728076 -113.25868616662650 56.152387686082520 \
-0.86602540378443815 0.50000000000000089 0.00000000000000000 \
-0.50000000000000089 -0.86602540378443815 0.00000000000000000 \
76.499999999999986
cylinder c2 1017.0706583606553 -103.24955863669388 56.152387686082548 \
0.86602540378443915 -0.49999999999999933 0.00000000000000000 \
0.49999999999999933 0.86602540378443915 0.00000000000000000 \
76.499999999999986
mkface f1 c1
mkface f2 c2
set curves_found [lindex [split [bopcurves f1 f2 -2d -noapprox] "\n"] 1]
if { $curves_found != "2 curve(s) found." } {
puts "Error wrong curves number"
}
smallview
donly c_1 c_2
fit
xwd ${imagedir}/${casename}_1.png
set lines [split [dump c_1] "\n"]
if { [lindex $lines 4] != " Origin :1031.71804748645, -112.593348962955, -20.34375449469 " ||
[lindex $lines 5] != " Axis :-0.866025403784438, 0.500000000000001, 0 " } {
puts "Error: wrong first curve"
}
set lines [split [dump c_2] "\n"]
if { [lindex $lines 4] != " Origin :1031.71804748645, -112.593348962957, 132.648529866855 " ||
[lindex $lines 5] != " Axis :-0.866025403784438, 0.500000000000001, 0 "} {
puts "Error: wrong second curve"
}