Carna Registration API Version 1.16.0
D:/Documents/mediTEC Projects/CRA/master/include/CRA/LinkedObject.h
00001 /*
00002  *  Copyright (C) 2010 - 2013 Leonid Kostrykin
00003  *
00004  *  Chair of Medical Engineering (mediTEC)
00005  *  RWTH Aachen University
00006  *  Pauwelsstr. 20
00007  *  52074 Aachen
00008  *  Germany
00009  *
00010  */
00011 
00012 #ifndef LINKEDOBJECT_H_2521354512
00013 #define LINKEDOBJECT_H_2521354512
00014 
00015 #include "VirtualElement.h"
00016 #include "Registration.h"
00017 #include <Carna/base/model/Position.h>
00018 #include <Carna/base/model/Object3D.h>
00019 
00020 namespace CRA
00021 {
00022 
00023 
00024 
00025 // ----------------------------------------------------------------------------------
00026 // LinkedObject Adaptive Interface
00027 // ----------------------------------------------------------------------------------
00028 
00036 class LinkedObject : public VirtualElement
00037 {
00038 
00039 public:
00040 
00043     LinkedObject( Carna::base::model::Object3D& );
00044 
00045 
00046     virtual void update( const Transformation& orientation
00047                        , const Registration& registration ) override;
00048 
00049 
00052     Carna::base::model::Object3D& object;
00053 
00054 }; // LinkedObject
00055 
00056 
00057 
00058 // ----------------------------------------------------------------------------------
00059 // LinkedObject Implementation
00060 // ----------------------------------------------------------------------------------
00061 
00062 inline
00063 LinkedObject::LinkedObject( Carna::base::model::Object3D& object )
00064     : object( object )
00065 {
00066 }
00067 
00068 
00069 inline
00070 void LinkedObject::update( const Transformation& bearing, const Registration& registration )
00071 {
00072     const Transformation orientation = registration.getTransformation() * bearing;
00073 
00074     Carna::base::model::Position position = Carna::base::model::Position::fromMillimeters( object.model
00075         , orientation.a14()
00076         , orientation.a24()
00077         , orientation.a34() );
00078 
00079     Transformation rotation = orientation;
00080     rotation.a14() = rotation.a24() = rotation.a34() = 0;
00081 
00082     object.setPosition( position );
00083     object.setRotation( rotation );
00084 }
00085 
00086 
00087 
00088 }  // namespace CRA
00089 
00090 #endif // LINKEDOBJECT_H_2521354512
 All Classes Functions Variables Enumerations Enumerator