Biomechanical Joint Model
 Author: Anderson Maciel

comepatient.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2002 by Anderson Maciel                                 *
00003  *   andi.maciel@gmail.com                                                 *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  **************************************************************************/
00020 
00022 //
00023 //  PROJECT.....: CO-ME
00024 //  RESPONSIBLE.: 
00025 //
00026 //  FILE........: comepatient.CPP
00027 //  DESCRIPTION.: 
00028 //                                 
00029 //
00030 //  AUTHOR......: Anderson Maciel
00031 //  DATE........: May/27/2002
00032 //  DESCRIPTION.: Class definition.
00033 //
00035 
00036 #include        <bio/comepatient.h>
00037 #include        <general/comescenario.h>
00038 #include        <bio/comebiostructure.h>
00039 #include        <bio/comemolecule.h>
00040 #include        <kinematics/comepolyaxialjoint.h>
00041 
00045 
00046 COME_Patient::COME_Patient(){
00047 
00048         name = "some patient";
00049         age = 25;
00050         gender = MALE;
00051         parent = NULL;
00052         rootJoint = new COME_PolyaxialJoint();
00053 }
00054 
00055 COME_Patient::COME_Patient( const COME_Patient &patientN ){
00056 
00057         name = patientN.getName();
00058         age = patientN.getAge();
00059         gender = patientN.getGender();
00060         weight = patientN.getWeight();
00061         height = patientN.getHeight();
00062         //rootJoint = patientN.getRootJoint();// this is not trivial DON'T USE THIS CONSTRUCTOR
00063         printf( "Non implemented feature in COME_Patient::COME_Patient( const COME_Patient &patientN )\n" );
00064         scanf("");
00066         organList = patientN.getOrganList();
00067         parent = (COME_Scenario*)(patientN.getParent());
00068 }
00069 
00070 COME_Patient::COME_Patient( COME_Patient *patientN ){
00071 
00072         name = patientN->getName();
00073         age = patientN->getAge();
00074         gender = patientN->getGender();
00075         weight = patientN->getWeight();
00076         height = patientN->getHeight();
00077         rootJoint = patientN->getRootJoint();
00078         organList = patientN->getOrganList();
00079         parent = (COME_Scenario*)(patientN->getParent());
00080 }
00081 
00082 COME_Patient::COME_Patient( string nameN, short ageN, bool genderN, double weightN, double heightN, COME_Joint *root, list<COME_BioStructure*> organListN, COME *scene ){
00083 
00084         name = nameN;
00085         age = ageN;
00086         gender = genderN;
00087         weight = weightN;
00088         height = heightN;
00089         rootJoint = root;
00090         organList = organListN;
00091         parent = scene;
00092 
00093         list<COME_BioStructure*>::iterator iter;
00094         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00095                 (*iter)->setParent( this );
00096         }
00097 }
00098 
00099 COME_Patient::~COME_Patient()
00100 {
00101 
00102 }
00103 
00107 
00108 void
00109 COME_Patient::setName( string nameN ){
00110 
00111         name = nameN;
00112 }
00113 
00114 void
00115 COME_Patient::setAge( short ageN ){
00116 
00117         age = ageN;
00118 }
00119 
00120 void
00121 COME_Patient::setGender( bool genderN ){
00122 
00123         gender = genderN;
00124 }
00125 
00126 void
00127 COME_Patient::setWeight( double weightN ){
00128 
00129         weight = weightN;
00130 }
00131 
00132 void
00133 COME_Patient::setHeight( double heightN ){
00134 
00135         height = heightN;
00136 }
00137 
00138 void
00139 COME_Patient::setOrganList( list<COME_BioStructure*> &listN ){
00140 
00141         organList = listN;
00142 }
00143 
00144 void
00145 COME_Patient::setRootJoint( COME_Joint* rootJointN ){
00146 
00147         rootJoint = rootJointN;
00148 }
00149 
00153 
00154 string
00155 COME_Patient::getName() const {
00156 
00157         return name;
00158 }
00159 
00160 short
00161 COME_Patient::getAge() const {
00162 
00163         return age;
00164 }
00165 
00166 bool
00167 COME_Patient::getGender() const {
00168 
00169         return gender;
00170 }
00171 
00172 double
00173 COME_Patient::getWeight() const {
00174 
00175         return weight;
00176 }
00177 
00178 double
00179 COME_Patient::getHeight() const {
00180 
00181         return height;
00182 }
00183 
00184 list<COME_BioStructure*>
00185 COME_Patient::getOrganList() const {
00186 
00187         return organList;
00188 }
00189 
00190 const list<COME_BioStructure*>*
00191 COME_Patient::getPtOrganList() const {
00192 
00193         return  &organList;
00194 }
00195 
00196 COME_BioStructure*
00197 COME_Patient::getOrgan( string desc ) const {
00198 
00199         list<COME_BioStructure*>::const_iterator iter;
00200         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00201                 if( (*iter)->getDescription() == desc ){
00202                         return (*iter);
00203                 }
00204         }
00205         return NULL;
00206 }
00207 
00208 COME_BioStructure*
00209 COME_Patient::getOrgan( int index ) const {
00210 
00211         list<COME_BioStructure*>::const_iterator iter;
00212         int i = 0;
00213         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00214                 if( i == index ){
00215                         return (*iter);
00216                 }
00217                 i++;
00218         }
00219         return NULL;
00220 }
00221 
00222 COME_BioStructure*
00223 COME_Patient::getSelected() const {
00224 
00225         list<COME_BioStructure*>::const_iterator iter;
00226         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00227                 if( (*iter)->isSelected() ){
00228                         return (*iter);
00229                 }
00230         }
00231         return NULL;
00232 }
00233 
00234 COME_Joint*
00235 COME_Patient::getRootJoint(){
00236 
00237         return rootJoint;
00238 }
00239 
00240 
00241 COME_Joint*
00242 COME_Patient::getJointByName( string target ){
00243 
00244   return searchJoint( rootJoint, target );
00245 }
00246 
00250 COME_Joint*
00251 COME_Patient::searchJoint( COME_Joint* currJoint, string target ){
00252 
00253         if( currJoint->getDescription() == target ){
00254                 return currJoint;
00255         } else if( currJoint->getChildListPt()->size() > 0 ){
00256                 return searchJoint( currJoint->getChildListPt()->front(), target );
00257         }
00258         return NULL;
00259 }
00260 
00264 void
00265 COME_Patient::addOrgan( COME_BioStructure *organN ){
00266 
00267         organN->setParent( (COME_Patient*)this );
00268         organList.push_back( organN );
00269 }
00270 
00274 bool
00275 COME_Patient::update( double timestep, double simClock ){
00276 
00277         list<COME_BioStructure*>::const_iterator iter;
00278         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00279                 //if( ((COME_Simulator*)(parent->getParent()))->getWhenRecalculate() == EVERY_ITERATION ){
00280                 //      (*iter)->getTissue()->recalculateAllSpringConstants( ((COME_Simulator*)(parent->getParent()))->getHowRecalculate(), simClock );
00281                 //}
00282                 if( !(*iter)->update( timestep, simClock ) ){
00283                         while( !(iter == organList.begin()) ){ 
00284                                 iter--;
00285                                 (*iter)->update( -timestep, simClock );
00286                         } 
00287                         return false;
00288                 }
00289         }
00290         return true;
00291 }
00292 
00298 void
00299 COME_Patient::getEnvelop( COME_Point3D& mins, COME_Point3D& maxs ) const {
00300 
00301         organList.front()->getEnvelop( mins, maxs );
00302 
00303         list<COME_BioStructure*>::const_iterator iter;
00304         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00305                 
00306                 COME_Point3D minsO , maxsO;
00307                 (*iter)->getEnvelop( minsO, maxsO );
00308                 
00309                 if( minsO.getX() < mins.getX() ){
00310                         mins.setX( minsO.getX() );
00311                 }
00312                 if( minsO.getY() < mins.getY() ){
00313                         mins.setY( minsO.getY() );
00314                 }
00315                 if( minsO.getZ() < mins.getZ() ){
00316                         mins.setZ( minsO.getZ() );
00317                 }
00318 
00319                 if( maxsO.getX() > maxs.getX() ){
00320                         maxs.setX( maxsO.getX() );
00321                 }
00322                 if( maxsO.getY() > maxs.getY() ){
00323                         maxs.setY( maxsO.getY() );
00324                 }
00325                 if( maxsO.getZ() > maxs.getZ() ){
00326                         maxs.setZ( maxsO.getZ() );
00327                 }
00328         }
00329 
00330 }
00331 
00332 void
00333 COME_Patient::unselectAll(){
00334 
00335         list<COME_BioStructure*>::const_iterator iter;
00336         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00337                 (*iter)->select(false);
00338         }
00339 }
00340 
00344 void
00345 COME_Patient::updateSkin(){
00346 
00347         list<COME_BioStructure*>::const_iterator iter;
00348         for (iter = organList.begin(); !(iter == organList.end()); iter++){
00349                 (*iter)->updateSkin();
00350         }
00351 }

Generated on Thu Dec 1 10:13:35 2005 for COME - Biomechanical Joint Model by  doxygen 1.4.5