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

Fix TransformShape::findBounds #683

Merged
merged 3 commits into from
Nov 21, 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
29 changes: 26 additions & 3 deletions src/shared/geometries/transform_shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,36 @@ class TransformShape : public BaseShapeType
protected:
Transform transform_;

/// Returns the AABB of the rotated underlying shape's AABB
/// ⚠️ It is not the tight fit AABB of the underlying shape
/// But at least it encloses the underlying shape fully
virtual BoundingBox findBounds() override
{
BoundingBox original_bound = BaseShapeType::findBounds();
return BoundingBox(transform_.shiftFrameStationToBase(original_bound.first_),
transform_.shiftFrameStationToBase(original_bound.second_));
Vecd bb_min = Vecd::Constant(MaxReal);
Vecd bb_max = Vecd::Constant(-MaxReal);
for (auto x : {original_bound.first_.x(), original_bound.second_.x()})
{
for (auto y : {original_bound.first_.y(), original_bound.second_.y()})
{
if constexpr (Dimensions == 3)
{
for (auto z : {original_bound.first_.z(), original_bound.second_.z()})
{
bb_min = bb_min.cwiseMin(transform_.shiftFrameStationToBase(Vecd(x, y, z)));
bb_max = bb_max.cwiseMax(transform_.shiftFrameStationToBase(Vecd(x, y, z)));
}
}
else
{
bb_min = bb_min.cwiseMin(transform_.shiftFrameStationToBase(Vecd(x, y)));
bb_max = bb_max.cwiseMax(transform_.shiftFrameStationToBase(Vecd(x, y)));
}
}
}
return BoundingBox(bb_min, bb_max);
};
};
} // namespace SPH

#endif // TRANSFORM_SHAPE_H
#endif // TRANSFORM_SHAPE_H
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ template <typename DataType, typename NormType, class DynamicsIdentifier>
template <class ExecutionPolicy, class EncloserType>
VariableNormCK<DataType, NormType, DynamicsIdentifier>::ReduceKernel::
ReduceKernel(const ExecutionPolicy &ex_policy, EncloserType &encloser)
: variable_(encloser.dv_variable_->template DelegatedDataField(ex_policy)) {}
: variable_(encloser.dv_variable_->DelegatedDataField(ex_policy)) {}
//=================================================================================================//
template <class ExecutionPolicy, class EncloserType>
TotalKineticEnergyCK::ReduceKernel::
Expand Down
Loading