70 "ObjCompAssembly cannot contain components of non-ObjComponent type");
74 (*it)->setParent(
this);
85 for (
auto &component :
m_group) {
105 throw std::runtime_error(
"ObjCompAssembly::add() called on a Parametrized object.");
111 "ObjCompAssembly cannot contain components of non-ObjComponent type");
116 return static_cast<int>(
m_group.size());
129 throw std::runtime_error(
"ObjCompAssembly::addCopy() called on a Parametrized object.");
136 "ObjCompAssembly cannot contain components of non-ObjComponent type");
141 return static_cast<int>(
m_group.size());
155 throw std::runtime_error(
"ObjCompAssembly::addCopy() called on a Parametrized object.");
162 "ObjCompAssembly cannot contain components of non-ObjComponent type");
168 return static_cast<int>(
m_group.size());
178 throw std::logic_error(
"Failed to cast base component to ObjCompAssembly");
180 return objCompAss->nelements();
182 return static_cast<int>(
m_group.size());
196 throw std::runtime_error(
"ObjCompAssembly::operator[] range not valid");
202 throw std::logic_error(
"Failed to cast base component to ObjCompAssembly");
219 for (
int i = 0; i < this->
nelements(); i++) {
220 std::shared_ptr<IComponent> comp = this->
getChild(i);
222 outVector.emplace_back(comp);
225 std::shared_ptr<ICompAssembly> assemb = std::dynamic_pointer_cast<ICompAssembly>(comp);
227 assemb->getChildren(outVector, recursive);
243 g_log.
debug() <<
"only implemented for children\n";
244 for (
int i = 0; i < nchildren; ++i) {
245 std::shared_ptr<Geometry::IComponent> comp = this->
getChild(i);
246 if (comp->getName() == cname)
249 return std::shared_ptr<const IComponent>();
261 for (i = 0; i < this->
nelements(); i++) {
262 os <<
"Component " << i <<
" : **********\n";
276 for (i = 0; i < this->
nelements(); i++) {
277 std::shared_ptr<const ObjCompAssembly> test = std::dynamic_pointer_cast<const ObjCompAssembly>(this->
operator[](i));
278 os <<
"Element " << i <<
" in the assembly : ";
280 os << test->getName() <<
'\n';
281 os <<
"Children :******** \n";
331 std::deque<IComponent_const_sptr> &searchQueue)
const {
333 for (
int i = 0; i < nchildren; ++i) {
334 std::shared_ptr<Geometry::IComponent> comp = this->
getChild(i);
335 if (std::dynamic_pointer_cast<ICompAssembly>(comp)) {
336 searchQueue.emplace_back(comp);
339 else if (
const auto *physicalObject =
dynamic_cast<IObjComponent *
>(comp.get())) {
340 physicalObject->interceptSurface(testRay);
364 g_log.
warning(
"Creating outline with fewer than 2 elements. The outline "
365 "displayed may be inaccurate.");
369 std::string detectorType;
371 std::vector<Kernel::V3D> vectors;
372 double radius,
height, innerRadius;
373 std::shared_ptr<const IObject>
obj =
m_group.front()->shape();
377 obj->GetObjectGeom(otype, vectors, innerRadius, radius,
height);
379 detectorType =
"box";
381 detectorType =
"cylinder";
383 throw std::runtime_error(
"IDF \"outline\" option is only allowed for assemblies containing "
384 "components of types \"box\" or \"cylinder\".");
390 double Ixx = 0, Iyy = 0, Izz = 0, Ixy = 0, Ixz = 0, Iyz = 0;
393 V3D p = (**it).getRelativePos();
398 V3D p = (**it).getRelativePos();
399 double x = p.
X() - Cmass.
X(), x2 =
x *
x;
400 double y = p.
Y() - Cmass.
Y(), y2 =
y *
y;
401 double z = p.
Z() - Cmass.
Z(), z2 =
z *
z;
442 g_log.
debug() <<
"Inertia matrix: " << II << II.determinant() <<
'\n';
443 II.Diagonalise(Vec, D);
446 vx =
V3D(Vec[0][0], Vec[1][0], Vec[2][0]);
447 vy =
V3D(Vec[0][1], Vec[1][1], Vec[2][1]);
448 vz =
V3D(Vec[0][2], Vec[1][2], Vec[2][2]);
457 double hxn = 0, hyn = 0, hzn = 0;
458 double hxp = 0, hyp = 0, hzp = 0;
461 V3D p = (**it).getRelativePos() - Cmass;
487 if (hx > 1e-3 || hy > 1e-3)
499 std::ostringstream obj_str;
500 if (detectorType ==
"box") {
504 for (
size_t i = 1; i < vectors.size(); ++i) {
505 V3D p = vectors[i] - p0;
521 if (!firstAtBottom) {
526 V3D p_lfb = Cmass - vx - vy - vz;
527 V3D p_lft = Cmass - vx - vy + vz;
528 V3D p_lbb = Cmass - vx + vy - vz;
529 V3D p_rfb = Cmass + vx - vy - vz;
530 obj_str <<
"<cuboid id=\"shape\">";
531 obj_str <<
"<left-front-bottom-point ";
532 obj_str <<
"x=\"" << p_lfb.
X();
533 obj_str <<
"\" y=\"" << p_lfb.
Y();
534 obj_str <<
"\" z=\"" << p_lfb.
Z();
536 obj_str <<
"<left-front-top-point ";
537 obj_str <<
"x=\"" << p_lft.
X();
538 obj_str <<
"\" y=\"" << p_lft.
Y();
539 obj_str <<
"\" z=\"" << p_lft.
Z();
541 obj_str <<
"<left-back-bottom-point ";
542 obj_str <<
"x=\"" << p_lbb.
X();
543 obj_str <<
"\" y=\"" << p_lbb.
Y();
544 obj_str <<
"\" z=\"" << p_lbb.
Z();
546 obj_str <<
"<right-front-bottom-point ";
547 obj_str <<
"x=\"" << p_rfb.
X();
548 obj_str <<
"\" y=\"" << p_rfb.
Y();
549 obj_str <<
"\" z=\"" << p_rfb.
Z();
551 obj_str <<
"</cuboid>";
553 }
else if (detectorType ==
"cylinder") {
565 obj_str <<
"<cylinder id=\"stick\">";
566 obj_str <<
"<centre-of-bottom-base ";
567 obj_str <<
"x=\"" << Cmass.
X();
568 obj_str <<
"\" y=\"" << Cmass.
Y();
569 obj_str <<
"\" z=\"" << Cmass.
Z();
571 obj_str <<
"<axis x=\"" << vz.
X() <<
"\" y=\"" << vz.
Y() <<
"\" z=\"" << vz.
Z() <<
"\" /> ";
572 obj_str <<
"<radius val=\"" << radius <<
"\" />";
573 obj_str <<
"<height val=\"" << hz <<
"\" />";
574 obj_str <<
"</cylinder>";
577 if (!obj_str.str().empty()) {
582 return std::shared_ptr<IObject>();
602 os <<
"************************\n";
603 os <<
"Number of children :" << ass.
nelements() <<
'\n';
double obj
the value of the quadratic function
ComponentVisitor : Visitor for IComponents.
virtual size_t registerObjComponentAssembly(const ObjCompAssembly &obj)=0
const ParameterMap * m_map
A pointer to const ParameterMap containing the parameters.
bool hasComponentInfo() const
Kernel::V3D getPos() const override
Get the position of the IComponent. Tree structure is traverse through the.
const Component * m_base
The base component - this is the unmodified component (without the parameters).
Kernel::Quat getRotation() const override
Get the absolute orientation of the IComponent.
Class for Assembly of geometric components.
virtual int add(IComponent *)=0
Add a component to the assembly.
base class for Geometric IComponent
virtual void printSelf(std::ostream &) const =0
Prints a text representation of itself.
virtual IComponent * clone() const =0
Return a clone to the current object.
virtual void setParent(IComponent *)=0
Assign a parent IComponent. Previous parent link is lost.
virtual Kernel::V3D getRelativePos() const =0
Get the position relative to the parent IComponent (absolute if no parent)
virtual void setName(const std::string &)=0
Set the IComponent name.
Object Component class, this class brings together the physical attributes of the component to the po...
Class for Assembly of geometric components.
std::shared_ptr< const IComponent > getComponentByName(const std::string &cname, int nlevels=0) const override
Returns a pointer to the first component of assembly encountered with the.
int nelements() const override
Return the number of elements in the assembly.
size_t registerContents(class Mantid::Geometry::ComponentVisitor &visitor) const override
void printChildren(std::ostream &) const override
Print information about all children.
IComponent * clone() const override
Make a clone of the present component.
void getChildren(std::vector< IComponent_const_sptr > &outVector, bool recursive) const override
Get all children.
void setOutline(std::shared_ptr< const IObject > obj)
Sets the outline shape for this assembly.
std::vector< ObjComponent * >::iterator comp_it
Iterator type.
std::vector< ObjComponent * >::const_iterator const_comp_it
Const iterator type.
void testIntersectionWithChildren(Track &, std::deque< IComponent_const_sptr > &) const override
Test the intersection of the ray with the children of the component assembly
std::shared_ptr< IComponent > getChild(const int i) const override
Get a pointer to the ith component within the assembly. Easier to use than.
void printTree(std::ostream &) const override
Print information about all the elements in the tree to a stream Loops through all components in the ...
ObjCompAssembly(const IComponent *base, const ParameterMap *map)
Empty constructor.
int addCopy(IComponent *) override
Add a copy (clone) of a component.
Kernel::Quat getRotation() const override
Gets the absolute position of the Parametrized ObjCompAssembly This attempts to read the cached posit...
~ObjCompAssembly() override
Destructor.
std::vector< ObjComponent * > m_group
the group of child components
ObjCompAssembly & operator=(const ObjCompAssembly &)
int add(IComponent *) override
Add a component to the assembly.
Kernel::V3D getPos() const override
Gets the absolute position of the Parametrized ObjCompAssembly This attempts to read the cached posit...
std::shared_ptr< IObject > createOutline()
Set the outline of the assembly.
std::shared_ptr< IComponent > operator[](int i) const override
Get a pointer to the ith component in the assembly.
Object Component class, this class brings together the physical attributes of the component to the po...
std::shared_ptr< const IObject > m_shape
The physical geometry representation.
static std::shared_ptr< IComponent > create(const std::shared_ptr< const IComponent > &base, const ParameterMap *map)
Create a parameterized component from the given base component and ParameterMap.
bool getCachedRotation(const IComponent *comp, Kernel::Quat &rotation) const
Attempts to retrieve a rotation from the rotation cache.
bool getCachedLocation(const IComponent *comp, Kernel::V3D &location) const
Attempts to retrieve a location from the location cache.
void setCachedLocation(const IComponent *comp, const Kernel::V3D &location) const
Sets a cached location on the location cache.
void setCachedRotation(const IComponent *comp, const Kernel::Quat &rotation) const
Sets a cached rotation on the rotation cache.
Class originally intended to be used with the DataHandling 'LoadInstrument' algorithm.
std::shared_ptr< CSGObject > createShape(Poco::XML::Element *pElem)
Creates a geometric object from a DOM-element-node pointing to an element whose child nodes contain t...
Defines a track as a start point and a direction.
Exception for errors associated with the instrument definition.
The Logger class is in charge of the publishing messages from the framework through various channels.
void debug(const std::string &msg)
Logs at debug level.
void warning(const std::string &msg)
Logs at warning level.
constexpr double scalar_prod(const V3D &v) const noexcept
Calculates the cross product.
constexpr double X() const noexcept
Get x.
constexpr double Y() const noexcept
Get y.
constexpr double Z() const noexcept
Get z.
This functor is used as the deleter object of a shared_ptr to effectively erase ownership Raw pointer...
Kernel::Logger g_log("DetermineSpinStateOrder")
Mantid::Kernel::Logger g_log("Goniometer")
MANTID_GEOMETRY_DLL std::ostream & operator<<(std::ostream &stream, const PointGroup &self)
Returns a streamed representation of the PointGroup object.
Mantid::Kernel::Matrix< double > DblMatrix