Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made Lofting algorithm throw Exception when side caps are invalid #999

Merged
merged 9 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/geometry/CTiglPatchShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
#include <StdFail_NotDone.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
#include <Geom_Plane.hxx>
#include <BRepCheck_Analyzer.hxx>

#include "CTiglLogging.h"
#include "CTiglLogSplitter.h"

namespace
{
Expand Down Expand Up @@ -70,6 +74,11 @@
BRepBuilderAPI_FindPlane Searcher( boundaryWire, _tolerance );
if (Searcher.Found()) {
cap = BRepBuilderAPI_MakeFace(Searcher.Plane(), boundaryWire);
#ifdef DEBUG
if(!BRepCheck_Analyzer(cap).IsValid()){
LOG(WARNING) << "WARNING: Side caps invalid.";
}
#endif
Ok = true;
}
else {
Expand All @@ -78,6 +87,11 @@
if (MF.IsDone())
{
cap = MF.Face();
#ifdef DEBUG
if(!BRepCheck_Analyzer(cap).IsValid()){
LOG(WARNING) << "WARNING: Side caps invalid.";

Check warning on line 92 in src/geometry/CTiglPatchShell.cpp

View check run for this annotation

Codecov / codecov/patch

src/geometry/CTiglPatchShell.cpp#L91-L92

Added lines #L91 - L92 were not covered by tests
}
#endif
Ok = true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/logging/CTiglLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ void CTiglLogging::SetConsoleVerbosity(TiglLogLevel vlevel)
}
}


TiglLogLevel CTiglLogging::GetConsoleVerbosity() const

{
return _consoleVerbosity;
}
Expand Down
1 change: 1 addition & 0 deletions src/logging/CTiglLogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class CTiglLogging
TIGL_EXPORT void SetTimeIdInFilenameEnabled(bool enabled);
TIGL_EXPORT void LogToConsole();
TIGL_EXPORT void SetConsoleVerbosity(TiglLogLevel vlevel);

TIGL_EXPORT TiglLogLevel GetConsoleVerbosity() const;

// allows installing a custom log sink/receiver
Expand Down
49 changes: 48 additions & 1 deletion tests/unittests/testCTiglPatchShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
* limitations under the License.
*/

#include "CTiglConsoleLogger.h"
#include "CTiglFileLogger.h"
#include "CTiglLogSplitter.h"
#include "test.h"
#include "BRepBuilderAPI_Transform.hxx"
#include "CTiglMakeLoft.h"
#include "CTiglPatchShell.h"
#include "CTiglError.h"
#include "CTiglPointsToBSplineInterpolation.h"
Expand All @@ -26,6 +31,8 @@
#include "BRepBuilderAPI_MakeFace.hxx"
#include "BRep_Builder.hxx"

#include "CTiglLogging.h"
#include "testUtils.h"

TEST(CTiglPatchShell, Success)
{
Expand Down Expand Up @@ -54,7 +61,7 @@ TEST(CTiglPatchShell, Success)
pnt2->SetValue(4, gp_Pnt(0., -1., 5.));
pnt2->SetValue(5, gp_Pnt(1., 0., 5.));

// interpoate points to curve
// interpolate points to curve
tigl::CTiglPointsToBSplineInterpolation app2(pnt2, 3, true);
Handle(Geom_BSplineCurve) tip_curve = app2.Curve();
gp_Trsf T;
Expand Down Expand Up @@ -90,3 +97,43 @@ TEST(CTiglPatchShell, brokenShape)
tigl::CTiglPatchShell patcher(brokenShape, 1e-6);
EXPECT_THROW(patcher.PatchedShape();, tigl::CTiglError);
}

TEST(CTiglPatchShell, noSideCaps)
{
#ifdef DEBUG
//define coordinates for profile wire enclosing two unconnected surface areas
std::vector<gp_Pnt> points = {gp_Pnt(0., 0., 0.),gp_Pnt(0., 0.,1.),gp_Pnt(0.,0.5,0.),
gp_Pnt(0.,1.,1.), gp_Pnt(0., 1.,0.), gp_Pnt(0.,0.,0.)};

//build 1st wire
BRepBuilderAPI_MakeWire wire1;
for(int i=0; i < points.size()-1; i++){
auto edge = BRepBuilderAPI_MakeEdge(points[i],points[i+1]).Edge();
wire1.Add(edge);
}

//build 2nd wire
auto trafo = gp_Trsf();
auto vec = gp_Vec(-1.,0.,0.);
trafo.SetTranslation(vec);
auto wire2 = BRepBuilderAPI_Transform(wire1.Shape(), trafo);

//lofting should throw exception building (no) side caps for given profile wire
auto loft = CTiglMakeLoft();
loft.addProfiles(wire1.Shape());
loft.addProfiles(wire2.Shape());

// Check for warning
{ // Scope to destroy object of type CaptureTiGLLog and therefore reset console verbosity
CaptureTiGLLog t{TILOG_WARNING};

//call function that returns warning
loft.Shape();

auto logOutput = t.log();

std::string comparisonString = "WARNING: Side caps invalid.";
ASSERT_TRUE((logOutput.find(comparisonString)) != std::string::npos);
} // scope
#endif
}
Loading