Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Atraxus committed Dec 19, 2024
1 parent fcb1482 commit 466cbd7
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 71 deletions.
57 changes: 28 additions & 29 deletions Intern/rayx-core/src/Data/Importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,43 +61,42 @@ namespace RAYX {

void addBeamlineObjectFromXML(rapidxml::xml_node<>* node, Beamline* beamline, const std::vector<xml::Group>& group_context,
std::filesystem::path filename) {
// the following three blocks of code are lambda expressions (see
// https://en.cppreference.com/w/cpp/language/lambda) They define functions
// to be used in the if-else-chain below to keep it structured and readable.

// //addLightSource(s, node) is a function adding a light source to the
// beamline (if it's not nullptr)

RAYX::xml::Parser parser(node, group_context, filename);
ElementType type = parser.type();

DesignSource ds;
ds.m_elementParameters = Map();

DesignElement de;
de.m_elementParameters = Map();

// Light sources have constructors that accept a const DesignObject& as argument.
// They use the param* functions declared in <Data/xml.h> to retrieve the relevant information.
if (type == ElementType::PointSource) {
setPointSource(parser, &ds);
beamline->m_DesignSources.push_back(ds);
} else if (type == ElementType::MatrixSource) {
setMatrixSource(parser, &ds);
beamline->m_DesignSources.push_back(ds);
} else if (type == ElementType::DipoleSource) {
setDipoleSource(parser, &ds);
beamline->m_DesignSources.push_back(ds);
} else if (type == ElementType::DipoleSrc) {
setDipoleSource(parser, &ds);
beamline->m_DesignSources.push_back(ds);
} else if (type == ElementType::PixelSource) {
setPixelSource(parser, &ds);
beamline->m_DesignSources.push_back(ds);
} else if (type == ElementType::CircleSource) {
setCircleSource(parser, &ds);
beamline->m_DesignSources.push_back(ds);
} else if (type == ElementType::SimpleUndulatorSource) {
setSimpleUndulatorSource(parser, &ds);
bool isSource = true;
switch (type) {
case ElementType::PointSource:
setPointSource(parser, &ds);
break;
case ElementType::MatrixSource:
setMatrixSource(parser, &ds);
break;
case ElementType::DipoleSource:
case ElementType::DipoleSrc:
setDipoleSource(parser, &ds);
break;
case ElementType::PixelSource:
setPixelSource(parser, &ds);
break;
case ElementType::CircleSource:
setCircleSource(parser, &ds);
break;
case ElementType::SimpleUndulatorSource:
setSimpleUndulatorSource(parser, &ds);
break;
default:
isSource = false;
break;
}

if (isSource) {
beamline->m_DesignSources.push_back(ds);
} else {
parseElement(parser, &de);
Expand Down
2 changes: 1 addition & 1 deletion Intern/rayx-core/src/Data/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ bool parseGroup(rapidxml::xml_node<>* node, xml::Group* out) {
out->m_position = glm::vec4(0, 0, 0, 1);
out->m_orientation = glm::dmat4x4();

if (strcmp(node->name(), "group") != 0) {
if (std::strcmp(node->name(), "group") != 0) {
return false;
}

Expand Down
13 changes: 5 additions & 8 deletions Intern/rayx-core/src/Design/DesignElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ namespace RAYX {

Element DesignElement::compile() const {
RAYX_PROFILE_FUNCTION_STDOUT();
Surface surface;
Behaviour behav;

if (getType() == ElementType::ExpertsMirror) {
return makeElement(*this, serializeMirror(), makeQuadric(*this));
} else {
surface = makeSurface(*this);
behav = makeBehaviour(*this);
Surface surface = makeSurface(*this);
Behaviour behavior = makeBehaviour(*this);
if (getType() == ElementType::Slit) {
return makeElement(*this, behav, surface, {}, DesignPlane::XY);
return makeElement(*this, behavior, surface, {}, DesignPlane::XY);
} else if (getType() == ElementType::ImagePlane) {
return makeElement(*this, behav, surface, serializeUnlimited(), DesignPlane::XY);
return makeElement(*this, behavior, surface, serializeUnlimited(), DesignPlane::XY);
} else {
return makeElement(*this, behav, surface);
return makeElement(*this, behavior, surface);
}
}
}
Expand Down
24 changes: 11 additions & 13 deletions Intern/rayx-core/src/Element/Behaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,17 @@
namespace RAYX {

Behaviour makeBehaviour(const DesignElement& dele) {
BehaviourType behave = dele.getBehaviourType();
if (behave == BehaviourType::Grating) {
return makeGrating(dele);
} else if (behave == BehaviourType::Mirror) {
return serializeMirror();
} else if (behave == BehaviourType::Rzp) {
return makeRZPBehaviour(dele);
} else if (behave == BehaviourType::Slit) {
return makeSlit(dele);
} else if (behave == BehaviourType::Mirror) {
return serializeMirror();
} else {
return serializeImagePlane();
switch (dele.getBehaviourType()) {
case BehaviourType::Grating:
return makeGrating(dele);
case BehaviourType::Mirror:
return serializeMirror();
case BehaviourType::Rzp:
return makeRZPBehaviour(dele);
case BehaviourType::Slit:
return makeSlit(dele);
default:
return serializeImagePlane();
}
}

Expand Down
39 changes: 19 additions & 20 deletions Intern/rayx-core/src/Element/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,24 @@
namespace RAYX {

Surface makeSurface(const DesignElement& dele) {
auto surface = dele.getCurvatureType();
if (surface == CurvatureType::Plane) {
return makePlane();
} else if (surface == CurvatureType::Toroidal) {
return makeToroid(dele);
} else if (surface == CurvatureType::Spherical) {
return makeSphere(dele.getRadius());
} else if (surface == CurvatureType::RzpSphere) {
return makeSphere(dele.getLongRadius());
} else if (surface == CurvatureType::Cone) {
return makeCone(dele);
} else if (surface == CurvatureType::Cylinder) {
return makeCylinder(dele);
} else if (surface == CurvatureType::Ellipsoid) {
return makeEllipsoid(dele);
} else if (surface == CurvatureType::Paraboloid) {
return makeParaboloid(dele);
} else {
return serializePlaneXZ();
switch (dele.getCurvatureType()) {
case CurvatureType::Toroidal:
return makeToroid(dele);
case CurvatureType::Spherical:
return makeSphere(dele.getRadius());
case CurvatureType::RzpSphere:
return makeSphere(dele.getLongRadius());
case CurvatureType::Cone:
return makeCone(dele);
case CurvatureType::Cylinder:
return makeCylinder(dele);
case CurvatureType::Ellipsoid:
return makeEllipsoid(dele);
case CurvatureType::Paraboloid:
return makeParaboloid(dele);
case CurvatureType::Plane:
default:
return makePlane();
}
}

Expand Down Expand Up @@ -77,7 +76,7 @@ Surface makeCylinder(const DesignElement& dele) {
}

Surface makeCone(const DesignElement& dele) {
auto incidence = dele.getGrazingIncAngle();
RAYX::Rad incidence = dele.getGrazingIncAngle();
double entranceArmLength = dele.getEntranceArmLength();
double exitArmLength = dele.getExitArmLength();

Expand Down

0 comments on commit 466cbd7

Please sign in to comment.