- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# C:/AngioLocalizeNoAuto/MevisLabNoAutoReg/STUMevisApp/Angiolocalize/Sources/ML/STUXMarkerTransform/mlXMarkerTransform.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 //----------------------------------------------------------------------------------
    00037
    00044 //----------------------------------------------------------------------------------
    00045
    00046 // Local includes
    00047 #include "mlXMarkerTransform.h"
    00048
    00049 ML_START_NAMESPACE
    00050
    00051
    00053 ML_BASEOP_CLASS_SOURCE(XMarkerTransform, BaseOp);
    00054
    00055 //----------------------------------------------------------------------------------
    00057 //----------------------------------------------------------------------------------
    00058 XMarkerTransform::XMarkerTransform ()
    00059   : BaseOp(0, 0)
    00060 {
    00061   ML_TRACE_IN("XMarkerTransform::XMarkerTransform ()");
    00062
    00063   // Suppress calls of handleNotification on field changes to
    00064   // avoid side effects during initialization phase.
    00065   handleNotificationOff();
    00066
    00068   FieldContainer &fields = *getFieldContainer();
    00069
    00070   ML_CHECK(&fields);
    00071
    00072   _matrix1Fld = fields.addMatrix("matrix1");
    00073   _matrix2Fld = fields.addMatrix("matrix2");
    00074   _matrix3Fld = fields.addMatrix("matrix3");
    00075
    00076   (_inMarkerListFld = fields.addBase("inMarkerList"))->setBaseValue(NULL);
    00077
    00078   // Generate field for marker list object.
    00079   _outMarkerListFld = fields.addBase("outMarkerList");
    00080
    00081   _inMarkerList = NULL;
    00082   _outMarkerList = NULL;
    00083   // Link marker list field to internal marker list object.
    00084   _outMarkerListFld->setBaseValue(NULL);
    00085
    00086   _apply1Fld = fields.addBool("apply1");
    00087   _apply1Fld->setBoolValue(true);
    00088
    00089   _apply2Fld = fields.addBool("apply2");
    00090   _apply2Fld->setBoolValue(true);
    00091
    00092   _apply3Fld = fields.addBool("apply3");
    00093   _apply3Fld->setBoolValue(true);
    00094
    00095   _autoApplyFld = fields.addBool("autoApply");
    00096   _autoApplyFld->setBoolValue(false);
    00097
    00098   _applyFld = fields.addNotify("apply");
    00099
    00100   // Connect input fields with output field to update connected
    00101   // modules if input images change.
    00102   for (int inIdx=0; inIdx < 0; ++inIdx){
    00103     for (int outIdx=0; outIdx < 0; ++outIdx){
    00104       getInField(inIdx)->attachField(getOutField(outIdx));
    00105     }
    00106   }
    00107
    00108   handleNotificationOn();
    00109 }
    00110
    00111 //----------------------------------------------------------------------------------
    00113 //----------------------------------------------------------------------------------
    00114 void XMarkerTransform::handleNotification (Field *field)
    00115 {
    00116   ML_TRACE_IN("XMarkerTransform::handleNotification ()");
    00117
    00118   if (_autoApplyFld->getBoolValue() == true || field == _applyFld
    00119           || field == _inMarkerListFld) {
    00120
    00121       if (ML_BASE_IS_A((static_cast<Base*>(_inMarkerListFld->getBaseValue())), XMarkerList)){
    00122
    00123                   _inMarkerList = static_cast<XMarkerList*>(_inMarkerListFld->getBaseValue());
    00124
    00125                   if (_inMarkerList != NULL){
    00126
    00127                         /*if (!_isInNotificationCB) {
    00128                                 _inputList->addNotificationObserver(_csoListNotificationCB, this);
    00129                         }*/
    00130                   }
    00131                 } else {
    00132                   _inMarkerList = NULL;
    00133                 }
    00134
    00135           if (_apply1Fld->getBoolValue() == true) {
    00136                  AffineTransform(_matrix1Fld->getMatrixValue(), 1);
    00137           }
    00138           if (_apply2Fld->getBoolValue() == true) {
    00139                  PerspectiveTransform(_matrix2Fld->getMatrixValue());
    00140           }
    00141           if (_apply3Fld->getBoolValue() == true) {
    00142                  AffineTransform(_matrix3Fld->getMatrixValue(), 3);
    00143           }
    00144           _outMarkerListFld->setBaseValue(_outMarkerList);
    00145   }
    00146
    00147   // Handle changes of module parameters and connectors here.
    00148   // For example:
    00149   // if (getInField(0) == field){ /* Handle changes of input 0. */ }
    00150   // if (fieldPtr == field){      /* Handle changes of a field added in constructor .*/ }
    00151   // See section "Implementing handleNotification()" in ML Programming Guide for details.
    00152   BaseOp::handleNotification(field);
    00153 }
    00154
    00155 //----------------------------------------------------------------------------------
    00157 //----------------------------------------------------------------------------------
    00158 void XMarkerTransform::activateAttachments ()
    00159 {
    00160   ML_TRACE_IN("XMarkerTransform::activateAttachments ()");
    00161
    00162   // Update members to new field state here.
    00163   // Call super class functionality to enable notification handling again.
    00164   BaseOp::activateAttachments ();
    00165 }
    00166
    00167 //----------------------------------------------------------------------------------
    00170 //----------------------------------------------------------------------------------
    00171 void XMarkerTransform::AffineTransform (const mat4& matrix, int step)
    00172 {
    00173         if (_inMarkerList == NULL)
    00174                         return;
    00175         if (step == 1) {
    00176                 _outMarkerList = new XMarkerList(*_inMarkerList);
    00177         }
    00178
    00179         for (size_t i = 0; i < _outMarkerList->getSize(); i ++) {
    00180                 XMarker *marker = (XMarker*)_outMarkerList->getItemAt(i);
    00181                 Tvec3<double> markerPos(marker->x(), marker->y(), marker->z());
    00182                 markerPos = (Tvec3<double>(matrix * markerPos.affinePoint(), true));
    00183                 marker->x() = markerPos[0];
    00184                 marker->y() = markerPos[1];
    00185                 marker->z() = markerPos[2];
    00186                 _outMarkerList->modifyItemAt(i, marker);
    00187         }
    00188 }
    00189
    00190
    00191 //----------------------------------------------------------------------------------
    00194 //----------------------------------------------------------------------------------
    00195 void XMarkerTransform::PerspectiveTransform (const mat4& matrix)
    00196 {
    00197         if (_outMarkerList == NULL)
    00198                 return;
    00199
    00200         for (size_t i = 0; i < _outMarkerList->getSize(); i ++) {
    00201                 XMarker *marker = (XMarker*)_outMarkerList->getItemAt(i);
    00202                 Tvec3<double> markerPos(marker->x(), marker->y(), marker->z());
    00203                 markerPos = (Tvec3<double>(matrix * markerPos.affinePoint(), true)).divideByLastComp();
    00204                 marker->x() = markerPos[0];
    00205                 marker->y() = markerPos[1];
    00206                 marker->z() = 0.0;
    00207                 _outMarkerList->modifyItemAt(i, marker);
    00208         }
    00209 }
    00210
    00211 ML_END_NAMESPACE
    00212

All Classes Namespaces Files Functions Variables Enumerator Friends