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

levelset: surface smoothing #461

Merged
merged 11 commits into from
Jun 6, 2024
37 changes: 37 additions & 0 deletions src/levelset/levelSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ int LevelSet::addObject( SurfUnstructured *segmentation, double angle, int id )
return registerObject(std::move(object));
}

/*!
* Adds a segmentation object
* Objects can be added to the levelset only after setting the mesh.
* @param[in] segmentation surface segmentation
* @param[in] angle feature angle
* @param[in] surfaceSmoothing is the given surface snoothing order
* @param[in] id identifier of object; in case no id is provided the insertion
* order will be used as identifier
*/
int LevelSet::addObject( SurfUnstructured *segmentation, double angle, LevelSetSurfaceSmoothing surfaceSmoothing, int id ) {

auto object = std::unique_ptr<LevelSetObject>(new LevelSetSegmentationObject(id, segmentation, angle, surfaceSmoothing));

return registerObject(std::move(object));
}

/*!
* Adds a segmentation object
* Objects can be added to the levelset only after setting the mesh.
Expand Down Expand Up @@ -276,6 +292,27 @@ int LevelSet::addObject( SurfaceKernel *segmentation, double angle, int id ) {
return registerObject(std::move(object));
}

/*!
* Adds a segmentation object
* Objects can be added to the levelset only after setting the mesh.
* @param[in] segmentation surface segmentation
* @param[in] angle feature angle
* @param[in] surfaceSmoothing is the given surface snoothing order
* @param[in] id identifier of object; in case no id is provided the insertion
* order will be used as identifier
*/
int LevelSet::addObject( SurfaceKernel *segmentation, double angle, LevelSetSurfaceSmoothing surfaceSmoothing, int id ) {

SurfUnstructured *surfUnstructured = dynamic_cast<SurfUnstructured *>(segmentation);
if (!surfUnstructured) {
throw std::runtime_error ("Segmentation type not supported");
}

auto object = std::unique_ptr<LevelSetObject>(new LevelSetSegmentationObject(id, surfUnstructured, angle, surfaceSmoothing));

return registerObject(std::move(object));
}

/*!
* Adds a LevelSetMask object composed of the external envelope of a list of mesh cells.
* Objects can be added to the levelset only after setting the mesh.
Expand Down
2 changes: 2 additions & 0 deletions src/levelset/levelSet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ class LevelSet{

int addObject( std::unique_ptr<SurfaceKernel> &&, double, int id = levelSetDefaults::OBJECT ) ;
int addObject( SurfaceKernel *, double, int id = levelSetDefaults::OBJECT ) ;
int addObject( SurfaceKernel *, double, LevelSetSurfaceSmoothing, int id = levelSetDefaults::OBJECT ) ;
int addObject( std::unique_ptr<SurfUnstructured> &&, double, int id = levelSetDefaults::OBJECT ) ;
int addObject( SurfUnstructured *, double, int id = levelSetDefaults::OBJECT ) ;
int addObject( SurfUnstructured *, double, LevelSetSurfaceSmoothing, int id = levelSetDefaults::OBJECT ) ;
int addObject( const std::unordered_set<long> &, int id=levelSetDefaults::OBJECT ) ;
int addObject( const std::vector<long> &, long, bool, int id=levelSetDefaults::OBJECT ) ;
int addObject( std::unique_ptr<LevelSetObject> && ) ;
Expand Down
9 changes: 9 additions & 0 deletions src/levelset/levelSetCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ enum class LevelSetField{
UNDEFINED
};

/*!
* @ingroup levelsetEnums
* Enum class containing the possible order of surface smooting
*/
enum class LevelSetSurfaceSmoothing{
LOW_ORDER, /**< low order surface smoothing */
HIGH_ORDER /**< high order surface smoothing */
};

/*!
* Hasher for the LevelSetField enum.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/levelset/levelSetObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,16 +827,16 @@ LevelSetCellLocation LevelSetObject::fillCellGeometricNarrowBandLocationCache(lo
{
// Get cell information
double cellCacheValue = evalCellValue(id, CELL_CACHE_IS_SIGNED);
double cellUnsigendValue = std::abs(cellCacheValue);
double cellUnsignedValue = std::abs(cellCacheValue);

// Identify cells that are geometrically inside the narrow band
//
// First we need to check if the cell intersectes the surface, and only if it
// deosn't we should check if its distance is lower than the narrow band size.
LevelSetCellLocation cellLocation = LevelSetCellLocation::UNKNOWN;
if (_intersectSurface(id, cellUnsigendValue, CELL_LOCATION_INTERSECTION_MODE) == LevelSetIntersectionStatus::TRUE) {
if (_intersectSurface(id, cellUnsignedValue, CELL_LOCATION_INTERSECTION_MODE) == LevelSetIntersectionStatus::TRUE) {
cellLocation = LevelSetCellLocation::NARROW_BAND_INTERSECTED;
} else if (cellUnsigendValue <= m_narrowBandSize) {
} else if (cellUnsignedValue <= m_narrowBandSize) {
cellLocation = LevelSetCellLocation::NARROW_BAND_DISTANCE;
}

Expand Down
Loading