mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-05-18 07:57:31 +08:00
Testing - Migrate QA DRAW tests to GTest (#818)
- Removed 37 DRAW test scripts from `tests/bugs/` directories - Added 31 new GTest C++ test files in appropriate `GTests/` directories - Removed corresponding QAcommands implementations from QABugs source files - Updated CMake FILES.cmake files to include new test files
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
// 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 <gtest/gtest.h>
|
||||
|
||||
#include <BRepAdaptor_CompCurve.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
|
||||
// Test OCC5696: BRepAdaptor_CompCurve::Edge() method
|
||||
// Migrated from QABugs_5.cxx
|
||||
TEST(BRepAdaptor_CompCurve_Test, OCC5696_EdgeMethod)
|
||||
{
|
||||
// Create a simple edge from two points
|
||||
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0, 0, 0), gp_Pnt(2, 0, 0));
|
||||
|
||||
// Create a wire from the edge
|
||||
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(anEdge);
|
||||
|
||||
// Create a composite curve adaptor
|
||||
BRepAdaptor_CompCurve aCurve(aWire);
|
||||
|
||||
// Get curve parameters
|
||||
Standard_Real aFirst = aCurve.FirstParameter();
|
||||
Standard_Real aLast = aCurve.LastParameter();
|
||||
Standard_Real aPar = (aFirst + aLast) / 2.0;
|
||||
|
||||
// Test the Edge() method
|
||||
Standard_Real aParEdge = 0.0;
|
||||
TopoDS_Edge anEdgeFound;
|
||||
|
||||
// The original test was checking that this method doesn't throw an exception
|
||||
// and returns valid parameter
|
||||
EXPECT_NO_THROW({ aCurve.Edge(aPar, anEdgeFound, aParEdge); })
|
||||
<< "Edge() method should not throw an exception";
|
||||
|
||||
// Verify that the returned edge is valid
|
||||
EXPECT_FALSE(anEdgeFound.IsNull()) << "Returned edge should not be null";
|
||||
|
||||
// Verify that the parameter is within valid range [0, edge length]
|
||||
EXPECT_GE(aParEdge, 0.0) << "Edge parameter should be non-negative";
|
||||
EXPECT_LE(aParEdge, 2.0) << "Edge parameter should not exceed edge length";
|
||||
|
||||
// The parameter should be approximately half of the edge length
|
||||
EXPECT_NEAR(1.0, aParEdge, 0.01) << "Edge parameter should be approximately 1.0";
|
||||
}
|
||||
@@ -2,4 +2,7 @@
|
||||
set(OCCT_TKBRep_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_TKBRep_GTests_FILES
|
||||
BRepAdaptor_CompCurve_Test.cxx
|
||||
TopoDS_Edge_Test.cxx
|
||||
TopoDS_Iterator_Test.cxx
|
||||
)
|
||||
|
||||
37
src/ModelingData/TKBRep/GTests/TopoDS_Edge_Test.cxx
Normal file
37
src/ModelingData/TKBRep/GTests/TopoDS_Edge_Test.cxx
Normal file
@@ -0,0 +1,37 @@
|
||||
// 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 <gtest/gtest.h>
|
||||
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
|
||||
// Test BUC60828: TopoDS_Edge Infinite flag getter/setter
|
||||
// Migrated from QABugs_16.cxx
|
||||
TEST(TopoDS_Edge_Test, BUC60828_InfiniteFlag)
|
||||
{
|
||||
// Create a simple edge
|
||||
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(gp_Pnt(0., 0., 0.), gp_Pnt(0., 0., 1.));
|
||||
|
||||
// Check initial flag value (should be false by default)
|
||||
Standard_Boolean anInitialValue = anEdge.Infinite();
|
||||
EXPECT_FALSE(anInitialValue) << "Initial Infinite flag should be false";
|
||||
|
||||
// Set the flag to true
|
||||
anEdge.Infinite(Standard_True);
|
||||
|
||||
// Verify the flag was set correctly
|
||||
Standard_Boolean aCurrentValue = anEdge.Infinite();
|
||||
EXPECT_TRUE(aCurrentValue) << "Infinite flag should be true after setting";
|
||||
}
|
||||
29
src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx
Normal file
29
src/ModelingData/TKBRep/GTests/TopoDS_Iterator_Test.cxx
Normal file
@@ -0,0 +1,29 @@
|
||||
// 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 <TopoDS_Iterator.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
TEST(TopoDS_Iterator_Test, OCC30708_1_InitializeWithNullShape)
|
||||
{
|
||||
TopoDS_Iterator it;
|
||||
TopoDS_Shape empty;
|
||||
|
||||
// Should not throw exception when initializing with null shape
|
||||
EXPECT_NO_THROW(it.Initialize(empty));
|
||||
|
||||
// More() should return false on null shape
|
||||
EXPECT_FALSE(it.More());
|
||||
}
|
||||
@@ -5,4 +5,5 @@ set(OCCT_TKG2d_GTests_FILES
|
||||
Geom2d_BSplineCurve_Test.cxx
|
||||
Geom2d_BezierCurve_Test.cxx
|
||||
Geom2d_OffsetCurve_Test.cxx
|
||||
Geom2dGcc_Circ2d2TanRad_Test.cxx
|
||||
)
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
// 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 <gtest/gtest.h>
|
||||
|
||||
#include <Geom2d_Ellipse.hxx>
|
||||
#include <Geom2dAdaptor_Curve.hxx>
|
||||
#include <Geom2dGcc_Circ2d2TanRad.hxx>
|
||||
#include <Geom2dGcc_QualifiedCurve.hxx>
|
||||
#include <GccEnt_Position.hxx>
|
||||
#include <gp_Circ2d.hxx>
|
||||
#include <gp_Elips2d.hxx>
|
||||
#include <gp_Pnt2d.hxx>
|
||||
|
||||
// Test OCC24303: Geom2dGcc_Circ2d2TanRad - Circle tangent to two ellipses
|
||||
// Migrated from QABugs_9.cxx
|
||||
TEST(Geom2dGcc_Circ2d2TanRad_Test, OCC24303_CircleTangentToTwoEllipses)
|
||||
{
|
||||
// Create two ellipses
|
||||
Standard_Real aMajorRadius = 2.0;
|
||||
Standard_Real aMinorRadius = 1.0;
|
||||
gp_Pnt2d aP0(gp::Origin2d());
|
||||
gp_Pnt2d aP1(4.0, 0.0);
|
||||
|
||||
gp_Elips2d anEllipse1 = gp_Elips2d(gp_Ax2d(aP0, gp::DX2d()), aMajorRadius, aMinorRadius, true);
|
||||
gp_Elips2d anEllipse2 = gp_Elips2d(gp_Ax2d(aP1, gp::DX2d()), aMajorRadius, aMinorRadius, true);
|
||||
|
||||
Handle(Geom2d_Curve) aCurve1 = new Geom2d_Ellipse(anEllipse1);
|
||||
Handle(Geom2d_Curve) aCurve2 = new Geom2d_Ellipse(anEllipse2);
|
||||
|
||||
// Expected tangent circle
|
||||
gp_Pnt2d aCentre(5.0, 0.0);
|
||||
Standard_Real aRadius = 3.0;
|
||||
gp_Circ2d aTheoricalTangent = gp_Circ2d(gp_Ax2d(aCentre, gp::DX2d()), aRadius);
|
||||
|
||||
// Calculate the tangent circles with Geom2dGcc_Circ2d2TanRad
|
||||
const Geom2dAdaptor_Curve anAdaptedCurve1(aCurve1);
|
||||
const Geom2dAdaptor_Curve anAdaptedCurve2(aCurve2);
|
||||
|
||||
GccEnt_Position aCurveQualif1 = GccEnt_unqualified;
|
||||
GccEnt_Position aCurveQualif2 = GccEnt_unqualified;
|
||||
|
||||
const Geom2dGcc_QualifiedCurve aQualifiedCurve1(anAdaptedCurve1, aCurveQualif1);
|
||||
const Geom2dGcc_QualifiedCurve aQualifiedCurve2(anAdaptedCurve2, aCurveQualif2);
|
||||
|
||||
const Geom2dGcc_Circ2d2TanRad aCircCalc(aQualifiedCurve1, aQualifiedCurve2, aRadius, 1.0e-9);
|
||||
|
||||
const Standard_Integer aNbSol = aCircCalc.NbSolutions();
|
||||
|
||||
// Verify that solutions were found
|
||||
EXPECT_GT(aNbSol, 0) << "Should find at least one solution";
|
||||
|
||||
// Check that all solutions have the correct radius
|
||||
for (Standard_Integer i = 1; i <= aNbSol; i++)
|
||||
{
|
||||
gp_Circ2d aCt = aCircCalc.ThisSolution(i);
|
||||
EXPECT_NEAR(aRadius, aCt.Radius(), 1.0e-6)
|
||||
<< "Solution " << i << " should have radius " << aRadius;
|
||||
}
|
||||
|
||||
// For the first solution, check the distance from theoretical tangent
|
||||
if (aNbSol > 0)
|
||||
{
|
||||
gp_Circ2d aCalculatedTangent = aCircCalc.ThisSolution(1);
|
||||
Standard_Real aDist = aTheoricalTangent.Location().Distance(aCalculatedTangent.Location());
|
||||
|
||||
// The distance should be relatively small (solutions should be close)
|
||||
// Note: The exact distance may vary depending on which solution is returned
|
||||
EXPECT_LT(aDist, 10.0) << "Distance from theoretical tangent should be reasonable";
|
||||
}
|
||||
}
|
||||
@@ -8,4 +8,6 @@ set(OCCT_TKG3d_GTests_FILES
|
||||
Geom_BSplineSurface_Test.cxx
|
||||
Geom_OffsetCurve_Test.cxx
|
||||
Geom_OffsetSurface_Test.cxx
|
||||
GeomAPI_ExtremaCurveCurve_Test.cxx
|
||||
GeomAPI_Interpolate_Test.cxx
|
||||
)
|
||||
|
||||
323
src/ModelingData/TKG3d/GTests/GeomAPI_ExtremaCurveCurve_Test.cxx
Normal file
323
src/ModelingData/TKG3d/GTests/GeomAPI_ExtremaCurveCurve_Test.cxx
Normal file
@@ -0,0 +1,323 @@
|
||||
// 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 <gtest/gtest.h>
|
||||
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
#include <Geom_TrimmedCurve.hxx>
|
||||
#include <GeomAPI_ExtremaCurveCurve.hxx>
|
||||
#include <TColgp_Array1OfPnt.hxx>
|
||||
#include <TColStd_Array1OfInteger.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
|
||||
// Test OCC862: GeomAPI_ExtremaCurveCurve - Extrema between BSpline and line
|
||||
TEST(GeomAPI_ExtremaCurveCurve_Test, OCC862_ExtremaBSplineAndLine)
|
||||
{
|
||||
// Define BSpline curve data (from Glob_Poles, Glob_Knots, Glob_Mults)
|
||||
const Standard_Integer aNbPoles = 195;
|
||||
const Standard_Real aPoles[195][3] = {
|
||||
{60000, 31.937047503393231, 799.36226142892554},
|
||||
{60000.000000027772, 16.712487623992825, 799.97053069028755},
|
||||
{59999.999999875639, 7.3723603687660546, 799.97042131653711},
|
||||
{60000.000000331296, 1.2070383839533065, 799.90534456032105},
|
||||
{59999.999999361171, -2.5807810139032785, 799.77442818789041},
|
||||
{60000.000000952597, -4.7405254527655112, 799.70146419719595},
|
||||
{59999.999998867599, -5.3922917628932563, 799.62943054158143},
|
||||
{60000.000001091154, -5.1399175234965044, 799.63364074172011},
|
||||
{59999.999999142601, -3.6992503431468067, 799.67179299415568},
|
||||
{60000.000000546061, -1.6910663098148713, 799.76799688166773},
|
||||
{59999.999999725333, 1.1886267067330731, 799.91818018455035},
|
||||
{60000.000000101914, 4.5979596894282677, 800.11782874041273},
|
||||
{59999.999999977204, 8.5921385739756673, 800.36980220999453},
|
||||
{60000.000000018619, 16.600658956791417, 800.90755378048414},
|
||||
{59999.999999985768, 26.040687605616604, 801.59827916977554},
|
||||
{60000.000000052918, 30.448324872994441, 801.9310695501531},
|
||||
{59999.999999883308, 35.089921752286457, 802.29194004854389},
|
||||
{60000.000000186978, 39.947755013962528, 802.68007678107051},
|
||||
{59999.99999976845, 45.005892525213071, 803.09465896567826},
|
||||
{60000.000000227068, 50.249778854659326, 803.53486876081706},
|
||||
{59999.999999821659, 55.665932960782108, 803.9998957687626},
|
||||
{60000.000000112479, 61.241734208767859, 804.48893829648762},
|
||||
{59999.999999943684, 66.965272918611916, 805.00120177704798},
|
||||
{60000.000000021486, 72.8252416954995, 805.53589657709654},
|
||||
{59999.99999999431, 78.810843745189473, 806.09223572876306},
|
||||
{60000.000000004045, 87.962119756404547, 806.95803383418911},
|
||||
{59999.99999999725, 97.349976765262795, 807.869010426567},
|
||||
{60000.000000017491, 100.50428991828356, 808.17759139897635},
|
||||
{59999.99999994829, 103.68239055379394, 808.49099684342912},
|
||||
{60000.000000105072, 106.88305649144334, 808.80912918631941},
|
||||
{59999.999999835563, 110.10508187457555, 809.13189073948308},
|
||||
{60000.000000207947, 113.34727572158297, 809.45918381767103},
|
||||
{59999.999999784653, 116.60846040037053, 809.79091039912782},
|
||||
{60000.000000180742, 119.88747020406682, 810.12697237079749},
|
||||
{59999.999999880296, 123.18314981484644, 810.46727114678265},
|
||||
{60000.000000059626, 126.49435287223255, 810.81170785335109},
|
||||
{59999.999999979838, 129.81994045902351, 811.16018308253979},
|
||||
{60000.000000015229, 134.8281992328765, 811.68880383859914},
|
||||
{59999.99999998945, 139.86373510893441, 812.2260602582727},
|
||||
{60000.000000059066, 141.54513692067022, 812.40609267860532},
|
||||
{59999.999999845008, 143.22928798266199, 812.58705944070834},
|
||||
{60000.000000278043, 144.91604799540772, 812.7689478797023},
|
||||
{59999.999999621934, 146.60527693312631, 812.95174532592102},
|
||||
{60000.000000407505, 148.29683501034282, 813.13543899059755},
|
||||
{59999.999999644526, 149.99058265886663, 813.32001613307352},
|
||||
{60000.000000252723, 151.68638048575326, 813.5054638442823},
|
||||
{59999.999999853622, 153.38408925794459, 813.69176926621947},
|
||||
{60000.000000068765, 155.08356985703421, 813.87891939578799},
|
||||
{59999.999999973967, 156.7846832610312, 814.06690122038856},
|
||||
{60000.00000002468, 159.33859412935516, 814.35010184114628},
|
||||
{59999.999999977736, 161.89555354531564, 814.63511466528189},
|
||||
{60000.000000145039, 162.74819471256941, 814.73031865086841},
|
||||
{59999.999999608634, 163.60113987644607, 814.82572069112655},
|
||||
{60000.000000709108, 164.45437167903589, 814.92131914784375},
|
||||
{59999.999999031643, 165.3078727497936, 815.0171123286641},
|
||||
{60000.000001042623, 166.16162573916125, 815.11309861889924},
|
||||
{59999.999999097396, 167.01561326831904, 815.20927628960794},
|
||||
{60000.000000630716, 167.86981798631649, 815.30564372626975},
|
||||
{59999.999999648215, 168.72422251240596, 815.40219920078994},
|
||||
{60000.000000151289, 169.57880948189478, 815.4989410625825},
|
||||
{59999.999999954052, 170.43356151298337, 815.5958676029403},
|
||||
{60000.000000034408, 171.71591108030151, 815.74153190228753},
|
||||
{59999.999999976135, 172.9985538007256, 815.88760410128577},
|
||||
{60000.000000129759, 173.42613177350728, 815.93633994702668},
|
||||
{59999.999999664251, 173.85373796967124, 815.98512067846866},
|
||||
{60000.00000060827, 174.28137021936112, 816.03394612011459},
|
||||
{59999.99999914426, 174.70902633885802, 816.08281598496671},
|
||||
{60000.000000969369, 175.13670416564241, 816.13173017155248},
|
||||
{59999.999999107844, 175.56440150794049, 816.18068832455049},
|
||||
{60000.00000066567, 175.9921162052986, 816.22969037578832},
|
||||
{59999.999999602165, 176.41984606692156, 816.27873598355484},
|
||||
{60000.00000018561, 176.84758892491178, 816.3278250228899},
|
||||
{59999.999999935775, 177.27534259516338, 816.37695722529566},
|
||||
{60000.000000054533, 177.91698605475608, 816.45071998561696},
|
||||
{59999.999999955864, 178.55864403901305, 816.52457892469988},
|
||||
{60000.000000281914, 178.7725313764083, 816.54920923644852},
|
||||
{59999.999999214248, 178.98641977813006, 816.57385016025694},
|
||||
{60000.000001492997, 179.20030898752373, 816.59850173903158},
|
||||
{59999.999997853804, 179.41419870083473, 816.62316380941468},
|
||||
{60000.000002424618, 179.62808869307457, 816.647836551757},
|
||||
{59999.999997816361, 179.84197863289955, 816.6725196831527},
|
||||
{60000.000001566797, 180.05586830671322, 816.69721343479125},
|
||||
{59999.999999121159, 180.26975739282756, 816.72191756454924},
|
||||
{60000.00000036486, 180.48364565146377, 816.74663219124841},
|
||||
{59999.999999904954, 180.69753279192835, 816.7713572079532},
|
||||
{60000.000000054562, 181.0183614269956, 816.8084603269557},
|
||||
{59999.999999978463, 181.33918632988278, 816.84558675379014},
|
||||
{60000.000000049782, 181.44612751539663, 816.85796481705847},
|
||||
{59999.999999914071, 181.55306821881811, 816.87034546240886},
|
||||
{60000.000000125139, 181.66000840292782, 816.88272868833144},
|
||||
{59999.999999843392, 181.76694804030186, 816.89511449082431},
|
||||
{60000.000000167289, 181.87388708628473, 816.90750286566583},
|
||||
{59999.999999847467, 181.98082551962966, 816.9198938103757},
|
||||
{60000.000000119864, 182.08776329350809, 816.93228732197861},
|
||||
{59999.999999917491, 182.19470038386558, 816.94468339453306},
|
||||
{60000.000000050633, 182.30163675019068, 816.9570820285785},
|
||||
{59999.999999972366, 182.40857236133851, 816.96948321649302},
|
||||
{60000.000000032509, 182.56897459276843, 816.98808882907122},
|
||||
{59999.999999965934, 182.7293749693155, 817.00670017517837},
|
||||
{60000.000000238462, 182.78284155215263, 817.01290459816312},
|
||||
{59999.999999345615, 182.83630791626743, 817.01910964099045},
|
||||
{60000.00000119608, 182.88977407140584, 817.02531535916364},
|
||||
{59999.999998362182, 182.94323998619015, 817.03152164472851},
|
||||
{60000.000001757064, 182.99670569682132, 817.03772865736005},
|
||||
{59999.999998499035, 183.05017115047181, 817.04393620474377},
|
||||
{60000.00000101691, 183.10363639052409, 817.05014447471717},
|
||||
{59999.999999469313, 183.15710137432194, 817.05635331513508},
|
||||
{60000.000000196254, 183.21056612270786, 817.06256282498509},
|
||||
{59999.999999961823, 183.26403061846696, 817.06877295237007},
|
||||
{60000.000000031148, 183.37095910597188, 817.0811944807366},
|
||||
{59999.999999975873, 183.47788656385964, 817.09361853568328},
|
||||
{60000.000000078871, 183.53291535756762, 817.10001332133618},
|
||||
{59999.999999822408, 183.57465447580566, 817.10486251586156},
|
||||
{60000.000000306398, 183.67093862701302, 817.11605868308925},
|
||||
{59999.999999580868, 183.62493711493508, 817.11070057755603},
|
||||
{60000.000000457883, 183.83983154073323, 817.13569840343439},
|
||||
{59999.999999600586, 183.70298550843307, 817.11977179379392},
|
||||
{60000.000000274122, 183.92091406059222, 817.14512405357789},
|
||||
{59999.999999859414, 183.87191278066462, 817.13941945054194},
|
||||
{60000.000000045809, 183.96882854112027, 817.15069318206758},
|
||||
{59999.99999999682, 184.01172713386404, 817.15568252551441},
|
||||
{60000.000000002117, 199.05860625274244, 818.90605990894926},
|
||||
{60000.000000011685, 213.77441984052732, 820.66779572748067},
|
||||
{59999.999999945896, 228.63273752574398, 822.50191665906459},
|
||||
{60000.000000137385, 243.60930053773387, 824.4160390659564},
|
||||
{59999.999999745312, 257.44864608947171, 826.20557537898253},
|
||||
{60000.000000371336, 272.37732017567259, 828.28374145687258},
|
||||
{59999.999999564294, 283.4609507719199, 829.76911975631128},
|
||||
{60000.000000411754, 297.87730027160165, 831.94635758332913},
|
||||
{59999.999999691667, 308.39894455125989, 833.48120705572103},
|
||||
{60000.000000175751, 321.04689540263291, 835.47802201470222},
|
||||
{59999.999999930937, 332.7974681685576, 837.36295119087083},
|
||||
{60000.000000012922, 344.23852019267594, 839.26003269871717},
|
||||
{59999.999999978521, 380.87159046869039, 845.50264944092885},
|
||||
{60000.000000031927, 417.67053058140004, 852.32838657260925},
|
||||
{59999.999999895757, 443.71876268540638, 857.33613824789597},
|
||||
{60000.00000023668, 470.42282907220516, 863.40925211937144},
|
||||
{59999.999999591026, 506.36442771103123, 868.70489233101273},
|
||||
{60000.000000559063, 504.29569767668107, 873.82665736030435},
|
||||
{59999.999999387175, 618.22680165126303, 889.69085497467483},
|
||||
{60000.00000054048, 520.96760954336719, 878.60259543512541},
|
||||
{59999.999999620944, 695.15397128954748, 909.33199431749756},
|
||||
{60000.000000202854, 652.21259368585868, 902.32746593221361},
|
||||
{59999.999999925931, 713.31441817738153, 914.25671409207371},
|
||||
{60000.000000011525, 744.93626878652026, 920.45067498376648},
|
||||
{59999.999999986139, 851.85145355849977, 941.08553924856312},
|
||||
{60000.000000015752, 955.13474569084099, 960.32812261133847},
|
||||
{59999.99999996031, 1019.9477908992111, 972.25457694191095},
|
||||
{60000.000000078573, 1109.7424197388102, 989.27219905591903},
|
||||
{59999.999999866697, 1103.4472241364576, 986.24901738812696},
|
||||
{60000.000000196575, 1283.5502566789903, 1025.857653448167},
|
||||
{59999.999999756859, 1241.170752696316, 1010.5034788173898},
|
||||
{60000.000000241002, 1380.0598100152401, 1044.321387312001},
|
||||
{59999.999999814674, 1417.3346489504095, 1047.4285724180056},
|
||||
{60000.000000106025, 1498.5882349740116, 1064.7148393296281},
|
||||
{59999.999999959189, 1562.4075471540843, 1076.5692870450682},
|
||||
{60000.000000006847, 1632.0446827427525, 1089.9951747091934},
|
||||
{59999.999999992855, 1819.187180960379, 1125.8766969823027},
|
||||
{60000.000000006774, 2005.7867190244558, 1161.6893152514506},
|
||||
{59999.999999993102, 2127.1610378717864, 1184.8982806691761},
|
||||
{59999.999999983789, 2224.9504474907289, 1204.7794295042536},
|
||||
{60000.000000076092, 2423.4034586285211, 1239.2849934128672},
|
||||
{59999.999999843334, 2352.5108743508281, 1233.9178625300717},
|
||||
{60000.00000021555, 2789.1958451831979, 1304.7841887599538},
|
||||
{59999.999999781059, 2516.5832651666447, 1267.6317850640198},
|
||||
{60000.000000168911, 2997.8479508975411, 1347.2273537129538},
|
||||
{59999.999999901927, 2872.9560675152225, 1329.8998228537541},
|
||||
{60000.000000040534, 3100.1634765888271, 1371.640798220885},
|
||||
{59999.999999990199, 3186.6552406648925, 1389.3336814233451},
|
||||
{60000.000000019143, 3570.5318534479206, 1462.8626017289478},
|
||||
{59999.999999969914, 3906.3811637172125, 1522.697974792497},
|
||||
{60000.000000105116, 4081.0496155485694, 1554.1195061318422},
|
||||
{59999.999999764274, 4440.4680391955444, 1682.9362787226369},
|
||||
{60000.000000389882, 4025.4579062184348, 1482.6543564450828},
|
||||
{59999.999999500047, 5340.2058728577267, 2096.5041911809035},
|
||||
{60000.000000509819, 4233.9915572764976, 1518.9299243967394},
|
||||
{59999.999999583706, 5430.8345183928068, 2200.8401562891845},
|
||||
{60000.000000267981, 5054.5402162751188, 1969.4793692255021},
|
||||
{59999.999999871681, 5428.966058504895, 2244.2141001944756},
|
||||
{60000.000000038024, 5546.4649349764723, 2352.3606428637349},
|
||||
{59999.999999998952, 5706.4753141683368, 2517.0835536242184},
|
||||
{59999.999999991771, 6129.2268892602051, 3030.8327236291348},
|
||||
{60000.000000020089, 6420.3065439166912, 3661.6495160497966},
|
||||
{59999.99999990526, 6235.8646808219391, 3444.1541944672813},
|
||||
{60000.000000247288, 8126.8536394010316, 8890.661747328244},
|
||||
{59999.99999954299, 2104.925285609057, -7996.1134321147983},
|
||||
{60000.00000064441, 14264.475617875083, 34652.739991203249},
|
||||
{59999.999999283253, -1684.3290491164355, -33238.811620330394},
|
||||
{60000.000000641696, 13782.902589951687, 46532.286752882486},
|
||||
{59999.999999532913, 2699.6074087223524, -19079.410940396814},
|
||||
{60000.000000275439, 9084.6892111341349, 21937.827319607131},
|
||||
{59999.999999871587, 6474.8937324409353, 5006.3713661893671},
|
||||
{60000.000000044485, 7350.4434791870981, 10709.698171043074},
|
||||
{59999.999999990541, 7306.414330937022, 10560.108503883888},
|
||||
{60000, 7397.0783263606427, 11218.963217145942}};
|
||||
|
||||
const Standard_Integer aNbKnots = 17;
|
||||
const Standard_Real aKnots[17] = {0,
|
||||
0.0087664292723375857,
|
||||
0.015654339342331427,
|
||||
0.019098294377328347,
|
||||
0.020820271894826808,
|
||||
0.021681260653576038,
|
||||
0.022111755032950653,
|
||||
0.022327002222637962,
|
||||
0.022434625817481617,
|
||||
0.022488437614903441,
|
||||
0.022542249412325268,
|
||||
0.037523693790797889,
|
||||
0.071526893170125505,
|
||||
0.1421299556831544,
|
||||
0.26514857375331263,
|
||||
0.51350664396810353,
|
||||
1};
|
||||
|
||||
const Standard_Integer aMults[17] =
|
||||
{15, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 15};
|
||||
|
||||
// Fill array of poles
|
||||
TColgp_Array1OfPnt aPolesArray(1, aNbPoles);
|
||||
for (Standard_Integer i = 0; i < aNbPoles; i++)
|
||||
{
|
||||
aPolesArray.SetValue(i + 1, gp_Pnt(aPoles[i][0], aPoles[i][1], aPoles[i][2]));
|
||||
}
|
||||
|
||||
// Fill array of knots
|
||||
TColStd_Array1OfReal aKnotsArray(1, aNbKnots);
|
||||
for (Standard_Integer i = 0; i < aNbKnots; i++)
|
||||
{
|
||||
aKnotsArray.SetValue(i + 1, aKnots[i]);
|
||||
}
|
||||
|
||||
// Fill array of mults
|
||||
TColStd_Array1OfInteger aMultsArray(1, aNbKnots);
|
||||
for (Standard_Integer i = 0; i < aNbKnots; i++)
|
||||
{
|
||||
aMultsArray.SetValue(i + 1, aMults[i]);
|
||||
}
|
||||
|
||||
// Create B-Spline curve
|
||||
const Standard_Integer aDegree = 14;
|
||||
Handle(Geom_BSplineCurve) aC1 =
|
||||
new Geom_BSplineCurve(aPolesArray, aKnotsArray, aMultsArray, aDegree);
|
||||
|
||||
// Create trimmed line
|
||||
gp_XYZ aP1(60000, -7504.83, 6000);
|
||||
gp_XYZ aP2(60000, 7504.83, 6000);
|
||||
Handle(Geom_Line) aLine = new Geom_Line(gp_Pnt(aP1), gp_Dir(aP2 - aP1));
|
||||
Handle(Geom_TrimmedCurve) aC2 = new Geom_TrimmedCurve(aLine, 0.0, (aP2 - aP1).Modulus());
|
||||
|
||||
// Try to find extrema
|
||||
// IMPORTANT: it is not allowed to input infinite curves!
|
||||
GeomAPI_ExtremaCurveCurve anEx(aC1, aC2);
|
||||
|
||||
// Check if curves are parallel
|
||||
if (anEx.Extrema().IsParallel())
|
||||
{
|
||||
// Parallel case - should have infinite number of extrema
|
||||
EXPECT_GT(anEx.LowerDistance(), 0.0) << "Parallel curves should have a distance";
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if extrema were found
|
||||
const Standard_Integer aNbEx = anEx.NbExtrema();
|
||||
EXPECT_GT(aNbEx, 0) << "Extrema should be found between BSpline and line";
|
||||
|
||||
if (aNbEx > 0)
|
||||
{
|
||||
// Get minimal distance data
|
||||
gp_Pnt aPoint1, aPoint2;
|
||||
anEx.NearestPoints(aPoint1, aPoint2);
|
||||
|
||||
Standard_Real aU1, aU2;
|
||||
anEx.LowerDistanceParameters(aU1, aU2);
|
||||
|
||||
const Standard_Real aDistance = anEx.LowerDistance();
|
||||
|
||||
// Verify minimal distance is reasonable
|
||||
EXPECT_GE(aDistance, 0.0) << "Minimal distance should be non-negative";
|
||||
|
||||
// Verify parameters are within valid range [0, 1] for the curves
|
||||
EXPECT_GE(aU1, 0.0) << "Parameter U1 should be non-negative";
|
||||
EXPECT_LE(aU1, 1.0) << "Parameter U1 should not exceed 1.0";
|
||||
EXPECT_GE(aU2, 0.0) << "Parameter U2 should be non-negative";
|
||||
|
||||
// Verify nearest points are valid
|
||||
EXPECT_FALSE(aPoint1.IsEqual(gp_Pnt(0, 0, 0), 1e-10)
|
||||
&& aPoint2.IsEqual(gp_Pnt(0, 0, 0), 1e-10))
|
||||
<< "Nearest points should not both be at origin";
|
||||
}
|
||||
}
|
||||
}
|
||||
71
src/ModelingData/TKG3d/GTests/GeomAPI_Interpolate_Test.cxx
Normal file
71
src/ModelingData/TKG3d/GTests/GeomAPI_Interpolate_Test.cxx
Normal file
@@ -0,0 +1,71 @@
|
||||
// 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 <gtest/gtest.h>
|
||||
|
||||
#include <GeomAPI_Interpolate.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
// Test BUC60902: GeomAPI_Interpolate tangent computation
|
||||
TEST(GeomAPI_Interpolate_Test, BUC60902_TangentPreservation)
|
||||
{
|
||||
// Create 5 points along a sine wave
|
||||
Handle(TColgp_HArray1OfPnt) aPnts = new TColgp_HArray1OfPnt(1, 5);
|
||||
gp_Pnt aP(0., 0., 0.);
|
||||
for (Standard_Integer i = 1; i <= 5; i++)
|
||||
{
|
||||
aP.SetX((i - 1) * 1.57);
|
||||
aP.SetY(sin((i - 1) * 1.57));
|
||||
aPnts->SetValue(i, aP);
|
||||
}
|
||||
|
||||
// First interpolation without tangents
|
||||
GeomAPI_Interpolate anInterpolater(aPnts, Standard_False, Precision::Confusion());
|
||||
anInterpolater.Perform();
|
||||
ASSERT_TRUE(anInterpolater.IsDone()) << "First interpolation should succeed";
|
||||
|
||||
// Get the generated tangents
|
||||
Handle(Geom_BSplineCurve) aCur = anInterpolater.Curve();
|
||||
ASSERT_FALSE(aCur.IsNull()) << "Interpolated curve should not be null";
|
||||
|
||||
gp_Vec aFirstTang, aLastTang;
|
||||
aCur->D1(aCur->FirstParameter(), aP, aFirstTang);
|
||||
aCur->D1(aCur->LastParameter(), aP, aLastTang);
|
||||
|
||||
// Second interpolation with the same tangents explicitly provided
|
||||
GeomAPI_Interpolate anInterpolater1(aPnts, Standard_False, Precision::Confusion());
|
||||
anInterpolater1.Load(aFirstTang, aLastTang, Standard_False);
|
||||
anInterpolater1.Perform();
|
||||
ASSERT_TRUE(anInterpolater1.IsDone()) << "Second interpolation should succeed";
|
||||
|
||||
// Get the tangents after recomputation
|
||||
aCur = anInterpolater1.Curve();
|
||||
ASSERT_FALSE(aCur.IsNull()) << "Second interpolated curve should not be null";
|
||||
|
||||
gp_Vec aFirstTang1, aLastTang1;
|
||||
aCur->D1(aCur->FirstParameter(), aP, aFirstTang1);
|
||||
aCur->D1(aCur->LastParameter(), aP, aLastTang1);
|
||||
|
||||
// Verify that the tangents are preserved
|
||||
EXPECT_TRUE(aFirstTang.IsEqual(aFirstTang1, Precision::Confusion(), Precision::Angular()))
|
||||
<< "First tangent should be preserved after recomputation";
|
||||
|
||||
EXPECT_TRUE(aLastTang.IsEqual(aLastTang1, Precision::Confusion(), Precision::Angular()))
|
||||
<< "Last tangent should be preserved after recomputation";
|
||||
}
|
||||
Reference in New Issue
Block a user