mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0027875: GeomFill_NSections constructor crash on sequence of curve containing only one curve
The GeomFill_NSections algorithm cannot create any surface from sequence with single curve only. Therefore, return is provided in corresponding place of the code. Additionally, some public methods of GeomFill_NSections class checks if the surface has been created earlier. Test case for this issue has been created. Compiler error has been eliminated.
This commit is contained in:
parent
5da005403b
commit
84bd25527c
@ -524,6 +524,12 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
Standard_Real myPres3d = 1.e-06;
|
Standard_Real myPres3d = 1.e-06;
|
||||||
Standard_Integer i,j,jdeb=1,jfin=mySections.Length();
|
Standard_Integer i,j,jdeb=1,jfin=mySections.Length();
|
||||||
|
|
||||||
|
if (jfin <= jdeb)
|
||||||
|
{
|
||||||
|
//We will not be able to create surface from single curve.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GeomFill_SectionGenerator section;
|
GeomFill_SectionGenerator section;
|
||||||
Handle(Geom_BSplineSurface) surface;
|
Handle(Geom_BSplineSurface) surface;
|
||||||
|
|
||||||
@ -641,9 +647,12 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
Standard_Integer& NbKnots,
|
Standard_Integer& NbKnots,
|
||||||
Standard_Integer& Degree) const
|
Standard_Integer& Degree) const
|
||||||
{
|
{
|
||||||
NbPoles = mySurface->NbUPoles();
|
if (mySurface.IsNull())
|
||||||
NbKnots = mySurface->NbUKnots();
|
return;
|
||||||
Degree = mySurface->UDegree();
|
|
||||||
|
NbPoles = mySurface->NbUPoles();
|
||||||
|
NbKnots = mySurface->NbUKnots();
|
||||||
|
Degree = mySurface->UDegree();
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================
|
//=======================================================
|
||||||
@ -651,7 +660,8 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
void GeomFill_NSections::Knots(TColStd_Array1OfReal& TKnots) const
|
void GeomFill_NSections::Knots(TColStd_Array1OfReal& TKnots) const
|
||||||
{
|
{
|
||||||
mySurface->UKnots(TKnots);
|
if (!mySurface.IsNull())
|
||||||
|
mySurface->UKnots(TKnots);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================
|
//=======================================================
|
||||||
@ -659,7 +669,8 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
void GeomFill_NSections::Mults(TColStd_Array1OfInteger& TMults) const
|
void GeomFill_NSections::Mults(TColStd_Array1OfInteger& TMults) const
|
||||||
{
|
{
|
||||||
mySurface->UMultiplicities(TMults);
|
if (!mySurface.IsNull())
|
||||||
|
mySurface->UMultiplicities(TMults);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -668,7 +679,10 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
Standard_Boolean GeomFill_NSections::IsRational() const
|
Standard_Boolean GeomFill_NSections::IsRational() const
|
||||||
{
|
{
|
||||||
return mySurface->IsURational();
|
if (!mySurface.IsNull())
|
||||||
|
return mySurface->IsURational();
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================
|
//=======================================================
|
||||||
@ -676,7 +690,10 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
Standard_Boolean GeomFill_NSections::IsUPeriodic() const
|
Standard_Boolean GeomFill_NSections::IsUPeriodic() const
|
||||||
{
|
{
|
||||||
return mySurface->IsUPeriodic();
|
if (!mySurface.IsNull())
|
||||||
|
return mySurface->IsUPeriodic();
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================
|
//=======================================================
|
||||||
@ -684,7 +701,10 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
Standard_Boolean GeomFill_NSections::IsVPeriodic() const
|
Standard_Boolean GeomFill_NSections::IsVPeriodic() const
|
||||||
{
|
{
|
||||||
return mySurface->IsVPeriodic();
|
if (!mySurface.IsNull())
|
||||||
|
return mySurface->IsVPeriodic();
|
||||||
|
|
||||||
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================
|
//=======================================================
|
||||||
@ -692,6 +712,9 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
Standard_Integer GeomFill_NSections::NbIntervals(const GeomAbs_Shape S) const
|
Standard_Integer GeomFill_NSections::NbIntervals(const GeomAbs_Shape S) const
|
||||||
{
|
{
|
||||||
|
if (mySurface.IsNull())
|
||||||
|
return 0;
|
||||||
|
|
||||||
GeomAdaptor_Surface AdS(mySurface);
|
GeomAdaptor_Surface AdS(mySurface);
|
||||||
return AdS.NbVIntervals(S);
|
return AdS.NbVIntervals(S);
|
||||||
}
|
}
|
||||||
@ -703,6 +726,9 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
void GeomFill_NSections::Intervals(TColStd_Array1OfReal& T,
|
void GeomFill_NSections::Intervals(TColStd_Array1OfReal& T,
|
||||||
const GeomAbs_Shape S) const
|
const GeomAbs_Shape S) const
|
||||||
{
|
{
|
||||||
|
if (mySurface.IsNull())
|
||||||
|
return;
|
||||||
|
|
||||||
GeomAdaptor_Surface AdS(mySurface);
|
GeomAdaptor_Surface AdS(mySurface);
|
||||||
AdS.VIntervals(T,S);
|
AdS.VIntervals(T,S);
|
||||||
}
|
}
|
||||||
@ -763,6 +789,9 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
gp_Pnt P, Bary;
|
gp_Pnt P, Bary;
|
||||||
Bary.SetCoord(0., 0., 0.);
|
Bary.SetCoord(0., 0., 0.);
|
||||||
|
|
||||||
|
if (mySurface.IsNull())
|
||||||
|
return Bary;
|
||||||
|
|
||||||
Standard_Integer ii,jj;
|
Standard_Integer ii,jj;
|
||||||
Standard_Real U0, U1, V0, V1;
|
Standard_Real U0, U1, V0, V1;
|
||||||
mySurface->Bounds(U0,U1,V0,V1);
|
mySurface->Bounds(U0,U1,V0,V1);
|
||||||
@ -801,6 +830,9 @@ GeomFill_NSections::GeomFill_NSections(const TColGeom_SequenceOfCurve& NC,
|
|||||||
//=======================================================
|
//=======================================================
|
||||||
void GeomFill_NSections::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
|
void GeomFill_NSections::GetMinimalWeight(TColStd_Array1OfReal& Weights) const
|
||||||
{
|
{
|
||||||
|
if (mySurface.IsNull())
|
||||||
|
return;
|
||||||
|
|
||||||
if (mySurface->IsURational()) {
|
if (mySurface->IsURational()) {
|
||||||
Standard_Integer NbU = mySurface->NbUPoles(),
|
Standard_Integer NbU = mySurface->NbUPoles(),
|
||||||
NbV = mySurface->NbVPoles();
|
NbV = mySurface->NbVPoles();
|
||||||
|
@ -2114,6 +2114,33 @@ static Standard_Integer OCC27552(Draw_Interpretor&,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <NCollection_IncAllocator.hxx>
|
||||||
|
static Standard_Integer OCC27875(Draw_Interpretor& theDI,
|
||||||
|
Standard_Integer theNArg,
|
||||||
|
const char ** theArgVal)
|
||||||
|
{
|
||||||
|
if (theNArg < 2)
|
||||||
|
{
|
||||||
|
theDI << "Use: OCC27875 curve\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
TColGeom_SequenceOfCurve aNC(new NCollection_IncAllocator());
|
||||||
|
|
||||||
|
const Handle(Geom_Curve) aC = Handle(Geom_Curve)::DownCast(DrawTrSurf::Get(theArgVal[1]));
|
||||||
|
|
||||||
|
aNC.Append(aC);
|
||||||
|
|
||||||
|
GeomFill_NSections aNS(aNC);
|
||||||
|
|
||||||
|
if (aNS.BSplineSurface().IsNull())
|
||||||
|
{
|
||||||
|
theDI << "GeomFill_NSections is not done.\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
||||||
const char *group = "QABugs";
|
const char *group = "QABugs";
|
||||||
|
|
||||||
@ -2132,5 +2159,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
|||||||
theCommands.Add ("OCC27357", "OCC27357", __FILE__, OCC27357, group);
|
theCommands.Add ("OCC27357", "OCC27357", __FILE__, OCC27357, group);
|
||||||
theCommands.Add("OCC26270", "OCC26270 shape result", __FILE__, OCC26270, group);
|
theCommands.Add("OCC26270", "OCC26270 shape result", __FILE__, OCC26270, group);
|
||||||
theCommands.Add ("OCC27552", "OCC27552", __FILE__, OCC27552, group);
|
theCommands.Add ("OCC27552", "OCC27552", __FILE__, OCC27552, group);
|
||||||
|
theCommands.Add("OCC27875", "OCC27875 curve", __FILE__, OCC27875, group);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
19
tests/bugs/modalg_6/bug27875
Normal file
19
tests/bugs/modalg_6/bug27875
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
puts "================"
|
||||||
|
puts "OCC27875"
|
||||||
|
puts "================"
|
||||||
|
puts ""
|
||||||
|
###############################
|
||||||
|
## GeomFill_NSections constructor crash on sequence of curve containing only one curve
|
||||||
|
###############################
|
||||||
|
|
||||||
|
# GeomFill_NSections does not work if the sequence of curves contains only single curve.
|
||||||
|
# Therefore, we should not expect any correct result from this operation. However, the
|
||||||
|
# exception must not be thrown.
|
||||||
|
|
||||||
|
pload QAcommands
|
||||||
|
|
||||||
|
restore [locate_data_file OCC606_2.brep] w2
|
||||||
|
explode w2 e
|
||||||
|
mkcurve cc w2_1
|
||||||
|
trim cc cc
|
||||||
|
OCC27875 cc
|
Loading…
x
Reference in New Issue
Block a user