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

0024195: Use of uninitialized data in IntCurve_IntPolyPolyGen.gxx

Fix for regressions
Modified test cases de/iges_1/R8 and de/iges_2/I7 according to new data
This commit is contained in:
ifv 2013-10-03 16:30:51 +04:00 committed by bugmaster
parent 7c4e9501b4
commit 1665a85a84
4 changed files with 444 additions and 513 deletions

View File

@ -41,17 +41,18 @@ IntCurve_ExactIntersectionPoint::IntCurve_ExactIntersectionPoint(const TheCurve&
StartingPoint(1,2),
Root(1,2),
anErrorOccurred(Standard_False)
{
{
ToleranceVector.Value(1) = TheCurveTool::EpsX(C1);
ToleranceVector.Value(2) = TheCurveTool::EpsX(C2);
}
}
//----------------------------------------------------------------------
void IntCurve_ExactIntersectionPoint::Perform( const IntCurve_ThePolygon2d& Poly1
,const IntCurve_ThePolygon2d& Poly2
,Standard_Integer& NumSegOn1
,Standard_Integer& NumSegOn2
,Standard_Real& ParamOnSeg1
,Standard_Real& ParamOnSeg2) {
,Standard_Real& ParamOnSeg2)
{
//----------------------------------------------------------------------
//-- On prend comme bornes de recherches :
//--
@ -88,9 +89,9 @@ void IntCurve_ExactIntersectionPoint::Perform( const IntCurve_ThePolygon2d& Poly
IntCurve_ExactIntersectionPoint::MathPerform();
if(nbroots == 0) {
// Standard_Real DeflectionOn1 = Poly1.DeflectionOverEstimation();
// Standard_Real DeflectionOn1 = Poly1.DeflectionOverEstimation();
Poly1.DeflectionOverEstimation();
// Standard_Real DeflectionOn2 = Poly2.DeflectionOverEstimation();
// Standard_Real DeflectionOn2 = Poly2.DeflectionOverEstimation();
Poly2.DeflectionOverEstimation();
// if(DeflectionOn2 > Poly1.BeginOfSeg(NumSegOn1).Distance(Poly1.EndOfSeg(NumSegOn1))) {
{
@ -150,7 +151,8 @@ void IntCurve_ExactIntersectionPoint::Perform( const IntCurve_ThePolygon2d& Poly
}
while( nbroots==0 && diff!=0);
//---------------- On elargit les bornes par la droite --------------------
if(nbroots==0) {
if(nbroots==0)
{
BInfVector.Value(2) = AnBinfVector;
diff=1;
do {
@ -169,7 +171,7 @@ void IntCurve_ExactIntersectionPoint::Perform( const IntCurve_ThePolygon2d& Poly
BSupVector.Value(2) = AnBsupVector;
}
}
}
}
//----------------------------------------------------------------------
void IntCurve_ExactIntersectionPoint::Perform( const Standard_Real Uo
,const Standard_Real Vo
@ -200,7 +202,8 @@ void IntCurve_ExactIntersectionPoint::Roots(Standard_Real& U,Standard_Real& V) {
}
//----------------------------------------------------------------------
void IntCurve_ExactIntersectionPoint::MathPerform(void) {
void IntCurve_ExactIntersectionPoint::MathPerform(void)
{
math_FunctionSetRoot Fct( FctDist
,StartingPoint
,ToleranceVector
@ -213,13 +216,16 @@ void IntCurve_ExactIntersectionPoint::MathPerform(void) {
math_Vector XY(1,2);
FctDist.Value(Root,XY);
Standard_Real dist2 = ((XY(1)*XY(1)+XY(2)*XY(2)));
if(dist2 > myTol) nbroots = 0;
if(dist2 > myTol)
{
nbroots = 0;
}
}
else {
anErrorOccurred = Standard_True;
nbroots = 0;
}
}
}
//======================================================================

View File

@ -93,9 +93,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
,const Standard_Real TheTolConf
,const Standard_Real TheTol)
{
Standard_Boolean AnErrorOccurred = Standard_False;
this->ResetFields();
DomainOnCurve1=D1;
DomainOnCurve2=D2;
@ -127,8 +124,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
//--------------------------------------------------------------------
Standard_Integer PosSegment = 0;
for(i=1;i<=n;i++) {
IntRes2d_Position Pos1 = this->Point(i).TransitionOfFirst().PositionOnCurve();
if(Pos1 == IntRes2d_Head) HeadOn1 = Standard_True;
@ -185,15 +180,10 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
}
}
Standard_Real U0 = D1.FirstParameter();
Standard_Real U1 = D1.LastParameter();
Standard_Real V0 = D2.FirstParameter();
Standard_Real V1 = D2.LastParameter();
Standard_Real v,u;
Standard_Real EpsX1 = TheCurveTool::EpsX(C1);
Standard_Real EpsX2 = TheCurveTool::EpsX(C2);
IntRes2d_IntersectionPoint IntPt;
if(D1.FirstTolerance() || D2.FirstTolerance()) {
@ -212,50 +202,9 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
if(HeadOrEndPoint(D1,C1,U1,D2,C2,V1,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
this->Insert(IntPt);
}
if(AnErrorOccurred) {
//----------------------------------------------------------------------------------
//-- On a donne un point approche a la recherche du point exact, et cette recherche
//-- a echoue.
//-- Soit le point n'existe pas, soit c'est un point en bout dont un des parameteres
//-- est en dehors du domaine de la courbe.
//--
//-- Dans le cas contraire, on suppose que les points en bouts ont ete trouves par
//-- les interferences des polygones
//--
if(!HeadOn1) {
u = U0;
v = TheProjPCur::FindParameter( C2,D1.FirstPoint(),V0,V1,EpsX2);
if(HeadOrEndPoint(D1,C1,u,D2,C2,v,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
this->Insert(IntPt);
}
if(!EndOn1) {
u = U1;
v = TheProjPCur::FindParameter( C2,D1.LastPoint(),V0,V1,EpsX2);
if(HeadOrEndPoint(D1,C1,u,D2,C2,v,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
this->Insert(IntPt);
}
if(!HeadOn2) {
u = TheProjPCur::FindParameter( C1,D2.FirstPoint(),U0,U1,EpsX1);
v = V0;
if(HeadOrEndPoint(D1,C1,u,D2,C2,v,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
this->Insert(IntPt);
}
if(!EndOn2) {
u = TheProjPCur::FindParameter( C1,D2.LastPoint(),U0,U1,EpsX1);
v = V1;
if(HeadOrEndPoint(D1,C1,u,D2,C2,v,TheTolConf,IntPt,HeadOn1,HeadOn2,EndOn1,EndOn2,PosSegment))
this->Insert(IntPt);
}
}
}
//======================================================================
//== A u t o I n t e r s e c t i o n
//======================================================================
@ -282,7 +231,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
Standard_Integer i;
Standard_Integer n=this->NbPoints();
//--------------------------------------------------------------------
//-- On ne rejette les points Head Head ... End End
//-- si ils figurent deja dans un bout de segment
@ -295,8 +243,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
//--------------------------------------------------------------------
Standard_Integer PosSegment = 0;
for(i=1;i<=n;i++) {
IntRes2d_Position Pos1 = this->Point(i).TransitionOfFirst().PositionOnCurve();
if(Pos1 == IntRes2d_Head) HeadOn1 = Standard_True;
@ -355,8 +301,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
}
//======================================================================
void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
,const IntRes2d_Domain& D1
,const Standard_Real TolConf
@ -369,8 +313,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
gp_Pnt2d P1,P2;
Standard_Integer nbsamples;
done = Standard_False;
Standard_Boolean AnErrorOccurred = Standard_False;
nbsamples = TheCurveTool::NbSamples(C1,D1.FirstParameter(),D1.LastParameter());
@ -462,7 +404,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
if( (PtrSegIndex1[TriIndex[i]] == PtrSegIndex1[TriIndex[i+1]])
&& (PtrSegIndex2[TriIndex[i]] == PtrSegIndex2[TriIndex[i+1]])) {
TriIndex[i]=-i;
}
}
@ -479,12 +420,10 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
if(Abs(SegIndex1-SegIndex2)>1) {
EIP.Perform(Poly1,Poly1,SegIndex1,SegIndex2,ParamOn1,ParamOn2);
AnErrorOccurred = EIP.AnErrorOccurred();
if(EIP.NbRoots()==0) {
//-- On supprime tous les segments voisins
for(Standard_Integer k=sp+1;k<=Nbsp;k++) {
Standard_Integer kk=TriIndex[k];
// modified by OFV OCC2502 Tue Apr 29 15:07:45 2003 .Begin
// --- avoid negative indicies as well as in outer done
if( kk > 0 ) {
if( Abs(SegIndex1-PtrSegIndex1[kk])< Nelarg
@ -492,7 +431,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
TriIndex[k]=-k;
}
}
// modified by OFV OCC2502 Tue Apr 29 15:11:34 2003 .End
}
}
else if(EIP.NbRoots()>=1) {
@ -549,7 +487,8 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
//-----------------------------------------------------------------
if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1
,Pos2,Tan2,Trans2
,TolConf) == Standard_False) {
,TolConf) == Standard_False)
{
TheCurveTool::D2(C1,U,P1,Tan1,Norm1);
TheCurveTool::D2(C1,V,P2,Tan2,Norm2);
IntImpParGen::DetermineTransition( Pos1,Tan1,Norm1,Trans1
@ -616,7 +555,6 @@ Standard_Boolean HeadOrEndPoint( const IntRes2d_Domain& D1
u = D1.LastParameter();
}
//----------------------------------------------------------------------
//-- Head On 2 : Head2 <-> P1
else if(P1.Distance(D2.FirstPoint())<=D2.FirstTolerance()) {
@ -637,7 +575,6 @@ Standard_Boolean HeadOrEndPoint( const IntRes2d_Domain& D1
Standard_Real EpsX1 = TheCurveTool::EpsX(C1);
Standard_Real EpsX2 = TheCurveTool::EpsX(C2);
if((Pos1 != IntRes2d_Middle)||(Pos2 != IntRes2d_Middle)) {
if(Pos1 == IntRes2d_Middle) {
if(Abs(u-D1.FirstParameter()) <= EpsX1) {
@ -681,7 +618,6 @@ Standard_Boolean HeadOrEndPoint( const IntRes2d_Domain& D1
}
}
//--------------------------------------------------------------------
//-- On Teste si un point de bout de segment a deja ces trnasitions
//-- Si Oui, on ne cree pas de nouveau point
@ -716,11 +652,6 @@ Standard_Boolean HeadOrEndPoint( const IntRes2d_Domain& D1
}
//======================================================================
void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
,const IntRes2d_Domain& D1
@ -739,7 +670,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
nbsamplesOnC1 = TheCurveTool::NbSamples(C1,D1.FirstParameter(),D1.LastParameter());
//// modified by jgv, 5.12.02 for OCC935 ////
if (NbIter == 0) // first time
{
if (nbsamplesOnC1 < 20)
@ -753,7 +683,6 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
nbsamplesOnC2 = TheCurveTool::NbSamples(C2,D2.FirstParameter(),D2.LastParameter());
//// modified by jgv, 5.12.02 for OCC935 ////
if (NbIter == 0) // first time
{
if (nbsamplesOnC2 < 20)
@ -834,7 +763,7 @@ void IntCurve_IntPolyPolyGen::Perform( const TheCurve& C1
}
//======================================================================
// Purpose :
// Purpose : findIntersect
//======================================================================
Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
@ -856,13 +785,13 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
gp_Pnt2d P1,P2;
Intf_InterferencePolygon2d InterPP(thePoly1,thePoly2);
IntCurve_ExactIntersectionPoint EIP(C1,C2,TolConf);
Standard_Real U,V;
Standard_Real U = 0., V = 0.;
Standard_Boolean AnErrorOccurred = Standard_False;
done = Standard_True; // To prevent exception in nbp=NbPoints();
//----------------------------------------------------------------------
//-- Traitement des SectionPoint
//----------------------------------------------------------------------
Standard_Integer Nbsp = InterPP.NbSectionPoints();
for(Standard_Integer sp=1; sp <= Nbsp; sp++) {
const Intf_SectionPoint& SPnt = InterPP.PntValue(sp);
Standard_Integer SegIndex1,SegIndex2;
@ -872,10 +801,15 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
SPnt.InfoFirst(Type,SegIndex1,ParamOn1);
SPnt.InfoSecond(Type,SegIndex2,ParamOn2);
EIP.Perform(thePoly1,thePoly2,SegIndex1,SegIndex2,ParamOn1,ParamOn2);
//AnErrorOccurred = EIP.AnErrorOccurred();
AnErrorOccurred = EIP.AnErrorOccurred();
if( !EIP.NbRoots() && !isFullPolygon)
return Standard_False;
if(AnErrorOccurred)
{
continue;
}
//--------------------------------------------------------------------
//-- On verifie que le point trouve est bien une racine
@ -887,11 +821,9 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
//-----------------------------------------------------------------
//-- On verifie que le point (u,v) n existe pas deja
//--
done = Standard_True;
Standard_Integer nbp=NbPoints();
Standard_Real EpsX1 = 10.0*TheCurveTool::EpsX(C1);
Standard_Real EpsX2 = 10.0*TheCurveTool::EpsX(C2);
for(Standard_Integer p=1; p<=nbp; p++) {
const IntRes2d_IntersectionPoint& P=Point(p);
if(Abs(U-P.ParamOnFirst()) <= EpsX1) {
@ -920,15 +852,10 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
//-----------------------------------------------------------------
//-- Calcul des Transitions (Voir IntImpParGen.cxx)
//--
if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1
,Pos2,Tan2,Trans2
,TolConf)==Standard_False) {
if(IntImpParGen::DetermineTransition (Pos1, Tan1, Trans1, Pos2, Tan2, Trans2, TolConf) == Standard_False) {
TheCurveTool::D2(C1,U,P1,Tan1,Norm1);
TheCurveTool::D2(C2,V,P2,Tan2,Norm2);
IntImpParGen::DetermineTransition( Pos1,Tan1,Norm1,Trans1
,Pos2,Tan2,Norm2,Trans2
,TolConf);
IntImpParGen::DetermineTransition (Pos1, Tan1, Norm1, Trans1, Pos2, Tan2, Norm2, Trans2, TolConf);
}
IntRes2d_IntersectionPoint IP(P1,U,V,Trans1,Trans2,Standard_False);
Insert(IP);
@ -983,7 +910,6 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
if(ParamSupOnCurve1 < _PolyUInf) ParamSupOnCurve1=_PolyUInf;
if(ParamSupOnCurve2 < _PolyVInf) ParamSupOnCurve2=_PolyVInf;
}
PolyUInf= ParamInfOnCurve1;
@ -1000,8 +926,6 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
Standard_Real qwerty=PolyVInf; PolyVInf=PolyVSup; PolyVSup=qwerty;
}
if( ( (thePoly1.DeflectionOverEstimation() > TolConf)
||(thePoly2.DeflectionOverEstimation() > TolConf))
&&(NbIter<NBITER_MAX_POLYGON)) {
@ -1060,7 +984,8 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
if(IntImpParGen::DetermineTransition( Pos1,Tan1,Trans1,Pos2,Tan2,Trans2,TolConf)
== Standard_False) {
== Standard_False)
{
TheCurveTool::D2(C1,PolyUInf,P1,Tan1,Norm1);
TheCurveTool::D2(C2,PolyVInf,P2,Tan2,Norm2);
IntImpParGen::DetermineTransition(Pos1,Tan1,Norm1,Trans1,
@ -1071,10 +996,12 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
//----------------------------------------------------------------------
if((Abs(PolyUInf-PolyUSup) <= TheCurveTool::EpsX(C1))
|| (Abs(PolyVInf-PolyVSup) <= TheCurveTool::EpsX(C2))) {
|| (Abs(PolyVInf-PolyVSup) <= TheCurveTool::EpsX(C2)))
{
Insert(PtSeg1);
}
else {
else
{
TheCurveTool::D1(C1,PolyUSup,P1,Tan1);
TheCurveTool::D1(C2,PolyVSup,P2,Tan2);
Pos1 = IntRes2d_Middle; Pos2 = IntRes2d_Middle;
@ -1116,8 +1043,6 @@ Standard_Boolean IntCurve_IntPolyPolyGen::findIntersect(
IntRes2d_IntersectionPoint PtSeg2(P1,PolyUSup,PolyVSup
,Trans1,Trans2,Standard_False);
Standard_Boolean Oppos = (Tan1.Dot(Tan2) > 0.0)? Standard_False : Standard_True;
if(ParamInfOnCurve1 > ParamSupOnCurve1) {
IntRes2d_IntersectionSegment Seg(PtSeg2,PtSeg1,Oppos,Standard_False);

View File

@ -11,9 +11,9 @@ set ref_data {
DATA : Faulties = 0 ( 2 ) Warnings = 0 ( 0 ) Summary = 0 ( 2 )
TPSTAT : Faulties = 3 ( 59 ) Warnings = 2203 ( 4654 ) Summary = 2206 ( 4713 )
CHECKSHAPE : Wires = 8 ( 17 ) Faces = 6 ( 11 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 3349 ( 2837 ) Summary = 45820 ( 39081 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 3349 ( 3349 ) FreeWire = 6 ( 6 ) FreeEdge = 67 ( 67 ) SharedEdge = 19534 ( 16688 )
TOLERANCE : MaxTol = 4.854604894 ( 5.769095076 ) AvgTol = 0.01657799259 ( 0.01735277012 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 3349 ( 2837 ) Summary = 45817 ( 39081 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 3349 ( 3349 ) FreeWire = 6 ( 6 ) FreeEdge = 67 ( 67 ) SharedEdge = 19532 ( 16688 )
TOLERANCE : MaxTol = 4.854604894 ( 5.769095076 ) AvgTol = 0.01656957183 ( 0.01735277012 )
LABELS : N0Labels = 11 ( 11 ) N1Labels = 2891 ( 6257 ) N2Labels = 0 ( 0 ) TotalLabels = 2902 ( 6268 ) NameLabels = 2900 ( 5879 ) ColorLabels = 2891 ( 6257 ) LayerLabels = 2411 ( 5261 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 4 ( 4 )

View File

@ -1,5 +1,5 @@
# !!!! This file is generated automatically, do not edit manually! See end script
puts "TODO CR23096 ALL: CHECKSHAPE : Faulty"
puts "TODO CR23096 ALL: NBSHAPES : Faulty"
puts "TODO CR23096 ALL: LABELS : Faulty"
puts "TODO CR23096 ALL: COLORS : Faulty"
@ -8,12 +8,12 @@ set filename ims016.igs
set ref_data {
DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 )
TPSTAT : Faulties = 0 ( 0 ) Warnings = 130 ( 402 ) Summary = 130 ( 402 )
CHECKSHAPE : Wires = 4 ( 0 ) Faces = 2 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) Summary = 10599 ( 10569 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) FreeWire = 6 ( 6 ) FreeEdge = 353 ( 353 ) SharedEdge = 4953 ( 4953 )
TOLERANCE : MaxTol = 0.2092687841 ( 0.2092687804 ) AvgTol = 0.0008878122295 ( 0.0009749254626 )
LABELS : N0Labels = 503 ( 503 ) N1Labels = 0 ( 200 ) N2Labels = 0 ( 0 ) TotalLabels = 503 ( 703 ) NameLabels = 503 ( 503 ) ColorLabels = 470 ( 703 ) LayerLabels = 313 ( 344 )
TPSTAT : Faulties = 0 ( 0 ) Warnings = 120 ( 402 ) Summary = 120 ( 402 )
CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) Summary = 10561 ( 10563 )
STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 138 ( 138 ) FreeWire = 6 ( 6 ) FreeEdge = 353 ( 353 ) SharedEdge = 4947 ( 4949 )
TOLERANCE : MaxTol = 0.07559058774 ( 0.07559058772 ) AvgTol = 0.0006486207316 ( 0.0006485487307 )
LABELS : N0Labels = 503 ( 503 ) N1Labels = 0 ( 196 ) N2Labels = 0 ( 0 ) TotalLabels = 503 ( 699 ) NameLabels = 503 ( 503 ) ColorLabels = 470 ( 699 ) LayerLabels = 313 ( 344 )
PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 )
NCOLORS : NColors = 6 ( 7 )
COLORS : Colors = CYAN1 GREEN MAGENTA1 RED WHITE YELLOW ( BLACK CYAN1 GREEN MAGENTA1 RED WHITE YELLOW )