-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transformed object construction (#1128)
* Add transformed shape * Fix single-precision casting * Add docs
- Loading branch information
Showing
9 changed files
with
434 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file orange/orangeinp/Transformed.cc | ||
//---------------------------------------------------------------------------// | ||
#include "Transformed.hh" | ||
|
||
#include "detail/CsgUnitBuilder.hh" | ||
#include "detail/VolumeBuilder.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace orangeinp | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Construct with daughter object and transform. | ||
* | ||
* The input transform should *not* be "no transform" because that would be | ||
* silly. | ||
*/ | ||
Transformed::Transformed(SPConstObject obj, VariantTransform&& transform) | ||
: obj_{std::move(obj)}, transform_{std::move(transform)} | ||
{ | ||
CELER_EXPECT(obj_); | ||
CELER_EXPECT(!transform_.valueless_by_exception()); | ||
CELER_EXPECT(!std::holds_alternative<NoTransformation>(transform_)); | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Construct a volume from this transformed shape. | ||
*/ | ||
NodeId Transformed::build(VolumeBuilder& vb) const | ||
{ | ||
// Apply the transform through the life of this object | ||
auto scoped_transform = vb.make_scoped_transform(transform_); | ||
return obj_->build(vb); | ||
} | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace orangeinp | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//----------------------------------*-C++-*----------------------------------// | ||
// Copyright 2024 UT-Battelle, LLC, and other Celeritas developers. | ||
// See the top-level COPYRIGHT file for details. | ||
// SPDX-License-Identifier: (Apache-2.0 OR MIT) | ||
//---------------------------------------------------------------------------// | ||
//! \file orange/orangeinp/Transformed.hh | ||
//---------------------------------------------------------------------------// | ||
#pragma once | ||
|
||
#include "orange/transform/VariantTransform.hh" | ||
|
||
#include "ObjectInterface.hh" | ||
|
||
namespace celeritas | ||
{ | ||
namespace orangeinp | ||
{ | ||
//---------------------------------------------------------------------------// | ||
/*! | ||
* Build a translated or transformed object. | ||
*/ | ||
class Transformed final : public ObjectInterface | ||
{ | ||
public: | ||
// Construct with daughter object and transform | ||
Transformed(SPConstObject obj, VariantTransform&& transform); | ||
|
||
//! Get the user-provided label | ||
std::string_view label() const final { return obj_->label(); } | ||
|
||
// Construct a volume from this object | ||
NodeId build(VolumeBuilder&) const final; | ||
|
||
private: | ||
SPConstObject obj_; | ||
VariantTransform transform_; | ||
}; | ||
|
||
//---------------------------------------------------------------------------// | ||
} // namespace orangeinp | ||
} // namespace celeritas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.