mirror of
https://github.com/Open-Cascade-SAS/OCCT.git
synced 2026-09-02 17:51:44 +08:00
Testing - Migration QADraw tests to GTests (#1235)
- Removed multiple legacy DRAW test scripts and several QABugs DRAW command implementations. - Added new GTest suites covering the migrated regressions in ModelingData/ModelingAlgorithms/FoundationClasses/DataExchange/ApplicationFramework. - Updated multiple `FILES.cmake` lists to compile/link the new tests; introduced an additional `STEPControl_Writer::SetShapeFixParameters()` overload.
This commit is contained in:
@@ -0,0 +1,204 @@
|
||||
// Copyright (c) 2026 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 <Bnd_Box.hxx>
|
||||
#include <BRepAlgoAPI_Common.hxx>
|
||||
#include <BRepAlgoAPI_Cut.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepCheck_Analyzer.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <NCollection_Array1.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Solid.hxx>
|
||||
|
||||
//! Runs OCC817 test: creates hollow box (30x30x30 outer minus 10x10x10 inner),
|
||||
//! grids the bounding box into cells of theMeshDelta size, computes
|
||||
//! BRepAlgoAPI_Common of the solid with each cell, and returns
|
||||
//! the ratio of accumulated meshed volume to original volume.
|
||||
//! Returns -1.0 on failure.
|
||||
static double runHollowBoxMeshTest(double theMeshDelta)
|
||||
{
|
||||
constexpr double aDelt = 5.0 * Precision::Confusion();
|
||||
|
||||
// Create outer box solid
|
||||
const TopoDS_Solid aFullSolid = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 30.0, 30.0, 30.0).Solid();
|
||||
|
||||
// Create inner box solid
|
||||
const TopoDS_Solid anInnerSolid =
|
||||
BRepPrimAPI_MakeBox(gp_Pnt(10, 10, 10), 10.0, 10.0, 10.0).Solid();
|
||||
|
||||
// Cut inner from outer
|
||||
BRepAlgoAPI_Cut aCut(aFullSolid, anInnerSolid);
|
||||
if (!aCut.IsDone())
|
||||
return -1.0;
|
||||
|
||||
// Extract the single solid from the cut result
|
||||
TopoDS_Solid aCutSolid;
|
||||
int aNbSolids = 0;
|
||||
TopExp_Explorer anExp;
|
||||
for (anExp.Init(aCut.Shape(), TopAbs_SOLID); anExp.More(); anExp.Next())
|
||||
{
|
||||
const TopoDS_Solid& aSol = TopoDS::Solid(anExp.Current());
|
||||
if (!aSol.IsNull())
|
||||
{
|
||||
aCutSolid = aSol;
|
||||
aNbSolids++;
|
||||
}
|
||||
}
|
||||
if (aNbSolids != 1)
|
||||
return -1.0;
|
||||
|
||||
// Calculate original volume
|
||||
GProp_GProps aVProps;
|
||||
BRepGProp::VolumeProperties(aCutSolid, aVProps);
|
||||
const double anOriginalVolume = aVProps.Mass();
|
||||
if (anOriginalVolume <= 0.0)
|
||||
return -1.0;
|
||||
|
||||
// Build bounding box and extend by small delta
|
||||
Bnd_Box aBndBox;
|
||||
BRepBndLib::Add(aCutSolid, aBndBox);
|
||||
double aXmin, aYmin, aZmin, aXmax, aYmax, aZmax;
|
||||
aBndBox.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
|
||||
aXmin -= aDelt;
|
||||
aYmin -= aDelt;
|
||||
aZmin -= aDelt;
|
||||
aXmax += aDelt;
|
||||
aYmax += aDelt;
|
||||
aZmax += aDelt;
|
||||
|
||||
// Grid the bounding box
|
||||
int aNx = (int)((aXmax - aXmin) / theMeshDelta);
|
||||
if (aNx <= 0)
|
||||
aNx = 1;
|
||||
int aNy = (int)((aYmax - aYmin) / theMeshDelta);
|
||||
if (aNy <= 0)
|
||||
aNy = 1;
|
||||
int aNz = (int)((aZmax - aZmin) / theMeshDelta);
|
||||
if (aNz <= 0)
|
||||
aNz = 1;
|
||||
|
||||
const double aStepX = (aXmax - aXmin) / aNx;
|
||||
const double aStepY = (aYmax - aYmin) / aNy;
|
||||
const double aStepZ = (aZmax - aZmin) / aNz;
|
||||
const int aNbSubvols = aNx * aNy * aNz;
|
||||
|
||||
NCollection_Array1<TopoDS_Shape> aSubvols(0, aNbSubvols - 1);
|
||||
NCollection_Array1<double> aSubvolVols(0, aNbSubvols - 1);
|
||||
|
||||
// Build grid cells
|
||||
int l = 0;
|
||||
for (int i = 0; i < aNx; i++)
|
||||
{
|
||||
for (int j = 0; j < aNy; j++)
|
||||
{
|
||||
for (int k = 0; k < aNz; k++)
|
||||
{
|
||||
const gp_Pnt aPnt(aXmin + i * aStepX, aYmin + j * aStepY, aZmin + k * aStepZ);
|
||||
aSubvols.SetValue(l, BRepPrimAPI_MakeBox(aPnt, aStepX, aStepY, aStepZ).Solid());
|
||||
BRepGProp::VolumeProperties(aSubvols(l), aVProps);
|
||||
aSubvolVols.SetValue(l, aVProps.Mass());
|
||||
l++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compute common of solid with each grid cell, accumulate volumes
|
||||
double anAccumulated = 0.0;
|
||||
for (l = 0; l < aNbSubvols; l++)
|
||||
{
|
||||
const TopoDS_Shape aCopySolid = BRepBuilderAPI_Copy(aCutSolid).Shape();
|
||||
BRepAlgoAPI_Common aCommon(aCopySolid, aSubvols(l));
|
||||
if (!aCommon.IsDone())
|
||||
continue;
|
||||
|
||||
int aNbCommon = 0;
|
||||
TopoDS_Shape aFoundSolid;
|
||||
for (anExp.Init(aCommon.Shape(), TopAbs_SOLID); anExp.More(); anExp.Next())
|
||||
{
|
||||
const TopoDS_Solid& aSol = TopoDS::Solid(anExp.Current());
|
||||
if (!aSol.IsNull())
|
||||
{
|
||||
aFoundSolid = aSol;
|
||||
aNbCommon++;
|
||||
}
|
||||
}
|
||||
if (aNbCommon == 1)
|
||||
{
|
||||
BRepGProp::VolumeProperties(aFoundSolid, aVProps);
|
||||
const double aVol = aVProps.Mass();
|
||||
if (aVol > 0.0 && aVol <= aSubvolVols(l))
|
||||
anAccumulated += aVol;
|
||||
}
|
||||
}
|
||||
|
||||
return anAccumulated / anOriginalVolume;
|
||||
}
|
||||
|
||||
// OCC817: BRepAlgoAPI_Common result accuracy with hollow box using mesh_delta=10.
|
||||
TEST(BRepAlgoAPI_CutTest, HollowBox_VolumeAccuracy_Delta10)
|
||||
{
|
||||
const double aRatio = runHollowBoxMeshTest(10.0);
|
||||
ASSERT_GE(aRatio, 0.0) << "Cut or Common operation failed";
|
||||
EXPECT_NEAR(aRatio, 1.0, 0.001) << "Accumulated meshed volume differs from original by > 0.1%";
|
||||
}
|
||||
|
||||
// OCC817: BRepAlgoAPI_Common result accuracy with hollow box using mesh_delta=15.
|
||||
TEST(BRepAlgoAPI_CutTest, HollowBox_VolumeAccuracy_Delta15)
|
||||
{
|
||||
const double aRatio = runHollowBoxMeshTest(15.0);
|
||||
ASSERT_GE(aRatio, 0.0) << "Cut or Common operation failed";
|
||||
EXPECT_NEAR(aRatio, 1.0, 0.001) << "Accumulated meshed volume differs from original by > 0.1%";
|
||||
}
|
||||
|
||||
// OCC817: BRepAlgoAPI_Common result accuracy with hollow box using mesh_delta=30.
|
||||
TEST(BRepAlgoAPI_CutTest, HollowBox_VolumeAccuracy_Delta30)
|
||||
{
|
||||
const double aRatio = runHollowBoxMeshTest(30.0);
|
||||
ASSERT_GE(aRatio, 0.0) << "Cut or Common operation failed";
|
||||
EXPECT_NEAR(aRatio, 1.0, 0.001) << "Accumulated meshed volume differs from original by > 0.1%";
|
||||
}
|
||||
|
||||
// OCC817: hollow box has correct surface area and valid shape.
|
||||
// Outer 30x30x30 has area 6*900=5400; inner 10x10x10 hole adds 6*100=600; total=6000.
|
||||
TEST(BRepAlgoAPI_CutTest, HollowBox_SurfaceAreaAndValidity)
|
||||
{
|
||||
const TopoDS_Solid aFullSolid = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), 30.0, 30.0, 30.0).Solid();
|
||||
const TopoDS_Solid anInnerSolid =
|
||||
BRepPrimAPI_MakeBox(gp_Pnt(10, 10, 10), 10.0, 10.0, 10.0).Solid();
|
||||
|
||||
BRepAlgoAPI_Cut aCut(aFullSolid, anInnerSolid);
|
||||
ASSERT_TRUE(aCut.IsDone());
|
||||
|
||||
// Extract solid
|
||||
TopoDS_Solid aCutSolid;
|
||||
TopExp_Explorer anExp;
|
||||
for (anExp.Init(aCut.Shape(), TopAbs_SOLID); anExp.More(); anExp.Next())
|
||||
aCutSolid = TopoDS::Solid(anExp.Current());
|
||||
ASSERT_FALSE(aCutSolid.IsNull());
|
||||
|
||||
// Surface area: outer box 6*900=5400, inner box adds 6*100=600 => total=6000
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aCutSolid, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 6000.0, 6.0); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aCutSolid);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
// Copyright (c) 2026 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 <BRepAlgoAPI_Cut.hxx>
|
||||
#include <BRepAlgoAPI_Fuse.hxx>
|
||||
#include <BRepBuilderAPI_MakeFace.hxx>
|
||||
#include <BRepBuilderAPI_MakePolygon.hxx>
|
||||
#include <BRepCheck_Analyzer.hxx>
|
||||
#include <BRepGProp.hxx>
|
||||
#include <BRepPrimAPI_MakeBox.hxx>
|
||||
#include <BRepPrimAPI_MakeCone.hxx>
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
#include <BRepPrimAPI_MakeRevol.hxx>
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
#include <BRepPrimAPI_MakeTorus.hxx>
|
||||
#include <GProp_GProps.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Ax2.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
// OCC822_1: BRepMesh_IncrementalMesh correctness test - boolean operations with cylinders and
|
||||
// cones. Creates two pairs (inner/outer) of cylinders and cones, fuses each pair, then cuts inner
|
||||
// from outer.
|
||||
TEST(BRepAlgoAPI_FuseTest, CylinderAndCone_FuseThenCut)
|
||||
{
|
||||
const gp_Ax2 anAxis1(gp_Pnt(0, 0, 0), gp_Dir(gp_Dir::D::Z));
|
||||
const TopoDS_Shape aCylIn = BRepPrimAPI_MakeCylinder(anAxis1, 40, 110).Shape();
|
||||
const TopoDS_Shape aCylOut = BRepPrimAPI_MakeCylinder(anAxis1, 50, 100).Shape();
|
||||
|
||||
const gp_Ax2 anAxis2(gp_Pnt(0, 0, 0), gp_Dir(gp_Dir::D::NZ));
|
||||
const TopoDS_Shape aConIn = BRepPrimAPI_MakeCone(anAxis2, 40, 60, 110).Shape();
|
||||
const TopoDS_Shape aConOut = BRepPrimAPI_MakeCone(anAxis2, 50, 70, 100).Shape();
|
||||
|
||||
BRepAlgoAPI_Fuse aFuseIn(aCylIn, aConIn);
|
||||
ASSERT_TRUE(aFuseIn.IsDone());
|
||||
|
||||
BRepAlgoAPI_Fuse aFuseOut(aCylOut, aConOut);
|
||||
ASSERT_TRUE(aFuseOut.IsDone());
|
||||
|
||||
BRepAlgoAPI_Cut aCut(aFuseOut.Shape(), aFuseIn.Shape());
|
||||
ASSERT_TRUE(aCut.IsDone());
|
||||
|
||||
const TopoDS_Shape aResult = aCut.Shape();
|
||||
ASSERT_FALSE(aResult.IsNull());
|
||||
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aResult, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 133931.0, 133.931); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aResult);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
|
||||
// OCC822_2: BRepMesh_IncrementalMesh correctness test - fuse of box and sphere.
|
||||
TEST(BRepAlgoAPI_FuseTest, BoxAndSphere)
|
||||
{
|
||||
const TopoDS_Shape aBox = BRepPrimAPI_MakeBox(gp_Pnt(0, 0, 0), gp_Pnt(100, 100, 100)).Shape();
|
||||
const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 50, 50), 25.0).Shape();
|
||||
|
||||
BRepAlgoAPI_Fuse aFuse(aBox, aSphere);
|
||||
ASSERT_TRUE(aFuse.IsDone());
|
||||
|
||||
const TopoDS_Shape aResult = aFuse.Shape();
|
||||
ASSERT_FALSE(aResult.IsNull());
|
||||
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aResult, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 61963.5, 61.9635); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aResult);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
|
||||
// OCC823: BRepAlgoAPI_Fuse correctness test - fuse of two nearly-parallel cylinders.
|
||||
TEST(BRepAlgoAPI_FuseTest, TwoCylinders)
|
||||
{
|
||||
const gp_Ax2 anAxis1(gp_Pnt(40, 50, 0), gp_Dir(100, 0, 0));
|
||||
const TopoDS_Shape aCyl1 = BRepPrimAPI_MakeCylinder(anAxis1, 20, 100).Shape();
|
||||
|
||||
constexpr double aSize = 0.001;
|
||||
const gp_Ax2 anAxis2(gp_Pnt(100, 50, aSize), gp_Dir(0, aSize, 80));
|
||||
const TopoDS_Shape aCyl2 = BRepPrimAPI_MakeCylinder(anAxis2, 20, 80).Shape();
|
||||
|
||||
BRepAlgoAPI_Fuse aFuse(aCyl2, aCyl1);
|
||||
ASSERT_TRUE(aFuse.IsDone());
|
||||
|
||||
const TopoDS_Shape aResult = aFuse.Shape();
|
||||
ASSERT_FALSE(aResult.IsNull());
|
||||
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aResult, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 23189.5, 23.1895); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aResult);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
|
||||
// OCC824: BRepAlgoAPI_Fuse correctness test - fuse of cylinder and sphere.
|
||||
TEST(BRepAlgoAPI_FuseTest, CylinderAndSphere)
|
||||
{
|
||||
const gp_Pnt aCenter(100, 0, 0);
|
||||
const gp_Ax2 anAxis(aCenter, gp_Dir(gp_Dir::D::NX));
|
||||
const TopoDS_Shape aCyl = BRepPrimAPI_MakeCylinder(anAxis, 20, 100).Shape();
|
||||
const TopoDS_Shape aSphere = BRepPrimAPI_MakeSphere(aCenter, 20.0).Shape();
|
||||
|
||||
BRepAlgoAPI_Fuse aFuse(aCyl, aSphere);
|
||||
ASSERT_TRUE(aFuse.IsDone());
|
||||
|
||||
const TopoDS_Shape aResult = aFuse.Shape();
|
||||
ASSERT_FALSE(aResult.IsNull());
|
||||
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aResult, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 16336.3, 16.3363); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aResult);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
|
||||
// OCC826: BRepAlgoAPI_Fuse correctness test - fuse of revolved face and sphere.
|
||||
// Intersection line passes near the pole of the sphere.
|
||||
TEST(BRepAlgoAPI_FuseTest, RevolvedFaceAndSphere)
|
||||
{
|
||||
BRepBuilderAPI_MakePolygon aWire;
|
||||
const double aX1 = 181.82808, aX2 = 202.39390;
|
||||
const double aY1 = 31.011970, aY2 = 123.06856;
|
||||
aWire.Add(gp_Pnt(aX1, aY1, 0));
|
||||
aWire.Add(gp_Pnt(aX2, aY1, 0));
|
||||
aWire.Add(gp_Pnt(aX2, aY2, 0));
|
||||
aWire.Add(gp_Pnt(aX1, aY2, 0));
|
||||
aWire.Add(gp_Pnt(aX1, aY1, 0));
|
||||
|
||||
const TopoDS_Face aFace = BRepBuilderAPI_MakeFace(aWire.Wire(), false);
|
||||
const gp_Ax1 anAxis(gp_Pnt(0, 0, 0), gp_Dir(0, 30, 0));
|
||||
const TopoDS_Shape aRevol = BRepPrimAPI_MakeRevol(aFace, anAxis, 2.0 * M_PI).Shape();
|
||||
const TopoDS_Shape aSphere =
|
||||
BRepPrimAPI_MakeSphere(gp_Pnt(166.373, 77.0402, 96.0555), 23.218586).Shape();
|
||||
|
||||
BRepAlgoAPI_Fuse aFuse(aRevol, aSphere);
|
||||
ASSERT_TRUE(aFuse.IsDone());
|
||||
|
||||
const TopoDS_Shape aResult = aFuse.Shape();
|
||||
ASSERT_FALSE(aResult.IsNull());
|
||||
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aResult, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 272935.0, 272.935); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aResult);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
|
||||
// OCC827: BRepAlgoAPI_Fuse correctness test - fuse of revolved solid with two tori.
|
||||
TEST(BRepAlgoAPI_FuseTest, RevolvedSolidAndTwoTori)
|
||||
{
|
||||
BRepBuilderAPI_MakePolygon aWire;
|
||||
aWire.Add(gp_Pnt(10, 0, 0));
|
||||
aWire.Add(gp_Pnt(20, 0, 0));
|
||||
aWire.Add(gp_Pnt(20, 0, 50));
|
||||
aWire.Add(gp_Pnt(10, 0, 50));
|
||||
aWire.Add(gp_Pnt(10, 0, 0));
|
||||
|
||||
const TopoDS_Face aFace = BRepBuilderAPI_MakeFace(aWire.Wire(), false);
|
||||
const gp_Ax1 anAxis(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 30));
|
||||
const TopoDS_Shape aRevol = BRepPrimAPI_MakeRevol(aFace, anAxis, 2.0 * M_PI).Shape();
|
||||
|
||||
constexpr double aMajRad = 15.0;
|
||||
constexpr double aMinRad = 5.0;
|
||||
|
||||
const TopoDS_Shape aTor1 =
|
||||
BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(0, 0, 50), gp_Dir(0, 0, 30)), aMajRad, aMinRad).Shape();
|
||||
const TopoDS_Shape aTor2 =
|
||||
BRepPrimAPI_MakeTorus(gp_Ax2(gp_Pnt(0, 0, 10), gp_Dir(0, 0, 30)), aMajRad, aMinRad).Shape();
|
||||
|
||||
BRepAlgoAPI_Fuse aFuse1(aTor1, aRevol);
|
||||
ASSERT_TRUE(aFuse1.IsDone());
|
||||
|
||||
BRepAlgoAPI_Fuse aFuse2(aTor2, aFuse1.Shape());
|
||||
ASSERT_TRUE(aFuse2.IsDone());
|
||||
|
||||
const TopoDS_Shape aResult = aFuse2.Shape();
|
||||
ASSERT_FALSE(aResult.IsNull());
|
||||
|
||||
GProp_GProps aSProps;
|
||||
BRepGProp::SurfaceProperties(aResult, aSProps);
|
||||
EXPECT_NEAR(aSProps.Mass(), 11847.7, 11.8477); // 0.1% tolerance
|
||||
|
||||
BRepCheck_Analyzer aChecker(aResult);
|
||||
EXPECT_TRUE(aChecker.IsValid());
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright (c) 2026 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 <BRepAlgoAPI_Section.hxx>
|
||||
#include <BRepPrimAPI_MakeCylinder.hxx>
|
||||
#include <BRepPrimAPI_MakeSphere.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
// Test OCCN2: BRepAlgoAPI_Section of a cylinder intersecting a sphere.
|
||||
// Migrated from QABugs_17.cxx OCCN2
|
||||
TEST(BRepAlgoAPI_SectionTest, OCCN2_CylinderSphereSectionIsDone)
|
||||
{
|
||||
BRepPrimAPI_MakeCylinder aCylMaker(50., 200.);
|
||||
const TopoDS_Shape& aCylinder = aCylMaker.Shape();
|
||||
|
||||
BRepPrimAPI_MakeSphere aSphereMaker(gp_Pnt(60., 0., 100.), 50.);
|
||||
const TopoDS_Shape& aSphere = aSphereMaker.Shape();
|
||||
|
||||
BRepAlgoAPI_Section aSection(aCylinder, aSphere);
|
||||
EXPECT_TRUE(aSection.IsDone());
|
||||
EXPECT_FALSE(aSection.Shape().IsNull());
|
||||
}
|
||||
@@ -2,5 +2,9 @@
|
||||
set(OCCT_TKBool_GTests_FILES_LOCATION "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(OCCT_TKBool_GTests_FILES
|
||||
BRepAlgoAPI_Cut_Test.cxx
|
||||
BRepAlgoAPI_Fuse_Test.cxx
|
||||
BRepAlgoAPI_Section_Test.cxx
|
||||
BRepFill_PipeShell_Test.cxx
|
||||
IntTools_FaceFace_Test.cxx
|
||||
)
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) 2026 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 <BRep_Builder.hxx>
|
||||
#include <Geom_CylindricalSurface.hxx>
|
||||
#include <Geom_Plane.hxx>
|
||||
#include <IntTools_Curve.hxx>
|
||||
#include <IntTools_FaceFace.hxx>
|
||||
#include <IntTools_PntOn2Faces.hxx>
|
||||
#include <NCollection_Sequence.hxx>
|
||||
#include <Precision.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
// Test OCC24005: IntTools_FaceFace should complete quickly and correctly when
|
||||
// intersecting a slightly off-angle plane with a cylinder. Previously took 7+ seconds.
|
||||
TEST(IntTools_FaceFaceTest, OCC24005_PlaneCylinderIntersection)
|
||||
{
|
||||
// Hardcoded geometry from the original regression test
|
||||
Handle(Geom_Plane) aPlane = new Geom_Plane(
|
||||
gp_Ax3(gp_Pnt(-72.948737453424499, 754.30437716359393, 259.52151854671678),
|
||||
gp_Dir(6.2471473085930200e-007, -0.99999999999980493, 0.00000000000000000),
|
||||
gp_Dir(0.99999999999980493, 6.2471473085930200e-007, 0.00000000000000000)));
|
||||
|
||||
Handle(Geom_CylindricalSurface) aCylinder = new Geom_CylindricalSurface(
|
||||
gp_Ax3(gp_Pnt(-6.4812490053250649, 753.39408794522092, 279.16400974257465),
|
||||
gp_Dir(1.0000000000000000, 0.0, 0.00000000000000000),
|
||||
gp_Dir(0.0, 1.0000000000000000, 0.00000000000000000)),
|
||||
19.712534607908712);
|
||||
|
||||
BRep_Builder aBuilder;
|
||||
TopoDS_Face aFace1, aFace2;
|
||||
aBuilder.MakeFace(aFace1, aPlane, Precision::Confusion());
|
||||
aBuilder.MakeFace(aFace2, aCylinder, Precision::Confusion());
|
||||
|
||||
IntTools_FaceFace anInters;
|
||||
anInters.SetParameters(false, true, true, Precision::Confusion());
|
||||
anInters.Perform(aFace1, aFace2);
|
||||
|
||||
ASSERT_TRUE(anInters.IsDone()) << "IntTools_FaceFace::Perform did not complete";
|
||||
|
||||
// The original test verified that intersection completes without hanging.
|
||||
// Check that we get at least one intersection curve.
|
||||
const NCollection_Sequence<IntTools_Curve>& aCurves = anInters.Lines();
|
||||
EXPECT_GE(aCurves.Length() + anInters.Points().Length(), 1)
|
||||
<< "Expected at least one intersection result (curve or point)";
|
||||
}
|
||||
Reference in New Issue
Block a user