- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Sources/ML/STUAngioTransformEdit/mlAngioTransformEdit.cpp

Go to the documentation of this file.

    00001 /*
    00002 * Copyright (c) 2009 Stanford University, School of Medicine All rights reserved.
    00003 *
    00004 * STANFORD ACADEMIC SOFTWARE LICENSE AGREEMENT
    00005 * FOR AngioLocalize SOURCE CODE:
    00006 *
    00007 * 1.  This is a legal agreement between you, RECIPIENT, and STANFORD UNIVERSITY.
    00008 *       By accepting, receiving, and using AngioLocalize.including any accompanying information, materials or
    00009 *       manuals (Program), you are agreeing to be bound by the terms of this Agreement.
    00010 *       If you do not agree to the terms of this Agreement, promptly return the Program to the STANFORD.
    00011
    00012 * 2.  STANFORD grants to RECIPIENT a royalty-free, nonexclusive, and nontransferable license to use the Program
    00013 *       and accompanying source code furnished hereunder, upon the terms and conditions set out below.
    00014 *       documentation and/or other materials provided with the distribution.
    00015 * 3.  RECIPIENT acknowledges that the Program is a research tool still in the development stage and that
    00016 *       it is being supplied as is, without any accompanying services, support or improvements from STANFORD.
    00017 * 4.  RECIPIENT agrees to use the Program solely for internal non-commercial purposes.
    00018 * 5.  RECIPIENT may create derivatives and further transfer the Program under the following terms and conditions:
    00019 *        A) Recipient agrees to not commercially exploit the Program and agrees all uses will be for non-commercial purposes; and,
    00020 *        B) Recipient may not mark any derivatives with the title of Program and may not to use iPad mark for any derivatives; and,
    00021 *        C) Recipient agrees to mark and acknowledge all derivatives as follows: "This is a derivative work based on AngioLocalize:
    00022 *           Frameless AVM localization with 2D Digital Subtraction Angiography (DSA) and 3D Rotational Angiography (DRA) Images developed
    00023 *           by Dimitre Hristov, Lina Liu.
    00024 *        D) Recipient agrees to make all improvements, enhancements and derivatives available under
    00025 *           similar terms and conditions to the research community.
    00026 * 6.   RECIPIENT warrants that RECIPIENT will not remove or export any part of the software or Program from the United
    00027 *       States except in full compliance with all United States and other applicable laws and regulations.
    00028 * 7.  RECIPIENT will use the Program in compliance with all applicable laws, policies and regulations including, but not
    00029 *       limited to, any approvals, informed consent and patient confidentiality principles.
    00030 * 8.   RECIPIENT will indemnify, hold harmless, and defend Stanford against any claim of any kind arising out of or
    00031 *       related to the exercise of any rights granted under this Agreement or the breach of this Agreement by RECIPIENT.
    00032 * 9.  Title and copyright to the Program and any associated documentation shall at all times remain with STANFORD,
    00033 *       and RECIPIENT agrees to preserve same.
    00034 */
    00035
    00036
    00037 //----------------------------------------------------------------------------------
    00039
    00046 //----------------------------------------------------------------------------------
    00047
    00048 // Local includes
    00049 #include "mlAngioTransformEdit.h"
    00050
    00051 ML_START_NAMESPACE
    00052
    00053
    00055 ML_BASEOP_CLASS_SOURCE(AngioTransformEdit, BaseOp);
    00056
    00057 //----------------------------------------------------------------------------------
    00059 //----------------------------------------------------------------------------------
    00060 AngioTransformEdit::AngioTransformEdit ()
    00061   : BaseOp(0, 0)
    00062 {
    00063   ML_TRACE_IN("AngioTransformEdit::AngioTransformEdit ()");
    00064
    00065   // Suppress calls of handleNotification on field changes to
    00066   // avoid side effects during initialization phase.
    00067   handleNotificationOff();
    00068
    00069   // Get reference to always existing field container (guaranteed by BaseOp).
    00070   FieldContainer &fields = *getFieldContainer();
    00071
    00072   _translationFld           = fields.addVec3f  ("translation"      );
    00073   _rotationFld              = fields.addVec3f  ("rotation"      );
    00074
    00075   _addxtranslationFld       = fields.addNotify ("addxtranslation");
    00076   _addytranslationFld       = fields.addNotify ("addytranslation");
    00077   _addztranslationFld       = fields.addNotify ("addztranslation");
    00078
    00079   _subxtranslationFld       = fields.addNotify ("subxtranslation");
    00080   _subytranslationFld       = fields.addNotify ("subytranslation");
    00081   _subztranslationFld       = fields.addNotify ("subztranslation");
    00082
    00083   _transxincreFld           = fields.addDouble("transincrex");
    00084   _transyincreFld           = fields.addDouble("transincrey");
    00085   _transzincreFld           = fields.addDouble("transincrez");
    00086
    00087   _transxincreFld->setDoubleValue(1);
    00088   _transyincreFld->setDoubleValue(1);
    00089   _transzincreFld->setDoubleValue(1);
    00090
    00091   _addxrotationFld          = fields.addNotify ("addxrotation");
    00092   _addyrotationFld          = fields.addNotify ("addyrotation");
    00093   _addzrotationFld          = fields.addNotify ("addzrotation");
    00094
    00095   _subxrotationFld          = fields.addNotify ("subxrotation");
    00096   _subyrotationFld          = fields.addNotify ("subyrotation");
    00097   _subzrotationFld          = fields.addNotify ("subzrotation");
    00098
    00099   _rotationxincreFld        = fields.addDouble("rotationxincre");
    00100   _rotationyincreFld        = fields.addDouble("rotationyincre");
    00101   _rotationzincreFld        = fields.addDouble("rotationzincre");
    00102
    00103   _rotationxincreFld->setDoubleValue(1);
    00104   _rotationyincreFld->setDoubleValue(1);
    00105   _rotationzincreFld->setDoubleValue(1);
    00106
    00107   _matrixFld                = fields.addMatrix("matrix");
    00108   _resetFld                 = fields.addNotify("reset");
    00109   handleNotificationOn();
    00110
    00111   // Activate inplace data buffers for output outIndex and input inIndex.
    00112   // setOutImgInplace(outIndex, inIndex);
    00113
    00114   // Activate page data bypass from input inIdx to output outIdx.
    00115   // Note that the module must still be able to calculate the output image.
    00116   // setBypass(outIndex, inIndex);
    00117
    00118   // Activate parallel execution of calcOutSubImage.
    00119   // setThreadSupport(supportMode);
    00120   // with supportMode =
    00121   //   NO_THREAD_SUPPORT                 //! The module is not thread safe at all.
    00122   //   CALC_OUTSUBIMAGE_ON_STD_TYPES     //! calcOutSubImage can be called in parallel for scalar voxel types.
    00123   //   CALC_OUTSUBIMAGE_ON_CARRIER_TYPES //! calcOutSubImage can be called in parallel for carrier voxel types.
    00124   //   CALC_OUTSUBIMAGE_ON_ALL_TYPES     //! calcOutSubImage can be called in parallel for all voxel types.
    00125   // Warning: You should be familiar with multithreading before activating this feature.
    00126
    00127   // Specify whether the module can only process standard scalar voxel types or
    00128   // also registered voxel types (vec2, mat2, complexf, Vector, etc.)
    00129   // setVoxelDataTypeSupport(permittedTypes);
    00130   // with permittedTypes =
    00131   //   ONLY_STANDARD_TYPES               //! Only standard scalar voxels are supported.
    00132   //   FULLY_OPERATIONAL                 //! Scalar and registered voxels types are supported.
    00133   //   MINIMUM_OPERATIONAL               //! Scalar and registered voxel types are supported.
    00134   //                                     //! Voxel operators are not used by algorithm.
    00135   //
    00136   // See ML Programming Guide, "Configuring Image Processing Behaviour of the BaseOp"
    00137   // for further details.
    00138 }
    00139
    00140 //----------------------------------------------------------------------------------
    00142 //----------------------------------------------------------------------------------
    00143 void AngioTransformEdit::handleNotification (Field *field)
    00144 {
    00145   ML_TRACE_IN("AngioTransformEdit::handleNotification ()");
    00146           if (field == _addxtranslationFld) {
    00147
    00148                  _translationFld->setVec3fValue(_translationFld->getVec3fValue() +
    00149                          vec3(_transxincreFld->getDoubleValue(), 0, 0));
    00150           } else if (field == _addytranslationFld) {
    00151         _translationFld->setVec3fValue(_translationFld->getVec3fValue() +
    00152                          vec3(0, _transyincreFld->getDoubleValue(), 0));
    00153           } else if (field == _addztranslationFld){
    00154                   _translationFld->setVec3fValue(_translationFld->getVec3fValue() +
    00155                          vec3(0, 0, _transzincreFld->getDoubleValue()));
    00156           } else if (field == _subxtranslationFld) {
    00157                   _translationFld->setVec3fValue(_translationFld->getVec3fValue() -
    00158                          vec3( _transxincreFld->getDoubleValue(), 0, 0));
    00159           } else if (field == _subytranslationFld) {
    00160                    _translationFld->setVec3fValue(_translationFld->getVec3fValue() -
    00161                          vec3(0, _transyincreFld->getDoubleValue(), 0));
    00162           } else if (field == _subztranslationFld) {
    00163                    _translationFld->setVec3fValue(_translationFld->getVec3fValue() -
    00164                          vec3(0, 0, _transzincreFld->getDoubleValue()));
    00165           } else if (field == _addxrotationFld) {
    00166                   _rotationFld->setVec3fValue(_rotationFld->getVec3fValue()  +
    00167                           vec3(_rotationxincreFld->getDoubleValue()/180.0 * PI, 0,0));
    00168           } else if (field == _addyrotationFld) {
    00169           _rotationFld->setVec3fValue(_rotationFld->getVec3fValue() +
    00170                           vec3(0, _rotationyincreFld->getDoubleValue()/ 180.0 * PI, 0));
    00171           } else if (field == _addzrotationFld) {
    00172                    _rotationFld->setVec3fValue(_rotationFld->getVec3fValue() +
    00173                            vec3(0,0,_rotationzincreFld->getDoubleValue()/ 180.0 * PI));
    00174           } else if (field == _subxrotationFld) {
    00175            _rotationFld->setVec3fValue(_rotationFld->getVec3fValue() -
    00176                            vec3(_rotationxincreFld->getDoubleValue()/ 180.0 * PI, 0,0));
    00177           } else if (field == _subyrotationFld) {
    00178             _rotationFld->setVec3fValue(_rotationFld->getVec3fValue() -
    00179                                 vec3(0, _rotationyincreFld->getDoubleValue()/ 180.0 * PI, 0));
    00180           } else if (field == _subzrotationFld) {
    00181                     _rotationFld->setVec3fValue(_rotationFld->getVec3fValue() -
    00182                                 vec3(0,0,_rotationzincreFld->getDoubleValue()/ 180.0 * PI));
    00183           } else if (field == _resetFld) {
    00184                   _matrixFld->setStringValue("1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1");
    00185                   _translationFld->setVec3fValue(vec3(0, 0, 0));
    00186                   _rotationFld->setVec3fValue(vec3(0,0,0));
    00187                   return;
    00188           }
    00189       updateMatrix();
    00190   // Handle changes of module parameters and connectors here.
    00191 }
    00192
    00193 //----------------------------------------------------------------------------------
    00195 //----------------------------------------------------------------------------------
    00196 void AngioTransformEdit::activateAttachments ()
    00197 {
    00198   ML_TRACE_IN("AngioTransformEdit::activateAttachments ()");
    00199
    00200   // Update members to new field state here.
    00201   // Call super class functionality to enable notification handling again.
    00202   BaseOp::activateAttachments ();
    00203 }
    00204
    00205 void AngioTransformEdit::updateMatrix()
    00206 {
    00207         vec3 v3 = _translationFld->getVec3fValue();
    00208         mat4 Translations(1,0,0,v3[0], 0,1,0,v3[1], 0,0,1,v3[2], 0, 0, 0,1);
    00209         //_affine1TempM = (_matrix1Fld->getMatrixValue()) * Translations;
    00210
    00211         vec3 x3 = _rotationFld->getVec3fValue();
    00212         vec3 axis(1, 0, 0); // x axis
    00213
    00214         Rotation RotTemp(axis, x3[0]);
    00215         axis.assign(0,1,0); // y axis
    00216         Rotation rot(axis, x3[1]); //y axis
    00217         rot *= RotTemp;
    00218         axis.assign(0,0,1); // z axis
    00219         RotTemp.setRotation(axis, x3[2]);
    00220         rot *= RotTemp;
    00221         mat4 RotMatrix = rot.getMatrix();
    00222         _matrixFld->setMatrixValue(RotMatrix * Translations);
    00223
    00224 }
    00225 ML_END_NAMESPACE
    00226

All Classes Namespaces Files Functions Variables Enumerator Friends