- Deletion of 20 legacy DRAW test files (.tcl format) from tests/bugs/ directories
- Addition of 15 new GTest C++ test files across multiple modules
- Removal of corresponding QA command implementations from TKQADraw
set(OCCT_TKLCAF_GTests_FILES
TDataStd_Attribute_Test.cxx
TDataStd_TreeNode_Test.cxx
+ TDF_AttributeIterator_Test.cxx
TNaming_Builder_Test.cxx
TNaming_Name_Test.cxx
)
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <TDF_AttributeIterator.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDocStd_Application.hxx>
+#include <TDocStd_Document.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(TDF_AttributeIterator_Test, OCC24755_AttributeInsertionOrder)
+{
+ Handle(TDocStd_Application) anApp = new TDocStd_Application();
+ Handle(TDocStd_Document) aDoc;
+ anApp->NewDocument("BinOcaf", aDoc);
+ TDF_Label aLab = aDoc->Main();
+
+ // Prepend an int value.
+ TDataStd_Integer::Set(aLab, 0);
+ // Prepend a name.
+ TDataStd_Name::Set(aLab, "test");
+ // Append a double value.
+ aLab.AddAttribute(new TDataStd_Real(), true /*append*/);
+
+ // Verify that attributes are iterated in the expected order:
+ // Integer (prepended second, so it's first), Name (prepended first), Real (appended)
+ TDF_AttributeIterator anIter(aLab);
+
+ ASSERT_TRUE(anIter.More()) << "Iterator should have first attribute";
+ Handle(TDF_Attribute) anAttr = anIter.Value();
+ EXPECT_TRUE(anAttr->IsKind(STANDARD_TYPE(TDataStd_Integer)))
+ << "First attribute should be TDataStd_Integer";
+
+ anIter.Next();
+ ASSERT_TRUE(anIter.More()) << "Iterator should have second attribute";
+ anAttr = anIter.Value();
+ EXPECT_TRUE(anAttr->IsKind(STANDARD_TYPE(TDataStd_Name)))
+ << "Second attribute should be TDataStd_Name";
+
+ anIter.Next();
+ ASSERT_TRUE(anIter.More()) << "Iterator should have third attribute";
+ anAttr = anIter.Value();
+ EXPECT_TRUE(anAttr->IsKind(STANDARD_TYPE(TDataStd_Real)))
+ << "Third attribute should be TDataStd_Real";
+
+ anIter.Next();
+ EXPECT_FALSE(anIter.More()) << "Iterator should have no more attributes";
+}
--- /dev/null
+# Test source files for TKXCAF
+set(OCCT_TKXCAF_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
+
+set(OCCT_TKXCAF_GTests_FILES
+ XCAFDoc_Test.cxx
+)
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <BRepPrimAPI_MakeBox.hxx>
+#include <Standard_GUID.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDocStd_Application.hxx>
+#include <TDocStd_Document.hxx>
+#include <XCAFDoc.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(XCAFDoc_Test, OCC738_ShapeRefGUID)
+{
+ // Bug OCC738: The GUIDs in XCAFDoc have incorrect format
+ // This test verifies that XCAFDoc::ShapeRefGUID() returns a valid GUID
+
+ Standard_GUID aGUID;
+ EXPECT_NO_THROW(aGUID = XCAFDoc::ShapeRefGUID());
+
+ // Verify the GUID is not null (all zeros)
+ Standard_GUID aNullGUID("00000000-0000-0000-0000-000000000000");
+ EXPECT_NE(aGUID, aNullGUID) << "ShapeRefGUID should not be null";
+}
+
+TEST(XCAFDoc_Test, OCC738_AssemblyGUID)
+{
+ // Bug OCC738: The GUIDs in XCAFDoc have incorrect format
+ // This test verifies that XCAFDoc::AssemblyGUID() returns a valid GUID
+
+ Standard_GUID aGUID;
+ EXPECT_NO_THROW(aGUID = XCAFDoc::AssemblyGUID());
+
+ // Verify the GUID is not null (all zeros)
+ Standard_GUID aNullGUID("00000000-0000-0000-0000-000000000000");
+ EXPECT_NE(aGUID, aNullGUID) << "AssemblyGUID should not be null";
+}
+
+// RAII guard to save and restore XCAFDoc_ShapeTool AutoNaming state
+class AutoNamingGuard
+{
+public:
+ AutoNamingGuard()
+ : mySavedValue(XCAFDoc_ShapeTool::AutoNaming())
+ {
+ }
+
+ ~AutoNamingGuard() { XCAFDoc_ShapeTool::SetAutoNaming(mySavedValue); }
+
+ // Disable copy and move
+ AutoNamingGuard(const AutoNamingGuard&) = delete;
+ AutoNamingGuard& operator=(const AutoNamingGuard&) = delete;
+
+private:
+ Standard_Boolean mySavedValue;
+};
+
+TEST(XCAFDoc_Test, OCC23595_AutoNaming)
+{
+ // Bug OCC23595: XCAFDoc_ShapeTool extended with two methods -
+ // SetAutoNaming() and AutoNaming()
+ // This test verifies that the AutoNaming feature works correctly
+
+ // RAII guard to automatically restore AutoNaming state on exit (exception-safe)
+ AutoNamingGuard aGuard;
+
+ // Create a new XmlXCAF document
+ Handle(TDocStd_Application) anApp = new TDocStd_Application();
+ Handle(TDocStd_Document) aDoc;
+ anApp->NewDocument("XmlXCAF", aDoc);
+ ASSERT_FALSE(aDoc.IsNull());
+
+ Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
+
+ // Check default value of AutoNaming
+ Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
+ EXPECT_TRUE(aValue) << "AutoNaming should be true by default";
+
+ // Test with AutoNaming enabled (true)
+ XCAFDoc_ShapeTool::SetAutoNaming(Standard_True);
+ TopoDS_Shape aShape1 = BRepPrimAPI_MakeBox(100., 200., 300.).Shape();
+ TDF_Label aLabel1 = aShTool->AddShape(aShape1);
+ Handle(TDataStd_Name) anAttr;
+ EXPECT_TRUE(aLabel1.FindAttribute(TDataStd_Name::GetID(), anAttr))
+ << "Shape should have a name attribute when AutoNaming is true";
+
+ // Test with AutoNaming disabled (false)
+ XCAFDoc_ShapeTool::SetAutoNaming(Standard_False);
+ TopoDS_Shape aShape2 = BRepPrimAPI_MakeBox(300., 200., 100.).Shape();
+ TDF_Label aLabel2 = aShTool->AddShape(aShape2);
+ EXPECT_FALSE(aLabel2.FindAttribute(TDataStd_Name::GetID(), anAttr))
+ << "Shape should not have a name attribute when AutoNaming is false";
+
+ // AutoNaming state will be automatically restored by the RAII guard
+}
#include <Standard_GUID.hxx>
-//=================================================================================================
-
-static Standard_Integer OCC669(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc != 2)
- {
- di << "Usage : " << argv[0] << " GUID\n";
- return -1;
- }
- Standard_GUID guid(argv[1]);
- // guid.ShallowDump(std::cout);
- Standard_SStream aSStream;
- guid.ShallowDump(aSStream);
- di << aSStream;
- di << "\n";
- return 0;
-}
-
-#include <XCAFDoc.hxx>
-
-//=================================================================================================
-
-static Standard_Integer OCC738_ShapeRef(Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv)
-{
- if (argc != 1)
- {
- di << "Usage : " << argv[0] << "\n";
- return -1;
- }
- const Standard_GUID& guid = XCAFDoc::ShapeRefGUID();
- // guid.ShallowDump(std::cout);
- Standard_SStream aSStream;
- guid.ShallowDump(aSStream);
- di << aSStream;
- return 0;
-}
-
-//=================================================================================================
-
-static Standard_Integer OCC738_Assembly(Draw_Interpretor& di,
- Standard_Integer argc,
- const char** argv)
-{
- if (argc != 1)
- {
- di << "Usage : " << argv[0] << "\n";
- return -1;
- }
- const Standard_GUID& guid = XCAFDoc::AssemblyGUID();
- // guid.ShallowDump(std::cout);
- Standard_SStream aSStream;
- guid.ShallowDump(aSStream);
- di << aSStream;
- return 0;
-}
-
#if defined(DDataStd_def01)
#include <DDataStd_DrawPresentation.hxx>
//=================================================================================================
-#include <TColStd_Array2OfInteger.hxx>
-
-static Standard_Integer OCC670(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc != 1)
- {
- di << "Usage : " << argv[0] << "\n";
- return -1;
- }
-
- // check that exception initialized without message string can be safely handled and printed
- try
- {
- throw Standard_OutOfRange();
- }
- catch (Standard_Failure const& anException)
- {
- std::cout << "Caught successfully: ";
- std::cout << anException << std::endl;
- }
- return 0;
-}
-
#include <GeomAPI_ProjectPointOnSurf.hxx>
//=================================================================================================
//=================================================================================================
-static Standard_Integer OCC902(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
-{
- if (argc != 2)
- {
- di << "Usage : " << argv[0] << " expression\n";
- return 1;
- }
-
- TCollection_AsciiString anExpStr(argv[1]);
- anExpStr.AssignCat("*x");
- anExpStr.Prepend("Exp(");
- anExpStr.AssignCat(")");
-
- Handle(ExprIntrp_GenExp) exprIntrp = ExprIntrp_GenExp::Create();
-
- //
- // Create the expression
- exprIntrp->Process(anExpStr);
-
- if (!exprIntrp->IsDone())
- {
- di << "Interpretation of expression " << argv[1] << " failed\n";
- return 1;
- }
-
- Handle(Expr_GeneralExpression) anExpr = exprIntrp->Expression();
- Handle(Expr_NamedUnknown) aVar = new Expr_NamedUnknown("x");
- Handle(Expr_GeneralExpression) newExpr = anExpr->Derivative(aVar);
-
- TCollection_AsciiString res = newExpr->String();
- Standard_CString resStr = res.ToCString();
- TCollection_AsciiString res_old = anExpr->String();
- Standard_CString res_oldStr = res_old.ToCString();
-
- di << "X = " << argv[1] << "\n";
- di << "Y = " << res_oldStr << "\n";
- di << "Y' = " << resStr << "\n";
-
- return 0;
-}
-
#include <DDF.hxx>
#include <TPrsStd_AISViewer.hxx>
return 0;
}
-Standard_Integer OCC31189(Draw_Interpretor& theDI, Standard_Integer /*argc*/, const char** /*argv*/)
-{
- // redirect output of default messenger to DRAW (temporarily)
- const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
- Message_SequenceOfPrinters aPrinters;
- aPrinters.Append(aMsgMgr->ChangePrinters());
- aMsgMgr->AddPrinter(new Draw_Printer(theDI));
-
- // scope block to test output of message on destruction of a stream buffer
- {
- Message_Messenger::StreamBuffer aSender = Message::SendInfo();
-
- // check that messages output to sender and directly to messenger do not intermix
- aSender << "Sender message 1: start ...";
- aMsgMgr->Send("Direct message 1");
- aSender << "... end" << std::endl; // endl should send the message
-
- // check that empty stream buffer does not produce output on destruction
- Message::SendInfo();
-
- // additional message to check that they go in expected order
- aMsgMgr->Send("Direct message 2");
-
- // check that empty stream buffer does produce empty line if std::endl is passed
- Message::SendInfo() << std::endl;
-
- // last message should be sent on destruction of a sender
- aSender << "Sender message 2";
- }
-
- // restore initial output queue
- aMsgMgr->RemovePrinters(STANDARD_TYPE(Draw_Printer));
- aMsgMgr->ChangePrinters().Append(aPrinters);
-
- return 0;
-}
-
namespace
{
struct Task
group);
// theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
theCommands.Add("OCC578", "OCC578 shape1 shape2 shape3", __FILE__, OCC578, group);
- theCommands.Add("OCC669", "OCC669 GUID", __FILE__, OCC669, group);
- theCommands.Add("OCC738_ShapeRef", "OCC738_ShapeRef", __FILE__, OCC738_ShapeRef, group);
- theCommands.Add("OCC738_Assembly", "OCC738_Assembly", __FILE__, OCC738_Assembly, group);
theCommands.Add("OCC708",
"OCC708 shape ; Deactivate the current transformation",
__FILE__,
OCC708,
group);
- theCommands.Add("OCC670", "OCC670", __FILE__, OCC670, group);
theCommands.Add("OCC867", "OCC867 Point Surface Umin Usup Vmin Vsup", __FILE__, OCC867, group);
theCommands.Add("OCC909", "OCC909 wire face", __FILE__, OCC909, group);
theCommands.Add("OCC921", "OCC921 face", __FILE__, OCC921, group);
- theCommands.Add("OCC902", "OCC902 expression", __FILE__, OCC902, group);
theCommands.Add("OCC1029_AISTransparency",
"OCC1029_AISTransparency (DOC, entry, [real])",
__FILE__,
OCC28478,
group);
- theCommands.Add("OCC31189",
- "OCC31189: check stream buffer interface of Message_Messenger",
- __FILE__,
- OCC31189,
- group);
theCommands.Add("OCC25748",
"OCC25748 [-niter val] [-matsize val] [-progr] [-parallel]\n"
"\t\ttest progress indicator in parallel execution",
return 0;
}
-static int geom_get_2Dpt_from_3Dpt(const gp_Pnt& pnt3d, const gp_Pln& pln, gp_Pnt2d& pnt2d)
-{
- int ret = 0;
- Handle(Geom_Plane) gpln = new Geom_Plane(pln);
- GeomAdaptor_Surface adsur(gpln);
- Extrema_ExtPS extps(pnt3d, adsur, 0.001, 0.001);
- if (extps.IsDone())
- {
- int index;
- for (index = 1; index <= extps.NbExt(); index++)
- {
- Extrema_POnSurf pons = extps.Point(index);
- Standard_Real U, V;
- pons.Parameter(U, V);
- pnt2d.SetCoord(U, V);
- ret = 1;
- }
- }
- return ret;
-}
-
-static Standard_Integer OCC353(Draw_Interpretor& di, Standard_Integer, const char**)
-{
- gp_Ax2 ax21(gp_Pnt(100, 0, 0), gp_Dir(gp_Dir::D::Z));
- Handle(Geom_Circle) h_cir1 = new Geom_Circle(ax21, 25);
-
- gp_Ax2 ax22(gp_Pnt(-100, 0, 0), gp_Dir(gp_Dir::D::Z));
- Handle(Geom_Circle) h_cir2 = new Geom_Circle(ax22, 25);
-
- gp_Pln refpln(gp_Pnt(0, 0, 0), gp_Dir(gp_Dir::D::Z));
- Handle(Geom2d_Curve) cir2d1 = GeomAPI::To2d(h_cir1, refpln);
- Handle(Geom2d_Curve) cir2d2 = GeomAPI::To2d(h_cir2, refpln);
-
- Geom2dAdaptor_Curve adop1(cir2d1);
- Geom2dAdaptor_Curve adop2(cir2d2);
-
- Geom2dGcc_QualifiedCurve qcur1(adop1, GccEnt_enclosing);
- Geom2dGcc_QualifiedCurve qcur2(adop2, GccEnt_enclosing);
-
- Handle(Geom_CartesianPoint) h_carpt = new Geom_CartesianPoint(0, 175, 0);
-
- gp_Pnt pt3d = h_carpt->Pnt();
- gp_Pnt2d pt2d;
- geom_get_2Dpt_from_3Dpt(pt3d, refpln, pt2d);
-
- Standard_CString st;
- st = "cir2d1";
- DrawTrSurf::Set(st, cir2d1);
- st = "cir2d2";
- DrawTrSurf::Set(st, cir2d2);
- st = "pt2d";
- DrawTrSurf::Set(st, pt2d);
-
- Handle(Geom2d_CartesianPoint) pt = new Geom2d_CartesianPoint(pt2d);
- Geom2dGcc_Circ2d3Tan sol(qcur1, qcur2, pt, 0.001, 0.0, 0.0);
-
- int res = 0;
- Standard_Character buf[10];
- buf[0] = '\0';
-
- if (sol.IsDone())
- {
- res = sol.NbSolutions();
- for (Standard_Integer i = 1; i <= res; i++)
- {
- Handle(Geom2d_Circle) aC = new Geom2d_Circle(sol.ThisSolution(i));
- Sprintf(buf, "Result_%d", i);
- st = buf;
- DrawTrSurf::Set(st, aC);
- }
- }
- else
- di << "\n Faulty: no solutions found ";
- // printf("\n Faulty: no solutions found ");
-
- // printf("\n Num of solutions are %d ", res );
- di << "\n Num of solutions are " << res << " ";
-
- return 0;
-}
-
static Standard_Integer OCC138LC(Draw_Interpretor& di, Standard_Integer /*argc*/, const char** argv)
{
Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
theCommands.Add("BUC60970", "BUC60970 shape result", __FILE__, BUC60970, group);
theCommands.Add("BUC60915", "BUC60915", __FILE__, BUC60915_1, group);
theCommands.Add("OCC138", "OCC138", __FILE__, OCC138, group);
- theCommands.Add("OCC353", "OCC353", __FILE__, OCC353, group);
theCommands.Add("OCC138LC", "OCC138LC", __FILE__, OCC138LC, group);
theCommands.Add("OCC566",
"OCC566 shape [ xmin ymin zmin xmax ymax zmax] ; print bounding box",
#include <cmath>
#include <iostream>
#include <random>
+#include <vector>
#define QCOMPARE(val1, val2) \
di << "Checking " #val1 " == " #val2 << ((val1) == (val2) ? ": OK\n" : ": Error\n")
return 0;
}
-static Standard_Integer OCC23595(Draw_Interpretor& di,
- Standard_Integer /*argc*/,
- const char** /*argv*/)
-{
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- Handle(TDocStd_Document) aDoc;
- anApp->NewDocument("XmlXCAF", aDoc);
- QCOMPARE(!aDoc.IsNull(), Standard_True);
-
- Handle(XCAFDoc_ShapeTool) aShTool = XCAFDoc_DocumentTool::ShapeTool(aDoc->Main());
-
- // check default value
- Standard_Boolean aValue = XCAFDoc_ShapeTool::AutoNaming();
- QCOMPARE(aValue, Standard_True);
-
- // true
- XCAFDoc_ShapeTool::SetAutoNaming(Standard_True);
- TopoDS_Shape aShape = BRepPrimAPI_MakeBox(100., 200., 300.).Shape();
- TDF_Label aLabel = aShTool->AddShape(aShape);
- Handle(TDataStd_Name) anAttr;
- QCOMPARE(aLabel.FindAttribute(TDataStd_Name::GetID(), anAttr), Standard_True);
-
- // false
- XCAFDoc_ShapeTool::SetAutoNaming(Standard_False);
- aShape = BRepPrimAPI_MakeBox(300., 200., 100.).Shape();
- aLabel = aShTool->AddShape(aShape);
- QCOMPARE(!aLabel.FindAttribute(TDataStd_Name::GetID(), anAttr), Standard_True);
-
- // restore
- XCAFDoc_ShapeTool::SetAutoNaming(aValue);
-
- return 0;
-}
-
#include <ExprIntrp_GenExp.hxx>
Standard_Integer OCC22611(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
return 0;
}
-#include <TDF_AttributeIterator.hxx>
-
-//=================================================================================================
-
-static Standard_Integer OCC24755(Draw_Interpretor& di, Standard_Integer n, const char** a)
-{
- if (n != 1)
- {
- std::cout << "Usage : " << a[0] << "\n";
- return 1;
- }
-
- Handle(TDocStd_Application) anApp = DDocStd::GetApplication();
- Handle(TDocStd_Document) aDoc;
- anApp->NewDocument("BinOcaf", aDoc);
- TDF_Label aLab = aDoc->Main();
- // Prepend an int value.
- TDataStd_Integer::Set(aLab, 0);
- // Prepend a name.
- TDataStd_Name::Set(aLab, "test");
- // Append a double value.
- aLab.AddAttribute(new TDataStd_Real(), true /*append*/);
-
- TDF_AttributeIterator i(aLab);
- Handle(TDF_Attribute) anAttr = i.Value();
- QCOMPARE(anAttr->IsKind(STANDARD_TYPE(TDataStd_Integer)), Standard_True);
- i.Next();
- anAttr = i.Value();
- QCOMPARE(anAttr->IsKind(STANDARD_TYPE(TDataStd_Name)), Standard_True);
- i.Next();
- anAttr = i.Value();
- QCOMPARE(anAttr->IsKind(STANDARD_TYPE(TDataStd_Real)), Standard_True);
-
- return 0;
-}
-
struct MyStubObject
{
MyStubObject()
return 0;
}
-#include <Geom2dAPI_InterCurveCurve.hxx>
-#include <IntRes2d_IntersectionPoint.hxx>
-
-//=================================================================================================
-
-static Standard_Integer OCC24889(Draw_Interpretor& theDI,
- Standard_Integer /*theNArg*/,
- const char** /*theArgs*/)
-{
- // Curves
- Handle(Geom2d_Circle) aCircle1 =
- new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(25, -25), gp_Dir2d(gp_Dir2d::D::X), gp_Dir2d(-0, 1)), 155);
-
- Handle(Geom2d_Circle) aCircle2 =
- new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(25, 25), gp_Dir2d(gp_Dir2d::D::X), gp_Dir2d(-0, 1)), 155);
-
- Handle(Geom2d_TrimmedCurve) aTrim[2] = {
- new Geom2d_TrimmedCurve(aCircle1, 1.57079632679490, 2.97959469729228),
- new Geom2d_TrimmedCurve(aCircle2, 3.30359060633978, 4.71238898038469)};
-
- DrawTrSurf::Set("c_1", aTrim[0]);
- DrawTrSurf::Set("c_2", aTrim[1]);
-
- // Intersection
- constexpr Standard_Real aTol = Precision::Confusion();
- Geom2dAPI_InterCurveCurve aIntTool(aTrim[0], aTrim[1], aTol);
-
- const IntRes2d_IntersectionPoint& aIntPnt = aIntTool.Intersector().Point(1);
-
- gp_Pnt2d aIntRes = aIntTool.Point(1);
- Standard_Real aPar[2] = {aIntPnt.ParamOnFirst(), aIntPnt.ParamOnSecond()};
-
- // theDI.precision( 5 );
- theDI << "Int point: X = " << aIntRes.X() << "; Y = " << aIntRes.Y() << "\n";
- for (int i = 0; i < 2; ++i)
- {
- theDI << "Curve " << i << ": FirstParam = " << aTrim[i]->FirstParameter()
- << "; LastParam = " << aTrim[i]->LastParameter() << "; IntParameter = " << aPar[i]
- << "\n";
- }
-
- return 0;
-}
-
#include <math_GlobOptMin.hxx>
#include <math_MultipleVarFunctionWithHessian.hxx>
return 0;
}
-//=================================================================================================
-
-static Standard_Integer OCC25348(Draw_Interpretor& theDI,
- Standard_Integer /*theArgNb*/,
- const char** /*theArgVec*/)
-{
- Handle(NCollection_IncAllocator) anAlloc1;
- NCollection_List<int> aList1(anAlloc1);
- for (int i = 0; i < 10; i++)
- {
- Handle(NCollection_IncAllocator) anAlloc2;
- NCollection_List<int> aList2(anAlloc2);
- aList2.Append(i);
- aList1.Assign(aList2);
- }
- theDI << "Test complete\n";
- return 0;
-}
-
#include <IntCurvesFace_ShapeIntersector.hxx>
#include <BRepBndLib.hxx>
return 0;
}
-//====================================================
-// Auxiliary functor class for the command OCC25545;
-// it gets access to a vertex with the given index and
-// checks that X coordinate of the point is equal to index;
-// if it is not so then a data race is reported.
-//====================================================
-struct OCC25545_Functor
-{
- OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
- : myShapeVec(&theShapeVec),
- myIsRaceDetected(0)
- {
- }
-
- void operator()(size_t i) const
- {
- if (!myIsRaceDetected)
- {
- const TopoDS_Vertex& aV = TopoDS::Vertex(myShapeVec->at(i));
- gp_Pnt aP = BRep_Tool::Pnt(aV);
- if (aP.X() != static_cast<double>(i))
- {
- ++myIsRaceDetected;
- }
- }
- }
-
- const std::vector<TopoDS_Shape>* myShapeVec;
- mutable std::atomic<int> myIsRaceDetected;
-};
-
-//=======================================================================
-// function : OCC25545
-// purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
-//=======================================================================
-
-static Standard_Integer OCC25545(Draw_Interpretor& /*di*/, Standard_Integer, const char**)
-{
- // Place vertices in a vector, giving the i-th vertex the
- // transformation that translates it on the vector (i,0,0) from the origin.
- Standard_Integer n = 1000;
- std::vector<TopoDS_Shape> aShapeVec(n);
- std::vector<TopLoc_Location> aLocVec(n);
- TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex(gp::Origin());
- aShapeVec[0] = aShape;
- for (Standard_Integer i = 1; i < n; ++i)
- {
- gp_Trsf aT;
- aT.SetTranslation(gp_Vec(1, 0, 0));
- aLocVec[i] = aLocVec[i - 1] * aT;
- aShapeVec[i] = aShape.Moved(aLocVec[i]);
- }
-
- // Evaluator function will access vertices geometry
- // concurrently
- OCC25545_Functor aFunc(aShapeVec);
-
- // concurrently process
- OSD_Parallel::For(0, n, aFunc);
-
- QVERIFY(!aFunc.myIsRaceDetected);
- return 0;
-}
-
-//=================================================================================================
-
-#include <BRepMesh_GeomTool.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepAdaptor_Surface.hxx>
-
-static Standard_Integer OCC25547(Draw_Interpretor& theDI,
- Standard_Integer /*argc*/,
- const char** /*argv*/)
-{
- // The general aim of this test is to prevent linkage errors due to missed
- // Standard_EXPORT attribute for static methods.
-
- // However, start checking the main functionality at first.
- const Standard_Real aFirstP = 0., aLastP = M_PI;
- Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
- Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
- TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
- BRepAdaptor_Curve aAdaptor(aEdge);
- BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
-
- if (aGeomTool.NbPoints() == 0)
- {
- theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
- return 1;
- }
-
- // Test static methods.
- TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
- BRepAdaptor_Surface aSurf(aFace);
- Handle(BRepAdaptor_Surface) aHSurf = new BRepAdaptor_Surface(aSurf);
-
- gp_Pnt aPnt;
- gp_Dir aNormal;
- if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
- {
- theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
- return 1;
- }
-
- gp_XY aRefPnts[4] = {gp_XY(-10., -10.), gp_XY(10., 10.), gp_XY(-10., 10.), gp_XY(10., -10.)};
-
- gp_Pnt2d aIntPnt;
- Standard_Real aParams[2];
- BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(aRefPnts[0],
- aRefPnts[1],
- aRefPnts[2],
- aRefPnts[3],
- aIntPnt.ChangeCoord(),
- aParams);
-
- Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
- if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
- {
- theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
- return 1;
- }
-
- aIntFlag = BRepMesh_GeomTool::IntSegSeg(aRefPnts[0],
- aRefPnts[1],
- aRefPnts[2],
- aRefPnts[3],
- Standard_False,
- Standard_False,
- aIntPnt);
-
- aDiff = aIntPnt.Distance(gp::Origin2d());
- if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
- {
- theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
- return 1;
- }
-
- theDI << "Test complete\n";
- return 0;
-}
-
static Standard_Integer OCC26139(Draw_Interpretor& theDI, Standard_Integer argc, const char** argv)
{
return 0;
}
-static Standard_Integer OCC26448(Draw_Interpretor& theDI, Standard_Integer, const char**)
-{
- TColStd_SequenceOfReal aSeq1, aSeq2;
- aSeq1.Append(11.);
- aSeq1.Prepend(aSeq2);
- theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
-
- NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
- nSeq1.Append(11.);
- nSeq1.Prepend(nSeq2);
- theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";
-
- theDI << "OK";
- return 0;
-}
-
//=================================================================================================
+#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
#include <TCollection_AsciiString.hxx>
}
#include <BRepOffsetAPI_DraftAngle.hxx>
-#include <vector>
static TopoDS_Shape taper(const TopoDS_Shape& shape,
const TopoDS_Face& face_a,
return 0;
}
-#include <math_FRPR.hxx>
-#include <math_BFGS.hxx>
-
-//=======================================================================
-// function : OCC30492
-// purpose : BFGS and FRPR fail if starting point is exactly the minimum.
-//=======================================================================
-// Function is:
-// f(x) = x^2
-class SquareFunction : public math_MultipleVarFunctionWithGradient
-{
-public:
- SquareFunction() {}
-
- virtual Standard_Integer NbVariables() const { return 1; }
-
- virtual Standard_Boolean Value(const math_Vector& X, Standard_Real& F)
- {
- const Standard_Real x = X(1);
- F = x * x;
-
- return Standard_True;
- }
-
- virtual Standard_Boolean Gradient(const math_Vector& X, math_Vector& G)
- {
- const Standard_Real x = X(1);
- G(1) = 2 * x;
-
- return Standard_True;
- }
-
- virtual Standard_Boolean Values(const math_Vector& X, Standard_Real& F, math_Vector& G)
- {
- Value(X, F);
- Gradient(X, G);
-
- return Standard_True;
- }
-
-private:
-};
-
-static Standard_Integer OCC30492(Draw_Interpretor& /*theDI*/,
- Standard_Integer /*theNArg*/,
- const char** /*theArgs*/)
-{
- SquareFunction aFunc;
- math_Vector aStartPnt(1, 1);
- aStartPnt(1) = 0.0;
-
- // BFGS and FRPR fail when if starting point is exactly the minimum.
- math_FRPR aFRPR(aFunc, Precision::Confusion());
- aFRPR.Perform(aFunc, aStartPnt);
- if (!aFRPR.IsDone())
- std::cout << "OCC30492: Error: FRPR optimization is not done." << std::endl;
- else
- std::cout << "OCC30492: OK: FRPR optimization is done." << std::endl;
-
- math_BFGS aBFGS(1, Precision::Confusion());
- aBFGS.Perform(aFunc, aStartPnt);
- if (!aBFGS.IsDone())
- std::cout << "OCC30492: Error: BFGS optimization is not done." << std::endl;
- else
- std::cout << "OCC30492: OK: BFGS optimization is done." << std::endl;
-
- return 0;
-}
-
//=================================================================================================
void QABugs::Commands_19(Draw_Interpretor& theCommands)
group);
theCommands.Add("OCC230", "OCC230 TrimmedCurve Pnt2d Pnt2d", __FILE__, OCC230, group);
- theCommands.Add("OCC23595", "OCC23595", __FILE__, OCC23595, group);
theCommands.Add("OCC22611", "OCC22611 string nb", __FILE__, OCC22611, group);
theCommands.Add("OCC23774", "OCC23774 shape1 shape2", __FILE__, OCC23774, group);
theCommands.Add("OCC23683", "OCC23683 shape", __FILE__, OCC23683, group);
__FILE__,
OCC24667,
group);
- theCommands.Add("OCC24755", "OCC24755", __FILE__, OCC24755, group);
theCommands.Add("OCC24834", "OCC24834", __FILE__, OCC24834, group);
- theCommands.Add("OCC24889", "OCC24889", __FILE__, OCC24889, group);
theCommands.Add("OCC23951", "OCC23951 path to saved step file", __FILE__, OCC23951, group);
theCommands.Add("OCC24931", "OCC24931 path to saved xml file", __FILE__, OCC24931, group);
theCommands.Add("OCC23950", "OCC23950 step_file", __FILE__, OCC23950, group);
theCommands.Add("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
theCommands.Add("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
theCommands.Add("OCC25340", "OCC25340", __FILE__, OCC25340, group);
- theCommands.Add("OCC25348", "OCC25348", __FILE__, OCC25348, group);
theCommands.Add("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
theCommands.Add("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
- theCommands.Add("OCC25545",
- "no args; tests data race when concurrently accessing \n"
- "\t\tTopLoc_Location::Transformation()",
- __FILE__,
- OCC25545,
- group);
- theCommands.Add("OCC25547", "OCC25547", __FILE__, OCC25547, group);
theCommands.Add("OCC24881", "OCC24881 shape", __FILE__, OCC24881, group);
theCommands.Add("xprojponf", "xprojponf p f", __FILE__, xprojponf, group);
theCommands.Add("OCC24923", "OCC24923", __FILE__, OCC24923, group);
group);
theCommands.Add("OCC26284", "OCC26284", __FILE__, OCC26284, group);
theCommands.Add("OCC26446", "OCC26446 r c1 c2", __FILE__, OCC26446, group);
- theCommands.Add("OCC26448",
- "OCC26448: check method Prepend() of sequence",
- __FILE__,
- OCC26448,
- group);
theCommands.Add("OCC26407", "OCC26407 result_name", __FILE__, OCC26407, group);
theCommands.Add("OCC26485", "OCC26485 shape", __FILE__, OCC26485, group);
theCommands.Add("OCC26553", "OCC26553 file_path", __FILE__, OCC26553, group);
__FILE__,
OCC29412,
group);
- theCommands.Add(
- "OCC30492",
- "OCC30492: Checks whether BFGS and FRPR fail when starting point is exact minimum.",
- __FILE__,
- OCC30492,
- group);
return;
}
return 0;
}
-namespace AllocTest
-{
-// The test is based of occupying of all available virtual memory.
-// Obviously it has no sense on 64-bit platforms.
-
-enum AllocTestStatus
-{
- NotApplicable = 0x1,
- OUMCatchOK = 0x2,
- OUMCatchFail = 0x4
-};
-
-template <int>
-int test()
-{
- // non-32-bit implementation
- return NotApplicable;
-}
-
-template <>
-int test<4>()
-{
- // 32-bit implementation
- NCollection_List<Standard_Address> aList;
- const Standard_Integer aBlockSizes[] = {100000, 10000, 10};
- int aStatus = 0;
-
- // start populate memory with blocks of large size, then
- // smaller ones and so on according to content of the array aBlockSizes
- for (size_t i = 0; i < sizeof(aBlockSizes) / sizeof(int); i++)
- {
- try
- {
- for (;;)
- aList.Append(Standard::Allocate(aBlockSizes[i]));
- }
- catch (Standard_Failure const&)
- {
- aStatus |= OUMCatchOK;
- }
- catch (...)
- {
- aStatus |= OUMCatchFail;
- break;
- }
- }
- // release all allocated blocks
- for (NCollection_List<Standard_Address>::Iterator it(aList); it.More(); it.Next())
- {
- Standard::Free(it.Value());
- }
- return aStatus;
-}
-} // namespace AllocTest
-
-//=================================================================================================
-
-static Standard_Integer OCC24836(Draw_Interpretor& theDI, Standard_Integer n, const char** a)
-{
- if (n != 1)
- {
- theDI << "Usage : " << a[0] << "\n";
- return 1;
- }
-
- int aStatus = AllocTest::test<sizeof(size_t)>();
-
- if (aStatus & AllocTest::NotApplicable)
- theDI << "This test case is not applicable for 64-bit and higher platforms\n";
- if (aStatus & AllocTest::OUMCatchOK)
- theDI << "out-of-memory has been caught: OK\n";
- if (aStatus & AllocTest::OUMCatchFail)
- theDI << "Error: out-of-memory is not always caught\n";
- return 0;
-}
-
//=======================================================================
// function : OCC27021
// purpose : Tests performance of obtaining geometry (points) via topological
#include "Geom2d_BezierCurve.hxx"
#include "Geom2dGcc_QualifiedCurve.hxx"
#include "Geom2dAdaptor_Curve.hxx"
-#include "Geom2dAPI_ProjectPointOnCurve.hxx"
-#include "Geom2dGcc_Circ2d2TanOn.hxx"
-
-//=================================================================================================
-
-static Standard_Integer OCC27357(Draw_Interpretor& theDI, Standard_Integer, const char**)
-{
- TColgp_Array1OfPnt2d aPoles(1, 3);
- aPoles.SetValue(1, gp_Pnt2d(0., 0.));
- aPoles.SetValue(2, gp_Pnt2d(0., 1.));
- aPoles.SetValue(3, gp_Pnt2d(6., 0.));
-
- Handle(Geom2d_BezierCurve) aCurve1 = new Geom2d_BezierCurve(aPoles);
- aPoles.SetValue(2, gp_Pnt2d(0., 1.5));
- Handle(Geom2d_BezierCurve) aCurve2 = new Geom2d_BezierCurve(aPoles);
- NCollection_List<Standard_Integer> aDuumyList;
- int nP = 100;
- for (int i = 0; i < nP; i++)
- {
- Standard_Real u = i / (nP - 1.);
- gp_Pnt2d aP1;
- gp_Vec2d aTangent;
- aCurve1->D1(u, aP1, aTangent);
- gp_Vec2d aNormal(-aTangent.Y(), aTangent.X());
- Handle(Geom2d_Line) normalLine = new Geom2d_Line(aP1, gp_Dir2d(aNormal));
- Geom2dGcc_QualifiedCurve qualifiedC1(Geom2dAdaptor_Curve(aCurve1), GccEnt_unqualified);
- Geom2dGcc_QualifiedCurve qualifiedC2(Geom2dAdaptor_Curve(aCurve2), GccEnt_unqualified);
-
- try
- {
- Geom2dAPI_ProjectPointOnCurve projPc1(aP1, aCurve1);
- double g1 = projPc1.LowerDistanceParameter();
- Geom2dAPI_ProjectPointOnCurve projPc3(aP1, normalLine);
- double g3 = projPc3.LowerDistanceParameter();
- Geom2dGcc_Circ2d2TanOn
- aCircleBuilder(qualifiedC1, qualifiedC2, Geom2dAdaptor_Curve(normalLine), 1e-9, g1, g1, g3);
- aDuumyList.Append(aCircleBuilder.NbSolutions());
- }
- catch (Standard_Failure const&)
- {
- theDI << "Exception was caught\n";
- }
- }
- return 0;
-}
#include <Standard_ErrorHandler.hxx>
#include <GeomFill_NSections.hxx>
return 0;
}
-#include "BRepBuilderAPI_MakeWire.hxx"
-#include "BRepBuilderAPI_MakeEdge.hxx"
-
-static Standard_Integer OCC27552(Draw_Interpretor&, Standard_Integer, const char**)
-{
- BRep_Builder BB;
- TopoDS_Vertex V1, V2, V3;
- TopoDS_Edge E1, E2;
- BB.MakeVertex(V1, gp_Pnt(0, 0, 0), 0.1);
- BB.MakeVertex(V2, gp_Pnt(5, 0, 0), 0.1);
- BB.MakeVertex(V3, gp_Pnt(10, 0, 0), 0.1);
- E1 = BRepBuilderAPI_MakeEdge(V1, V2).Edge();
- E2 = BRepBuilderAPI_MakeEdge(V2, V3).Edge();
- BRepBuilderAPI_MakeWire MW;
- MW.Add(E1);
- MW.Add(E2);
- TopoDS_Vertex V4, V5, V6, V7;
- TopoDS_Edge E3, E4;
- BB.MakeVertex(V4, gp_Pnt(10, 0 + 0.05, 0), 0.07);
- BB.MakeVertex(V5, gp_Pnt(10, 0 - 0.05, 0), 0.07);
- BB.MakeVertex(V6, gp_Pnt(10, 0 + 2, 0), 0.07);
- BB.MakeVertex(V7, gp_Pnt(10, 0 - 2, 0), 0.07);
- E3 = BRepBuilderAPI_MakeEdge(V4, V6).Edge();
- E4 = BRepBuilderAPI_MakeEdge(V5, V7).Edge();
- TopTools_ListOfShape LLE;
- LLE.Append(E3);
- LLE.Append(E4);
- MW.Add(LLE);
- TopoDS_Shape W = MW.Wire();
- DBRep::Set("outw", W);
-
- return 0;
-}
-
#include <NCollection_IncAllocator.hxx>
static Standard_Integer OCC27875(Draw_Interpretor& theDI,
return 0;
}
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepClass_FaceClassifier.hxx>
static Standard_Integer OCC27884(Draw_Interpretor& theDI,
#include <BRepPrimAPI_MakeBox.hxx>
-static Standard_Integer OCC30704(Draw_Interpretor& di, Standard_Integer, const char**)
-{
- // Make a shape somewhere far from (0, 0, 0).
- BRepPrimAPI_MakeBox mkBox(gp_Pnt(100, 100, 100), 100, 100, 100);
- const TopoDS_Shape& box = mkBox.Shape();
-
- // Add a bounding box of a shape to a void bounding box.
- Bnd_OBB aVoidBox, aBox;
- BRepBndLib::AddOBB(box, aBox, Standard_False, Standard_False, Standard_False);
- aVoidBox.Add(aBox);
-
- // Print the center point of the bounding box.
- const gp_XYZ& center = aVoidBox.Center();
- di << center.X() << " " << center.Y() << " " << center.Z();
- return 0;
-}
-
-static Standard_Integer OCC30704_1(Draw_Interpretor& di, Standard_Integer, const char**)
-{
- // A point.
- gp_Pnt aP(100, 200, 300);
-
- // Add the point to a void bounding box.
- Bnd_OBB aVoidBox;
- aVoidBox.Add(aP);
-
- // Print the center point of the bounding box.
- const gp_XYZ& center = aVoidBox.Center();
- di << center.X() << " " << center.Y() << " " << center.Z();
- return 0;
-}
-
//=======================================================================
// function : OCC30990
// purpose : check consistency of implementation of cache in B-Spline surfaces
return 0;
}
-//=======================================================================
-// function : OCC31294
-// purpose : check list of shapes generated from shape, which is not any subshape
-// of input shape for prism algorithm
-//=======================================================================
-#include <BRepPrimAPI_MakePrism.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-
-static Standard_Integer OCC31294(Draw_Interpretor& di, Standard_Integer, const char**)
-{
- BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(0., 0., 0.));
- BRepBuilderAPI_MakeVertex mkDummy(gp_Pnt(0., 0., 0.));
- BRepPrimAPI_MakePrism mkPrism(mkVert.Shape(), gp_Vec(0., 0., 1.));
-
- Standard_Integer nbgen = mkPrism.Generated(mkVert.Shape()).Extent();
- Standard_Integer nbdummy = mkPrism.Generated(mkDummy.Shape()).Extent();
-
- if (nbgen != 1 || nbdummy != 0)
- {
- di << "Error: wrong generated list \n";
- }
-
- return 0;
-}
-
#include <ExprIntrp_GenExp.hxx>
#include <Expr_GeneralExpression.hxx>
#include <Expr_NamedUnknown.hxx>
const char* group = "QABugs";
theCommands.Add("OCC26675_1", "OCC26675_1 result", __FILE__, SurfaceGenOCC26675_1, group);
- theCommands.Add("OCC24836", "OCC24836", __FILE__, OCC24836, group);
theCommands.Add("OCC27021", "OCC27021", __FILE__, OCC27021, group);
theCommands.Add("OCC27235", "OCC27235", __FILE__, OCC27235, group);
theCommands.Add("OCC26930", "OCC26930", __FILE__, OCC26930, group);
theCommands.Add("OCC26747_1", "OCC26747_1 result", __FILE__, OCC26747_1, group);
theCommands.Add("OCC26747_2", "OCC26747_2 result", __FILE__, OCC26747_2, group);
theCommands.Add("OCC26747_3", "OCC26747_3 result", __FILE__, OCC26747_3, group);
- theCommands.Add("OCC27357", "OCC27357", __FILE__, OCC27357, group);
theCommands.Add("OCC26270", "OCC26270 shape result", __FILE__, OCC26270, group);
- theCommands.Add("OCC27552", "OCC27552", __FILE__, OCC27552, group);
theCommands.Add("OCC27875", "OCC27875 curve", __FILE__, OCC27875, group);
theCommands.Add("OCC27884",
"OCC27884: Possible improvement for 2d classifier",
OCC30880,
group);
- theCommands.Add("OCC30704", "OCC30704", __FILE__, OCC30704, group);
- theCommands.Add("OCC30704_1", "OCC30704_1", __FILE__, OCC30704_1, group);
- theCommands.Add("OCC31294", "OCC31294", __FILE__, OCC31294, group);
-
theCommands.Add("OCC31697", "OCC31697 expression variable", __FILE__, OCC31697, group);
theCommands.Add(
// commercial license or contractual agreement.
#include <Bnd_OBB.hxx>
+#include <BRepBndLib.hxx>
+#include <BRepPrimAPI_MakeBox.hxx>
#include <gp_Pnt.hxx>
#include <TColgp_Array1OfPnt.hxx>
// Should not throw exception when rebuilding with points
EXPECT_NO_THROW(aBndBox.ReBuild(aPoints, (const TColStd_Array1OfReal*)0, true));
}
+
+TEST(Bnd_OBB_Test, OCC30704_AddBoundingBoxToVoidBox)
+{
+ // Bug OCC30704: Oriented bounding box (Bnd_OBB) gives a wrong result
+ // if a box is added to a void box
+ // This test verifies that adding a bounding box to a void bounding box
+ // correctly sets the center of the void box
+
+ // Make a shape somewhere far from (0, 0, 0)
+ BRepPrimAPI_MakeBox aMkBox(gp_Pnt(100, 100, 100), 100, 100, 100);
+ const TopoDS_Shape& aBox = aMkBox.Shape();
+
+ // Add a bounding box of a shape to a void bounding box
+ Bnd_OBB aVoidBox, aOBB;
+ BRepBndLib::AddOBB(aBox, aOBB, Standard_False, Standard_False, Standard_False);
+ aVoidBox.Add(aOBB);
+
+ // Check the center point of the bounding box
+ const gp_XYZ& aCenter = aVoidBox.Center();
+ EXPECT_DOUBLE_EQ(aCenter.X(), 150.0);
+ EXPECT_DOUBLE_EQ(aCenter.Y(), 150.0);
+ EXPECT_DOUBLE_EQ(aCenter.Z(), 150.0);
+}
+
+TEST(Bnd_OBB_Test, OCC30704_AddPointToVoidBox)
+{
+ // Bug OCC30704: Oriented bounding box (Bnd_OBB) gives a wrong result
+ // if a point is added to a void box
+ // This test verifies that adding a point to a void bounding box
+ // correctly sets the center of the void box to that point
+
+ // A point
+ gp_Pnt aP(100, 200, 300);
+
+ // Add the point to a void bounding box
+ Bnd_OBB aVoidBox;
+ aVoidBox.Add(aP);
+
+ // Check the center point of the bounding box
+ const gp_XYZ& aCenter = aVoidBox.Center();
+ EXPECT_DOUBLE_EQ(aCenter.X(), 100.0);
+ EXPECT_DOUBLE_EQ(aCenter.Y(), 200.0);
+ EXPECT_DOUBLE_EQ(aCenter.Z(), 300.0);
+}
// commercial license or contractual agreement.
#include <math_BFGS.hxx>
+#include <math_FRPR.hxx>
#include <math_MultipleVarFunctionWithGradient.hxx>
#include <math_Vector.hxx>
EXPECT_NEAR(anOptimizer.Location()(1), 1.0, 1.0e-6) << "Each should find correct X minimum";
EXPECT_NEAR(anOptimizer.Location()(2), 2.0, 1.0e-6) << "Each should find correct Y minimum";
}
+}
+
+// Simple 1D square function: f(x) = x^2 (minimum at x=0, value = 0)
+class SquareFunction1D : public math_MultipleVarFunctionWithGradient
+{
+public:
+ SquareFunction1D() {}
+
+ Standard_Integer NbVariables() const override { return 1; }
+
+ Standard_Boolean Value(const math_Vector& theX, Standard_Real& theF) override
+ {
+ if (theX.Length() != 1)
+ return Standard_False;
+ const Standard_Real x = theX(1);
+ theF = x * x;
+ return Standard_True;
+ }
+
+ Standard_Boolean Gradient(const math_Vector& theX, math_Vector& theG) override
+ {
+ if (theX.Length() != 1 || theG.Length() != 1)
+ return Standard_False;
+ const Standard_Real x = theX(1);
+ theG(1) = 2.0 * x;
+ return Standard_True;
+ }
+
+ Standard_Boolean Values(const math_Vector& theX, Standard_Real& theF, math_Vector& theG) override
+ {
+ return Value(theX, theF) && Gradient(theX, theG);
+ }
+};
+
+TEST(MathBFGSTest, OCC30492_StartingPointAtMinimum)
+{
+ // Bug OCC30492: BFGS and FRPR fail if starting point is exactly the minimum
+ // Test that both BFGS and FRPR work correctly when the starting point is at the minimum
+ SquareFunction1D aFunc;
+ math_Vector aStartPnt(1, 1);
+ aStartPnt(1) = 0.0; // Start exactly at the minimum
+
+ // Test FRPR
+ math_FRPR aFRPR(aFunc, Precision::Confusion());
+ aFRPR.Perform(aFunc, aStartPnt);
+ EXPECT_TRUE(aFRPR.IsDone()) << "FRPR optimization should succeed when starting at minimum";
+
+ // Test BFGS
+ math_BFGS aBFGS(1, Precision::Confusion());
+ aBFGS.Perform(aFunc, aStartPnt);
+ EXPECT_TRUE(aBFGS.IsDone()) << "BFGS optimization should succeed when starting at minimum";
+
+ // Verify that both found the minimum (or stayed at it)
+ if (aFRPR.IsDone())
+ {
+ EXPECT_NEAR(aFRPR.Location()(1), 0.0, Precision::Confusion())
+ << "FRPR should stay at/find the minimum";
+ EXPECT_NEAR(aFRPR.Minimum(), 0.0, Precision::Confusion())
+ << "FRPR should report minimum value of 0";
+ }
+
+ if (aBFGS.IsDone())
+ {
+ EXPECT_NEAR(aBFGS.Location()(1), 0.0, Precision::Confusion())
+ << "BFGS should stay at/find the minimum";
+ EXPECT_NEAR(aBFGS.Minimum(), 0.0, Precision::Confusion())
+ << "BFGS should report minimum value of 0";
+ }
}
\ No newline at end of file
set(OCCT_TKernel_GTests_FILES
Handle_Advanced_Test.cxx
Handle_Operations_Test.cxx
+ Message_Messenger_Test.cxx
NCollection_Array1_Test.cxx
NCollection_Array2_Test.cxx
NCollection_BaseAllocator_Test.cxx
Standard_Atomic_Test.cxx
Standard_Character_Test.cxx
Standard_Dump_Test.cxx
+ Standard_Failure_Test.cxx
+ Standard_GUID_Test.cxx
Standard_Handle_Test.cxx
TCollection_AsciiString_Test.cxx
TCollection_ExtendedString_Test.cxx
+ TopLoc_Location_Test.cxx
UnitsAPI_Test.cxx
)
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Message_Messenger.hxx>
+#include <Message_Printer.hxx>
+#include <Message.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <gtest/gtest.h>
+
+#include <sstream>
+
+namespace
+{
+//! Custom message printer that collects messages into a string stream
+class TestMessagePrinter : public Message_Printer
+{
+public:
+ TestMessagePrinter(std::ostringstream& theStream)
+ : myStream(theStream)
+ {
+ }
+
+ virtual void send(const TCollection_AsciiString& theString,
+ const Message_Gravity theGravity) const override
+ {
+ if (theGravity >= Message_Info)
+ {
+ myStream << theString << "\n";
+ }
+ }
+
+private:
+ std::ostringstream& myStream;
+};
+} // namespace
+
+TEST(Message_Messenger_Test, OCC31189_StreamBufferMessageOrdering)
+{
+ // Bug OCC31189: Test consistency of messages output using stream buffer interface
+ // Verify that messages sent via stream buffers and directly to messenger don't intermix
+
+ std::ostringstream anOutput;
+ Handle(TestMessagePrinter) aPrinter = new TestMessagePrinter(anOutput);
+ const Handle(Message_Messenger)& aMsgMgr = ::Message::DefaultMessenger();
+
+ // Save original printers
+ Message_SequenceOfPrinters anOriginalPrinters;
+ anOriginalPrinters.Append(aMsgMgr->ChangePrinters());
+
+ // Replace with our test printer
+ aMsgMgr->ChangePrinters().Clear();
+ aMsgMgr->AddPrinter(aPrinter);
+
+ // Scope block to test output of message on destruction of a stream buffer
+ {
+ Message_Messenger::StreamBuffer aSender = ::Message::SendInfo();
+
+ // Check that messages output to sender and directly to messenger do not intermix
+ aSender << "Sender message 1: start ...";
+ aMsgMgr->Send("Direct message 1");
+ aSender << "... end" << std::endl; // endl should send the message
+
+ // Check that empty stream buffer does not produce output on destruction
+ ::Message::SendInfo();
+
+ // Additional message to check that they go in expected order
+ aMsgMgr->Send("Direct message 2");
+
+ // Check that empty stream buffer does produce empty line if std::endl is passed
+ ::Message::SendInfo() << std::endl;
+
+ // Last message should be sent on destruction of a sender
+ aSender << "Sender message 2";
+ }
+
+ // Restore original printers
+ aMsgMgr->ChangePrinters().Clear();
+ aMsgMgr->ChangePrinters().Append(anOriginalPrinters);
+
+ // Verify the output matches expected format
+ std::string anOutputStr = anOutput.str();
+
+ // Expected messages in order:
+ // 1. Direct message 1
+ // 2. Sender message 1: start ...... end
+ // 3. Direct message 2
+ // 4. Empty line
+ // 5. Sender message 2
+ EXPECT_NE(anOutputStr.find("Direct message 1"), std::string::npos)
+ << "Direct message 1 should be present";
+ EXPECT_NE(anOutputStr.find("Sender message 1: start ...... end"), std::string::npos)
+ << "Sender message 1 should be complete and present";
+ EXPECT_NE(anOutputStr.find("Direct message 2"), std::string::npos)
+ << "Direct message 2 should be present";
+ EXPECT_NE(anOutputStr.find("Sender message 2"), std::string::npos)
+ << "Sender message 2 should be present";
+
+ // Verify order: Direct 1 should come before Sender 1
+ size_t aDirect1Pos = anOutputStr.find("Direct message 1");
+ size_t aSender1Pos = anOutputStr.find("Sender message 1");
+ size_t aDirect2Pos = anOutputStr.find("Direct message 2");
+ size_t aSender2Pos = anOutputStr.find("Sender message 2");
+
+ EXPECT_LT(aDirect1Pos, aSender1Pos) << "Direct message 1 should appear before Sender message 1";
+ EXPECT_LT(aSender1Pos, aDirect2Pos) << "Sender message 1 should appear before Direct message 2";
+ EXPECT_LT(aDirect2Pos, aSender2Pos) << "Direct message 2 should appear before Sender message 2";
+}
+
+TEST(Message_Messenger_Test, StreamBufferBasicUsage)
+{
+ // Test basic stream buffer functionality
+ std::ostringstream anOutput;
+ Handle(TestMessagePrinter) aPrinter = new TestMessagePrinter(anOutput);
+ const Handle(Message_Messenger)& aMsgMgr = Message::DefaultMessenger();
+
+ Message_SequenceOfPrinters anOriginalPrinters;
+ anOriginalPrinters.Append(aMsgMgr->ChangePrinters());
+
+ aMsgMgr->ChangePrinters().Clear();
+ aMsgMgr->AddPrinter(aPrinter);
+ {
+ Message_Messenger::StreamBuffer aBuffer = Message::SendInfo();
+ aBuffer << "Test message" << std::endl;
+ }
+
+ aMsgMgr->ChangePrinters().Clear();
+ aMsgMgr->ChangePrinters().Append(anOriginalPrinters);
+
+ std::string anOutputStr = anOutput.str();
+ EXPECT_NE(anOutputStr.find("Test message"), std::string::npos)
+ << "Stream buffer should output message";
+}
// commercial license or contractual agreement.
#include <NCollection_List.hxx>
+#include <NCollection_IncAllocator.hxx>
#include <Standard_Integer.hxx>
#include <gtest/gtest.h>
std::replace(aStdList.begin(), aStdList.end(), aTargetValue, aNewValue);
EXPECT_TRUE(std::equal(aList.begin(), aList.end(), aStdList.begin()));
+}
+
+TEST_F(NCollection_ListTest, OCC25348_AssignDoesNotChangeAllocator)
+{
+ // Bug OCC25348: Method Assign of NCollection containers must not change
+ // own allocator of the target
+ // This test verifies that calling Assign() doesn't change the allocator
+ // of the target list
+
+ Handle(NCollection_IncAllocator) anAlloc1 = new NCollection_IncAllocator();
+ NCollection_List<int> aList1(anAlloc1);
+
+ // Perform multiple assign operations with different source lists,
+ // each having their own allocator
+ for (int i = 0; i < 10; i++)
+ {
+ Handle(NCollection_IncAllocator) anAlloc2 = new NCollection_IncAllocator();
+ NCollection_List<int> aList2(anAlloc2);
+ aList2.Append(i);
+
+ // Store the allocator before Assign
+ Handle(NCollection_BaseAllocator) anAllocBefore = aList1.Allocator();
+
+ // Assign aList2 to aList1
+ aList1.Assign(aList2);
+
+ // Verify that the allocator of aList1 hasn't changed
+ Handle(NCollection_BaseAllocator) anAllocAfter = aList1.Allocator();
+ EXPECT_EQ(anAllocBefore, anAllocAfter) << "Assign() should not change the target's allocator";
+
+ // Verify the content was copied correctly
+ EXPECT_EQ(1, aList1.Size());
+ EXPECT_EQ(i, aList1.First());
+ }
}
\ No newline at end of file
#include <NCollection_Sequence.hxx>
#include <NCollection_IncAllocator.hxx>
#include <NCollection_BaseAllocator.hxx>
+#include <TColStd_SequenceOfReal.hxx>
#include <gtest/gtest.h>
#include <algorithm>
std::reverse(aStdList.begin(), aStdList.end());
EXPECT_TRUE(std::equal(aSequence.begin(), aSequence.end(), aStdList.begin()));
+}
+
+TEST(NCollection_SequenceTest, OCC26448_PrependEmptySequence)
+{
+ // Bug OCC26448: Method Prepend() of sequence breaks it if argument is empty sequence
+ // This test verifies that prepending an empty sequence doesn't affect the target sequence
+
+ // Test with NCollection_Sequence
+ NCollection_Sequence<Standard_Real> aNSeq1, aNSeq2;
+ aNSeq1.Append(11.);
+ aNSeq1.Prepend(aNSeq2); // Prepend empty sequence
+ EXPECT_EQ(aNSeq1.Size(), 1);
+ EXPECT_DOUBLE_EQ(aNSeq1.First(), 11.0);
+
+ // Test with TColStd_SequenceOfReal
+ TColStd_SequenceOfReal aTSeq1, aTSeq2;
+ aTSeq1.Append(11.);
+ aTSeq1.Prepend(aTSeq2); // Prepend empty sequence
+ EXPECT_EQ(aTSeq1.Size(), 1);
+ EXPECT_DOUBLE_EQ(aTSeq1.First(), 11.0);
}
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Standard_OutOfRange.hxx>
+
+#include <gtest/gtest.h>
+
+#include <sstream>
+
+TEST(Standard_Failure_Test, OCC670_ExceptionWithoutMessage)
+{
+ // Bug OCC670: Problem with the Print method
+ // This test verifies that an exception initialized without a message string
+ // can be safely handled and printed
+
+ bool aCaught = false;
+ try
+ {
+ throw Standard_OutOfRange("test");
+ }
+ catch (Standard_Failure const& anException)
+ {
+ aCaught = true;
+
+ // Verify that the exception can be safely printed
+ std::ostringstream aStream;
+ EXPECT_NO_THROW(aStream << anException);
+
+ // Verify that printing produced some output
+ std::string aMessage = aStream.str();
+ EXPECT_FALSE(aMessage.empty()) << "Exception message should not be empty";
+ }
+
+ EXPECT_TRUE(aCaught) << "Exception should have been caught";
+}
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Standard_GUID.hxx>
+
+#include <Standard_Failure.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(Standard_GUID_Test, OCC669_ValidGUIDConstruction)
+{
+ // Bug OCC669: Standard_GUID(HoleFeature) cause stack overwrite
+ // This test verifies that Standard_GUID correctly parses various valid GUID strings
+ // with hex digits (0-9, a-f, A-F) in different positions
+
+ // Test GUIDs with uppercase hex digits A-F
+ EXPECT_NO_THROW(Standard_GUID("0000000A-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000B-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000C-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000D-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000E-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000F-0000-0000-0000-000000000000"));
+
+ // Test GUIDs with lowercase hex digits a-f
+ EXPECT_NO_THROW(Standard_GUID("0000000a-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000b-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000c-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000d-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000e-0000-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("0000000f-0000-0000-0000-000000000000"));
+
+ // Test hex digits in second group
+ EXPECT_NO_THROW(Standard_GUID("00000000-000A-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-000F-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-000a-0000-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-000f-0000-0000-000000000000"));
+
+ // Test hex digits in third group
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-000A-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-000F-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-000a-0000-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-000f-0000-000000000000"));
+
+ // Test hex digits in fourth group
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-000A-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-000F-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-000a-000000000000"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-000f-000000000000"));
+
+ // Test hex digits in fifth group
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000A"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000F"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000a"));
+ EXPECT_NO_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000f"));
+}
+
+TEST(Standard_GUID_Test, OCC669_InvalidGUIDConstruction)
+{
+ // Test that invalid GUID strings throw exceptions or fail gracefully
+ // Invalid characters (G/g instead of valid hex)
+ EXPECT_THROW(Standard_GUID("0000000G-0000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("0000000g-0000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-000G-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-000g-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-000G-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-000g-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-000G-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-000g-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000G"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000g"), Standard_Failure);
+
+ // Invalid formats - wrong lengths
+ EXPECT_THROW(Standard_GUID("000000000000000000000000000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("0000000000000000000000000000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000000000000000000000000000000"), Standard_Failure);
+
+ // Invalid formats - wrong group lengths
+ EXPECT_THROW(Standard_GUID("0000000000000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-000000000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-000000000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-00000000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("000000000-0000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("0000000-0000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-00000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-000-0000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-00000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-000-0000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-00000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-000-000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-0000-0000000000000"), Standard_Failure);
+ EXPECT_THROW(Standard_GUID("00000000-0000-0000-0000-00000000000"), Standard_Failure);
+
+ // Empty string
+ EXPECT_THROW(Standard_GUID(""), Standard_Failure);
+}
+
+TEST(Standard_GUID_Test, OCC669_GUIDFormatting)
+{
+ // Test that a valid GUID can be constructed and formatted back to a string
+ Standard_GUID aGUID1("00000000-0000-0000-0000-000000000000");
+ Standard_GUID aGUID2("0000000A-000B-000C-000D-00000000000E");
+ Standard_GUID aGUID3("0000000a-000b-000c-000d-00000000000e");
+
+ // Verify that GUIDs with the same string representation are equal
+ Standard_GUID aGUID4("0000000A-000B-000C-000D-00000000000E");
+ EXPECT_EQ(aGUID2, aGUID4);
+
+ // Verify that uppercase and lowercase hex digits create equal GUIDs
+ EXPECT_EQ(aGUID2, aGUID3);
+
+ // Verify that different GUIDs are not equal
+ EXPECT_NE(aGUID1, aGUID2);
+}
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <TopLoc_Location.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRep_Tool.hxx>
+#include <gp.hxx>
+#include <gp_Trsf.hxx>
+#include <gp_Vec.hxx>
+#include <gp_Pnt.hxx>
+#include <OSD_Parallel.hxx>
+
+#include <gtest/gtest.h>
+
+#include <atomic>
+#include <vector>
+
+namespace
+{
+//! Functor for testing concurrent access to TopLoc_Location::Transformation()
+struct TopLocTransformFunctor
+{
+ TopLocTransformFunctor(const std::vector<TopoDS_Shape>& theShapeVec)
+ : myShapeVec(&theShapeVec),
+ myIsRaceDetected(0)
+ {
+ }
+
+ void operator()(size_t i) const
+ {
+ if (!myIsRaceDetected)
+ {
+ const TopoDS_Vertex& aVertex = TopoDS::Vertex(myShapeVec->at(i));
+ gp_Pnt aPoint = BRep_Tool::Pnt(aVertex);
+ if (aPoint.X() != static_cast<double>(i))
+ {
+ ++myIsRaceDetected;
+ }
+ }
+ }
+
+ const std::vector<TopoDS_Shape>* myShapeVec;
+ mutable std::atomic<int> myIsRaceDetected;
+};
+} // namespace
+
+TEST(TopLoc_Location_Test, OCC25545_ConcurrentTransformationAccess)
+{
+ // Bug OCC25545: TopLoc_Location::Transformation() provokes data races
+ // This test verifies that concurrent access to TopLoc_Location::Transformation()
+ // does not cause data races or incorrect geometry results
+
+ // Place vertices in a vector, giving the i-th vertex the
+ // transformation that translates it on the vector (i,0,0) from the origin
+ Standard_Integer n = 1000;
+ std::vector<TopoDS_Shape> aShapeVec(n);
+ std::vector<TopLoc_Location> aLocVec(n);
+ TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex(gp::Origin());
+ aShapeVec[0] = aShape;
+
+ for (Standard_Integer i = 1; i < n; ++i)
+ {
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation(gp_Vec(1, 0, 0));
+ aLocVec[i] = aLocVec[i - 1] * aTrsf;
+ aShapeVec[i] = aShape.Moved(aLocVec[i]);
+ }
+
+ // Evaluator function will access vertices geometry concurrently
+ TopLocTransformFunctor aFunc(aShapeVec);
+
+ // Process concurrently
+ OSD_Parallel::For(0, n, aFunc);
+
+ // Verify no data race was detected
+ EXPECT_EQ(aFunc.myIsRaceDetected, 0)
+ << "Data race detected in concurrent TopLoc_Location::Transformation() access";
+}
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Expr_GeneralExpression.hxx>
+#include <Expr_NamedUnknown.hxx>
+#include <ExprIntrp_GenExp.hxx>
+#include <TCollection_AsciiString.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(Expr_GeneralExpression_Test, OCC902_ExpressionDerivative)
+{
+ // Bug OCC902: Bad derivative computation
+ // This test verifies that the derivative of Exp(5*x) is correctly computed
+ // The expected result is either "Exp(5*x)*5" or "5*Exp(5*x)"
+
+ TCollection_AsciiString anExpStr("5");
+ anExpStr.AssignCat("*x");
+ anExpStr.Prepend("Exp(");
+ anExpStr.AssignCat(")");
+
+ Handle(ExprIntrp_GenExp) anExprIntrp = ExprIntrp_GenExp::Create();
+
+ // Create the expression
+ anExprIntrp->Process(anExpStr);
+
+ ASSERT_TRUE(anExprIntrp->IsDone()) << "Expression interpretation should succeed";
+
+ Handle(Expr_GeneralExpression) anExpr = anExprIntrp->Expression();
+ ASSERT_FALSE(anExpr.IsNull()) << "Expression should not be null";
+
+ Handle(Expr_NamedUnknown) aVar = new Expr_NamedUnknown("x");
+ Handle(Expr_GeneralExpression) aNewExpr = anExpr->Derivative(aVar);
+
+ ASSERT_FALSE(aNewExpr.IsNull()) << "Derivative should not be null";
+
+ TCollection_AsciiString aDerivativeStr = aNewExpr->String();
+
+ // The derivative of Exp(5*x) should be either "Exp(5*x)*5" or "5*Exp(5*x)"
+ bool isCorrect = (aDerivativeStr == "Exp(5*x)*5") || (aDerivativeStr == "5*Exp(5*x)");
+
+ EXPECT_TRUE(isCorrect) << "Derivative result was: " << aDerivativeStr.ToCString()
+ << ", expected either 'Exp(5*x)*5' or '5*Exp(5*x)'";
+}
set(OCCT_TKExpress_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKExpress_GTests_FILES
+ Expr_GeneralExpression_Test.cxx
)
set(OCCT_TKGeomAlgo_GTests_FILES
Geom2dAPI_InterCurveCurve_Test.cxx
+ Geom2dGcc_Circ2d3Tan_Test.cxx
GeomFill_CorrectedFrenet_Test.cxx
GeomPlate_BuildPlateSurface_Test.cxx
)
\ No newline at end of file
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Geom2dAdaptor_Curve.hxx>
+#include <Geom2dGcc_Circ2d3Tan.hxx>
+#include <Geom2dGcc_QualifiedCurve.hxx>
+#include <Geom2d_CartesianPoint.hxx>
+#include <Geom2d_Circle.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <Geom_Circle.hxx>
+#include <GeomAPI.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Pln.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(Geom2dGcc_Circ2d3Tan_Test, OCC353_TangentCircleDoesNotHang)
+{
+ // Bug OCC353: Attached DRAW command hangs in Geom2dGcc_Circ2d3Tan
+ // This test verifies that computing a circle tangent to two circles and
+ // passing through a point doesn't hang
+
+ // Create two 3D circles
+ gp_Ax2 anAx21(gp_Pnt(100, 0, 0), gp_Dir(gp::DZ()));
+ Handle(Geom_Circle) aCirc1 = new Geom_Circle(anAx21, 25);
+
+ gp_Ax2 anAx22(gp_Pnt(-100, 0, 0), gp_Dir(gp::DZ()));
+ Handle(Geom_Circle) aCirc2 = new Geom_Circle(anAx22, 25);
+
+ // Reference plane for 2D projection
+ gp_Pln aRefPln(gp_Pnt(0, 0, 0), gp_Dir(gp::DZ()));
+
+ // Convert 3D circles to 2D
+ Handle(Geom2d_Curve) aCirc2d1 = GeomAPI::To2d(aCirc1, aRefPln);
+ Handle(Geom2d_Curve) aCirc2d2 = GeomAPI::To2d(aCirc2, aRefPln);
+
+ // Create adaptors
+ Geom2dAdaptor_Curve anAdap1(aCirc2d1);
+ Geom2dAdaptor_Curve anAdap2(aCirc2d2);
+
+ // Create qualified curves (enclosing)
+ Geom2dGcc_QualifiedCurve aQCur1(anAdap1, GccEnt_enclosing);
+ Geom2dGcc_QualifiedCurve aQCur2(anAdap2, GccEnt_enclosing);
+
+ // Create a 2D point
+ gp_Pnt2d aPt2d(0, 175);
+ Handle(Geom2d_CartesianPoint) aPt = new Geom2d_CartesianPoint(aPt2d);
+
+ // Compute tangent circle - this should not hang
+ Geom2dGcc_Circ2d3Tan aSol(aQCur1, aQCur2, aPt, 0.001, 0.0, 0.0);
+
+ // Verify that the computation completed successfully
+ EXPECT_TRUE(aSol.IsDone()) << "Geom2dGcc_Circ2d3Tan computation should complete";
+
+ // Verify that we have solutions
+ if (aSol.IsDone())
+ {
+ Standard_Integer aNbSol = aSol.NbSolutions();
+ EXPECT_GT(aNbSol, 0) << "Should find at least one solution";
+
+ // Verify that we can access the solutions
+ for (Standard_Integer i = 1; i <= aNbSol; i++)
+ {
+ EXPECT_NO_THROW(aSol.ThisSolution(i)) << "Should be able to access solution " << i;
+ }
+ }
+}
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <BRepAdaptor_Curve.hxx>
+#include <BRepAdaptor_Surface.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepMesh_GeomTool.hxx>
+#include <Geom_Circle.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <Precision.hxx>
+#include <gp_Ax2.hxx>
+#include <gp_Pln.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(BRepMesh_GeomTool_Test, OCC25547_StaticMethodsExportAndFunctionality)
+{
+ // Bug OCC25547: static class methods not exported in BRepMesh_GeomTool
+ // This test verifies that BRepMesh_GeomTool static methods are properly exported
+ // and functional
+
+ // Test 1: Discretize an arc
+ const Standard_Real aFirstP = 0., aLastP = M_PI;
+ Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
+ Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
+ TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(aHalf);
+ BRepAdaptor_Curve anAdaptor(anEdge);
+ BRepMesh_GeomTool aGeomTool(anAdaptor, aFirstP, aLastP, 0.1, 0.5);
+
+ EXPECT_GT(aGeomTool.NbPoints(), 0) << "BRepMesh_GeomTool failed to discretize an arc";
+
+ // Test 2: Test Normal() static method
+ TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
+ BRepAdaptor_Surface aSurf(aFace);
+ Handle(BRepAdaptor_Surface) aHSurf = new BRepAdaptor_Surface(aSurf);
+
+ gp_Pnt aPnt;
+ gp_Dir aNormal;
+ Standard_Boolean isNormalComputed = BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal);
+
+ EXPECT_TRUE(isNormalComputed) << "BRepMesh_GeomTool failed to compute a normal of surface";
+
+ // Test 3: Test IntLinLin() static method - line-line intersection
+ gp_XY aRefPnts[4] = {gp_XY(-10., -10.), gp_XY(10., 10.), gp_XY(-10., 10.), gp_XY(10., -10.)};
+
+ gp_Pnt2d anIntPnt;
+ Standard_Real aParams[2];
+ BRepMesh_GeomTool::IntFlag anIntFlag = BRepMesh_GeomTool::IntLinLin(aRefPnts[0],
+ aRefPnts[1],
+ aRefPnts[2],
+ aRefPnts[3],
+ anIntPnt.ChangeCoord(),
+ aParams);
+
+ Standard_Real aDiff = anIntPnt.Distance(gp::Origin2d());
+ EXPECT_EQ(anIntFlag, BRepMesh_GeomTool::Cross)
+ << "BRepMesh_GeomTool::IntLinLin should return Cross flag";
+ EXPECT_LE(aDiff, Precision::PConfusion())
+ << "BRepMesh_GeomTool failed to intersect two lines at origin";
+
+ // Test 4: Test IntSegSeg() static method - segment-segment intersection
+ anIntFlag = BRepMesh_GeomTool::IntSegSeg(aRefPnts[0],
+ aRefPnts[1],
+ aRefPnts[2],
+ aRefPnts[3],
+ Standard_False,
+ Standard_False,
+ anIntPnt);
+
+ aDiff = anIntPnt.Distance(gp::Origin2d());
+ EXPECT_EQ(anIntFlag, BRepMesh_GeomTool::Cross)
+ << "BRepMesh_GeomTool::IntSegSeg should return Cross flag";
+ EXPECT_LE(aDiff, Precision::PConfusion())
+ << "BRepMesh_GeomTool failed to intersect two segments at origin";
+}
set(OCCT_TKMesh_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKMesh_GTests_FILES
+ BRepMesh_GeomTool_Test.cxx
)
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepPrimAPI_MakePrism.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Vec.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(BRepPrimAPI_MakePrism_Test, OCC31294_GeneratedListForNonBaseShape)
+{
+ // Bug OCC31294: Modeling Algorithms - Regression relatively 7.3.0.
+ // Crash in method BRepPrimAPI_MakePrism::Generated(...) if input sub-shape
+ // does not belong to the base shape
+ //
+ // This test verifies that calling Generated() with a shape that doesn't belong
+ // to the base shape doesn't crash and returns an empty list
+
+ BRepBuilderAPI_MakeVertex aMkVert(gp_Pnt(0., 0., 0.));
+ BRepBuilderAPI_MakeVertex aMkDummy(gp_Pnt(0., 0., 0.));
+ BRepPrimAPI_MakePrism aMkPrism(aMkVert.Shape(), gp_Vec(0., 0., 1.));
+
+ // Check that Generated() returns 1 shape for the vertex used to create the prism
+ Standard_Integer aNbGen = aMkPrism.Generated(aMkVert.Shape()).Extent();
+ EXPECT_EQ(aNbGen, 1);
+
+ // Check that Generated() returns 0 shapes for a vertex not used to create the prism
+ // (this should not crash)
+ Standard_Integer aNbDummy = aMkPrism.Generated(aMkDummy.Shape()).Extent();
+ EXPECT_EQ(aNbDummy, 0);
+}
set(OCCT_TKPrim_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKPrim_GTests_FILES
+ BRepPrimAPI_MakePrism_Test.cxx
)
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <gp_Pnt.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(BRepBuilderAPI_MakeWire_Test, OCC27552_AddEdgesAndListOfEdges)
+{
+ // Bug OCC27552: Wire creation fails depending on the order of edges
+ // This test verifies that BRepBuilderAPI_MakeWire can successfully add
+ // edges individually and as a list
+
+ BRep_Builder aBB;
+ TopoDS_Vertex aV1, aV2, aV3;
+ TopoDS_Edge anE1, anE2;
+
+ // Create vertices
+ aBB.MakeVertex(aV1, gp_Pnt(0, 0, 0), 0.1);
+ aBB.MakeVertex(aV2, gp_Pnt(5, 0, 0), 0.1);
+ aBB.MakeVertex(aV3, gp_Pnt(10, 0, 0), 0.1);
+
+ // Create edges
+ anE1 = BRepBuilderAPI_MakeEdge(aV1, aV2).Edge();
+ anE2 = BRepBuilderAPI_MakeEdge(aV2, aV3).Edge();
+
+ // Build wire with individually added edges
+ BRepBuilderAPI_MakeWire aMW;
+ EXPECT_NO_THROW(aMW.Add(anE1));
+ EXPECT_NO_THROW(aMW.Add(anE2));
+
+ // Create additional vertices and edges for list test
+ TopoDS_Vertex aV4, aV5, aV6, aV7;
+ TopoDS_Edge anE3, anE4;
+ aBB.MakeVertex(aV4, gp_Pnt(10, 0.05, 0), 0.07);
+ aBB.MakeVertex(aV5, gp_Pnt(10, -0.05, 0), 0.07);
+ aBB.MakeVertex(aV6, gp_Pnt(10, 2, 0), 0.07);
+ aBB.MakeVertex(aV7, gp_Pnt(10, -2, 0), 0.07);
+
+ anE3 = BRepBuilderAPI_MakeEdge(aV4, aV6).Edge();
+ anE4 = BRepBuilderAPI_MakeEdge(aV5, aV7).Edge();
+
+ // Add edges as a list
+ TopTools_ListOfShape aListOfEdges;
+ aListOfEdges.Append(anE3);
+ aListOfEdges.Append(anE4);
+
+ EXPECT_NO_THROW(aMW.Add(aListOfEdges));
+
+ // Verify wire was created successfully
+ EXPECT_TRUE(aMW.IsDone()) << "Wire builder should complete successfully";
+ TopoDS_Wire aWire = aMW.Wire();
+ EXPECT_FALSE(aWire.IsNull()) << "Resulting wire should not be null";
+}
set(OCCT_TKTopAlgo_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
set(OCCT_TKTopAlgo_GTests_FILES
+ BRepBuilderAPI_MakeWire_Test.cxx
BRepLib_MakeWire_Test.cxx
BRepOffsetAPI_ThruSections_Test.cxx
)
Geom2d_BSplineCurve_Test.cxx
Geom2d_BezierCurve_Test.cxx
Geom2d_OffsetCurve_Test.cxx
+ Geom2dAPI_InterCurveCurve_Test.cxx
+ Geom2dGcc_Circ2d2TanOn_Test.cxx
Geom2dGcc_Circ2d2TanRad_Test.cxx
)
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Geom2d_Circle.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dAPI_InterCurveCurve.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <Precision.hxx>
+#include <gp_Ax22d.hxx>
+#include <gp_Dir2d.hxx>
+#include <gp_Pnt2d.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(Geom2dAPI_InterCurveCurve_Test, OCC24889_IntersectionParameterWithinLimits)
+{
+ // Bug OCC24889: Geom2dAPI_InterCurveCurve produces result with parameter outside the curve limits
+ // This test verifies that intersection parameters are within the curve parameter limits
+
+ // Create two circles
+ Handle(Geom2d_Circle) aCircle1 =
+ new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(25, -25), gp_Dir2d(gp_Dir2d::D::X), gp_Dir2d(-0, 1)), 155);
+
+ Handle(Geom2d_Circle) aCircle2 =
+ new Geom2d_Circle(gp_Ax22d(gp_Pnt2d(25, 25), gp_Dir2d(gp_Dir2d::D::X), gp_Dir2d(-0, 1)), 155);
+
+ // Create trimmed curves
+ Handle(Geom2d_TrimmedCurve) aTrim1 =
+ new Geom2d_TrimmedCurve(aCircle1, 1.57079632679490, 2.97959469729228);
+ Handle(Geom2d_TrimmedCurve) aTrim2 =
+ new Geom2d_TrimmedCurve(aCircle2, 3.30359060633978, 4.71238898038469);
+
+ // Perform intersection
+ constexpr Standard_Real aTol = Precision::Confusion();
+ Geom2dAPI_InterCurveCurve aIntTool(aTrim1, aTrim2, aTol);
+
+ ASSERT_GT(aIntTool.NbPoints(), 0) << "Intersection should find at least one point";
+
+ const IntRes2d_IntersectionPoint& aIntPnt = aIntTool.Intersector().Point(1);
+
+ Standard_Real aParOnC1 = aIntPnt.ParamOnFirst();
+ Standard_Real aParOnC2 = aIntPnt.ParamOnSecond();
+ Standard_Real aFirstPar1 = aTrim1->FirstParameter();
+ Standard_Real aLastPar1 = aTrim1->LastParameter();
+ Standard_Real aFirstPar2 = aTrim2->FirstParameter();
+ Standard_Real aLastPar2 = aTrim2->LastParameter();
+
+ // Verify that intersection parameters are within the curve limits
+ EXPECT_GE(aParOnC1, aFirstPar1) << "IntParameter on curve 1 (" << aParOnC1
+ << ") should be >= FirstParam (" << aFirstPar1 << ")";
+ EXPECT_LE(aParOnC1, aLastPar1) << "IntParameter on curve 1 (" << aParOnC1
+ << ") should be <= LastParam (" << aLastPar1 << ")";
+
+ EXPECT_GE(aParOnC2, aFirstPar2) << "IntParameter on curve 2 (" << aParOnC2
+ << ") should be >= FirstParam (" << aFirstPar2 << ")";
+ EXPECT_LE(aParOnC2, aLastPar2) << "IntParameter on curve 2 (" << aParOnC2
+ << ") should be <= LastParam (" << aLastPar2 << ")";
+
+ // Verify that both curves evaluate to the same point at the intersection parameters
+ gp_Pnt2d aP1 = aTrim1->Value(aParOnC1);
+ gp_Pnt2d aP2 = aTrim2->Value(aParOnC2);
+
+ Standard_Real aDist2 = aP1.SquareDistance(aP2);
+ EXPECT_LT(aDist2, 1.0e-14) << "Points on both curves at intersection parameters should coincide";
+}
--- /dev/null
+// Copyright (c) 2025 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.
+
+#include <Geom2d_BezierCurve.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2dAPI_ProjectPointOnCurve.hxx>
+#include <Geom2dGcc_Circ2d2TanOn.hxx>
+#include <Geom2dGcc_QualifiedCurve.hxx>
+#include <Geom2dAdaptor_Curve.hxx>
+#include <GccEnt.hxx>
+#include <NCollection_List.hxx>
+#include <TColgp_Array1OfPnt2d.hxx>
+#include <gp_Dir2d.hxx>
+#include <gp_Pnt2d.hxx>
+#include <gp_Vec2d.hxx>
+
+#include <gtest/gtest.h>
+
+TEST(Geom2dGcc_Circ2d2TanOn_Test, OCC27357_NoExceptions)
+{
+ // Bug OCC27357: Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
+ // This test verifies that the algorithm handles edge cases without throwing exceptions
+
+ TColgp_Array1OfPnt2d aPoles(1, 3);
+ aPoles.SetValue(1, gp_Pnt2d(0., 0.));
+ aPoles.SetValue(2, gp_Pnt2d(0., 1.));
+ aPoles.SetValue(3, gp_Pnt2d(6., 0.));
+
+ Handle(Geom2d_BezierCurve) aCurve1 = new Geom2d_BezierCurve(aPoles);
+ aPoles.SetValue(2, gp_Pnt2d(0., 1.5));
+ Handle(Geom2d_BezierCurve) aCurve2 = new Geom2d_BezierCurve(aPoles);
+ NCollection_List<Standard_Integer> aDummyList;
+ int nP = 100;
+
+ for (int i = 0; i < nP; i++)
+ {
+ Standard_Real u = i / (nP - 1.);
+ gp_Pnt2d aP1;
+ gp_Vec2d aTangent;
+ aCurve1->D1(u, aP1, aTangent);
+ gp_Vec2d aNormal(-aTangent.Y(), aTangent.X());
+ Handle(Geom2d_Line) aNormalLine = new Geom2d_Line(aP1, gp_Dir2d(aNormal));
+ Geom2dGcc_QualifiedCurve aQualifiedC1(Geom2dAdaptor_Curve(aCurve1), GccEnt_unqualified);
+ Geom2dGcc_QualifiedCurve aQualifiedC2(Geom2dAdaptor_Curve(aCurve2), GccEnt_unqualified);
+
+ // This should not throw an exception even in edge cases
+ EXPECT_NO_THROW({
+ Geom2dAPI_ProjectPointOnCurve aProjPc1(aP1, aCurve1);
+ double g1 = aProjPc1.LowerDistanceParameter();
+ Geom2dAPI_ProjectPointOnCurve aProjPc3(aP1, aNormalLine);
+ double g3 = aProjPc3.LowerDistanceParameter();
+ Geom2dGcc_Circ2d2TanOn aCircleBuilder(aQualifiedC1,
+ aQualifiedC2,
+ Geom2dAdaptor_Curve(aNormalLine),
+ 1e-9,
+ g1,
+ g1,
+ g3);
+ aDummyList.Append(aCircleBuilder.NbSolutions());
+ });
+ }
+
+ // Test completed without exceptions
+ SUCCEED();
+}
+++ /dev/null
-puts "==========="
-puts "OCC24755"
-puts "==========="
-
-pload QAcommands
-
-OCC24755
+++ /dev/null
-puts "All exceptions is OK"
-puts "TODO OCC12345 ALL: An exception was caught"
-
-puts "========"
-puts "0000669: Standard_GUID(HoleFeature) cause stack overwrite"
-puts "========"
-puts ""
-
-pload QAcommands
-
-set GoodGUIDList [list 00000000-0000-0000-0000-000000000000 \
- \
- 0000000A-0000-0000-0000-000000000000 \
- 0000000B-0000-0000-0000-000000000000 \
- 0000000C-0000-0000-0000-000000000000 \
- 0000000D-0000-0000-0000-000000000000 \
- 0000000E-0000-0000-0000-000000000000 \
- 0000000F-0000-0000-0000-000000000000 \
- \
- 0000000a-0000-0000-0000-000000000000 \
- 0000000b-0000-0000-0000-000000000000 \
- 0000000c-0000-0000-0000-000000000000 \
- 0000000d-0000-0000-0000-000000000000 \
- 0000000e-0000-0000-0000-000000000000 \
- 0000000f-0000-0000-0000-000000000000 \
- \
- 00000000-000A-0000-0000-000000000000 \
- 00000000-000B-0000-0000-000000000000 \
- 00000000-000C-0000-0000-000000000000 \
- 00000000-000D-0000-0000-000000000000 \
- 00000000-000E-0000-0000-000000000000 \
- 00000000-000F-0000-0000-000000000000 \
- \
- 00000000-000a-0000-0000-000000000000 \
- 00000000-000b-0000-0000-000000000000 \
- 00000000-000c-0000-0000-000000000000 \
- 00000000-000d-0000-0000-000000000000 \
- 00000000-000e-0000-0000-000000000000 \
- 00000000-000f-0000-0000-000000000000 \
- \
- 00000000-0000-000A-0000-000000000000 \
- 00000000-0000-000B-0000-000000000000 \
- 00000000-0000-000C-0000-000000000000 \
- 00000000-0000-000D-0000-000000000000 \
- 00000000-0000-000E-0000-000000000000 \
- 00000000-0000-000F-0000-000000000000 \
- \
- 00000000-0000-000a-0000-000000000000 \
- 00000000-0000-000b-0000-000000000000 \
- 00000000-0000-000c-0000-000000000000 \
- 00000000-0000-000d-0000-000000000000 \
- 00000000-0000-000e-0000-000000000000 \
- 00000000-0000-000f-0000-000000000000 \
- \
- 00000000-0000-0000-000A-000000000000 \
- 00000000-0000-0000-000B-000000000000 \
- 00000000-0000-0000-000C-000000000000 \
- 00000000-0000-0000-000D-000000000000 \
- 00000000-0000-0000-000E-000000000000 \
- 00000000-0000-0000-000F-000000000000 \
- \
- 00000000-0000-0000-000a-000000000000 \
- 00000000-0000-0000-000b-000000000000 \
- 00000000-0000-0000-000c-000000000000 \
- 00000000-0000-0000-000d-000000000000 \
- 00000000-0000-0000-000e-000000000000 \
- 00000000-0000-0000-000f-000000000000 \
- \
- 00000000-0000-0000-0000-00000000000A \
- 00000000-0000-0000-0000-00000000000B \
- 00000000-0000-0000-0000-00000000000C \
- 00000000-0000-0000-0000-00000000000D \
- 00000000-0000-0000-0000-00000000000E \
- 00000000-0000-0000-0000-00000000000F \
- \
- 00000000-0000-0000-0000-00000000000a \
- 00000000-0000-0000-0000-00000000000b \
- 00000000-0000-0000-0000-00000000000c \
- 00000000-0000-0000-0000-00000000000d \
- 00000000-0000-0000-0000-00000000000e \
- 00000000-0000-0000-0000-00000000000f ]
-
-set BadGUIDList [list \
- \
- 0000000G-0000-0000-0000-000000000000 \
- 0000000g-0000-0000-0000-000000000000 \
- \
- 00000000-000G-0000-0000-000000000000 \
- 00000000-000g-0000-0000-000000000000 \
- \
- 00000000-0000-000G-0000-000000000000 \
- 00000000-0000-000g-0000-000000000000 \
- \
- 00000000-0000-0000-000G-000000000000 \
- 00000000-0000-0000-000g-000000000000 \
- \
- 00000000-0000-0000-0000-00000000000G \
- 00000000-0000-0000-0000-00000000000g \
- \
- 000000000000000000000000000000000000 \
- 0000000000000000000000000000000000000 \
- 00000000000000000000000000000000000 \
- \
- 0000000000000-0000-0000-000000000000 \
- 00000000-000000000-0000-000000000000 \
- 00000000-0000-000000000-000000000000 \
- 00000000-0000-0000-00000000000000000 \
- \
- 000000000-0000-0000-0000-000000000000 \
- 0000000-0000-0000-0000-000000000000 \
- \
- 00000000-00000-0000-0000-000000000000 \
- 00000000-000-0000-0000-000000000000 \
- \
- 00000000-0000-00000-0000-000000000000 \
- 00000000-0000-000-0000-000000000000 \
- \
- 00000000-0000-0000-00000-000000000000 \
- 00000000-0000-0000-000-000000000000 \
- \
- 00000000-0000-0000-0000-0000000000000 \
- 00000000-0000-0000-0000-00000000000 \
- \
- "" ]
-
-set IsOK 1
-
-set i 0
-
-foreach GUID ${GoodGUIDList} {
- incr i
- if [catch { OCC669 ${GUID} }] then {
- set IsOK 0
- puts "GUID=\"${GUID}\""
- puts "Faulty OCC669 (case ${i})"
- } else {
- puts "OCC669 OK (case ${i})"
- }
-}
-
-
-foreach GUID ${BadGUIDList} {
- incr i
- if [catch { OCC669 ${GUID} }] then {
- puts "OCC669 OK (case ${i})"
- } else {
- set IsOK 0
- puts "GUID=\"${GUID}\""
- puts "Faulty OCC669 (case ${i})"
- }
-}
-
-if { ${IsOK} == 1} {
- puts "OCC669 OK"
-} else {
- puts "Faulty OCC669"
-}
-
+++ /dev/null
-puts "========"
-puts "OCC738"
-puts "========"
-puts ""
-###################################
-## The GUIDs in XCAFDoc have incorrect format.
-###################################
-
-pload QAcommands
-
-if [catch { OCC738_Assembly }] then {
- puts "Faulty OCC738"
-} else {
- puts "OCC738 OK"
-}
-
-
+++ /dev/null
-puts "========"
-puts "OCC738"
-puts "========"
-puts ""
-##################################
-##The GUIDs in XCAFDoc have incorrect format.
-##################################
-
-pload QAcommands
-
-if [catch { OCC738_ShapeRef }] then {
- puts "Faulty OCC738"
-} else {
- puts "OCC738 OK"
-}
-
-
+++ /dev/null
-puts "============"
-puts "OCC24836"
-puts "============"
-puts ""
-#######################################################################
-# Stack overflow when raising exception in low memory condition
-#######################################################################
-
-pload QAcommands
-
-OCC24836
+++ /dev/null
-puts "========"
-puts "OCC25348"
-puts "========"
-puts ""
-#######################################################################################
-# Method Assign of NCollection containers must not change own allocator of the target
-#######################################################################################
-
-pload QAcommands
-
-OCC25348
+++ /dev/null
-puts "============"
-puts "OCC25545"
-puts "============"
-puts ""
-#######################################################################
-# TopLoc_Location::Transformation() provokes data races
-#######################################################################
-
-pload QAcommands
-
-OCC25545
+++ /dev/null
-puts "============"
-puts "OCC26448"
-puts "============"
-puts ""
-#######################################################################
-# Method Prepend() of sequence breaks it if argument is empty sequence
-#######################################################################
-
-pload QAcommands
-OCC26448
+++ /dev/null
-puts "============"
-puts "0030492: Foundation Classes - math_BFGS fails if starting point is exactly the minimum"
-puts "============"
-puts ""
-
-pload QAcommands
-
-OCC30492
+++ /dev/null
-puts "# ============"
-puts "# 0031189: Draw Harness, ViewerTest - send messages to Message::DefaultMessenger()"
-puts "# ============"
-puts ""
-puts "# Test consistency of messages output using stream buffer interface"
-
-pload QAcommands
-set out [OCC31189]
-
-set expected {
- {Direct message 1}
- {Sender message 1: start ...... end}
- {Direct message 2}
- {}
- {Sender message 2}
-}
-
-if { [string compare [string trim $out] [join $expected "\n"]] } {
- puts "Error: output (see above) does not match expected one:"
- puts "[join $expected "\n"]"
- puts ""
-}
\ No newline at end of file
+++ /dev/null
-puts "========"
-puts "OCC670: Problem with the Print method."
-puts "========"
-puts ""
-
-pload QAcommands
-
-# Check that exception is handled and does not kill DRAWEXE (TEST COMPLETED)
-OCC670
-
-puts "OCC670 OK"
+++ /dev/null
-puts "======="
-puts "OCC902"
-puts "======="
-puts ""
-###############
-## bad derivative
-###############
-
-pload QAcommands
-
-set arg 5
-set list [OCC902 $arg]
-
-set we_have [lindex $list 8]
-puts "we_have = $we_have"
-
-set must_be_1 "Exp($arg*x)*$arg"
-puts "must_be_1 = $must_be_1"
-set must_be_2 "$arg*Exp($arg*x)"
-puts "must_be_2 = $must_be_2"
-
-if {[string compare $we_have $must_be_1] == 0} {
- puts "OCC902 OK"
-} else {
- if { [string compare $we_have $must_be_2] == 0} {
- puts "OCC902 OK"
- } else {
- puts "OCC902 Faulty"
- }
-}
-
+++ /dev/null
-puts "========="
-puts "CR25547"
-puts "========="
-puts ""
-###############################################
-# static class methods not exported in BrepMesh_GeomTool
-###############################################
-
-pload QAcommands
-
-OCC25547
+++ /dev/null
-puts "=========="
-puts "OCC24889"
-puts "=========="
-puts ""
-#####################################################################################
-# Geom2dAPI_InterCurveCurve produces result with parameter outside the curve limits
-#####################################################################################
-
-pload QAcommands
-
-set info [OCC24889]
-regexp {Curve 0: +FirstParam += +([-0-9.+eE]+); +LastParam += +([-0-9.+eE]+); +IntParameter += +([-0-9.+eE]+)} $info full first1 last1 intp1
-regexp {Curve 1: +FirstParam += +([-0-9.+eE]+); +LastParam += +([-0-9.+eE]+); +IntParameter += +([-0-9.+eE]+)} $info full first2 last2 intp2
-
-if { $intp1 >= $first1 && $intp1 <= $last1 } {
- puts "OK: IntParameter1 inside the curve limits"
-} else {
- puts "Error: IntParameter1 outside the curve limits"
-}
-
-if { $intp2 >= $first2 && $intp2 <= $last2 } {
- puts "OK: IntParameter2 inside the curve limits"
-} else {
- puts "Error: IntParameter2 outside the curve limits"
-}
-
-2dcvalue c_1 $intp1 xx1 yy1
-2dcvalue c_2 $intp2 xx2 yy2
-
-dump xx1 yy1
-dump xx2 yy2
-
-set dist_val [dval (xx1-xx2)*(xx1-xx2)+(yy1-yy2)*(yy1-yy2)]
-if { $dist_val < 1.0e-14 } {
- puts "OK: point distance is good"
-} else {
- puts "Error: point distance is wrong"
-}
+++ /dev/null
-puts "========"
-puts "OCC27357"
-puts "========"
-puts ""
-#################################################################
-# Geom2dGcc_Circ2d2TanOn: check status of sub-algorithms to avoid exceptions
-#################################################################
-
-pload QAcommands
-
-set info [OCC27357]
-if { [regexp "Exception" $info] != 0 } {
- puts "Error : Exception was caught"
-} else {
- puts "OK"
-}
+++ /dev/null
-puts "=========="
-puts "OCC27552"
-puts "=========="
-puts ""
-#######################################
-# Wire creation fails depending on the order of edges
-#######################################
-
-pload QAcommands
-OCC27552
-
-#outw is output wire
-checkshape outw
-checknbshapes outw -vertex 5 -edge 4
-nexplode outw v
-checkmaxtol outw_4 -ref 0.12
\ No newline at end of file
+++ /dev/null
-puts "======================================================="
-puts "0031294: Modeling Algorithms - Regression relatively 7.3.0."
-puts "Crash in method BRepPrimAPI_MakePrism::Generated(...) if input sub-shape does not belong to the base shape"
-puts "======================================================="
-puts ""
-
-pload QAcommands
-OCC31294
\ No newline at end of file
+++ /dev/null
-pload QAcommands
-
-puts "================"
-puts "OCC353"
-puts "================"
-puts ""
-##########################################################
-## Attached DRAW command hangs in Geom2dGcc_Circ2d3Tan.
-##########################################################
-
-if [catch { OCC353 }] {
- puts "OCC353: Error"
-} else {
- puts "OCC353: OK"
-}
-
+++ /dev/null
-puts "============"
-puts "0030704: Oriented bounding box (Bnd_OBB) gives a wrong result if a box is added to a void box"
-puts "============"
-
-pload QAcommands
-
-set ret1 [OCC30704]
-if { ${ret1} != "150 150 150" } {
- puts "Error: add bounding box to void bounding box"
-}
-
-set ret2 [OCC30704_1]
-if { ${ret2} != "100 200 300" } {
- puts "Error: add point to void bounding box"
-}
+++ /dev/null
-puts "============"
-puts "OCC23595"
-puts "============"
-puts ""
-#######################################################################
-# XCAFDoc_ShapeTool extended with two methods - SetAutoNaming() and AutoNaming()
-#######################################################################
-
-pload QAcommands
-
-OCC23595