Skip to content

Commit

Permalink
Reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
VHLM2001 committed Aug 13, 2024
1 parent 09b9339 commit 18340da
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 406 deletions.
2 changes: 1 addition & 1 deletion src/orange/OrangeTypes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,9 @@ enum class SurfaceType : unsigned char
kx, //!< Cone parallel to X axis
ky, //!< Cone parallel to Y axis
kz, //!< Cone parallel to Z axis
inv, //!< Involute
sq, //!< Simple quadric
gq, //!< General quadric
inv, //!< Involute
size_ //!< Sentinel value for number of surface types
};

Expand Down
90 changes: 45 additions & 45 deletions src/orange/orangeinp/IntersectRegion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,51 @@ Involute::Involute(Real3 const& radii,
- t_bounds_[1]);
}

//---------------------------------------------------------------------------//
// INFWEDGE
//---------------------------------------------------------------------------//
/*!
* Construct from a starting angle and interior angle.
*/
InfWedge::InfWedge(Turn start, Turn interior)
: start_{start}, interior_{interior}
{
CELER_VALIDATE(start_ >= zero_quantity() && start_ < Turn{1},
<< "invalid start angle " << start_.value()
<< " [turns]: must be in the range [0, 1)");
CELER_VALIDATE(interior_ > zero_quantity() && interior_ <= Turn{0.5},
<< "invalid interior wedge angle " << interior.value()
<< " [turns]: must be in the range (0, 0.5]");
}

//---------------------------------------------------------------------------//
/*!
* Build surfaces.
*
* Both planes should point "outward" to the wedge. In the degenerate case of
* interior = 0.5 we rely on CSG object deduplication.
*/
void InfWedge::build(IntersectSurfaceBuilder& insert_surface) const
{
real_type sinstart, cosstart, sinend, cosend;
sincos(start_, &sinstart, &cosstart);
sincos(start_ + interior_, &sinend, &cosend);

insert_surface(Sense::inside, Plane{Real3{sinstart, -cosstart, 0}, 0.0});
insert_surface(Sense::outside, Plane{Real3{sinend, -cosend, 0}, 0.0});

// TODO: restrict bounding boxes, at least eliminating two quadrants...
}

//---------------------------------------------------------------------------//
/*!
* Write output to the given JSON object.
*/
void InfWedge::output(JsonPimpl* j) const
{
to_json_pimpl(j, *this);
}

//---------------------------------------------------------------------------//
/*!
* Build surfaces.
Expand Down Expand Up @@ -716,51 +761,6 @@ void Involute::output(JsonPimpl* j) const
to_json_pimpl(j, *this);
}

//---------------------------------------------------------------------------//
// INFWEDGE
//---------------------------------------------------------------------------//
/*!
* Construct from a starting angle and interior angle.
*/
InfWedge::InfWedge(Turn start, Turn interior)
: start_{start}, interior_{interior}
{
CELER_VALIDATE(start_ >= zero_quantity() && start_ < Turn{1},
<< "invalid start angle " << start_.value()
<< " [turns]: must be in the range [0, 1)");
CELER_VALIDATE(interior_ > zero_quantity() && interior_ <= Turn{0.5},
<< "invalid interior wedge angle " << interior.value()
<< " [turns]: must be in the range (0, 0.5]");
}

//---------------------------------------------------------------------------//
/*!
* Build surfaces.
*
* Both planes should point "outward" to the wedge. In the degenerate case of
* interior = 0.5 we rely on CSG object deduplication.
*/
void InfWedge::build(IntersectSurfaceBuilder& insert_surface) const
{
real_type sinstart, cosstart, sinend, cosend;
sincos(start_, &sinstart, &cosstart);
sincos(start_ + interior_, &sinend, &cosend);

insert_surface(Sense::inside, Plane{Real3{sinstart, -cosstart, 0}, 0.0});
insert_surface(Sense::outside, Plane{Real3{sinend, -cosend, 0}, 0.0});

// TODO: restrict bounding boxes, at least eliminating two quadrants...
}

//---------------------------------------------------------------------------//
/*!
* Write output to the given JSON object.
*/
void InfWedge::output(JsonPimpl* j) const
{
to_json_pimpl(j, *this);
}

//---------------------------------------------------------------------------//
// PARALLELEPIPED
//---------------------------------------------------------------------------//
Expand Down
68 changes: 34 additions & 34 deletions src/orange/orangeinp/IntersectRegion.hh
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,40 @@ class GenPrism final : public IntersectRegionInterface
Degenerate degen_{Degenerate::none}; //!< no plane on this z axis
};

//---------------------------------------------------------------------------//
/*!
* An open wedge shape from the Z axis.
*
* The wedge is defined by an interior angle that *must* be less than or equal
* to 180 degrees (half a turn) and *must* be more than zero. It can be
* subtracted, or its negation can be subtracted. The start angle is mapped
* onto [0, 1) on construction.
*/
class InfWedge final : public IntersectRegionInterface
{
public:
// Construct from a starting angle and interior angle
InfWedge(Turn start, Turn interior);

// Build surfaces
void build(IntersectSurfaceBuilder&) const final;

// Output to JSON
void output(JsonPimpl*) const final;

//// ACCESSORS ////

//! Starting angle
Turn start() const { return start_; }

//! Interior angle
Turn interior() const { return interior_; }

private:
Turn start_;
Turn interior_;
};

//---------------------------------------------------------------------------//
/*!
* An involute centered on the origin.
Expand Down Expand Up @@ -331,40 +365,6 @@ class Involute final : public IntersectRegionInterface
real_type hh_;
};

//---------------------------------------------------------------------------//
/*!
* An open wedge shape from the Z axis.
*
* The wedge is defined by an interior angle that *must* be less than or equal
* to 180 degrees (half a turn) and *must* be more than zero. It can be
* subtracted, or its negation can be subtracted. The start angle is mapped
* onto [0, 1) on construction.
*/
class InfWedge final : public IntersectRegionInterface
{
public:
// Construct from a starting angle and interior angle
InfWedge(Turn start, Turn interior);

// Build surfaces
void build(IntersectSurfaceBuilder&) const final;

// Output to JSON
void output(JsonPimpl*) const final;

//// ACCESSORS ////

//! Starting angle
Turn start() const { return start_; }

//! Interior angle
Turn interior() const { return interior_; }

private:
Turn start_;
Turn interior_;
};

//---------------------------------------------------------------------------//
/*!
* A general parallelepiped centered on the origin.
Expand Down
28 changes: 14 additions & 14 deletions src/orange/surf/SoftSurfaceEqual.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ bool SoftSurfaceEqual::operator()(SphereCentered const& a,
return this->soft_eq_sq(a.radius_sq(), b.radius_sq());
}

//---------------------------------------------------------------------------//
/*!
* Compare two centered involutes for near equality.
*/
bool SoftSurfaceEqual::operator()(Involute const& a, Involute const& b) const
{
return this->soft_eq_(a.r_b(), b.r_b())
&& this->soft_eq_(a.displacement_angle(), b.displacement_angle())
&& a.sign() == b.sign() && this->soft_eq_(a.tmin(), b.tmin())
&& this->soft_eq_(a.tmax(), b.tmax())
&& this->soft_eq_distance({a.origin()[0], a.origin()[1], 0},
{b.origin()[0], b.origin()[1], 0});
}

//---------------------------------------------------------------------------//
/*!
* Compare two aligned cylinders for near equality.
Expand All @@ -98,6 +84,20 @@ bool SoftSurfaceEqual::operator()(CylAligned<T> const& a,
ORANGE_INSTANTIATE_OP(CylAligned);
//! \endcond

//---------------------------------------------------------------------------//
/*!
* Compare two centered involutes for near equality.
*/
bool SoftSurfaceEqual::operator()(Involute const& a, Involute const& b) const
{
return this->soft_eq_(a.r_b(), b.r_b())
&& this->soft_eq_(a.displacement_angle(), b.displacement_angle())
&& a.sign() == b.sign() && this->soft_eq_(a.tmin(), b.tmin())
&& this->soft_eq_(a.tmax(), b.tmax())
&& this->soft_eq_distance({a.origin()[0], a.origin()[1], 0},
{b.origin()[0], b.origin()[1], 0});
}

//---------------------------------------------------------------------------//
/*!
* Compare two planes for near equality.
Expand Down
4 changes: 2 additions & 2 deletions src/orange/surf/SoftSurfaceEqual.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ class SoftSurfaceEqual

bool operator()(Sphere const&, Sphere const&) const;

bool operator()(Involute const&, Involute const&) const;

template<Axis T>
bool operator()(ConeAligned<T> const&, ConeAligned<T> const&) const;

bool operator()(Involute const&, Involute const&) const;

bool operator()(SimpleQuadric const&, SimpleQuadric const&) const;

bool operator()(GeneralQuadric const&, GeneralQuadric const&) const;
Expand Down
12 changes: 6 additions & 6 deletions src/orange/surf/SurfaceClipper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,29 +149,29 @@ ORANGE_INSTANTIATE_OP(ConeAligned);

//---------------------------------------------------------------------------//
/*!
* Clip the bounding boxes to a simple quadric.
* Clip the bounding boxes to an involute.
*/
void SurfaceClipper::operator()(SimpleQuadric const&) const
void SurfaceClipper::operator()(Involute const&) const
{
// We no longer can guarantee any point being inside the shape; reset it
*int_ = BoundingBox{};
}

//---------------------------------------------------------------------------//
/*!
* Clip the bounding boxes to a general quadric.
* Clip the bounding boxes to a simple quadric.
*/
void SurfaceClipper::operator()(GeneralQuadric const&) const
void SurfaceClipper::operator()(SimpleQuadric const&) const
{
// We no longer can guarantee any point being inside the shape; reset it
*int_ = BoundingBox{};
}

//---------------------------------------------------------------------------//
/*!
* Clip the bounding boxes to an involute.
* Clip the bounding boxes to a general quadric.
*/
void SurfaceClipper::operator()(Involute const&) const
void SurfaceClipper::operator()(GeneralQuadric const&) const
{
// We no longer can guarantee any point being inside the shape; reset it
*int_ = BoundingBox{};
Expand Down
4 changes: 2 additions & 2 deletions src/orange/surf/SurfaceClipper.hh
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ class SurfaceClipper
template<Axis T>
void operator()(ConeAligned<T> const&) const;

void operator()(Involute const&) const;

void operator()(SimpleQuadric const&) const;

void operator()(GeneralQuadric const&) const;

void operator()(Involute const&) const;

// Apply to a surface with unknown type
void operator()(VariantSurface const& surf) const;

Expand Down
2 changes: 1 addition & 1 deletion src/orange/surf/SurfaceFwd.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ class CylAligned;
template<Axis T>
class CylCentered;
class GeneralQuadric;
class Involute;
class Plane;
template<Axis T>
class PlaneAligned;
class SimpleQuadric;
class Sphere;
class SphereCentered;
class Involute;

//---------------------------------------------------------------------------//
} // namespace celeritas
36 changes: 18 additions & 18 deletions src/orange/surf/SurfaceIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,24 @@ std::ostream& operator<<(std::ostream& os, GeneralQuadric const& s)
return os;
}

//---------------------------------------------------------------------------//
std::ostream& operator<<(std::ostream& os, Involute const& s)
{
if (s.sign() == Involute::Sign::clockwise)
{
os << "Involute cw: r=" << s.r_b()
<< ", a=" << constants::pi - s.displacement_angle() << ", t={"
<< s.tmin() << ',' << s.tmax() << '}' << " at " << s.origin();
}
else
{
os << "Involute ccw: r=" << s.r_b() << ", a=" << s.displacement_angle()
<< ", t={" << s.tmin() << ',' << s.tmax() << '}' << " at "
<< s.origin();
}
return os;
}

//---------------------------------------------------------------------------//
std::ostream& operator<<(std::ostream& os, Plane const& s)
{
Expand Down Expand Up @@ -109,24 +127,6 @@ std::ostream& operator<<(std::ostream& os, SphereCentered const& s)
return os;
}

//---------------------------------------------------------------------------//
std::ostream& operator<<(std::ostream& os, Involute const& s)
{
if (s.sign() == Involute::Sign::clockwise)
{
os << "Involute cw: r=" << s.r_b()
<< ", a=" << constants::pi - s.displacement_angle() << ", t={"
<< s.tmin() << ',' << s.tmax() << '}' << " at " << s.origin();
}
else
{
os << "Involute ccw: r=" << s.r_b() << ", a=" << s.displacement_angle()
<< ", t={" << s.tmin() << ',' << s.tmax() << '}' << " at "
<< s.origin();
}
return os;
}

//---------------------------------------------------------------------------//
#undef ORANGE_INSTANTIATE_SHAPE_STREAM
} // namespace celeritas
4 changes: 2 additions & 2 deletions src/orange/surf/SurfaceIO.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ std::ostream& operator<<(std::ostream&, CylCentered<T> const&);

std::ostream& operator<<(std::ostream&, GeneralQuadric const&);

std::ostream& operator<<(std::ostream&, Involute const&);

std::ostream& operator<<(std::ostream&, Plane const&);

template<Axis T>
Expand All @@ -39,8 +41,6 @@ std::ostream& operator<<(std::ostream&, SimpleQuadric const&);
std::ostream& operator<<(std::ostream&, Sphere const&);

std::ostream& operator<<(std::ostream&, SphereCentered const&);

std::ostream& operator<<(std::ostream&, Involute const&);
//!@}
//---------------------------------------------------------------------------//
} // namespace celeritas
Loading

0 comments on commit 18340da

Please sign in to comment.