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

Add convex surface builder #1113

Merged
merged 8 commits into from
Feb 21, 2024

Conversation

sethrj
Copy link
Member

@sethrj sethrj commented Feb 16, 2024

The "convex surface builder" is going to be the next building block above surfaces when constructing shapes, solids, etc. It's a single intersection operation on a list of convex surfaces, so it will be easy to reason about when formulating safety calculations, constructing building boxes, etc.

The expected use case will be to have a ConvexRegion class that can be reusable (for example doing rings and other partially negated regions). A Shape class, which "is-a" Object, i.e. something that can be turned into a Volume, will have a single convex region; a solid may have an inside and outside; etc.

// The building block of a shape or solid
class ConvexRegion
{
    virtual void build(ConvexSurfaceBuilder& add_surface) const = 0;
};

// A hemisphere as part of a shape or a solid
class HemisphereRegion : public ConvexRegion
{
    void build(ConvexSurfaceBuilder& add_surface) const final
    {
        add_surface(PlaneZ{0.0});
        add_surface(SphereCentered{radius_});
    }
};

// Primitive shape consisting of a single solid
class Shape : public Object
{
  public:
    virtual ConvexRegion const& interior() const;

    NodeId build(VolumeBuilder& vb) const final;
};

NodeId Shape::build(VolumeBuilder& vb) const final
{
    detail::ConvexSurfaceState css;
    css.transform = &sb.current_transform();
    css.object_name = this->label();
    ConvexSurfaceBuilder sb{vb.unit_builder(), &css};
    this->interior().build(sb);
    auto result = vb.add_csg_node(Join, std::move(css.nodes));
    // Save bounding zone and metadata for the shape
    return result;
}

@sethrj sethrj added enhancement New feature or request orange Work on ORANGE geometry engine labels Feb 16, 2024
src/orange/orangeinp/ConvexSurfaceBuilder.hh Show resolved Hide resolved
src/orange/orangeinp/ConvexSurfaceBuilder.cc Outdated Show resolved Hide resolved
src/orange/orangeinp/ConvexSurfaceBuilder.cc Show resolved Hide resolved
src/orange/orangeinp/ConvexSurfaceBuilder.cc Outdated Show resolved Hide resolved
src/orange/orangeinp/ConvexSurfaceBuilder.cc Show resolved Hide resolved
src/orange/orangeinp/detail/BoundingZone.hh Show resolved Hide resolved
src/orange/orangeinp/detail/NegatedSurfaceClipper.hh Outdated Show resolved Hide resolved
src/orange/surf/SurfaceClipper.cc Show resolved Hide resolved
@sethrj sethrj enabled auto-merge (squash) February 21, 2024 13:42
@sethrj sethrj merged commit dd805a2 into celeritas-project:develop Feb 21, 2024
20 of 21 checks passed
@sethrj sethrj deleted the convex-surface-builder branch February 21, 2024 14:07
@sethrj sethrj mentioned this pull request Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request orange Work on ORANGE geometry engine
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants