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

Coding - Refactor switch-case statements and improve memory management #569

- Added missing break statements in switch-case blocks in LDOMBasicString, LDOM_BasicElement, PCDM_ReadWriter, and IntCurve_IntConicConic_1 to prevent fall-through behavior.
- Enhanced Standard_Macro.hxx to support fallthrough attributes across different compilers.
- Corrected the use of std::forward in Standard_MemoryUtils.hxx for better type deduction.
- Replaced raw arrays with NCollection_Array1 in AdvApp2Var_SysBase for improved memory safety.
- Updated Extrema_ExtCC2d to utilize smart pointers for better memory management and avoid potential leaks.
- Refactored Units_UnitsDictionary to use NCollection_Array2 for matrix representation, improving readability and maintainability.
- Initialized TranFirst and TranLast in TopTrans_CurveTransition constructor for better default state management.
- Set myStatus in ShapeConstruct_ProjectCurveOnSurface constructor to ensure proper initialization.
- Changed matrix access in Units_UnitsDictionary to use NCollection_Array2 syntax for consistency.
This commit is contained in:
Pasukhin Dmitry 2025-05-30 14:31:26 +01:00 committed by GitHub
parent 3b62a5eb29
commit 4629ee0ca3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 177 additions and 144 deletions

View File

@ -110,6 +110,7 @@ LDOMBasicString::LDOMBasicString(const LDOMBasicString& anOther)
break;
case LDOM_Integer:
myVal.i = anOther.myVal.i;
break;
default:;
}
}
@ -167,7 +168,9 @@ LDOMBasicString& LDOMBasicString::operator=(const LDOMBasicString& anOther)
break;
case LDOM_Integer:
myVal.i = anOther.myVal.i;
default:;
break;
default:
break;
}
return *this;
}

View File

@ -74,7 +74,8 @@ void LDOM_BasicElement::RemoveNodes()
aTxt = NULL;
break;
}
default:;
default:
break;
}
aNode = aNext;
}

View File

@ -57,6 +57,7 @@ void PCDM_ReadWriter::Open(const Handle(Storage_BaseDriver)& aDriver,
break;
case Storage_VSAlreadyOpen:
aMsg << "; file was already opened";
break;
default:
break;
}

View File

@ -63,11 +63,21 @@
//! Expands to C++17 attribute statement "[[fallthrough]];" on compilers that
//! declare support of C++17, or to "__attribute__((fallthrough));" on
//! GCC 7+.
#if defined(__cplusplus) && (__cplusplus >= 201703L)
// part of C++17 standard
#define Standard_FALLTHROUGH [[fallthrough]];
#if defined(__has_cpp_attribute)
#if __has_cpp_attribute(fallthrough)
// C++17 standard attribute is supported
#define Standard_FALLTHROUGH [[fallthrough]];
#elif __has_cpp_attribute(clang::fallthrough)
// Clang-specific attribute
#define Standard_FALLTHROUGH [[clang::fallthrough]];
#elif __has_cpp_attribute(gnu::fallthrough)
// GCC-specific attribute (rare, but possible)
#define Standard_FALLTHROUGH [[gnu::fallthrough]];
#else
#define Standard_FALLTHROUGH
#endif
#elif defined(__GNUC__) && (__GNUC__ >= 7)
// gcc 7+
// GCC 7+ supports __attribute__((fallthrough))
#define Standard_FALLTHROUGH __attribute__((fallthrough));
#else
#define Standard_FALLTHROUGH

View File

@ -49,7 +49,7 @@ template <class T, class... Args>
std::shared_ptr<T> make_oshared(NCollection_OccAllocator<T>&& theAlloc, Args&&... theArgs)
{
return std::allocate_shared<T, NCollection_OccAllocator<T>, Args...>(
std::forward < NCollection_OccAllocator<T>(> theAlloc),
std::forward<NCollection_OccAllocator<T>>(theAlloc),
std::forward<Args>(theArgs)...);
}

View File

@ -18,6 +18,7 @@
#include <OSD.hxx>
#include <OSD_OpenFile.hxx>
#include <NCollection_Array2.hxx>
#include <Standard_Stream.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
@ -93,14 +94,15 @@ static const char* readLine(TCollection_AsciiString& theLine, const char* theStr
void Units_UnitsDictionary::Creates()
{
Standard_Boolean ismove;
Standard_Integer i, j, k, charnumber, unitscomputed;
Standard_Real matrix[50][50], coeff = 0, move = 0;
Handle(Units_Token) token;
Handle(Units_UnitsSequence) theunitssequence;
Handle(Units_Unit) unit;
Handle(Units_ShiftedUnit) shiftedunit;
Handle(Units_Quantity) quantity;
Standard_Boolean ismove;
Standard_Integer i, j, k, charnumber, unitscomputed;
NCollection_Array2<Standard_Real> matrix(0, 49, 0, 49);
Standard_Real coeff = 0, move = 0;
Handle(Units_Token) token;
Handle(Units_UnitsSequence) theunitssequence;
Handle(Units_Unit) unit;
Handle(Units_ShiftedUnit) shiftedunit;
Handle(Units_Quantity) quantity;
thequantitiessequence = new Units_QuantitiesSequence();
@ -125,23 +127,23 @@ void Units_UnitsDictionary::Creates()
{
unitscomputed = 0;
for (i = 0; i <= numberofunits; i++)
matrix[i][i] = 1.;
matrix(i, i) = 1.;
for (i = 0; i <= numberofunits; i++)
{
if (matrix[i][0])
if (matrix(i, 0))
unitscomputed++;
}
while (unitscomputed != numberofunits + 1)
{
for (j = 1; j <= numberofunits; j++)
{
if (!matrix[j][0])
if (!matrix(j, 0))
{
for (i = 1; i < j; i++)
{
if (matrix[j][i] && matrix[i][0])
if (matrix(j, i) && matrix(i, 0))
{
matrix[j][0] = matrix[i][0] * matrix[j][i];
matrix(j, 0) = matrix(i, 0) * matrix(j, i);
unitscomputed++;
if (unitscomputed == numberofunits + 1)
break;
@ -149,9 +151,9 @@ void Units_UnitsDictionary::Creates()
}
for (k = j + 1; k <= numberofunits; k++)
{
if (matrix[k][j] && matrix[k][0])
if (matrix(k, j) && matrix(k, 0))
{
matrix[j][0] = matrix[k][0] / matrix[k][j];
matrix(j, 0) = matrix(k, 0) / matrix(k, j);
unitscomputed++;
if (unitscomputed == numberofunits + 1)
break;
@ -165,7 +167,7 @@ void Units_UnitsDictionary::Creates()
for (i = 1; i <= theunitssequence->Length(); i++)
{
unit = theunitssequence->Value(i);
unit->Value(matrix[i][0]);
unit->Value(matrix(i, 0));
}
}
@ -224,7 +226,7 @@ void Units_UnitsDictionary::Creates()
for (i = 0; i < 50; i++)
{
for (j = 0; j < 50; j++)
matrix[i][j] = 0.;
matrix(i, j) = 0.;
}
// skip next line (dotted)
@ -330,19 +332,19 @@ void Units_UnitsDictionary::Creates()
if (j < numberofunits)
{
matrix[numberofunits][j] = coeff;
matrix(numberofunits, j) = coeff;
}
else
{
Units_UnitSentence unitsentence(unit2, thequantitiessequence);
matrix[numberofunits][0] = coeff * (unitsentence.Evaluate())->Value();
matrix(numberofunits, 0) = coeff * (unitsentence.Evaluate())->Value();
}
}
else
{
if (numberofunits == 1)
{
matrix[1][0] = coeff;
matrix(1, 0) = coeff;
unit = theunitssequence->Value(numberofunits);
unit->Value(coeff);
}

View File

@ -2068,6 +2068,7 @@ void IntCurve_IntConicConic::Perform(const gp_Lin2d& L1,
ParamEnd2 = ParamEnd - Org2SurL1;
}
}
break;
default: //~~~ Segment Infini a droite
break;
}

View File

@ -486,6 +486,7 @@ void Recadre(const Standard_Boolean,
U1 += M_PI + M_PI;
while (U1 > (U1p + 1.5 * M_PI))
U1 -= M_PI + M_PI;
break;
default:
break;
}
@ -504,6 +505,7 @@ void Recadre(const Standard_Boolean,
U2 += M_PI + M_PI;
while (U2 > (U2p + 1.5 * M_PI))
U2 -= M_PI + M_PI;
break;
default:
break;
}

View File

@ -32,6 +32,8 @@ TopTrans_CurveTransition::TopTrans_CurveTransition()
CurvFirst(0.0),
CurvLast(0.0)
{
TranFirst = TopAbs_FORWARD;
TranLast = TopAbs_FORWARD;
}
//=======================================================================

View File

@ -108,6 +108,7 @@ ShapeConstruct_ProjectCurveOnSurface::ShapeConstruct_ProjectCurveOnSurface()
myBuild = Standard_False;
myAdjustOverDegen = 1; //: c0 //szv#4:S4163:12Mar99 was boolean
myNbCashe = 0; //: q9
myStatus = ShapeExtend::EncodeStatus(ShapeExtend_OK);
}
//=================================================================================================

View File

@ -51,8 +51,8 @@ void Geom2dLProp_NumericCurInf2d::PerformCurExt(const Handle(Geom2d_Curve)& C,
{
isDone = Standard_True;
Standard_Real EpsH = 1.e-4 * (UMax - UMin);
Standard_Real Tol = Precision::PConfusion();
Standard_Real EpsH = 1.e-4 * (UMax - UMin);
constexpr Standard_Real Tol = Precision::PConfusion();
// la premiere recherce se fait avec une tolerance assez grande
// car la derivee de la fonction est estimee assez grossierement.

View File

@ -14,6 +14,7 @@
// AdvApp2Var_SysBase.cxx
#include <assert.h>
#include <cmath>
#include <NCollection_Array1.hxx>
#include <string.h>
#include <AdvApp2Var_SysBase.hxx>
#include <AdvApp2Var_Data.hxx>
@ -1850,11 +1851,11 @@ int mcrcomm_(integer* kop, integer* noct, intptr_t* iadr, integer* ier)
integer i__1, i__2;
/* Local variables */
intptr_t ideb;
doublereal dtab[32000];
intptr_t itab[160] /* was [4][40] */;
intptr_t ipre;
integer i__, j, k;
intptr_t ideb;
NCollection_Array1<doublereal> dtab(0, 32000 - 1);
NCollection_Array1<intptr_t> itab(0, 160 - 1); // was [4][40] but now flattened to a single array
intptr_t ipre;
integer i__, j, k;
/************************************************************************
*******/
@ -1973,7 +1974,7 @@ int mcrcomm_(integer* kop, integer* noct, intptr_t* iadr, integer* ier)
itab[(i__ << 2) - 4] = *noct / 8 + 1;
itab[(i__ << 2) - 3] = ipre;
itab[(i__ << 2) - 2] = *noct;
*iadr = reinterpret_cast<intptr_t>(&dtab[ipre - 1]);
*iadr = reinterpret_cast<intptr_t>(&dtab[static_cast<Standard_Integer>(ipre) - 1]);
itab[(i__ << 2) - 1] = *iadr;
goto L9900;
}

View File

@ -25,6 +25,7 @@
#include <GeomAbs_CurveType.hxx>
#include <gp_Pnt2d.hxx>
#include <Precision.hxx>
#include <Standard_MemoryUtils.hxx>
#include <Standard_OutOfRange.hxx>
#include <StdFail_NotDone.hxx>
@ -34,6 +35,7 @@ Extrema_ExtCC2d::Extrema_ExtCC2d()
myIsPar(Standard_False),
mynbext(0),
inverse(Standard_False),
myC(nullptr),
myv1(0.0),
myv2(0.0),
mytolc1(0.0),
@ -109,6 +111,9 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
P2f = Extrema_Curve2dTool::Value(*myC, U21);
P2l = Extrema_Curve2dTool::Value(*myC, U22);
std::shared_ptr<Extrema_ExtElC2d> aXtream;
std::shared_ptr<Extrema_ECC2d> aParamSolver;
switch (type1)
{
//
@ -120,44 +125,45 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
{
case GeomAbs_Line: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Circle(C1),
Tol);
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Circle(C1),
Tol);
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 0.);
}
break;
case GeomAbs_Circle: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Circle(*myC));
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Circle(*myC));
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
}
break;
case GeomAbs_Ellipse: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Ellipse(*myC));
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Ellipse(*myC));
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
}
break;
case GeomAbs_Parabola: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Parabola(*myC));
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Parabola(*myC));
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 0.);
}
break;
case GeomAbs_Hyperbola: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Hyperbola(*myC));
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 0.);
aXtream =
opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(C1),
Extrema_Curve2dTool::Hyperbola(*myC));
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 0.);
}
break;
default: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Standard_Real Period2 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(*myC))
Period2 = Extrema_Curve2dTool::Period(*myC);
Results(aParamSolver, U11, U12, U21, U22, 2 * M_PI, Period2);
Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, Period2);
}
break;
}; // switch(type2)
@ -173,50 +179,51 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
{
case GeomAbs_Line: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*myC), Extrema_Curve2dTool::Ellipse(C1));
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Ellipse(C1));
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 0.);
}
break;
case GeomAbs_Circle: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(*myC),
Extrema_Curve2dTool::Ellipse(C1));
Results(Xtrem, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(*myC),
Extrema_Curve2dTool::Ellipse(C1));
Results(*aXtream, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
}
break;
case GeomAbs_Ellipse: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, 2 * M_PI);
}
break;
case GeomAbs_Parabola: {
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(C1),
// Extrema_Curve2dTool::Parabola(*myC));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 2 * M_PI, 0.);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, 0.);
}
break;
case GeomAbs_Hyperbola: {
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(C1),
// Extrema_Curve2dTool::Hyperbola(*myC));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 2 * M_PI, 0.);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, 0.);
}
break;
default: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Standard_Real Period2 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(*myC))
Period2 = Extrema_Curve2dTool::Period(*myC);
Results(aParamSolver, U11, U12, U21, U22, 2 * M_PI, Period2);
Results(*aParamSolver, U11, U12, U21, U22, 2 * M_PI, Period2);
}
break;
}; // switch(type2)
@ -232,55 +239,55 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
{
case GeomAbs_Line: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Parabola(C1));
Results(Xtrem, U11, U12, U21, U22, 0., 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Parabola(C1));
Results(*aXtream, U11, U12, U21, U22, 0., 0.);
}
break;
case GeomAbs_Circle: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(*myC),
Extrema_Curve2dTool::Parabola(C1));
Results(Xtrem, U11, U12, U21, U22, 0., 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(*myC),
Extrema_Curve2dTool::Parabola(C1));
Results(*aXtream, U11, U12, U21, U22, 0., 2 * M_PI);
}
break;
case GeomAbs_Ellipse: {
// inverse = Standard_True;
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(*myC),
// Extrema_Curve2dTool::Parabola(C1));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 0., 2 * M_PI);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 0., 2 * M_PI);
}
break;
case GeomAbs_Parabola: {
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Parabola(C1),
// Extrema_Curve2dTool::Parabola(*myC));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 0., 0.);
}
break;
case GeomAbs_Hyperbola: {
// inverse = Standard_True;
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Hyperbola(*myC),
// Extrema_Curve2dTool::Parabola(C1));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 0., 0.);
}
break;
default: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Standard_Real Period2 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(*myC))
Period2 = Extrema_Curve2dTool::Period(*myC);
Results(aParamSolver, U11, U12, U21, U22, 0., Period2);
Results(*aParamSolver, U11, U12, U21, U22, 0., Period2);
}
break;
}; // switch(type2)
@ -296,54 +303,54 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
{
case GeomAbs_Line: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Hyperbola(C1));
Results(Xtrem, U11, U12, U21, U22, 0., 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(*myC),
Extrema_Curve2dTool::Hyperbola(C1));
Results(*aXtream, U11, U12, U21, U22, 0., 0.);
}
break;
case GeomAbs_Circle: {
inverse = Standard_True;
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Circle(*myC),
Extrema_Curve2dTool::Hyperbola(C1));
Results(Xtrem, U11, U12, U21, U22, 0., 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Circle(*myC),
Extrema_Curve2dTool::Hyperbola(C1));
Results(*aXtream, U11, U12, U21, U22, 0., 2 * M_PI);
}
break;
case GeomAbs_Ellipse: {
// inverse = Standard_True;
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Ellipse(*myC),
// Extrema_Curve2dTool::Hyperbola(C1));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 0., 2 * M_PI);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 0., 2 * M_PI);
}
break;
case GeomAbs_Parabola: {
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Hyperbola(C1),
// Extrema_Curve2dTool::Parabola(*myC));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 0., 0.);
}
break;
case GeomAbs_Hyperbola: {
// Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Hyperbola(C1),
// Extrema_Curve2dTool::Hyperbola(*myC));
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
Results(aParamSolver, U11, U12, U21, U22, 0., 0.);
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Results(*aParamSolver, U11, U12, U21, U22, 0., 0.);
}
break;
default: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Standard_Real Period2 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(*myC))
Period2 = Extrema_Curve2dTool::Period(*myC);
Results(aParamSolver, U11, U12, U21, U22, 0., Period2);
Results(*aParamSolver, U11, U12, U21, U22, 0., Period2);
}
break;
}; // switch(type2)
@ -358,44 +365,46 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
switch (type2)
{
case GeomAbs_Line: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Line(*myC),
Tol);
Results(Xtrem, U11, U12, U21, U22, 0., 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Line(*myC),
Tol);
Results(*aXtream, U11, U12, U21, U22, 0., 0.);
}
break;
case GeomAbs_Circle: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Circle(*myC),
Tol);
Results(Xtrem, U11, U12, U21, U22, 0., 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Circle(*myC),
Tol);
Results(*aXtream, U11, U12, U21, U22, 0., 2 * M_PI);
}
break;
case GeomAbs_Ellipse: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1), Extrema_Curve2dTool::Ellipse(*myC));
Results(Xtrem, U11, U12, U21, U22, 0., 2 * M_PI);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Ellipse(*myC));
Results(*aXtream, U11, U12, U21, U22, 0., 2 * M_PI);
}
break;
case GeomAbs_Parabola: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Parabola(*myC));
Results(Xtrem, U11, U12, U21, U22, 0., 0.);
aXtream = opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Parabola(*myC));
Results(*aXtream, U11, U12, U21, U22, 0., 0.);
}
break;
case GeomAbs_Hyperbola: {
Extrema_ExtElC2d Xtrem(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Hyperbola(*myC));
Results(Xtrem, U11, U12, U21, U22, 0., 0.);
aXtream =
opencascade::make_shared<Extrema_ExtElC2d>(Extrema_Curve2dTool::Line(C1),
Extrema_Curve2dTool::Hyperbola(*myC));
Results(*aXtream, U11, U12, U21, U22, 0., 0.);
}
break;
default: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Standard_Real Period2 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(*myC))
Period2 = Extrema_Curve2dTool::Period(*myC);
Results(aParamSolver, U11, U12, U21, U22, 0., Period2);
Results(*aParamSolver, U11, U12, U21, U22, 0., Period2);
}
break;
}; // switch(type2)
@ -406,16 +415,16 @@ void Extrema_ExtCC2d::Perform(const Adaptor2d_Curve2d& C1,
// La premiere courbe est une BezierCurve ou une BSplineCurve:
//
default: {
Extrema_ECC2d aParamSolver(C1, *myC);
aParamSolver.SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver.Perform();
aParamSolver = opencascade::make_shared<Extrema_ECC2d>(C1, *myC);
aParamSolver->SetSingleSolutionFlag(GetSingleSolutionFlag());
aParamSolver->Perform();
Standard_Real Period1 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(C1))
Period1 = Extrema_Curve2dTool::Period(C1);
Standard_Real Period2 = 0.;
if (Extrema_Curve2dTool::IsPeriodic(*myC))
Period2 = Extrema_Curve2dTool::Period(*myC);
Results(aParamSolver, U11, U12, U21, U22, Period1, Period2);
Results(*aParamSolver, U11, U12, U21, U22, Period1, Period2);
}
break;
};