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";
297 std::deque<IComponent_const_sptr> &searchQueue)
const {
299 for (
int i = 0; i < nchildren; ++i) {
300 std::shared_ptr<Geometry::IComponent> comp = this->
getChild(i);
301 if (std::dynamic_pointer_cast<ICompAssembly>(comp)) {
302 searchQueue.emplace_back(comp);
305 else if (
const auto *physicalObject =
dynamic_cast<IObjComponent *
>(comp.get())) {
306 physicalObject->interceptSurface(testRay);
330 g_log.
warning(
"Creating outline with fewer than 2 elements. The outline "
331 "displayed may be inaccurate.");
335 std::string detectorType;
337 std::vector<Kernel::V3D> vectors;
338 double radius,
height, innerRadius;
339 std::shared_ptr<const IObject>
obj =
m_group.front()->shape();
343 obj->GetObjectGeom(otype, vectors, innerRadius, radius,
height);
345 detectorType =
"box";
347 detectorType =
"cylinder";
349 throw std::runtime_error(
"IDF \"outline\" option is only allowed for assemblies containing "
350 "components of types \"box\" or \"cylinder\".");
356 double Ixx = 0, Iyy = 0, Izz = 0, Ixy = 0, Ixz = 0, Iyz = 0;
359 V3D p = (**it).getRelativePos();
364 V3D p = (**it).getRelativePos();
365 double x = p.
X() - Cmass.
X(), x2 =
x *
x;
366 double y = p.
Y() - Cmass.
Y(), y2 =
y *
y;
367 double z = p.
Z() - Cmass.
Z(), z2 =
z *
z;
408 g_log.
debug() <<
"Inertia matrix: " << II << II.determinant() <<
'\n';
409 II.Diagonalise(Vec, D);
412 vx =
V3D(Vec[0][0], Vec[1][0], Vec[2][0]);
413 vy =
V3D(Vec[0][1], Vec[1][1], Vec[2][1]);
414 vz =
V3D(Vec[0][2], Vec[1][2], Vec[2][2]);
423 double hxn = 0, hyn = 0, hzn = 0;
424 double hxp = 0, hyp = 0, hzp = 0;
427 V3D p = (**it).getRelativePos() - Cmass;
453 if (hx > 1e-3 || hy > 1e-3)
465 std::ostringstream obj_str;
466 if (detectorType ==
"box") {
470 for (
size_t i = 1; i < vectors.size(); ++i) {
471 V3D p = vectors[i] - p0;
487 if (!firstAtBottom) {
492 V3D p_lfb = Cmass - vx - vy - vz;
493 V3D p_lft = Cmass - vx - vy + vz;
494 V3D p_lbb = Cmass - vx + vy - vz;
495 V3D p_rfb = Cmass + vx - vy - vz;
496 obj_str <<
"<cuboid id=\"shape\">";
497 obj_str <<
"<left-front-bottom-point ";
498 obj_str <<
"x=\"" << p_lfb.
X();
499 obj_str <<
"\" y=\"" << p_lfb.
Y();
500 obj_str <<
"\" z=\"" << p_lfb.
Z();
502 obj_str <<
"<left-front-top-point ";
503 obj_str <<
"x=\"" << p_lft.
X();
504 obj_str <<
"\" y=\"" << p_lft.
Y();
505 obj_str <<
"\" z=\"" << p_lft.
Z();
507 obj_str <<
"<left-back-bottom-point ";
508 obj_str <<
"x=\"" << p_lbb.
X();
509 obj_str <<
"\" y=\"" << p_lbb.
Y();
510 obj_str <<
"\" z=\"" << p_lbb.
Z();
512 obj_str <<
"<right-front-bottom-point ";
513 obj_str <<
"x=\"" << p_rfb.
X();
514 obj_str <<
"\" y=\"" << p_rfb.
Y();
515 obj_str <<
"\" z=\"" << p_rfb.
Z();
517 obj_str <<
"</cuboid>";
519 }
else if (detectorType ==
"cylinder") {
531 obj_str <<
"<cylinder id=\"stick\">";
532 obj_str <<
"<centre-of-bottom-base ";
533 obj_str <<
"x=\"" << Cmass.
X();
534 obj_str <<
"\" y=\"" << Cmass.
Y();
535 obj_str <<
"\" z=\"" << Cmass.
Z();
537 obj_str <<
"<axis x=\"" << vz.
X() <<
"\" y=\"" << vz.
Y() <<
"\" z=\"" << vz.
Z() <<
"\" /> ";
538 obj_str <<
"<radius val=\"" << radius <<
"\" />";
539 obj_str <<
"<height val=\"" << hz <<
"\" />";
540 obj_str <<
"</cylinder>";
543 if (!obj_str.str().empty()) {
548 return std::shared_ptr<IObject>();
568 os <<
"************************\n";
569 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.
const Component * m_base
The base component - this is the unmodified component (without the parameters).
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.
~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.
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.
Parameter map iterator typedef.
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