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

0033180: We had a problem calling the OCC library at the customer site, and the program crashed

Added status for thrusection operations and changed throw constructions to set of the status and break the function.
This commit is contained in:
akaftasev
2022-11-17 10:25:36 +03:00
committed by smoskvin
parent 057dcfddf7
commit 3eb891ec49
12 changed files with 308 additions and 47 deletions

View File

@@ -656,7 +656,7 @@ static void BuildConnectedEdges(const TopoDS_Wire& aWire,
//=======================================================================
BRepFill_CompatibleWires::BRepFill_CompatibleWires()
:myIsDone(Standard_False)
:myStatus(BRepFill_ThruSectionErrorStatus_NotDone)
{
}
@@ -682,7 +682,7 @@ void BRepFill_CompatibleWires::Init(const TopTools_SequenceOfShape& Sections)
myInit = Sections;
myWork = Sections;
myPercent = 0.01;
myIsDone = Standard_False;
myStatus = BRepFill_ThruSectionErrorStatus_NotDone;
myMap.Clear();
}
@@ -707,7 +707,7 @@ void BRepFill_CompatibleWires::SetPercent(const Standard_Real Percent)
Standard_Boolean BRepFill_CompatibleWires::IsDone() const
{
return myIsDone;
return myStatus == BRepFill_ThruSectionErrorStatus_Done;
}
@@ -766,6 +766,7 @@ Standard_Boolean BRepFill_CompatibleWires::IsDegeneratedLastSection() const
void BRepFill_CompatibleWires::Perform (const Standard_Boolean WithRotation)
{
myStatus = BRepFill_ThruSectionErrorStatus_Done;
// compute origin and orientation on wires to avoid twisted results
// and update wires to have same number of edges
@@ -838,7 +839,7 @@ void BRepFill_CompatibleWires::Perform (const Standard_Boolean WithRotation)
allClosed = (allClosed && wClosed);
allOpen = (allOpen && !wClosed);
}
if (allClosed) {
// All sections are closed
if (report) {
@@ -849,24 +850,26 @@ void BRepFill_CompatibleWires::Perform (const Standard_Boolean WithRotation)
// origin
ComputeOrigin(Standard_False);
}
myIsDone = Standard_True;
}
else if (allOpen) {
// All sections are open
// origin
SearchOrigin();
if (myStatus != BRepFill_ThruSectionErrorStatus_Done)
{
return;
}
// same number of elements
if (report) {
SameNumberByACR(report);
}
myIsDone = Standard_True;
}
else {
// There are open and closed sections :
// not processed
throw Standard_DomainError("Sections must be all closed or all open");
myStatus = BRepFill_ThruSectionErrorStatus_NotSameTopology;
return;
}
}
@@ -906,7 +909,10 @@ void BRepFill_CompatibleWires::
//allClosed = (allClosed && myWork(i).Closed());
}
if (!allClosed)
throw Standard_NoSuchObject("BRepFill_CompatibleWires::SameNumberByPolarMethod : the wires must be closed");
{
myStatus = BRepFill_ThruSectionErrorStatus_NotSameTopology;
return;
}
// sections ponctuelles, sections bouclantes ?
if (myDegen1) ideb++;
@@ -986,8 +992,11 @@ void BRepFill_CompatibleWires::
// sequence of vertices of the first wire
SeqOfVertices(wire1,SeqV);
if (SeqV.Length()>NbMaxV)
throw Standard_NoSuchObject("BRepFill::SameNumberByPolarMethod failed");
if (SeqV.Length() > NbMaxV)
{
myStatus = BRepFill_ThruSectionErrorStatus_Failed;
return;
}
// loop on vertices of wire1
for (ii=1;ii<=SeqV.Length();ii++) {
@@ -1062,7 +1071,10 @@ void BRepFill_CompatibleWires::
// sequence of vertices of the first wire
SeqOfVertices(wire1,SeqV);
if ( SeqV.Length()>NbMaxV || SeqV.Length()>SizeMap )
throw Standard_NoSuchObject("BRepFill::SameNumberByPolarMethod failed");
{
myStatus = BRepFill_ThruSectionErrorStatus_Failed;
return;
}
// next wire
@@ -1184,14 +1196,17 @@ void BRepFill_CompatibleWires::
}
} //end of for(; itW.More(); itW.Next())
if (Esol.IsNull())
throw Standard_ConstructionError("BRepFill :: profiles are inconsistent");
{
myStatus = BRepFill_ThruSectionErrorStatus_ProfilesInconsistent;
return;
}
MW.Add(Esol);
TopTools_ListOfShape ConnectedEdges;
BuildConnectedEdges( TopoDS::Wire(myWork(i)), Esol, V2, ConnectedEdges );
TopTools_ListIteratorOfListOfShape itCE(ConnectedEdges);
for(; anExp.More(), itCE.More(); anExp.Next(), itCE.Next())
for(; anExp.More() && itCE.More(); anExp.Next(), itCE.Next())
{
ECur = anExp.Current();
TopExp::Vertices(ECur,VF,VL,Standard_True);
@@ -1264,8 +1279,10 @@ void BRepFill_CompatibleWires::
if (nbmax<nbEdges) nbmax = nbEdges;
if (nbmin>nbEdges) nbmin = nbEdges;
}
if (nbmin!=nbmax) {
throw Standard_NoSuchObject("BRepFill_CompatibleWires::SameNumberByPolarMethod failed");
if (nbmin!=nbmax)
{
myStatus = BRepFill_ThruSectionErrorStatus_Failed;
return;
}
//Fill <myMap>
@@ -1487,7 +1504,10 @@ void BRepFill_CompatibleWires::SameNumberByACR(const Standard_Boolean report)
if (nbmin>nbEdges(i)) nbmin = nbEdges(i);
}
if (nbmax!=nbmin)
throw Standard_NoSuchObject("BRepFill_CompatibleWires::SameNumberByACR failed");
{
myStatus = BRepFill_ThruSectionErrorStatus_Failed;
return;
}
}
//=======================================================================
@@ -1532,7 +1552,10 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
}
*/
if (!allClosed)
throw Standard_NoSuchObject("BRepFill_CompatibleWires::ComputeOrigin : the wires must be closed");
{
myStatus = BRepFill_ThruSectionErrorStatus_NotSameTopology;
return;
}
/*
// Max number of possible cuts
@@ -1869,7 +1892,10 @@ void BRepFill_CompatibleWires::ComputeOrigin(const Standard_Boolean /*polar*/ )
gp_Pnt Pmini,P1,P2;
SeqOfVertices(wire,SeqV);
if (SeqV.Length()>NbMaxV)
throw Standard_NoSuchObject("BRepFill::ComputeOrigin failed");
{
myStatus = BRepFill::ThruSectionsError_Failed;
return;
}
if (!polar) {
// choix du vertex le plus proche comme origine
distmini = Precision::Infinite();
@@ -2094,7 +2120,10 @@ void BRepFill_CompatibleWires::SearchOrigin()
allOpen = (allOpen && !myWork(i).Closed());
}
if (!allOpen)
throw Standard_NoSuchObject("BRepFill_CompatibleWires::SearchOrigin : the wires must be open");
{
myStatus = BRepFill_ThruSectionErrorStatus_NotSameTopology;
return;
}
// init

View File

@@ -20,6 +20,7 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <BRepFill_ThruSectionErrorStatus.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
#include <TopTools_ListOfShape.hxx>
@@ -49,6 +50,11 @@ public:
Standard_EXPORT void Perform (const Standard_Boolean WithRotation = Standard_True);
Standard_EXPORT Standard_Boolean IsDone() const;
BRepFill_ThruSectionErrorStatus GetStatus() const
{
return myStatus;
}
//! returns the generated sequence.
Standard_EXPORT const TopTools_SequenceOfShape& Shape() const;
@@ -101,7 +107,7 @@ private:
Standard_Real myPercent;
Standard_Boolean myDegen1;
Standard_Boolean myDegen2;
Standard_Boolean myIsDone;
BRepFill_ThruSectionErrorStatus myStatus;
TopTools_DataMapOfShapeListOfShape myMap;

View File

@@ -65,6 +65,7 @@ Standard_Integer DetectKPart(const TopoDS_Edge& Edge1,
const TopoDS_Edge& Edge2)
{
// initializations
// !Note if IType set as -1 it means that occurs error with null 3d curve for the edge
Standard_Integer IType = 0;
// characteristics of the first edge
@@ -89,7 +90,9 @@ Standard_Integer DetectKPart(const TopoDS_Edge& Edge1,
else {
curv1 = BRep_Tool::Curve(Edge1, loc, first1, last1);
if (curv1.IsNull())
throw Standard_NullObject("Null 3D curve in edge");
{
return -1;
}
curv1 =
Handle(Geom_Curve)::DownCast(curv1->Transformed(loc.Transformation()));
ff = first1;
@@ -156,7 +159,9 @@ Standard_Integer DetectKPart(const TopoDS_Edge& Edge1,
else {
curv = BRep_Tool::Curve(Edge2, loc, first2, last2);
if (curv.IsNull())
throw Standard_NullObject("Null 3D curve in edge");
{
return -1;
}
curv =
Handle(Geom_Curve)::DownCast(curv->Transformed(loc.Transformation()));
ff = first2;
@@ -312,12 +317,12 @@ Standard_Integer DetectKPart(const TopoDS_Edge& Edge1,
//=======================================================================
//function : CreateKPart
//purpose :
//purpose : Returns true if there is no errors occur
//=======================================================================
void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
const Standard_Integer IType,
Handle(Geom_Surface)& Surf)
Standard_Boolean CreateKPart (const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
const Standard_Integer IType,
Handle(Geom_Surface)& Surf)
{
// find the dimension
TopoDS_Vertex V1, V2;
@@ -326,6 +331,8 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
Standard_Real a1, b1, aa =0., bb =0.;
TopoDS_Vertex v1f,v1l,v2f,v2l;
Standard_Boolean isDone = Standard_True;
// find characteristics of the first edge
Handle(Geom_Curve) C1;
Standard_Boolean degen1 = BRep_Tool::Degenerated(Edge1);
@@ -336,7 +343,9 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
else {
C1 = BRep_Tool::Curve(Edge1, loc, a1, b1);
if (C1.IsNull())
throw Standard_NullObject("Null 3D curve in edge");
{
return Standard_False;
}
C1 = Handle(Geom_Curve)::DownCast(C1->Transformed(loc.Transformation()));
aa = a1;
bb = b1;
@@ -361,7 +370,9 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
else {
C2 = BRep_Tool::Curve(Edge2, loc, a1, b1);
if (C2.IsNull())
throw Standard_NullObject("Null 3D curve in edge");
{
return Standard_False;
}
C2 = Handle(Geom_Curve)::DownCast(C2->Transformed(loc.Transformation()));
if (Edge2.Orientation() == TopAbs_REVERSED) {
C2->Reverse();
@@ -496,6 +507,7 @@ void CreateKPart(const TopoDS_Edge& Edge1,const TopoDS_Edge& Edge2,
// IType incorrect
}
Surf = surface;
return isDone;
}
//=======================================================================
@@ -528,7 +540,8 @@ static TopoDS_Edge CreateNewEdge(const TopoDS_Edge& theEdge, TopTools_DataMapOfS
//=======================================================================
BRepFill_Generator::BRepFill_Generator():
myMutableInput (Standard_True)
myMutableInput (Standard_True),
myStatus (BRepFill_ThruSectionErrorStatus_NotDone)
{
}
@@ -551,6 +564,8 @@ void BRepFill_Generator::AddWire(const TopoDS_Wire& Wire)
void BRepFill_Generator::Perform()
{
myStatus = BRepFill_ThruSectionErrorStatus_Done;
TopoDS_Shell Shell;
TopoDS_Face Face;
TopoDS_Shape S1, S2;
@@ -679,6 +694,12 @@ void BRepFill_Generator::Perform()
// processing of KPart
Standard_Integer IType = DetectKPart(Edge1,Edge2);
if (IType == -1)
{
myStatus = BRepFill_ThruSectionErrorStatus_Null3DCurve;
return;
}
if (IType==0) {
// no part cases
TopLoc_Location L,L1,L2;
@@ -694,7 +715,10 @@ void BRepFill_Generator::Perform()
else {
C1 = BRep_Tool::Curve(Edge1,L1,f1,l1);
if (C1.IsNull())
throw Standard_NullObject("Null 3D curve in edge");
{
myStatus = BRepFill_ThruSectionErrorStatus_Null3DCurve;
return;
}
}
if (degen2) {
Extremities(1) = BRep_Tool::Pnt(V2l);
@@ -704,7 +728,10 @@ void BRepFill_Generator::Perform()
else {
C2 = BRep_Tool::Curve(Edge2,L2,f2,l2);
if (C2.IsNull())
throw Standard_NullObject("Null 3D curve in edge");
{
myStatus = BRepFill_ThruSectionErrorStatus_Null3DCurve;
return;
}
}
// compute the location
@@ -746,7 +773,11 @@ void BRepFill_Generator::Perform()
}
else {
// particular case
CreateKPart(Edge1,Edge2,IType,Surf);
if (!CreateKPart(Edge1, Edge2, IType, Surf))
{
myStatus = BRepFill_ThruSectionErrorStatus_Null3DCurve;
return;
}
B.MakeFace(Face,Surf,Precision::Confusion());
}

View File

@@ -20,6 +20,7 @@
#include <Standard.hxx>
#include <Standard_DefineAlloc.hxx>
#include <BRepFill_ThruSectionErrorStatus.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopoDS_Shell.hxx>
#include <TopTools_DataMapOfShapeListOfShape.hxx>
@@ -68,6 +69,12 @@ public:
//! Returns the current mutable input state
Standard_EXPORT Standard_Boolean IsMutableInput() const;
//! Returns status of the operation
BRepFill_ThruSectionErrorStatus GetStatus() const
{
return myStatus;
}
protected:
private:
@@ -78,6 +85,7 @@ private:
TopTools_DataMapOfShapeShape myOldNewShapes;
BRepTools_ReShape myReshaper;
Standard_Boolean myMutableInput;
BRepFill_ThruSectionErrorStatus myStatus;
};

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2022 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef _BRepFill_ThruSectionErrorStatus_HeaderFile
#define _BRepFill_ThruSectionErrorStatus_HeaderFile
//! Errors that can occur at thrusection algorithm.
enum BRepFill_ThruSectionErrorStatus
{
BRepFill_ThruSectionErrorStatus_Done, //!< Thrusection algorithm is done
BRepFill_ThruSectionErrorStatus_NotDone, //!< Thrusection algorithm is not done
BRepFill_ThruSectionErrorStatus_NotSameTopology, //!< All profiles have not same topology (they should be all closed or all opened)
BRepFill_ThruSectionErrorStatus_ProfilesInconsistent, //!< Profiles are inconsistent
BRepFill_ThruSectionErrorStatus_WrongUsage, //!< Wrong usage of punctual sections
BRepFill_ThruSectionErrorStatus_Null3DCurve, //!< Null 3D curve in edge
BRepFill_ThruSectionErrorStatus_Failed //!< Thrusection algorithm has failed
};
#endif // _BRepFill_ThruSectionErrorStatus_HeaderFile

View File

@@ -77,6 +77,7 @@ BRepFill_ShapeLaw.hxx
BRepFill_ShapeLaw.lxx
BRepFill_Sweep.cxx
BRepFill_Sweep.hxx
BRepFill_ThruSectionErrorStatus.hxx
BRepFill_TransitionStyle.hxx
BRepFill_TrimEdgeTool.cxx
BRepFill_TrimEdgeTool.hxx