Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
TransformationManager.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef TRANSFORMATIONMANAGER_H
27#define TRANSFORMATIONMANAGER_H
28
29// -- Core stuff
30#include "CamiTKAPI.h"
31
32#include "FrameOfReference.h"
33#include "Transformation.h"
34
35// -- QT stuff
36#include <QHash>
37#include <QString>
38#include <QVector>
39#include <QPalette>
40#include <QVariant>
41
42#include <vtkSmartPointer.h>
43#include <vtkTransform.h>
44
45#include <memory>
46#include <unordered_set>
47
48namespace camitk {
49
50class Transformation;
51class FrameOfReference;
52class Application;
53
236public:
237
239 static QString toString();
240
243
247 static std::shared_ptr<FrameOfReference> getFrameOfReferenceOwnership(const QUuid& uuid);
248
255 static std::shared_ptr<FrameOfReference> getFrameOfReferenceOwnership(const FrameOfReference*);
256
263 static std::shared_ptr<FrameOfReference> addFrameOfReference(QString name, QString description = "");
264
270 static std::shared_ptr<FrameOfReference> addFrameOfReference(const FrameOfReference&);
271
275 static QVector<FrameOfReference*> getFramesOfReference();
277
280
287 static bool hasPath(const FrameOfReference* from, const FrameOfReference* to);
288
294 static bool isDefaultIdentityToWorld(const Transformation*);
295
299 static Transformation* getTransformation(const FrameOfReference* from, const FrameOfReference* to);
300
311 static std::shared_ptr<Transformation> getTransformationOwnership(const Transformation*);
312
323 static std::shared_ptr<Transformation> getTransformationOwnership(const QUuid& uuid);
324
335 static std::shared_ptr<Transformation> getTransformationOwnership(const FrameOfReference* from, const FrameOfReference* to);
336
341 static void ensurePathToWorld(const FrameOfReference* frame);
342
350 static bool preferredDefaultIdentityToWorldLink(const FrameOfReference* frame);
351
361 static const FrameOfReference* getWorldFrame();
362
366 static QVector<Transformation*> getDirectTransformations();
367
371 static QVector<Transformation*> getTransformations();
372
375 static std::shared_ptr<Transformation> addTransformation(const QVariant&);
376
380 static std::shared_ptr<Transformation> addTransformation(const FrameOfReference* from, const FrameOfReference* to);
381
383 static std::shared_ptr<Transformation> addTransformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to);
384
390 static std::shared_ptr<Transformation> addTransformation(const FrameOfReference* from, const FrameOfReference* to, vtkSmartPointer<vtkTransform> vtkTr);
391
393 static std::shared_ptr<Transformation> addTransformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to, vtkSmartPointer<vtkTransform> vtkTr);
394
398 static std::shared_ptr<Transformation> addTransformation(const FrameOfReference* from, const FrameOfReference* to, const vtkMatrix4x4* matrix);
399
401 static std::shared_ptr<Transformation> addTransformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to, const vtkMatrix4x4* matrix);
402
403
407 static void cleanupFramesAndTransformations();
408
424 static bool removeTransformation(std::shared_ptr<Transformation>& tr);
425
431 static bool removeTransformation(const FrameOfReference* from, const FrameOfReference* to);
432
439
441
444 static bool updateTransformation(const FrameOfReference* from, const FrameOfReference* to, vtkSmartPointer<vtkTransform> vtkTr);
445
447 static bool updateTransformation(const FrameOfReference* from, const FrameOfReference* to, vtkMatrix4x4* matrix);
448
451 static bool updateTransformation(Transformation* tr, vtkSmartPointer<vtkTransform> vtkTr);
452
454 static bool updateTransformation(Transformation* tr, vtkMatrix4x4* matrix);
455
457
461 static bool hasSources(const Transformation*);
462
466 static QVector<Transformation*> getSources(const Transformation*);
467
469 static bool isInverseTransformation(const Transformation*);
470
472 static Transformation* getInverseTransformation(const Transformation* tr);
473
477 static bool isCompositeTransformation(const Transformation* tr);
478
480
488 static QVariant toVariant();
489
497 static void fromVariant(const QVariant&);
498
499private:
500
503
505 static std::shared_ptr<FrameOfReference> worldFrame;
506
508 static std::vector<std::shared_ptr<FrameOfReference>> frames;
509
511 static std::vector<std::shared_ptr<Transformation>> transformations;
512
514 static QHash<QUuid, FrameOfReference*> frameMap;
515
517 static QHash<QUuid, Transformation*> transformationMap;
518
523 static QHash<const Transformation*, QVector<std::shared_ptr<Transformation>>> transformationSources;
524
526 static QHash<const FrameOfReference*, QHash<const FrameOfReference*, Transformation*>> transformationFromTo;
527
544 static std::unordered_set<const Transformation*> defaultIdentityToWorldTransformations;
545
554 static std::shared_ptr<Transformation> registerTransformation(Transformation* tr, const QVector<std::shared_ptr<Transformation>>& sources = {});
555
565 static QVector<std::shared_ptr<Transformation>> getPath(const FrameOfReference* from, const FrameOfReference* to);
566
567
571 static std::shared_ptr<Transformation> addCompositeTransformation(QVector<std::shared_ptr<Transformation>> transforms);
572
577 static std::shared_ptr<FrameOfReference> addFrameOfReference(QUuid uuid, QString name, QString description, int dimensions = 3, const AnatomicalOrientation& ao = {}, std::vector<Unit> units = {"", "", "", "", ""});
578
582 static std::shared_ptr<FrameOfReference> addFrameOfReference(const QVariant&);
583
585
588 static bool removeDefaultPaths(const FrameOfReference* from, const FrameOfReference* to);
589
592 static void removeTransformationFromInternalStructures(const Transformation* trToDelete);
593
595 static void cleanupCompositeTransformations();
596
601 static std::shared_ptr<Transformation> getTransformationSharedPtr(const Transformation*);
602};
603}
604#endif // TRANSFORMATIONMANAGER_H
#define CAMITK_API
Definition CamiTKAPI.h:66
const char * description
Definition applications/cepgenerator/main.cpp:38
AnatomicalOrientation describes the relationship between 3D axes of a FrameOfReference and medical im...
Definition AnatomicalOrientation.h:83
FrameOfReference is only a label for an abstract coordinate system.
Definition FrameOfReference.h:71
TransformationManager manages frames of reference and transformations for a CamiTK Application.
Definition TransformationManager.h:235
Transformation represents a geometrical transformation between two FrameOfReferences.
Definition Transformation.h:83
Definition Action.cpp:40
char * toString(const FrameOfReference &frame)
Definition TestTransformationManager.cpp:31