Skip to content

Commit

Permalink
updated unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
merakulix committed Oct 22, 2024
1 parent 4a5248c commit 674ccd1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/common/tiglcommonfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ TIGL_EXPORT TopoDS_Wire BuildWireRectangle(const double heightToWidthRatio, cons
* @param mUpper Exponent m for upper semi-ellipse
* @param nLower Exponent n for lower semi-ellipse
* @param nUpper Exponent n for upper semi-ellipse
* @param tol
* @param tol Tolerance required for approximation of the superellipse as a b-spline curve
* @return
*/
TIGL_EXPORT TopoDS_Wire BuildWireSuperEllipse(const double lowerHeightFraction,
Expand Down
22 changes: 0 additions & 22 deletions tests/unittests/testFuselageStandardProfileSuperellipse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,6 @@ TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle1 =
TixiDocumentHandle FuselageStandardProfileSuperEllipse::tixiHandle2 = 0;
TiglCPACSConfigurationHandle FuselageStandardProfileSuperEllipse::tiglHandle2 = 0;

TEST_F(FuselageStandardProfileSuperEllipse, BuildWireSuperEllipse)
{
//test valid values
auto wire = BuildWireSuperEllipse(0.25,5.,0.5,3.,2);
ASSERT_TRUE(wire.Closed());
auto trafo = gp_Trsf();
auto vec = gp_Vec(-1.,0.,0.);
trafo.SetTranslation(vec);
auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape();
ASSERT_TRUE(wire2.Closed());
auto loft = CTiglMakeLoft();
loft.addProfiles(wire);
loft.addProfiles(wire2);
ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid());

//check invalid values
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,0.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.,5.,0.5,3.,2.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(1.,5.,0.5,3.,2.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,0.,0.5,3.,2.), tigl::CTiglError);
}


TEST_F(FuselageStandardProfileSuperEllipse, BuildFuselageMixedProfilesWithGuides_Superellipse)
{
Expand Down
36 changes: 36 additions & 0 deletions tests/unittests/tiglCommonFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,42 @@ TEST(TiglCommonFunctions, BuildWireRectangle_CornerRadiusInvalid)
ASSERT_THROW(BuildWireRectangle(0.5, -1.), tigl::CTiglError);
}

TEST(TiglCommonFunctions, BuildWireSuperEllipse)
{
//test valid values
auto wire = BuildWireSuperEllipse(0.25,5.,0.5,3.,2);
ASSERT_TRUE(wire.Closed());
auto trafo = gp_Trsf();
auto vec = gp_Vec(-1.,0.,0.);
trafo.SetTranslation(vec);
auto wire2 = BRepBuilderAPI_Transform(wire, trafo).Shape();
ASSERT_TRUE(wire2.Closed());
auto loft = CTiglMakeLoft();
loft.addProfiles(wire);
loft.addProfiles(wire2);
ASSERT_TRUE(BRepCheck_Analyzer(loft.Shape()).IsValid());

//check invalid values
//exponent 0
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,0.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,0.,2.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.,3.,2.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,0.,0.5,3.,2.), tigl::CTiglError);
//exponent negative
ASSERT_THROW(BuildWireSuperEllipse(0.25,-5.,0.5,3.,2), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,-0.5,3.,2), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,-3.,2), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,-2), tigl::CTiglError);
//exponent outside tolerance
ASSERT_THROW(BuildWireSuperEllipse(0.25,1e-16,0.5,3.,2), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,1e-16,3.,2), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,1e-16,2), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(0.25,5.,0.5,3.,1e-16), tigl::CTiglError);
//invalid lowerHeightFraction
ASSERT_THROW(BuildWireSuperEllipse(2.,5.,0.5,3.,2.), tigl::CTiglError);
ASSERT_THROW(BuildWireSuperEllipse(-0.25,5.,0.5,3.,2), tigl::CTiglError);
}

TEST(TiglCommonFunctions, LinspaceWithBreaks)
{
std::vector<double> breaks;
Expand Down

0 comments on commit 674ccd1

Please sign in to comment.