Skip to content

Commit

Permalink
Merge pull request #683 from Xiangyu-Hu/fix/transform-shape-bounds
Browse files Browse the repository at this point in the history
Fix `TransformShape::findBounds`
  • Loading branch information
Xiangyu-Hu authored Nov 21, 2024
2 parents 00815cb + 7f3ab0a commit 62a6a9c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
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

0 comments on commit 62a6a9c

Please sign in to comment.