TAPs 0.7.7.3
TAPsAdvSimSupport_DS.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsAdvSimSupport_DS.cpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (09/29/2008)
00009 UPDATE          (09/03/2010)
00010 ******************************************************************************/
00011 #include "TAPsAdvSimSupport_DS.hpp"
00012 // Using Inclusion Model (i.e. definitions are included in declarations)
00013 //                       (this name.cpp is included in name.hpp)
00014 // Each friend is defined directly inside its declaration.
00015 
00016 BEGIN_NAMESPACE_TAPs
00017 //=============================================================================
00018 //-----------------------------------------------------------------------------
00019 template <typename T, typename DATA>
00020 AdvSimSupport_DS<T,DATA>::AdvSimSupport_DS ()
00021 {}
00022 //-----------------------------------------------------------------------------
00023 template <typename T, typename DATA>
00024 AdvSimSupport_DS<T,DATA>::~AdvSimSupport_DS ()
00025 {
00026     ClearAllConstraints();
00027 }
00028 //-----------------------------------------------------------------------------
00029 template <typename T, typename DATA>
00030 std::string AdvSimSupport_DS<T,DATA>::StrInfo () const
00031 {
00032     std::stringstream ss;
00033     ss << "AdvSimSupport_DS<T,DATA>\n";
00034     return ss.str();
00035 }
00036 //-----------------------------------------------------------------------------
00037 //-----------------------------------------------------------------------------
00038 //template <typename T, typename DATA>
00039 //int AdvSimSupport_DS<T,DATA>::AddModel ( OpenGL::ModelSuture<T> * pModel )
00040 //{
00041 //  m_ListOfSutureModelsBasedOnMSS.push_back( pModel );
00042 //}
00043 //-----------------------------------------------------------------------------
00044 template <typename T, typename DATA>
00045 int AdvSimSupport_DS<T,DATA>::AddModel ( ModelElasticRod<T> * pModel )
00046 {
00047     m_ListOfSutureModelsBasedOnER.push_back( pModel );
00048     return AddERBasedSuture();
00049 }
00050 //-----------------------------------------------------------------------------
00051 //template <typename T, typename DATA>
00052 //int AdvSimSupport_DS<T,DATA>::AddModel ( ModelForSurgery<T> * pModel )
00053 //{
00054 //  m_ListOfModelsForSurgeryBasedOnMSS.push_back( pModel );
00055 //
00056 //  // Add each part of the surgery model to the list of submodels
00057 //  for ( int i = 0; i < pModel->GetNumberOfParts(); ++i ) {
00058 //      m_ListOfHETriMeshOneModelMultiParts.push_back( pModel->GetPtrToPartNo(i) );
00059 //  }
00060 //}
00061 //-----------------------------------------------------------------------------
00062 template <typename T, typename DATA>
00063 int AdvSimSupport_DS<T,DATA>::AddModel ( ModelDefBasedOnFEM<T,DATA> * pModel )
00064 {
00065     m_ModelType.push_back( MODEL_BASED_ON_FEM );
00066     m_ModelLocation.push_back( m_ListOfModelsForSurgeryBasedOnFEM.size() );
00067     m_ListOfModelsForSurgeryBasedOnFEM.push_back( pModel );
00068 
00069     return AddModel();
00070 }
00071 //-----------------------------------------------------------------------------
00072 template <typename T, typename DATA>
00073 int AdvSimSupport_DS<T,DATA>::AddModel ()
00074 {
00075     // Add data storage for the added model
00076     m_ListOfInteractionModelVsModel.push_back( std::vector< std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * > >() );
00077     std::vector< std::vector< std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * > > >::iterator it = m_ListOfInteractionModelVsModel.begin();
00078     while ( it != m_ListOfInteractionModelVsModel.end() ) {
00079         // Add data storage for the existed models with the added model
00080         it->push_back( std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * >() );
00081         ++it;
00082     }
00083 
00084     // DEBUG
00085     //std::cout << "size of m_ListOfInteractionModelVsModel: " << m_ListOfInteractionModelVsModel.size() << "\n";
00086     //for ( unsigned int i = 0; i < m_ListOfInteractionModelVsModel.size(); ++i ) {
00087     //  std::cout << "size of m_ListOfInteractionModelVsModel["<<i<<"]: " << m_ListOfInteractionModelVsModel[i].size() << "\n";
00088     //}
00089 
00090     // Add data storage for interaction with ER-based sutures
00091     std::vector< std::vector< std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * > > >::iterator itS = m_ListOfInteractionERSutureVsModel.begin();
00092     while ( itS != m_ListOfInteractionERSutureVsModel.end() ) {
00093         itS->push_back( std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * >() );
00094         ++itS;
00095     }
00096 
00097     // returns the assigned ID for the added model
00098     return m_ListOfInteractionModelVsModel.size()-1;
00099 }
00100 //-----------------------------------------------------------------------------
00101 template <typename T, typename DATA>
00102 int AdvSimSupport_DS<T,DATA>::AddERBasedSuture ()
00103 {
00104     // Add data storage for the added suture model
00105     m_ListOfInteractionERSutureVsModel.push_back( std::vector< std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * > >() );
00106     std::vector< std::vector< std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * > > >::iterator it = m_ListOfInteractionModelVsModel.begin();
00107     while ( it != m_ListOfInteractionModelVsModel.end() ) {
00108         // Add data storage for interaction of the existed (non-suture) models with the added suture model
00109         m_ListOfInteractionERSutureVsModel.back().push_back( std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * >() );
00110         ++it;
00111     }
00112 
00113     // returns the assigned ID for the added ER-based suture
00114     return m_ListOfInteractionERSutureVsModel.size()-1;
00115 }
00116 //-----------------------------------------------------------------------------
00117 //-----------------------------------------------------------------------------
00118 template <typename T, typename DATA>
00119 void AdvSimSupport_DS<T,DATA>::AddVertexConnectionModelAndModel (
00120         unsigned int modelA,                        
00121         HEVertex<T> * pVertexA,                     
00122         enum Enum::AddOn::SimConstraints flagsA,    
00123         unsigned int modelB,                        
00124         HEVertex<T> * pVertexB,                     
00125         enum Enum::AddOn::SimConstraints flagsB,    
00126         T forceRatio,           
00127         T forceScaleForModelA,  
00128         T forceScaleForModelB,  
00129         T forceThresholdForModelA,  
00130         T forceThresholdForModelB   
00131 )
00132 {
00133     pVertexA->SimFlags.SetSimulationConstraints( flagsA );
00134     pVertexB->SimFlags.SetSimulationConstraints( flagsB );
00135     m_ListOfInteractionModelVsModel[modelA][modelB].push_back( 
00136         new AdvSimConstraint_HEVertexVsHEVertex<T>( pVertexA, pVertexB, forceRatio, forceScaleForModelA, forceScaleForModelB, forceThresholdForModelA, forceThresholdForModelB ) );
00137     m_ListOfInteractionModelVsModel[modelA][modelB].back()->RefToSavedPositionA() = pVertexA->GetPosition();
00138     m_ListOfInteractionModelVsModel[modelA][modelB].back()->RefToSavedPositionB() = pVertexB->GetPosition();
00139 }
00140 //-----------------------------------------------------------------------------
00141 template <typename T, typename DATA>
00142 void AdvSimSupport_DS<T,DATA>::AddVertexConnectionERSutureAndModel (
00143         unsigned int sutureID,                          
00144         unsigned int vertexIDSuture,                    
00145         //DS::SimulationFlags * simFlagsSuture,         //!< simulation flags of suture
00146         //Vector3<T> * vertexSuture,                        //!< vertex of suture
00147         enum Enum::AddOn::SimConstraints flagsSuture,   
00148         unsigned int modelID,                           
00149         HEVertex<T> * pVertexModel,                     
00150         enum Enum::AddOn::SimConstraints flagsModel,    
00151         T forceRatio,           
00152         T forceScaleForSuture,  
00153         T forceScaleForModel,   
00154         T forceThresholdForSuture,  
00155         T forceThresholdForModel    
00156 )
00157 {
00158     std::cout << "suture vertex id: " << vertexIDSuture << "\n";
00159     std::cout << "SIM FLAG" << m_ListOfSutureModelsBasedOnER[sutureID]->GetListOfNodes()[vertexIDSuture].SimFlags << "\n";
00160     
00161     m_ListOfSutureModelsBasedOnER[sutureID]->GetListOfNodes()[vertexIDSuture].SimFlags.SetSimulationConstraints( flagsSuture );
00162     m_ListOfSutureModelsBasedOnER[sutureID]->GetListOfNodes()[vertexIDSuture].SimFlags.SetSimulationConstraints( TAPs::Enum::AddOn::ATTACHED );
00163 
00164     std::cout << "SIM FLAG" << m_ListOfSutureModelsBasedOnER[sutureID]->GetListOfNodes()[vertexIDSuture].SimFlags << "\n";
00165     
00166     pVertexModel->SimFlags.SetSimulationConstraints( flagsModel );
00167     m_ListOfInteractionERSutureVsModel[sutureID][modelID].push_back( 
00168         new AdvSimConstraint_ERSutureVsHEVertex<T>( vertexIDSuture, pVertexModel, forceRatio, forceScaleForSuture, forceScaleForModel, forceThresholdForSuture, forceThresholdForModel ) );
00169     //m_ListOfInteractionERSutureVsModel[sutureID][modelID].back()->RefToSavedPositionA() = m_ListOfSutureModelsBasedOnER[sutureID]->GetListOfNodes()[vertexIDSuture].GetPosition();
00170     m_ListOfInteractionERSutureVsModel[sutureID][modelID].back()->RefToSavedPositionB() = pVertexModel->GetPosition();
00171 }
00172 //-----------------------------------------------------------------------------
00173 //-----------------------------------------------------------------------------
00174 template <typename T, typename DATA>
00175 void AdvSimSupport_DS<T,DATA>::EnforceAllConstraints ()
00176 {
00177     // Clear all connection (aka interaction) loads from FEM-based models
00178     for ( unsigned int i = 0; i < m_ListOfModelsForSurgeryBasedOnFEM.size(); ++i ) {
00179         m_ListOfModelsForSurgeryBasedOnFEM[i]->ClearAllConnectionLoads();
00180     }
00181 
00182     // Clear all point forces
00183     ListOfPointForces::iterator it = m_ListOfPointForces.begin();
00184     while ( it != m_ListOfPointForces.end() ) {
00185         delete *it;
00186         ++it;
00187     }
00188     m_ListOfPointForces.clear();
00189 
00190     // model-model interactions
00191     for ( unsigned int i = 0; i < m_ListOfInteractionModelVsModel.size(); ++i ) {
00192         for ( unsigned int j = i; j < m_ListOfInteractionModelVsModel.size(); ++j ) {
00193             EnforceAllConstraintsOfTwoModels( i, j );
00194         }
00195     }
00196 
00197     // ERSuture-model interactions
00198     for ( unsigned int i = 0; i < m_ListOfInteractionERSutureVsModel.size(); ++i ) {
00199         for ( unsigned int j = 0; j < m_ListOfInteractionERSutureVsModel[i].size(); ++j ) {
00200             EnforceAllConstraintsOfERSutureAndModel( i, j );
00201         }
00202     }
00203 }
00204 //-----------------------------------------------------------------------------
00205 template <typename T, typename DATA>
00206 void AdvSimSupport_DS<T,DATA>::EnforceAllConstraintsOfTwoModels ( int modelA, int modelB )
00207 {
00208     Matrix4x4<T> TrxModelA;
00209     Matrix4x4<T> InvTrxModelA;
00210     if ( m_ModelType[modelA] == MODEL_BASED_ON_FEM ) {
00211         unsigned int loc = m_ModelLocation[modelA];
00212         TrxModelA = m_ListOfModelsForSurgeryBasedOnFEM[modelA]->RefToTransformationSupport().ReturnMatrixTransform();
00213         InvTrxModelA = TrxModelA.GetInverse();
00214     }
00215     Matrix4x4<T> TrxModelB;
00216     Matrix4x4<T> InvTrxModelB;
00217     if ( m_ModelType[modelB] == MODEL_BASED_ON_FEM ) {
00218         unsigned int loc = m_ModelLocation[modelB];
00219         TrxModelB = m_ListOfModelsForSurgeryBasedOnFEM[modelB]->RefToTransformationSupport().ReturnMatrixTransform();
00220         InvTrxModelB = TrxModelB.GetInverse();
00221     }
00222 
00223     modelB -= modelA;   // since the data in the std::vector starts from 0, not from the model number
00224     for ( unsigned int i = 0; i < m_ListOfInteractionModelVsModel[modelA][modelB].size(); ++i ) {
00225         EnforceTheConstraintNumberOfTwoModels( modelA, TrxModelA, InvTrxModelA, modelB, TrxModelB, InvTrxModelB, i );
00226     }
00227 }
00228 //-----------------------------------------------------------------------------
00229 template <typename T, typename DATA>
00230 void AdvSimSupport_DS<T,DATA>::EnforceAllConstraintsOfERSutureAndModel ( int suture, int model )
00231 {
00232     Matrix4x4<T> TrxModel;
00233     Matrix4x4<T> InvTrxModel;
00234     TrxModel = m_ListOfModelsForSurgeryBasedOnFEM[model]->RefToTransformationSupport().ReturnMatrixTransform();
00235     InvTrxModel = TrxModel.GetInverse();
00236     for ( unsigned int i = 0; i < m_ListOfInteractionERSutureVsModel[suture][model].size(); ++i ) {
00237         EnforceTheConstraintNumberOfERSutureAndModel( suture, model, TrxModel, InvTrxModel, i );
00238     }
00239 }
00240 //-----------------------------------------------------------------------------
00241 template <typename T, typename DATA>
00242 void AdvSimSupport_DS<T,DATA>::EnforceTheConstraintNumberOfTwoModels (
00243     int modelA,                         
00244     Matrix4x4<T> const & TrxModelA,     
00245     Matrix4x4<T> const & InvTrxModelA,  
00246     int modelB,                         
00247     Matrix4x4<T> const & TrxModelB,     
00248     Matrix4x4<T> const & InvTrxModelB,  
00249     unsigned int constraintNumber       
00250 )
00251 {
00252     AdvSimConstraint_HEVertexVsHEVertex<T> * pConstraint = m_ListOfInteractionModelVsModel[modelA][modelB][constraintNumber];
00253 
00254     HEVertex<T> * heA = pConstraint->GetPtrToVertexFromModel_1();
00255     HEVertex<T> * heB = pConstraint->GetPtrToVertexFromModel_2();
00256     Vector3<T> V1 = heA->GetProtectedPosition() = pConstraint->RefToSavedPositionA();
00257     Vector3<T> V2 = heB->GetProtectedPosition() = pConstraint->RefToSavedPositionB();
00258     V1 = TrxModelA * V1;
00259     V2 = TrxModelB * V2;
00260     T ratio = pConstraint->GetForceRatio();
00261     pConstraint->RefToTargetPositionA() = pConstraint->RefToTargetPositionB() = ratio*V1 + (1-ratio)*V2;
00262     V1 = InvTrxModelA * pConstraint->RefToTargetPositionA();
00263     V2 = InvTrxModelB * pConstraint->RefToTargetPositionB();
00264     pConstraint->RefToTargetPositionA() = V1;
00265     pConstraint->RefToTargetPositionB() = V2;
00266 
00267     // If modelA is FEM-based, then add the connection as a point force.
00268     if ( m_ModelType[modelA] == MODEL_BASED_ON_FEM ) {
00269         Vector3<T> Fa = V1 - heA->GetProtectedPosition();
00270         PointForce<T> * pF = new PointForce<T>();
00271         m_ListOfPointForces.push_back( pF );
00272 
00273         // Set connection (i.e. point) force
00274         pF->SetID( heA->GetID() );
00275         pF->RefToPosition() = heA->GetBarycentricPtr()->RetGenBaryCoords();
00276         pF->RefToForce() = Fa * pConstraint->GetForceScaleA();
00277 
00278         unsigned int loc = m_ModelLocation[modelA];
00279         m_ListOfModelsForSurgeryBasedOnFEM[loc]->AddConnectionForceInLocalCoordinates( m_ListOfPointForces.back() );
00280     }
00281     // If modelB is FEM-based, then add the connection as a point force.
00282     if ( m_ModelType[modelB] == MODEL_BASED_ON_FEM ) {
00283         Vector3<T> Fb = V2 - heB->GetProtectedPosition();
00284         PointForce<T> * pF = new PointForce<T>();
00285         m_ListOfPointForces.push_back( pF );
00286 
00287         // Set connection (i.e. point) force
00288         pF->SetID( heB->GetID() );
00289         pF->RefToPosition() = heB->GetBarycentricPtr()->RetGenBaryCoords();
00290         pF->RefToForce() = Fb * pConstraint->GetForceScaleB();
00291 
00292         unsigned int loc = m_ModelLocation[modelB];
00293         m_ListOfModelsForSurgeryBasedOnFEM[loc]->AddConnectionForceInLocalCoordinates( m_ListOfPointForces.back() );
00294     }
00295 }
00296 //-----------------------------------------------------------------------------
00297 template <typename T, typename DATA>
00298 void AdvSimSupport_DS<T,DATA>::EnforceTheConstraintNumberOfERSutureAndModel (
00299     int suture,                         
00300     int model,                          
00301     Matrix4x4<T> const & TrxModel,      
00302     Matrix4x4<T> const & InvTrxModel,   
00303     unsigned int constraintNumber       
00304 )
00305 {
00306     AdvSimConstraint_ERSutureVsHEVertex<T> * pConstraint = m_ListOfInteractionERSutureVsModel[suture][model][constraintNumber];
00307     int SuturePt = pConstraint->GetVertexIDFromSuture();
00308 
00309     if ( m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].UseEnforcedPosition ) {
00310         // Fix the suture point and make the model's point follow the suture's point
00311         Vector3<T> & S = m_ListOfSutureModelsBasedOnER[suture]->RefToCurrentVertexPositionOfNodeNumber( SuturePt );
00312         HEVertex<T> * he = pConstraint->GetPtrToVertexFromModel();
00313         Vector3<T> V = he->GetProtectedPosition() = pConstraint->RefToSavedPositionB();
00314         V = TrxModel * V;
00315         pConstraint->RefToTargetPositionA() = pConstraint->RefToTargetPositionB() = S;
00316         V = InvTrxModel * pConstraint->RefToTargetPositionB();
00317         pConstraint->RefToTargetPositionB() = V;
00318 
00319         // If model is FEM-based, then add the connection as a point force.
00320         if ( m_ModelType[model] == MODEL_BASED_ON_FEM ) {
00321             Vector3<T> F = V - he->GetProtectedPosition();
00322             PointForce<T> * pF = new PointForce<T>();
00323             m_ListOfPointForces.push_back( pF );
00324 
00325             // Set connection (i.e. point) force
00326             pF->SetID( he->GetID() );
00327             pF->RefToPosition() = he->GetBarycentricPtr()->RetGenBaryCoords();
00328             pF->RefToForce() = F * pConstraint->GetForceScaleB();
00329             unsigned int loc = m_ModelLocation[model];
00330             m_ListOfModelsForSurgeryBasedOnFEM[loc]->AddConnectionForceInLocalCoordinates( m_ListOfPointForces.back() );
00331         }
00332     }
00333     else {
00334         Vector3<T> & S = m_ListOfSutureModelsBasedOnER[suture]->RefToCurrentVertexPositionOfNodeNumber( SuturePt );
00335         HEVertex<T> * he = pConstraint->GetPtrToVertexFromModel();
00336         Vector3<T> V = he->GetProtectedPosition() = pConstraint->RefToSavedPositionB();
00337         V = TrxModel * V;
00338         T ratio = pConstraint->GetForceRatio();
00339         pConstraint->RefToTargetPositionA() = 
00340         pConstraint->RefToTargetPositionB() = ratio*S + (1-ratio)*V;
00341         //S = pConstraint->RefToTargetPositionA();  // suture current position
00342         V = InvTrxModel * pConstraint->RefToTargetPositionB();
00343         pConstraint->RefToTargetPositionB() = V;
00344 
00345         // If model is FEM-based, then add the connection as a point force.
00346         if ( m_ModelType[model] == MODEL_BASED_ON_FEM ) {
00347             Vector3<T> F = V - he->GetProtectedPosition();
00348             PointForce<T> * pF = new PointForce<T>();
00349             m_ListOfPointForces.push_back( pF );
00350 
00351             // Set connection (i.e. point) force
00352             pF->SetID( he->GetID() );
00353             pF->RefToPosition() = he->GetBarycentricPtr()->RetGenBaryCoords();
00354             pF->RefToForce() = F * pConstraint->GetForceScaleB();
00355             unsigned int loc = m_ModelLocation[model];
00356             m_ListOfModelsForSurgeryBasedOnFEM[loc]->AddConnectionForceInLocalCoordinates( m_ListOfPointForces.back() );
00357 
00358             std::cout << "F mag: " << pF->RefToForce().Magnitude() << "\n";
00359             std::cout << "Force Ratio: " << pConstraint->GetForceRatio() << "\n";
00360             std::cout << "Force Scale A: " << pConstraint->GetForceScaleA() << "\n";
00361             std::cout << "Force Threshold A: " << pConstraint->GetForceThresholdA() << "\n";
00362             std::cout << "Force Scale B: " << pConstraint->GetForceScaleB() << "\n";
00363             std::cout << "Force Threshold B: " << pConstraint->GetForceThresholdB() << "\n";
00364             std::cout << "SuturePt: " << SuturePt << "\n";
00365             std::cout << m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags << "\n";
00366             std::cout << "WHY THE SIMFLAGS IS NOT SET PROPERLY (GOT RESET SOMEWHERE) ???\n";
00367 
00368             //if ( SuturePt < m_ListOfSutureModelsBasedOnER[suture]->GetNumberOfLinks()-1 ) {
00369             //  //if ( m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.CheckSimulationConstraints( Enum::AddOn::SLIDABLE ) )
00370             //  // WHY THE SIMFLAGS IS NOT SET PROPERLY (GOT RESET SOMEWHERE) ???
00371             //  {
00372             //      if ( pF->RefToForce().Magnitude() > pConstraint->GetForceThresholdA() )
00373             //      {
00374             //          //if (
00375             //          // Backward ???
00376 
00377             //          // Forward
00378             //          ++SuturePt;
00379 
00380             //          std::cout << "SuturePt after: " << SuturePt << "\n";
00381 
00382             //          pConstraint->SetVertexIDFromSuture( SuturePt );
00383             //          m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.SetSimulationConstraints( Enum::AddOn::SLIDABLE );
00384             //      }
00385             //  }
00386             //}
00387         }
00388 
00389         // Calculate the external force apply to Suture
00390         Vector3<T> Fs = pConstraint->RefToTargetPositionA() - S;
00391 
00392         bool bLinearForce = true;
00393         T scaleNonlinearForce = 0.5;
00394 
00395         if ( bLinearForce )
00396         {
00397             // LINEAR FORCE
00398             Fs *= pConstraint->GetForceScaleA();
00399         }
00400         else
00401         {
00402             // NONLINEAR FORCE
00403             T suture_link_length = m_ListOfSutureModelsBasedOnER[suture]->GetLinkLength();
00404             T magnitude = Fs.Magnitude();
00405             T scale = pow( pConstraint->GetForceScaleA(), magnitude/suture_link_length );
00406             if ( scale*magnitude <= m_ListOfSutureModelsBasedOnER[suture]->GetStretchModulus()*scaleNonlinearForce ) {
00407                 Fs *= scale;
00408             }
00409             else {
00410                 Fs *= m_ListOfSutureModelsBasedOnER[suture]->GetStretchModulus();
00411             }
00412         }
00413 
00414         T SforceMag = Fs.Magnitude();
00415         //Fs /= m_ListOfSutureModelsBasedOnER[suture]->GetSimTimeStep();
00416 
00417         //std::cout << "GetForceScaleA: " << pConstraint->GetForceScaleA() << "\n";
00418         std::cout << "Fs: " << Fs << "\n";
00419         m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].ExternalForce_ForAdvSimCtrl = Fs;
00420 
00421         // For slidable suture points
00422         //if ( !m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].UseEnforcedPosition ... && ...
00423         if ( SuturePt < m_ListOfSutureModelsBasedOnER[suture]->GetNumberOfLinks()-5 ) {
00424             if ( m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.CheckSimulationConstraints( Enum::AddOn::SLIDABLE ) )
00425             // WHY THE SIMFLAGS IS NOT SET PROPERLY (GOT RESET SOMEWHERE) ???
00426             {
00427                 // If the next suture point is not attached, then check if the suture point will slide due to the high force.
00428                 //if ( m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt+1].SimFlags.CheckSimulationConstraints( Enum::AddOn::ATTACHED ) ) 
00429                 {
00430                     if ( SforceMag > pConstraint->GetForceThresholdA() )
00431                     {
00432                         //if (
00433                         // Backward ???
00434 
00435                         //-----------------------------------------------
00436                         // Forward
00437                         //-----------------------------------------------
00438                         // Clear simulation states of the current node, e.g. clear ATTACHED status
00439                         m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].ExternalForce_ForAdvSimCtrl.Clear();
00440                         m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.ClearSimulationConstraints( Enum::AddOn::ATTACHED );
00441 
00442                         // move to next suture point
00443                         ++SuturePt;
00444 
00445                         std::cout << "SuturePt after: " << SuturePt << "\n";
00446 
00447                         pConstraint->SetVertexIDFromSuture( SuturePt );
00448 
00449                         // Set the status of the new suture point
00450 
00451                         //*
00452                         // DEBUG
00453                         // Enforce Suture's Position
00454                         if ( SuturePt == 25 )
00455                         {
00456                             m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].UseEnforcedPosition = true;
00457                         }
00458                         //*/
00459 
00460                         // Calculate the external force apply to Suture
00461                         Vector3<T> Fs = pConstraint->RefToTargetPositionA() - m_ListOfSutureModelsBasedOnER[suture]->RefToCurrentVertexPositionOfNodeNumber( SuturePt );
00462                         if ( bLinearForce )
00463                         {
00464                             // LINEAR FORCE
00465                             Fs *= pConstraint->GetForceScaleA();
00466                         }
00467                         else
00468                         {
00469                             // NONLINEAR FORCE
00470                             T suture_link_length = m_ListOfSutureModelsBasedOnER[suture]->GetLinkLength();
00471                             T magnitude = Fs.Magnitude();
00472                             T scale = pow( pConstraint->GetForceScaleA(), magnitude/suture_link_length );
00473                             if ( scale*magnitude <= m_ListOfSutureModelsBasedOnER[suture]->GetStretchModulus()*scaleNonlinearForce ) {
00474                                 Fs *= scale;
00475                             }
00476                             else {
00477                                 Fs *= m_ListOfSutureModelsBasedOnER[suture]->GetStretchModulus();
00478                             }
00479                         }
00480                         m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].ExternalForce_ForAdvSimCtrl = Fs;
00481                         if ( SuturePt < m_ListOfSutureModelsBasedOnER[suture]->GetNumberOfLinks()-5 ) {
00482                             m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.SetSimulationConstraints( Enum::AddOn::SLIDABLE );
00483                             m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.SetSimulationConstraints( Enum::AddOn::ATTACHED );
00484                         }
00485                         else {
00486                             m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[SuturePt].SimFlags.SetSimulationConstraints( Enum::AddOn::ATTACHED );
00487                         }
00488                     }
00489                 }
00490             }
00491         }
00492     }
00493 }
00494 //-----------------------------------------------------------------------------
00495 //-----------------------------------------------------------------------------
00496 template <typename T, typename DATA>
00497 void AdvSimSupport_DS<T,DATA>::EnforceAllConsistentPositions ()
00498 {
00499     // model-model interactions
00500     for ( unsigned int i = 0; i < m_ListOfInteractionModelVsModel.size(); ++i ) {
00501         for ( unsigned int j = i; j < m_ListOfInteractionModelVsModel.size(); ++j ) {
00502             EnforceAllConsistentPositionsOfTwoModels( i, j );
00503         }
00504     }
00505 
00506     // ERSuture-model interactions
00507     for ( unsigned int i = 0; i < m_ListOfInteractionERSutureVsModel.size(); ++i ) {
00508         for ( unsigned int j = 0; j < m_ListOfInteractionERSutureVsModel[i].size(); ++j ) {
00509             EnforceAllConsistentPositionsOfERSutureAndModel( i, j );
00510         }
00511     }
00512 }
00513 //-----------------------------------------------------------------------------
00514 template <typename T, typename DATA>
00515 void AdvSimSupport_DS<T,DATA>::EnforceAllConsistentPositionsOfTwoModels ( int modelA, int modelB )
00516 {
00517     modelB -= modelA;   // since the data in the std::vector starts from 0, not from the model number
00518     std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * >::iterator it = m_ListOfInteractionModelVsModel[modelA][modelB].begin();
00519     while ( it != m_ListOfInteractionModelVsModel[modelA][modelB].end() ) {
00520         (*it)->RefToSavedPositionA() = (*it)->GetPtrToVertexFromModel_1()->GetProtectedPosition();
00521         (*it)->RefToSavedPositionB() = (*it)->GetPtrToVertexFromModel_2()->GetProtectedPosition();
00522         (*it)->GetPtrToVertexFromModel_1()->GetProtectedPosition() = (*it)->RefToTargetPositionA();
00523         (*it)->GetPtrToVertexFromModel_2()->GetProtectedPosition() = (*it)->RefToTargetPositionB();
00524         ++it;
00525     }
00526 }
00527 //-----------------------------------------------------------------------------
00528 template <typename T, typename DATA>
00529 void AdvSimSupport_DS<T,DATA>::EnforceAllConsistentPositionsOfERSutureAndModel ( int suture, int model )
00530 {
00531     Matrix4x4<T> TrxModel;
00532     Matrix4x4<T> InvTrxModel;
00533     TrxModel = m_ListOfModelsForSurgeryBasedOnFEM[model]->RefToTransformationSupport().ReturnMatrixTransform();
00534     InvTrxModel = TrxModel.GetInverse();
00535 
00536     std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * >::iterator it = m_ListOfInteractionERSutureVsModel[suture][model].begin();
00537     while ( it != m_ListOfInteractionERSutureVsModel[suture][model].end() ) {
00538 
00539         // Move the suture's constrained point to the target point
00540         //Vector3<T> & Sp = m_ListOfSutureModelsBasedOnER[suture]->RefToPreviousVertexPositionOfNodeNumber( (*it)->GetVertexIDFromSuture() );
00541         //Vector3<T> & Sc = m_ListOfSutureModelsBasedOnER[suture]->RefToCurrentVertexPositionOfNodeNumber( (*it)->GetVertexIDFromSuture() );
00542         //Sp = Sc = (*it)->RefToTargetPositionA();
00543 
00544         unsigned int nodeID = (*it)->GetVertexIDFromSuture();
00545 
00546         // Enforce Suture's Position
00547         m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[nodeID].EnforcedPosition = (*it)->RefToTargetPositionA();
00548 
00549         // Move the model's constrained point to the target point
00550         (*it)->RefToSavedPositionB() = (*it)->GetPtrToVertexFromModel()->GetProtectedPosition();
00551         //(*it)->GetPtrToVertexFromModel()->GetProtectedPosition() = (*it)->RefToTargetPositionB(); // TO THE TARGET POSITION B
00552         (*it)->GetPtrToVertexFromModel()->GetProtectedPosition() = InvTrxModel * 
00553             m_ListOfSutureModelsBasedOnER[suture]->RefToCurrentVertexPositionOfNodeNumber( 
00554                 (*it)->GetVertexIDFromSuture() );   // TO THE SUTURE POINT
00555 
00556         ++it;
00557     }
00558 }
00559 //-----------------------------------------------------------------------------
00560 //-----------------------------------------------------------------------------
00561 template <typename T, typename DATA>
00562 void AdvSimSupport_DS<T,DATA>::ClearAllConstraints ()
00563 {
00564     // Clear model-model interactions
00565     for ( unsigned int i = 0; i < m_ListOfInteractionModelVsModel.size(); ++i ) {
00566         for ( unsigned int j = i; j < m_ListOfInteractionModelVsModel.size(); ++j ) {
00567             ClearAllConstraintsOfTwoModels( i, j );
00568         }
00569     }
00570 
00571     // Clear ERSuture-model interactions
00572     for ( unsigned int i = 0; i < m_ListOfInteractionERSutureVsModel.size(); ++i ) {
00573         for ( unsigned int j = 0; j < m_ListOfInteractionERSutureVsModel[i].size(); ++j ) {
00574             ClearAllConstraintsOfERSutureAndModel( i, j );
00575         }
00576     }
00577 }
00578 //-----------------------------------------------------------------------------
00579 template <typename T, typename DATA>
00580 void AdvSimSupport_DS<T,DATA>::ClearAllConstraintsOfTwoModels ( int modelA, int modelB )
00581 {
00582     modelB -= modelA;   // since the data in the std::vector starts from 0, not from the model number
00583     std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * >::iterator it = m_ListOfInteractionModelVsModel[modelA][modelB].begin();
00584     while ( it != m_ListOfInteractionModelVsModel[modelA][modelB].end() ) {
00585         delete *it;
00586         ++it;
00587     }
00588     m_ListOfInteractionModelVsModel[modelA][modelB].clear();
00589 }
00590 //-----------------------------------------------------------------------------
00591 template <typename T, typename DATA>
00592 void AdvSimSupport_DS<T,DATA>::ClearAllConstraintsOfERSutureAndModel ( int suture, int model )
00593 {
00594     std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * >::iterator it = m_ListOfInteractionERSutureVsModel[suture][model].begin();
00595     while ( it != m_ListOfInteractionERSutureVsModel[suture][model].end() ) {
00596 
00597         // Commented out because causing a run-time error during the exit of the program
00598         // ALL OF THESE STATEMENTS ARE ADDED INTO Reset() function of ModelElasticRod.
00599         //m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[(*it)->GetVertexIDFromSuture()].EnforcedPosition.Clear();
00600         //m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[(*it)->GetVertexIDFromSuture()].UseEnforcedPosition = false;
00601         //m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[(*it)->GetVertexIDFromSuture()].ExternalForce_ForAdvSimCtrl.Clear();
00602 
00603         delete *it;
00604         ++it;
00605     }
00606     m_ListOfInteractionERSutureVsModel[suture][model].clear();
00607 }
00608 //-----------------------------------------------------------------------------
00609 template <typename T, typename DATA>
00610 void AdvSimSupport_DS<T,DATA>::ClearTheConstraintNumberOfTwoModels ( int modelA, int modelB, unsigned int constraintNumber )
00611 {
00612     // REMARK: The erased element's destructor is called before it is removed from the std::vector.
00613     // Therefore, calling the desctructor after the erase will generate a runtime error.
00614     modelB -= modelA;   // since the data in the std::vector starts from 0, not from the model number
00615     m_ListOfInteractionModelVsModel[modelA][modelB].erase( m_ListOfInteractionModelVsModel[modelA][modelB].begin() + constraintNumber );
00616 }
00617 //-----------------------------------------------------------------------------
00618 template <typename T, typename DATA>
00619 void AdvSimSupport_DS<T,DATA>::ClearTheConstraintNumberOfERSutureAndModel ( int suture, int model, unsigned int constraintNumber )
00620 {
00621     // REMARK: The erased element's destructor is called before it is removed from the std::vector.
00622     // Therefore, calling the desctructor after the erase will generate a runtime error.
00623     std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * >::iterator it = m_ListOfInteractionERSutureVsModel[suture][model].begin() + constraintNumber;
00624     m_ListOfInteractionERSutureVsModel[suture][model].erase( it );
00625 
00626     // Enforce Suture's Position
00627     //m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[(*it)->GetVertexIDFromSuture()].EnforcedPosition.Clear();
00628     //m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[(*it)->GetVertexIDFromSuture()].UseEnforcedPosition = false;
00629 
00630     m_ListOfSutureModelsBasedOnER[suture]->GetListOfNodes()[(*it)->GetVertexIDFromSuture()].ExternalForce_ForAdvSimCtrl.Clear();
00631 }
00632 //-----------------------------------------------------------------------------
00633 template <typename T, typename DATA>
00634 void AdvSimSupport_DS<T,DATA>::AdvSimAllModels (
00635     T timestep,                         
00636     bool bEnforceAllConstraints,        
00637     bool bEnforceAllConsistentPositions 
00638 )
00639 {
00640     // Enforce all constraints
00641     if ( bEnforceAllConstraints ) {
00642         EnforceAllConstraints();
00643     }
00644 
00645     //for ( unsigned int i = 0; i < m_ListOfSutureModelsBasedOnMSS.size(); ++i ) {
00646     //  AdvSimSutureModelBasedOnMSS( i, timestep );
00647     //}
00648     for ( unsigned int i = 0; i < m_ListOfSutureModelsBasedOnER.size(); ++i ) {
00649         AdvSimSutureModelBasedOnER( i, timestep );
00650     }
00651     //for ( unsigned int i = 0; i < m_ListOfModelsForSurgeryBasedOnMSS.size(); ++i ) {
00652     //  AdvSimModelForSurgeryBasedOnMSS( i, timestep );
00653     //}
00654     for ( unsigned int i = 0; i < m_ListOfModelsForSurgeryBasedOnFEM.size(); ++i ) {
00655         AdvSimModelForSurgeryBasedOnFEM( i, timestep );
00656     }
00657 
00658     if ( bEnforceAllConsistentPositions ) {
00659         EnforceAllConsistentPositions();
00660     }
00661 
00662     for ( unsigned int i = 0; i < m_ListOfModelsForSurgeryBasedOnFEM.size(); ++i ) {
00663         m_ListOfModelsForSurgeryBasedOnFEM[i]->UpdateSurfaceMeshNormals();
00664     }
00665 }
00666 //-----------------------------------------------------------------------------
00667 template <typename T, typename DATA>
00668 void AdvSimSupport_DS<T,DATA>::AdvSimSutureModelBasedOnMSS ( unsigned int sutureID, T timestep )
00669 {
00670     m_ListOfSutureModelsBasedOnMSS[sutureID]->AdvanceSimulation( 0, timestep );
00671 }
00672 //-----------------------------------------------------------------------------
00673 template <typename T, typename DATA>
00674 void AdvSimSupport_DS<T,DATA>::AdvSimSutureModelBasedOnER ( unsigned int sutureID, T timestep )
00675 {
00676     m_ListOfSutureModelsBasedOnER[sutureID]->AdvanceSimulation();
00677 }
00678 //-----------------------------------------------------------------------------
00679 template <typename T, typename DATA>
00680 void AdvSimSupport_DS<T,DATA>::AdvSimModelForSurgeryBasedOnMSS ( unsigned int sutureID, T timestep )
00681 {
00682     m_ListOfModelsForSurgeryBasedOnMSS[sutureID]->AdvanceSimulation( 0, timestep );
00683 }
00684 //-----------------------------------------------------------------------------
00685 template <typename T, typename DATA>
00686 void AdvSimSupport_DS<T,DATA>::AdvSimModelForSurgeryBasedOnFEM ( unsigned int sutureID, T timestep )
00687 {
00688     m_ListOfModelsForSurgeryBasedOnFEM[sutureID]->AdvanceSimulationDynamic();
00689 }
00690 //-----------------------------------------------------------------------------
00691 
00692 
00693 
00694 
00695 //=============================================================================
00696 #if defined(__gl_h_) || defined(__GL_H__)
00697 //-----------------------------------------------------------------------------
00698 template <typename T, typename DATA>
00699 void AdvSimSupport_DS<T,DATA>::DrawAllModels ()
00700 {
00701     std::vector< OpenGL::ModelSuture<T> * >::iterator A = m_ListOfSutureModelsBasedOnMSS.begin();
00702     while ( A != m_ListOfSutureModelsBasedOnMSS.end() ) {
00703         (*A)->Draw();
00704         ++A;
00705     }
00706     std::vector< ModelForSurgery<T> * >::iterator B = m_ListOfModelsForSurgeryBasedOnMSS.begin();
00707     while ( B != m_ListOfModelsForSurgeryBasedOnMSS.end() ) {
00708         (*B)->Draw();
00709         ++B;
00710     }
00711     std::vector< ModelElasticRod<T> * >::iterator C = m_ListOfSutureModelsBasedOnER.begin();
00712     while ( C != m_ListOfSutureModelsBasedOnER.end() ) {
00713         (*C)->Draw();
00714         ++C;
00715     }
00716     std::vector< ModelDefBasedOnFEM<T,DATA> * >::iterator D = m_ListOfModelsForSurgeryBasedOnFEM.begin();
00717     while ( D != m_ListOfModelsForSurgeryBasedOnFEM.end() ) {
00718         (*D)->Draw();
00719         ++D;
00720     }
00721 }
00722 //-----------------------------------------------
00723 template <typename T, typename DATA>
00724 void AdvSimSupport_DS<T,DATA>::DrawAddedInteractions ()
00725 {
00726     // Draw model-model interactions
00727     for ( unsigned int i = 0; i < m_ListOfInteractionModelVsModel.size(); ++i ) {
00728         for ( unsigned int j = i; j < m_ListOfInteractionModelVsModel.size(); ++j ) {
00729             DrawAddedInteractionsBetweenTwoModels( i, j );
00730             //std::cout << "model#" << i << " vs model#" << j+i << "\n";
00731         }
00732     }
00733 
00734     // Draw ERSuture-model interactions
00735     for ( unsigned int i = 0; i < m_ListOfInteractionERSutureVsModel.size(); ++i ) {
00736         for ( unsigned int j = 0; j < m_ListOfInteractionERSutureVsModel[i].size(); ++j ) {
00737             DrawAddedInteractionsBetweenERSutureAndModel( i, j );
00738             //std::cout << "ERsuture#" << i << " vs model#" << j << "\n";
00739         }
00740     }
00741 }
00742 //-----------------------------------------------------------------------------
00743 template <typename T, typename DATA>
00744 void AdvSimSupport_DS<T,DATA>::DrawAddedInteractionsBetweenTwoModels ( int modelA, int modelB )
00745 {
00746     glPushAttrib( GL_ALL_ATTRIB_BITS );
00747     glDisable( GL_LIGHTING );
00748     glLineWidth( 2 );
00749     glPointSize( 5 );
00750     GLfloat V[2][3];
00751 
00752     Matrix4x4<T> Trx1;
00753     if ( m_ModelType[modelA] == MODEL_BASED_ON_FEM ) {
00754         unsigned int loc = m_ModelLocation[modelA];
00755         Trx1 = m_ListOfModelsForSurgeryBasedOnFEM[modelA]->RefToTransformationSupport().ReturnMatrixTransform();
00756     }
00757     Matrix4x4<T> Trx2;
00758     if ( m_ModelType[modelB] == MODEL_BASED_ON_FEM ) {
00759         unsigned int loc = m_ModelLocation[modelB];
00760         Trx2 = m_ListOfModelsForSurgeryBasedOnFEM[modelB]->RefToTransformationSupport().ReturnMatrixTransform();
00761     }
00762 
00763     modelB -= modelA;   // since the data in the std::vector starts from 0, not from the model number
00764     std::vector< AdvSimConstraint_HEVertexVsHEVertex<T> * >::iterator it = m_ListOfInteractionModelVsModel[modelA][modelB].begin();
00765     while ( it != m_ListOfInteractionModelVsModel[modelA][modelB].end() ) {
00766         Vector3<T> v1 = (Trx1 * Vector4<T>( (*it)->GetPtrToVertexFromModel_1()->GetPosition() ) ).GetVector3();
00767         Vector3<T> v2 = (Trx2 * Vector4<T>( (*it)->GetPtrToVertexFromModel_2()->GetPosition() ) ).GetVector3();
00768         V[0][0] = v1[0];    V[0][1] = v1[1];    V[0][2] = v1[2];
00769         V[1][0] = v2[0];    V[1][1] = v2[1];    V[1][2] = v2[2];
00770         glBegin( GL_POINTS );
00771             glColor3f( 0.3f, 0.7f, 0.2f );
00772             glVertex3fv( V[0] );
00773             glVertex3fv( V[1] );
00774             glColor3f( 1.0f, 1.0f, 0.0f );
00775             glVertex3fv( (Trx1*Vector4<T>((*it)->RefToTargetPositionA())).GetVector3().GetDataFloat() );
00776             glColor3f( 1.0f, 0.0f, 1.0f );
00777             glVertex3fv( (Trx2*Vector4<T>((*it)->RefToTargetPositionB())).GetVector3().GetDataFloat() );
00778         glEnd();
00779         glBegin( GL_LINES );
00780             glColor3f( 0.3f, 0.7f, 0.5f );
00781             glVertex3fv( V[0] );
00782             glVertex3fv( V[1] );
00783         glEnd();
00784         ++it;
00785     }
00786     glPopAttrib();
00787 }
00788 //-----------------------------------------------------------------------------
00789 template <typename T, typename DATA>
00790 void AdvSimSupport_DS<T,DATA>::DrawAddedInteractionsBetweenERSutureAndModel ( int suture, int model )
00791 {
00792     glPushAttrib( GL_ALL_ATTRIB_BITS );
00793     glDisable( GL_LIGHTING );
00794     glLineWidth( 2 );
00795     glPointSize( 5 );
00796     GLfloat V[2][3];
00797     
00798     Matrix4x4<T> Trx;
00799     if ( m_ModelType[model] == MODEL_BASED_ON_FEM ) {
00800         unsigned int loc = m_ModelLocation[model];
00801         Trx = m_ListOfModelsForSurgeryBasedOnFEM[model]->RefToTransformationSupport().ReturnMatrixTransform();
00802     }
00803 
00804     std::vector< AdvSimConstraint_ERSutureVsHEVertex<T> * >::iterator it = m_ListOfInteractionERSutureVsModel[suture][model].begin();
00805     while ( it != m_ListOfInteractionERSutureVsModel[suture][model].end() ) {
00806         Vector3<T> v1 = m_ListOfSutureModelsBasedOnER[suture]->RefToCurrrentVertexPositionOfNodeNumber( (*it)->GetVertexIDFromSuture() );
00807         Vector3<T> v2 = (Trx * Vector4<T>( (*it)->GetPtrToVertexFromModel()->GetPosition() ) ).GetVector3();
00808         V[0][0] = v1[0];    V[0][1] = v1[1];    V[0][2] = v1[2];
00809         V[1][0] = v2[0];    V[1][1] = v2[1];    V[1][2] = v2[2];
00810         glBegin( GL_POINTS );
00811             glColor3f( 0.3f, 0.7f, 0.2f );
00812             glVertex3fv( V[0] );
00813             glVertex3fv( V[1] );
00814             glColor3f( 1.0f, 1.0f, 0.0f );
00815             glVertex3fv( (*it)->RefToTargetPositionA().GetDataFloat() );
00816             glColor3f( 1.0f, 0.0f, 1.0f );
00817             glVertex3fv( (Trx*Vector4<T>((*it)->RefToTargetPositionB())).GetVector3().GetDataFloat() );
00818         glEnd();
00819         glBegin( GL_LINES );
00820             glColor3f( 0.3f, 0.7f, 0.5f );
00821             glVertex3fv( V[0] );
00822             glVertex3fv( V[1] );
00823         glEnd();
00824         ++it;
00825     }
00826     glPopAttrib();
00827 }
00828 //-----------------------------------------------------------------------------
00829 #endif  // #if defined(__gl_h_) || defined(__GL_H__)
00830 //=============================================================================
00831 
00832 //=============================================================================
00833 END_NAMESPACE_TAPs
00834 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00835 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines