<commit_before>#ifndef OPENMC_SURFACE_H
#define OPENMC_SURFACE_H

#include <map>
#include <limits>  // For numeric_limits
#include <string>
#include <vector>

#include "hdf5.h"
#include "pugixml.hpp"

#include "openmc/constants.h"
#include "openmc/position.h"

#ifdef DAGMC
#include "DagMC.hpp"
#endif

namespace openmc {

//==============================================================================
// Module constant declarations (defined in .cpp)
//==============================================================================

// TODO: Convert to enum
extern "C" const int BC_TRANSMIT;
extern "C" const int BC_VACUUM;
extern "C" const int BC_REFLECT;
extern "C" const int BC_PERIODIC;

//==============================================================================
// Global variables
//==============================================================================

extern "C" int32_t n_surfaces;

class Surface;
extern std::vector<Surface*> surfaces;

extern std::map<int, int> surface_map;

//==============================================================================
//! Coordinates for an axis-aligned cube that bounds a geometric object.
//==============================================================================

struct BoundingBox
{	      
  double xmin;
  double xmax;
  double ymin;
  double ymax;
  double zmin;
  double zmax;
};

//==============================================================================
//! A geometry primitive used to define regions of 3D space.
//==============================================================================

class Surface
{
public:
  int id_;                    //!< Unique ID
  int bc_;                    //!< Boundary condition
  std::string name_;          //!< User-defined name

  std::vector<int> neighbor_pos_; //!< List of cells on positive side
  std::vector<int> neighbor_neg_; //!< List of cells on negative side

  explicit Surface(pugi::xml_node surf_node);
  Surface();
  
  virtual ~Surface() {}

  //! Determine which side of a surface a point lies on.
  //! \param r The 3D Cartesian coordinate of a point.
  //! \param u A direction used to "break ties" and pick a sense when the
  //!   point is very close to the surface.
  //! \return true if the point is on the "positive" side of the surface and
  //!   false otherwise.
  bool sense(Position r, Direction u) const;

  //! Determine the direction of a ray reflected from the surface.
  //! \param[in] r The point at which the ray is incident.
  //! \param[in] u Incident direction of the ray
  //! \return Outgoing direction of the ray
  Direction reflect(Position r, Direction u) const;

  //! Evaluate the equation describing the surface.
  //!
  //! Surfaces can be described by some function f(x, y, z) = 0.  This member
  //! function evaluates that mathematical function.
  //! \param r A 3D Cartesian coordinate.
  virtual double evaluate(Position r) const = 0;

  //! Compute the distance between a point and the surface along a ray.
  //! \param r A 3D Cartesian coordinate.
  //! \param u The direction of the ray.
  //! \param coincident A hint to the code that the given point should lie
  //!   exactly on the surface.
  virtual double distance(Position r, Direction u, bool coincident) const = 0;

  //! Compute the local outward normal direction of the surface.
  //! \param r A 3D Cartesian coordinate.
  //! \return Normal direction
  virtual Direction normal(Position r) const = 0;

  //! Write all information needed to reconstruct the surface to an HDF5 group.
  //! \param group_id An HDF5 group id.
  //TODO: this probably needs to include i_periodic for PeriodicSurface
  virtual void to_hdf5(hid_t group_id) const = 0;
  
};

class CSGSurface : public Surface
{
 public:
  explicit CSGSurface(pugi::xml_node surf_node);
  CSGSurface();

  void to_hdf5(hid_t group_id) const;
  
 protected:
  virtual void to_hdf5_inner(hid_t group_id) const = 0;  
};
 
//==============================================================================
//! A `Surface` representing a DAGMC-based surface in DAGMC.
//==============================================================================
#ifdef DAGMC
class DAGSurface : public Surface
{
 public:
  moab::DagMC* dagmc_ptr_;
  DAGSurface();
  double evaluate(Position r) const;
  double distance(Position r, Direction u,
                  bool coincident) const;
  Direction normal(Position r) const;
  //! Get the bounding box of this surface.
  BoundingBox bounding_box() const;

  void to_hdf5(hid_t group_id) const;
};
#endif 
//==============================================================================
//! A `Surface` that supports periodic boundary conditions.
//!
//! Translational periodicity is supported for the `XPlane`, `YPlane`, `ZPlane`,
//! and `Plane` types.  Rotational periodicity is supported for
//! `XPlane`-`YPlane` pairs.
//==============================================================================

class PeriodicSurface : public CSGSurface
{
public:
  int i_periodic_{C_NONE};    //!< Index of corresponding periodic surface

  explicit PeriodicSurface(pugi::xml_node surf_node);

  //! Translate a particle onto this surface from a periodic partner surface.
  //! \param other A pointer to the partner surface in this periodic BC.<commit_msg>Removing trailing white space.<commit_after>#ifndef OPENMC_SURFACE_H
#define OPENMC_SURFACE_H

#include <map>
#include <limits>  // For numeric_limits
#include <string>
#include <vector>

#include "hdf5.h"
#include "pugixml.hpp"

#include "openmc/constants.h"
#include "openmc/position.h"

#ifdef DAGMC
#include "DagMC.hpp"
#endif

namespace openmc {

//==============================================================================
// Module constant declarations (defined in .cpp)
//==============================================================================

// TODO: Convert to enum
extern "C" const int BC_TRANSMIT;
extern "C" const int BC_VACUUM;
extern "C" const int BC_REFLECT;
extern "C" const int BC_PERIODIC;

//==============================================================================
// Global variables
//==============================================================================

extern "C" int32_t n_surfaces;

class Surface;
extern std::vector<Surface*> surfaces;

extern std::map<int, int> surface_map;

//==============================================================================
//! Coordinates for an axis-aligned cube that bounds a geometric object.
//==============================================================================

struct BoundingBox
{
  double xmin;
  double xmax;
  double ymin;
  double ymax;
  double zmin;
  double zmax;
};

//==============================================================================
//! A geometry primitive used to define regions of 3D space.
//==============================================================================

class Surface
{
public:
  int id_;                    //!< Unique ID
  int bc_;                    //!< Boundary condition
  std::string name_;          //!< User-defined name

  std::vector<int> neighbor_pos_; //!< List of cells on positive side
  std::vector<int> neighbor_neg_; //!< List of cells on negative side

  explicit Surface(pugi::xml_node surf_node);
  Surface();

  virtual ~Surface() {}

  //! Determine which side of a surface a point lies on.
  //! \param r The 3D Cartesian coordinate of a point.
  //! \param u A direction used to "break ties" and pick a sense when the
  //!   point is very close to the surface.
  //! \return true if the point is on the "positive" side of the surface and
  //!   false otherwise.
  bool sense(Position r, Direction u) const;

  //! Determine the direction of a ray reflected from the surface.
  //! \param[in] r The point at which the ray is incident.
  //! \param[in] u Incident direction of the ray
  //! \return Outgoing direction of the ray
  Direction reflect(Position r, Direction u) const;

  //! Evaluate the equation describing the surface.
  //!
  //! Surfaces can be described by some function f(x, y, z) = 0.  This member
  //! function evaluates that mathematical function.
  //! \param r A 3D Cartesian coordinate.
  virtual double evaluate(Position r) const = 0;

  //! Compute the distance between a point and the surface along a ray.
  //! \param r A 3D Cartesian coordinate.
  //! \param u The direction of the ray.
  //! \param coincident A hint to the code that the given point should lie
  //!   exactly on the surface.
  virtual double distance(Position r, Direction u, bool coincident) const = 0;

  //! Compute the local outward normal direction of the surface.
  //! \param r A 3D Cartesian coordinate.
  //! \return Normal direction
  virtual Direction normal(Position r) const = 0;

  //! Write all information needed to reconstruct the surface to an HDF5 group.
  //! \param group_id An HDF5 group id.
  //TODO: this probably needs to include i_periodic for PeriodicSurface
  virtual void to_hdf5(hid_t group_id) const = 0;

};

class CSGSurface : public Surface
{
 public:
  explicit CSGSurface(pugi::xml_node surf_node);
  CSGSurface();

  void to_hdf5(hid_t group_id) const;

 protected:
  virtual void to_hdf5_inner(hid_t group_id) const = 0;
};

//==============================================================================
//! A `Surface` representing a DAGMC-based surface in DAGMC.
//==============================================================================
#ifdef DAGMC
class DAGSurface : public Surface
{
 public:
  moab::DagMC* dagmc_ptr_;
  DAGSurface();
  double evaluate(Position r) const;
  double distance(Position r, Direction u,
                  bool coincident) const;
  Direction normal(Position r) const;
  //! Get the bounding box of this surface.
  BoundingBox bounding_box() const;

  void to_hdf5(hid_t group_id) const;
};
#endif
//==============================================================================
//! A `Surface` that supports periodic boundary conditions.
//!
//! Translational periodicity is supported for the `XPlane`, `YPlane`, `ZPlane`,
//! and `Plane` types.  Rotational periodicity is supported for
//! `XPlane`-`YPlane` pairs.
//==============================================================================

class PeriodicSurface : public CSGSurface
{
public:
  int i_periodic_{C_NONE};    //!< Index of corresponding periodic surface

  explicit PeriodicSurface(pugi::xml_node surf_node);

  //! Translate a particle onto this surface from a periodic partner surface.
  //! \param other A pointer to the partner surface in this periodic BC.
{'fraction_non_alphanumeric': 0.2617202268431002, 'fraction_numerical': 0.003780718336483932, 'mean_word_length': 4.186764705882353, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1426713', 'n_tokens_mistral': 2916, 'n_tokens_neox': 2702, 'n_words': 1050}