Skip to content

Commit

Permalink
add algorithm enum to CTiglMakeLoft
Browse files Browse the repository at this point in the history
  • Loading branch information
joergbrech committed Dec 11, 2024
1 parent 30e1e84 commit b717ae4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ target_compile_features(tigl3_objects PRIVATE cxx_std_11)
set_property(TARGET tigl3_objects PROPERTY POSITION_INDEPENDENT_CODE ON) # needed for shared libraries

option(TIGL_GORDON_SURFACE "Loft curve networks using the Gordon surface algorithm (instead of using Coons patches)" OFF)
mark_as_advanced(TIGL_GORDON_SURFACE)
if (TIGL_GORDON_SURFACE)
target_compile_definitions(tigl3_objects PUBLIC TIGL_GORDON_SURFACE)
endif(TIGL_GORDON_SURFACE)
Expand Down
31 changes: 17 additions & 14 deletions src/geometry/CTiglMakeLoft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,10 @@ namespace {
CTiglMakeLoft::CTiglMakeLoft(double tolerance, double sameKnotTolerance)
: _hasPerformed{false}
, _makeSolid{true}
, _makeSmooth{false}
, _myTolerance{tolerance}
, _mySameKnotTolerance{sameKnotTolerance}
#ifdef TIGL_GORDON_SURFACE
, _use_gordon_surface_algorithm(true)
#else
, _use_gordon_surface_algorithm(false)
#endif
, _algorithm(Algorithm::COONS_PATCHES)
{
_result.Nullify();
}
Expand Down Expand Up @@ -148,10 +145,6 @@ void CTiglMakeLoft::Perform()
_hasPerformed = true;
}

void CTiglMakeLoft::useGordonSurfaceAlgorithm(bool enabled) {
_use_gordon_surface_algorithm = enabled;
}

void CTiglMakeLoft::setMakeSolid(bool enabled)
{
_makeSolid = enabled;
Expand All @@ -162,16 +155,26 @@ void CTiglMakeLoft::setMakeSmooth(bool enabled)
_makeSmooth = enabled;
}

void CTiglMakeLoft::setAlgorithm(Algorithm algorithm)
{
_algorithm = algorithm;
}

/**
* @brief Builds the loft using profiles and guide curves
*/
void CTiglMakeLoft::makeLoftWithGuides()
{
if (_use_gordon_surface_algorithm) {
makeLoftGordon();
}
else {
makeLoftCoons();
switch(_algorithm) {
case Algorithm::GORDON_SURFACE: {
makeLoftGordon();
break;
}
case Algorithm::COONS_PATCHES: {
makeLoftCoons();
break;
}
default: throw tigl::CTiglError("Invalid algorithm. Currently only Algorithm::GORDON_SURFACE and Algorithm::COONS_PATCHES are supported.", TIGL_ERROR);
}
}

Expand Down
18 changes: 17 additions & 1 deletion src/geometry/CTiglMakeLoft.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <vector>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Wire.hxx>

/**
* @brief The CTiglMakeLoft class is used to create loft topologies using cross sections
* and optional guide curves. By default, the resulting topology is a solid. In order to
Expand All @@ -33,6 +34,12 @@
class CTiglMakeLoft
{
public:
enum class Algorithm {
COONS_PATCHES,
GORDON_SURFACE
};


TIGL_EXPORT CTiglMakeLoft(double tolerance = 1e-6, double sameKnotTolerance = 1e-6);
TIGL_EXPORT CTiglMakeLoft(const TopoDS_Shape& profiles, const TopoDS_Shape& guides, double tolerance = 1e-6, double sameKnotTolerance = 1e-6);

Expand All @@ -59,6 +66,14 @@ class CTiglMakeLoft
*/
TIGL_EXPORT void setMakeSolid(bool enabled);

/**
* @brief use this function to select the internal algorithm used by the lofter.
*
* @param algorithm enum for the algorithm (default: Algorithm::COONS_PATCHES)
*/
TIGL_EXPORT void setAlgorithm(Algorithm algorithm);


/**
* @brief Use the function to enable the Gordon surface algorithm to
* interpolate curve networks.
Expand Down Expand Up @@ -116,8 +131,9 @@ class CTiglMakeLoft
double _mySameKnotTolerance;
std::vector<TopoDS_Wire> guides, profiles;
std::vector<Standard_Real> uparams, vparams;
bool _hasPerformed, _makeSolid, _use_gordon_surface_algorithm;
bool _hasPerformed, _makeSolid;
bool _makeSmooth = false;
Algorithm _algorithm;

TopoDS_Shape _result;
};
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/tiglMakeLoft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ TEST_P(CurveNetworkCoons, testFromBRep)

CTiglMakeLoft lofter(1e-6, 1e-4);
lofter.setMakeSolid(false);
lofter.useGordonSurfaceAlgorithm(false);
lofter.setAlgorithm(CTiglMakeLoft::Algorithm::COONS_PATCHES);

for (std::vector<Handle(Geom_BSplineCurve)>::const_iterator it = splines_u_vector.begin(); it != splines_u_vector.end(); ++it) {
const Handle(Geom_BSplineCurve)& curve = *it;
Expand Down

0 comments on commit b717ae4

Please sign in to comment.