Going back to PlotBase. Makes more sense as Plot inherits from it.

This commit is contained in:
Patrick Shriwise 2019-03-08 09:23:33 -06:00
parent fbd0e5e4c5
commit 1e7271d0b4
3 changed files with 28 additions and 28 deletions

View file

@ -73,7 +73,7 @@ enum class PlotColorBy {
//===============================================================================
// Plot class
//===============================================================================
struct Slice {
struct PlotBase {
// Members
Position origin_; //!< Plot origin in geometry
Position width_; //!< Plot width in geometry
@ -82,7 +82,7 @@ struct Slice {
int level_; //!< Plot universe level
};
class Plot : public Slice
class Plot : public PlotBase
{
public:

View file

@ -64,8 +64,8 @@ class _Position(Structure):
return "Position: ({}, {}, {})".format(self.x, self.y, self.z)
class _Slice(Structure):
"""A structure defining a 2-D slice with underlying c-types
class _PlotBase(Structure):
"""A structure defining a 2-D geometry slice with underlying c-types
C-Type Attributes
-----------------
@ -212,20 +212,20 @@ class _Slice(Structure):
return self.__repr__()
_dll.openmc_id_map.argtypes = [POINTER(_Slice), POINTER(c_int32)]
_dll.openmc_id_map.argtypes = [POINTER(_PlotBase), POINTER(c_int32)]
_dll.openmc_id_map.restype = c_int
_dll.openmc_id_map.errcheck = _error_handler
def id_map(slice_view):
def id_map(plot):
"""
Generate a 2-D map of (cell_id, material_id). Used for in-memory image
generation.
Parameters
----------
plot : An openmc.capi.plot._Slice object describing the slice of the model
to be generated
plot : An openmc.capi.plot._PlotBase object describing the slice of the
model to be generated
Returns
-------
@ -233,8 +233,8 @@ def id_map(slice_view):
of OpenMC property ids with dtype int32
"""
img_data = np.zeros((slice_view.vRes, slice_view.hRes, 2),
img_data = np.zeros((plot.vRes, plot.hRes, 2),
dtype=np.dtype('int32'))
_dll.openmc_id_map(POINTER(_Slice)(slice_view),
_dll.openmc_id_map(POINTER(_PlotBase)(plot),
img_data.ctypes.data_as(POINTER(c_int32)))
return img_data

View file

@ -952,20 +952,20 @@ RGBColor random_color() {
return {int(prn()*255), int(prn()*255), int(prn()*255)};
}
extern "C" int openmc_id_map(void* slice, int32_t* data_out) {
extern "C" int openmc_id_map(void* plot, int32_t* data_out) {
auto sl = reinterpret_cast<Slice*>(slice);
if (!sl) {
auto plt = reinterpret_cast<PlotBase*>(plot);
if (!plt) {
set_errmsg("Invalid slice pointer passed to openmc_id_map");
return OPENMC_E_INVALID_ARGUMENT;
}
size_t width = sl->pixels_[0];
size_t height = sl->pixels_[1];
size_t width = plt->pixels_[0];
size_t height = plt->pixels_[1];
// get pixel size
double in_pixel = (sl->width_[0])/static_cast<double>(width);
double out_pixel = (sl->width_[1])/static_cast<double>(height);
double in_pixel = (plt->width_[0])/static_cast<double>(width);
double out_pixel = (plt->width_[1])/static_cast<double>(height);
// size data array
IDData data;
@ -974,27 +974,27 @@ extern "C" int openmc_id_map(void* slice, int32_t* data_out) {
// setup basis indices and initial position centered on pixel
int in_i, out_i;
double xyz[3];
switch(sl->basis_) {
switch(plt->basis_) {
case PlotBasis::xy :
in_i = 0;
out_i = 1;
xyz[0] = sl->origin_[0] - sl->width_[0] / 2. + in_pixel / 2.;
xyz[1] = sl->origin_[1] + sl->width_[1] / 2. - out_pixel / 2.;
xyz[2] = sl->origin_[2];
xyz[0] = plt->origin_[0] - plt->width_[0] / 2. + in_pixel / 2.;
xyz[1] = plt->origin_[1] + plt->width_[1] / 2. - out_pixel / 2.;
xyz[2] = plt->origin_[2];
break;
case PlotBasis::xz :
in_i = 0;
out_i = 2;
xyz[0] = sl->origin_[0] - sl->width_[0] / 2. + in_pixel / 2.;
xyz[1] = sl->origin_[1];
xyz[2] = sl->origin_[2] + sl->width_[1] / 2. - out_pixel / 2.;
xyz[0] = plt->origin_[0] - plt->width_[0] / 2. + in_pixel / 2.;
xyz[1] = plt->origin_[1];
xyz[2] = plt->origin_[2] + plt->width_[1] / 2. - out_pixel / 2.;
break;
case PlotBasis::yz :
in_i = 1;
out_i = 2;
xyz[0] = sl->origin_[0];
xyz[1] = sl->origin_[1] - sl->width_[0] / 2. + in_pixel / 2.;
xyz[2] = sl->origin_[2] + sl->width_[1] / 2. - out_pixel / 2.;
xyz[0] = plt->origin_[0];
xyz[1] = plt->origin_[1] - plt->width_[0] / 2. + in_pixel / 2.;
xyz[2] = plt->origin_[2] + plt->width_[1] / 2. - out_pixel / 2.;
break;
}
@ -1007,7 +1007,7 @@ extern "C" int openmc_id_map(void* slice, int32_t* data_out) {
p.r() = xyz;
p.u() = dir;
p.coord_[0].universe = model::root_universe;
int level = sl->level_;
int level = plt->level_;
int j{};
#pragma omp for