77 "ObjCompAssembly cannot contain components of non-ObjComponent type");
81 (*it)->setParent(
this);
92 for (
auto &component :
m_group) {
112 throw std::runtime_error(
"ObjCompAssembly::add() called on a Parametrized object.");
118 "ObjCompAssembly cannot contain components of non-ObjComponent type");
123 return static_cast<int>(
m_group.size());
136 throw std::runtime_error(
"ObjCompAssembly::addCopy() called on a Parametrized object.");
143 "ObjCompAssembly cannot contain components of non-ObjComponent type");
148 return static_cast<int>(
m_group.size());
162 throw std::runtime_error(
"ObjCompAssembly::addCopy() called on a Parametrized object.");
169 "ObjCompAssembly cannot contain components of non-ObjComponent type");
175 return static_cast<int>(
m_group.size());
185 throw std::logic_error(
"Failed to cast base component to ObjCompAssembly");
187 return objCompAss->nelements();
189 return static_cast<int>(
m_group.size());
203 throw std::runtime_error(
"ObjCompAssembly::operator[] range not valid");
209 throw std::logic_error(
"Failed to cast base component to ObjCompAssembly");
226 for (
int i = 0; i < this->
nelements(); i++) {
227 std::shared_ptr<IComponent> comp = this->
getChild(i);
229 outVector.emplace_back(comp);
232 std::shared_ptr<ICompAssembly> assemb = std::dynamic_pointer_cast<ICompAssembly>(comp);
234 assemb->getChildren(outVector, recursive);
250 g_log.
debug() <<
"only implemented for children\n";
251 for (
int i = 0; i < nchildren; ++i) {
252 std::shared_ptr<Geometry::IComponent> comp = this->
getChild(i);
253 if (comp->getName() == cname)
256 return std::shared_ptr<const IComponent>();
268 for (i = 0; i < this->
nelements(); i++) {
269 os <<
"Component " << i <<
" : **********\n";
283 for (i = 0; i < this->
nelements(); i++) {
284 std::shared_ptr<const ObjCompAssembly> test = std::dynamic_pointer_cast<const ObjCompAssembly>(this->
operator[](i));
285 os <<
"Element " << i <<
" in the assembly : ";
287 os << test->getName() <<
'\n';
288 os <<
"Children :******** \n";
338 std::deque<IComponent_const_sptr> &searchQueue)
const {
340 for (
int i = 0; i < nchildren; ++i) {
341 std::shared_ptr<Geometry::IComponent> comp = this->
getChild(i);
342 if (std::dynamic_pointer_cast<ICompAssembly>(comp)) {
343 searchQueue.emplace_back(comp);
346 else if (
auto *physicalObject =
dynamic_cast<IObjComponent *
>(comp.get())) {
347 physicalObject->interceptSurface(testRay);
371 g_log.
warning(
"Creating outline with fewer than 2 elements. The outline "
372 "displayed may be inaccurate.");
378 std::vector<Kernel::V3D> vectors;
380 std::shared_ptr<const IObject>
obj =
m_group.front()->shape();
390 throw std::runtime_error(
"IDF \"outline\" option is only allowed for assemblies containing "
391 "components of types \"box\" or \"cylinder\".");
397 double Ixx = 0, Iyy = 0, Izz = 0, Ixy = 0, Ixz = 0, Iyz = 0;
400 V3D p = (**it).getRelativePos();
405 V3D p = (**it).getRelativePos();
406 double x = p.
X() - Cmass.
X(), x2 =
x *
x;
407 double y = p.
Y() - Cmass.
Y(), y2 =
y *
y;
408 double z = p.
Z() - Cmass.
Z(), z2 =
z *
z;
449 g_log.
debug() <<
"Inertia matrix: " << II << II.determinant() <<
'\n';
450 II.Diagonalise(Vec, D);
453 vx =
V3D(Vec[0][0], Vec[1][0], Vec[2][0]);
454 vy =
V3D(Vec[0][1], Vec[1][1], Vec[2][1]);
455 vz =
V3D(Vec[0][2], Vec[1][2], Vec[2][2]);
464 double hxn = 0, hyn = 0, hzn = 0;
465 double hxp = 0, hyp = 0, hzp = 0;
468 V3D p = (**it).getRelativePos() - Cmass;
494 if (hx > 1e-3 || hy > 1e-3)
506 std::ostringstream obj_str;
511 for (
size_t i = 1; i < vectors.size(); ++i) {
512 V3D p = vectors[i] - p0;
528 if (!firstAtBottom) {
533 V3D p_lfb = Cmass - vx - vy - vz;
534 V3D p_lft = Cmass - vx - vy + vz;
535 V3D p_lbb = Cmass - vx + vy - vz;
536 V3D p_rfb = Cmass + vx - vy - vz;
537 obj_str <<
"<cuboid id=\"shape\">";
538 obj_str <<
"<left-front-bottom-point ";
539 obj_str <<
"x=\"" << p_lfb.
X();
540 obj_str <<
"\" y=\"" << p_lfb.
Y();
541 obj_str <<
"\" z=\"" << p_lfb.
Z();
543 obj_str <<
"<left-front-top-point ";
544 obj_str <<
"x=\"" << p_lft.
X();
545 obj_str <<
"\" y=\"" << p_lft.
Y();
546 obj_str <<
"\" z=\"" << p_lft.
Z();
548 obj_str <<
"<left-back-bottom-point ";
549 obj_str <<
"x=\"" << p_lbb.
X();
550 obj_str <<
"\" y=\"" << p_lbb.
Y();
551 obj_str <<
"\" z=\"" << p_lbb.
Z();
553 obj_str <<
"<right-front-bottom-point ";
554 obj_str <<
"x=\"" << p_rfb.
X();
555 obj_str <<
"\" y=\"" << p_rfb.
Y();
556 obj_str <<
"\" z=\"" << p_rfb.
Z();
558 obj_str <<
"</cuboid>";
560 }
else if (
type ==
"cylinder") {
572 obj_str <<
"<cylinder id=\"stick\">";
573 obj_str <<
"<centre-of-bottom-base ";
574 obj_str <<
"x=\"" << Cmass.
X();
575 obj_str <<
"\" y=\"" << Cmass.
Y();
576 obj_str <<
"\" z=\"" << Cmass.
Z();
578 obj_str <<
"<axis x=\"" << vz.
X() <<
"\" y=\"" << vz.
Y() <<
"\" z=\"" << vz.
Z() <<
"\" /> ";
579 obj_str <<
"<radius val=\"" <<
radius <<
"\" />";
580 obj_str <<
"<height val=\"" << hz <<
"\" />";
581 obj_str <<
"</cylinder>";
584 if (!obj_str.str().empty()) {
589 return std::shared_ptr<IObject>();
609 os <<
"************************\n";
610 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...
Void deleter for shared pointers.
void operator()(void *p)
deleting operator. Does nothing
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
Register the contents of this ObjComponent.
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::string type() const override
String description of the type of component.
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.
Kernel::Logger g_log("ExperimentInfo")
static logger object
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