TAPs 0.7.7.3
TAPsModelDefBasedOnFEMHex.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsModelDefBasedOnFEMHex.cpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (02/26/2010)
00009 UPDATE          (12/05/2010)
00010 ******************************************************************************/
00011 #include "TAPsModelDefBasedOnFEMHex.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 ModelDefBasedOnFEMHex<T,DATA>::ModelDefBasedOnFEMHex ( std::string const & modelFile )
00021     : ModelDefBasedOnFEM<T,DATA>( modelFile )
00022     , m_ElementsGridLocs( NULL )
00023 {
00024     m_NumOfElementsPerGridSize[0] = 
00025     m_NumOfElementsPerGridSize[1] = 
00026     m_NumOfElementsPerGridSize[2] = 0;
00027 }
00028 //-----------------------------------------------------------------------------
00029 //template <typename T, typename DATA>
00030 //ModelDefBasedOnFEMHex<T,DATA>::ModelDefBasedOnFEMHex ( ModelDefBasedOnFEMHex<T,DATA> const &orig )
00031 //  :
00032 //{}
00033 //-----------------------------------------------------------------------------
00034 template <typename T, typename DATA>
00035 ModelDefBasedOnFEMHex<T,DATA>::~ModelDefBasedOnFEMHex ()
00036 {
00037     DeallocateElementsGridLocations();
00038 }
00039 //-----------------------------------------------------------------------------
00040 template <typename T, typename DATA>
00041 std::string ModelDefBasedOnFEMHex<T,DATA>::StrInfo () const
00042 {
00043     std::ostringstream ss;
00044     ss << "ModelDefBasedOnFEMHex<" << typeid(T).name() << ">";
00045     ss << "\n";
00046     return ss.str();
00047 }
00048 //-----------------------------------------------------------------------------
00049 template <typename T, typename DATA>
00050 void ModelDefBasedOnFEMHex<T,DATA>::AllocateElementsGridLocations ( unsigned int xWidth, unsigned int yHeight, unsigned int zDepth )
00051 {
00052     m_NumOfElementsPerGridSize[0] = xWidth;
00053     m_NumOfElementsPerGridSize[1] = yHeight;
00054     m_NumOfElementsPerGridSize[2] = zDepth;
00055     if ( m_ElementsGridLocs )   DeallocateElementsGridLocations();
00056     try {
00057         m_ElementsGridLocs = new int**[m_NumOfElementsPerGridSize[0]];
00058         for ( unsigned int i = 0; i < m_NumOfElementsPerGridSize[0]; ++i ) {
00059             m_ElementsGridLocs[i] = new int*[m_NumOfElementsPerGridSize[1]];
00060             for ( unsigned int j = 0; j < m_NumOfElementsPerGridSize[1]; ++j ) {
00061                 m_ElementsGridLocs[i][j] = new int[m_NumOfElementsPerGridSize[2]];
00062                 for ( unsigned int k = 0; k < m_NumOfElementsPerGridSize[2]; ++k ) {
00063                     m_ElementsGridLocs[i][j][k] = -1;
00064                 }
00065             }
00066         }
00067     }
00068     catch ( Exception & e ) {
00069         throw e;
00070     }
00071 }
00072 //-----------------------------------------------------------------------------
00073 template <typename T, typename DATA>
00074 void ModelDefBasedOnFEMHex<T,DATA>::DeallocateElementsGridLocations ()
00075 {
00076     if ( m_ElementsGridLocs ) {
00077         for ( unsigned int i = 0; i < m_NumOfElementsPerGridSize[0]; ++i ) {
00078             for ( unsigned int j = 0; j < m_NumOfElementsPerGridSize[1]; ++j ) {
00079                 delete [] m_ElementsGridLocs[i][j];
00080             }
00081             delete [] m_ElementsGridLocs[i];
00082         }
00083     }
00084     delete [] m_ElementsGridLocs;
00085     m_ElementsGridLocs = NULL;
00086 }
00087 //-----------------------------------------------------------------------------
00088 template <typename T, typename DATA>
00089 int ModelDefBasedOnFEMHex<T,DATA>::GetElementIDFromGridLocation_wErrChk ( unsigned int xWidth, unsigned int yHeight, unsigned int zDepth ) const
00090 {
00091     if ( m_ElementsGridLocs ) {
00092         if (    xWidth  < m_NumOfElementsPerGridSize[0]
00093             &&  yHeight < m_NumOfElementsPerGridSize[1]
00094             &&  zDepth  < m_NumOfElementsPerGridSize[2] )
00095         {
00096             return m_ElementsGridLocs[xWidth][yHeight][zDepth];
00097         }
00098         else {
00099             return -2;  // one of grid is out of range
00100         }
00101     }
00102     else {
00103         return -10; // m_ElementsGridLocs is not available
00104     }
00105 }
00106 //-----------------------------------------------------------------------------
00107 template <typename T, typename DATA>
00108 int ModelDefBasedOnFEMHex<T,DATA>::GetElementIDFromGridLocation ( unsigned int xWidth, unsigned int yHeight, unsigned int zDepth ) const
00109 {
00110     return m_ElementsGridLocs[xWidth][yHeight][zDepth];
00111 }
00112 //-----------------------------------------------------------------------------
00113 template <typename T, typename DATA>
00114 void ModelDefBasedOnFEMHex<T,DATA>::ListAllElementIDsInGridLocationFormat_zYx () const
00115 {
00116     std::cout << "START: ListAllElementIDsInGridLocationFormat_zYx "
00117         << "[0-"<<m_NumOfElementsPerGridSize[2]<<"] -- back to front (z-direction)"
00118         << "["<<m_NumOfElementsPerGridSize[1]<<"-0] -- bottom to top (y-direction)"
00119         << "[0-"<<m_NumOfElementsPerGridSize[0]<<"] -- left to right (x-direction)"
00120         << "\n";
00121     //int limit = 0;
00122     for ( int z = 0; z < static_cast<int>( m_NumOfElementsPerGridSize[2] ); ++z ) {
00123         std::cout << "Depth: " << z << "\n";
00124         for ( int y = static_cast<int>( m_NumOfElementsPerGridSize[1] )-1; y >= 0; --y ) {
00125             for ( int x = 0; x < static_cast<int>( m_NumOfElementsPerGridSize[0] ); ++x ) {
00126                 std::cout << std::setw(6) << m_ElementsGridLocs[x][y][z];
00127             }
00128             std::cout << "\n";
00129 
00130             //++limit;
00131             //if ( limit > 1000 ) return;
00132         }
00133     }
00134     std::cout << "END: ListAllElementIDsInGridLocationFormat_zYx "
00135         << "[0-"<<m_NumOfElementsPerGridSize[2]<<"] -- back to front (z-direction)"
00136         << "["<<m_NumOfElementsPerGridSize[1]<<"-0] -- bottom to top (y-direction)"
00137         << "[0-"<<m_NumOfElementsPerGridSize[0]<<"] -- left to right (x-direction)"
00138         << "\n";
00139 }
00140 //-----------------------------------------------------------------------------
00141 //=============================================================================
00142 // Assignment Operator
00143 //-----------------------------------------------------------------------------
00144 //template <typename T, typename DATA>
00145 //inline ModelDefBasedOnFEMHex<T,DATA> & ModelDefBasedOnFEMHex<T,DATA>::operator= ( ModelDefBasedOnFEMHex<T,DATA> const &orig )
00146 //{ 
00147 //    return *this;
00148 //}
00149 //-----------------------------------------------------------------------------
00150 //=============================================================================
00151 
00152 
00153 
00154 
00155 
00156 
00157 
00158 
00159 
00160 //-----------------------------------------------------------------------------
00161 template <typename T, typename DATA>
00162 bool ModelDefBasedOnFEMHex<T,DATA>::GenerateGridsWithDimension (
00163     T iGridWidth,       
00164     T iGridHeight,      
00165     T iGridDepth,       
00166     T   mass,           
00167     T   YoungsModulus,  
00168     T   PoissonsRatio,  
00169     bool bGenElementsInsideVolume,      
00170     bool bRecordsElementsGridLocations  
00171 )
00172 {
00173     std::cout << __FILE__ << " (LINE#" << __LINE__ << ") NOT IMPLEMENTED YET!\n";
00174     return false;
00175 }
00176 
00177 
00178 //-----------------------------------------------------------------------------
00179 template <typename T, typename DATA>
00180 bool ModelDefBasedOnFEMHex<T,DATA>::GenerateGridsWithSize (
00181     int iNumOfXSlices,  
00182     int iNumOfYSlices,  
00183     int iNumOfZSlices,  
00184     T   mass,           
00185     T   YoungsModulus,  
00186     T   PoissonsRatio,  
00187     bool bGenElementsInsideVolume,      
00188     bool bRecordsElementsGridLocations  
00189 )
00190 {
00191     if ( !m_pHEModel ) {
00192         return false;
00193     }
00194 
00195     // Generate grids
00196     //GridGenerator<T,DATA> GridGen;
00197     m_GridGen.SetModelUseToGenGrid( m_pHEModel );
00198     if ( m_GridGen.GenerateGridsWithSize( iNumOfXSlices, iNumOfYSlices, iNumOfZSlices ) ) {
00199         // Generate FEM mesh from the generated grids
00200         if ( GenerateMeshFromGridGenerator( m_GridGen, mass, YoungsModulus, PoissonsRatio, bGenElementsInsideVolume ) ) {
00201             // Clear the generated grids
00202             m_GridGen.DeleteGrids();
00203 
00204             // Set transformation support
00205             m_FEMMesh.SetTransformationSupportPointer( &(m_pHEModel->GetTransform()) );
00206 
00207             return true;
00208         }
00209         else {
00210             std::cout << "ModelDefBasedOnFEMHex<T,DATA>::GenerateGridsWithSize(...) FAILED to generate FEM mesh!\n";
00211             // Clear the generated grids
00212             m_GridGen.DeleteGrids();
00213             return false;
00214         }
00215     }
00216     else {
00217         std::cout << "ModelDefBasedOnFEMHex<T,DATA>::GenerateGridsWithSize(...) FAILED to generate grids!\n";
00218         return false;
00219     }
00220 }
00221 
00222 
00223 //-----------------------------------------------------------------------------
00224 template <typename T, typename DATA>
00225 bool ModelDefBasedOnFEMHex<T,DATA>::GenerateMeshFromGridGenerator (
00226     GridGenerator<T,DATA> & GridGen,    
00227     T   mass,                           
00228     T   YoungsModulus,                  
00229     T   PoissonsRatio,                  
00230     bool bGenElementsInsideVolume,      
00231     bool bRecordsElementsGridLocations  
00232 )
00233 {
00234     // FOR HALF-EDGE MODEL ONLY
00235     if ( !m_pHEModel ) {
00236         return false;
00237     }
00238     if ( !GridGen.IsGridGenerated() ) {
00239         return false;
00240     }
00241 
00242     GridGen.RecordHexBarycentricCoordinates();
00243 
00244     // Clear data
00245     // other data are clear by MeshHexahedraGen function
00246     m_BaryCoords.clear();
00247 
00248     // Use the static function of Meshexahedra Genetator to generate the hexahedral mesh from the grid generator
00249     if ( bRecordsElementsGridLocations ) {
00250         //std::cout << "ModelDefBasedOnFEMHex<T,DATA>::GenerateMeshFromGridGenerator() called with bRecordsElementsGridLocations is true.\n";
00251         AllocateElementsGridLocations( GridGen.GetGridSizeX()-1, GridGen.GetGridSizeY()-1, GridGen.GetGridSizeZ()-1 );
00252         if ( !FEM::MeshHexahedraGen<T,DATA>::MeshFromGridGenerator(
00253                 m_FEMMesh, m_BaryCoords, GridGen, mass, YoungsModulus, PoissonsRatio, 
00254                 bGenElementsInsideVolume, m_ElementsGridLocs ) )
00255         {
00256             DeallocateElementsGridLocations();
00257             return false;
00258         }
00259         ListAllElementIDsInGridLocationFormat_zYx();    // CHECKING
00260         //std::cout << "m_NumOfElementsPerGridSize: " << Vector3<unsigned int>( m_NumOfElementsPerGridSize ) << "\n";
00261     }
00262     else {
00263         //std::cout << "ModelDefBasedOnFEMHex<T,DATA>::GenerateMeshFromGridGenerator() called with bRecordsElementsGridLocations is false.\n";
00264         if ( !FEM::MeshHexahedraGen<T,DATA>::MeshFromGridGenerator(
00265                 m_FEMMesh, m_BaryCoords, GridGen, mass, YoungsModulus, PoissonsRatio, 
00266                 bGenElementsInsideVolume, NULL ) )
00267         {
00268             return false;
00269         }
00270     }
00271 
00272     // Set the link between HEVertex and FEM element
00273     // HEVertex'ID <--> FEM element location in the element list
00274     SetHEVertexIDToElementLocation();
00275 
00276     return true;
00277 }
00278 
00279 //-----------------------------------------------------------------------------
00280 template <typename T, typename DATA>
00281 void ModelDefBasedOnFEMHex<T,DATA>::AdvanceSimulationStatic ()
00282 {
00283     CDUnit().MoveAllGrabbedParts();
00284     m_FEMMesh.AdvanceSimulationStatic();
00285     UpdateSurfaceMesh();
00286 }
00287 
00288 //-----------------------------------------------------------------------------
00289 template <typename T, typename DATA>
00290 void ModelDefBasedOnFEMHex<T,DATA>::AdvanceSimulationStatic_woFixedDisplacementNodes ()
00291 {
00292     CDUnit().MoveAllGrabbedParts();
00293     m_FEMMesh.AdvanceSimulationStatic_woFixedDisplacementNodes();
00294     UpdateSurfaceMesh();
00295 }
00296 
00297 //-----------------------------------------------------------------------------
00298 #ifdef  TAPs_SIM_DYNAMIC_SYSTEM
00299 template <typename T, typename DATA>
00300 void ModelDefBasedOnFEMHex<T,DATA>::AdvanceSimulationDynamic ()
00301 {
00302     CDUnit().MoveAllGrabbedParts();
00303     m_FEMMesh.AdvanceSimulationDynamic();
00304     UpdateSurfaceMesh();
00305 }
00306 #endif//TAPs_SIM_DYNAMIC_SYSTEM
00307 
00308 //-----------------------------------------------------------------------------
00309 #ifdef  TAPs_SIM_DYNAMIC_SYSTEM
00310 template <typename T, typename DATA>
00311 void ModelDefBasedOnFEMHex<T,DATA>::AdvanceSimulationDynamic_woFixedDisplacementNodes ()
00312 {
00313     CDUnit().MoveAllGrabbedParts();
00314     m_FEMMesh.AdvanceSimulationDynamic_woFixedDisplacementNodes();
00315     UpdateSurfaceMesh();
00316 }
00317 #endif//TAPs_SIM_DYNAMIC_SYSTEM
00318 
00319 //-----------------------------------------------------------------------------
00320 template <typename T, typename DATA>
00321 void ModelDefBasedOnFEMHex<T,DATA>::UpdateSurfaceMesh ()
00322 {
00323     // Iterate all vertices of the surface mesh
00324     //std::vector< HexBarycentricCoordsForVertexRef<T,DATA> >::iterator it = m_BaryCoords.begin();
00325     //std::vector< FEM::Hexahedron<T> > & E = m_FEMMesh.RetListOfElements();
00326     //std::vector< Vector3<T> > &   Nd = m_FEMMesh.RetListOfDeformedMeshNodes();
00327     //std::vector< Vector3<T> > &   Nu = m_FEMMesh.RetListOfUndeformedMeshNodes();
00328     //unsigned int e;
00329     //int C_1 = m_GridGen.GetGridSizeX()-1;
00330     //int R_1 = m_GridGen.GetGridSizeY()-1;
00331     for ( unsigned int v = 0; v < m_BaryCoords.size(); ++v ) {
00332         //e = m_ElementID[v];
00333         //e = m_BaryCoords[v].GetElementID();
00334         m_BaryCoords[v].ComputeNewVertexLocation();
00335         /*
00336         m_BaryCoords[v].ComputeNewVertexLocation(
00337             E[e].DeformedNode(0)->GetX(), E[e].DeformedNode(0)->GetY(), E[e].DeformedNode(0)->GetZ(),
00338             E[e].DeformedNode(1)->GetX(), E[e].DeformedNode(1)->GetY(), E[e].DeformedNode(1)->GetZ(),
00339             E[e].DeformedNode(2)->GetX(), E[e].DeformedNode(2)->GetY(), E[e].DeformedNode(2)->GetZ(),
00340             E[e].DeformedNode(3)->GetX(), E[e].DeformedNode(3)->GetY(), E[e].DeformedNode(3)->GetZ(),
00341             E[e].DeformedNode(4)->GetX(), E[e].DeformedNode(4)->GetY(), E[e].DeformedNode(4)->GetZ(),
00342             E[e].DeformedNode(5)->GetX(), E[e].DeformedNode(5)->GetY(), E[e].DeformedNode(5)->GetZ(),
00343             E[e].DeformedNode(6)->GetX(), E[e].DeformedNode(6)->GetY(), E[e].DeformedNode(6)->GetZ(),
00344             E[e].DeformedNode(7)->GetX(), E[e].DeformedNode(7)->GetY(), E[e].DeformedNode(7)->GetZ()
00345         );
00346         //*/
00347     }
00348 
00349     // Update all extra vertices
00350     HexBarycentricCoordsForVertexRef<T,DATA> * pHexBC;
00351     for ( unsigned int v = 0; v < m_SetOfExtraVertexCoords.size(); ++v ) {
00352         pHexBC = dynamic_cast< HexBarycentricCoordsForVertexRef<T,DATA>* >( m_SetOfExtraVertexCoords[v] );
00353         pHexBC->ComputeNewVertexLocation();
00354     }
00355 
00356     // Update BVH tree
00357     // The update of normals is not done by this function.
00358     // The update of normals must be done after this but before rendering.
00359     ModelDefBasedOnFEM<T,DATA>::UpdateSurfaceMesh();
00360 
00361     // Adjust the surface mesh, i.e. the vertices that is collided with another object.
00362     //CDUnit().AdjustSurfaceMeshByCDObjs();
00363     CDUnit().AdjustSurfaceMeshDueToGrabbedParts();
00364 
00365     if ( m_CD.GetCollisionStatus() ) {
00366         m_CD.SetCollisionStatus( false );
00367     }
00368 }
00369 
00370 //-----------------------------------------------------------------------------
00371 template <typename T, typename DATA>
00372 void ModelDefBasedOnFEMHex<T,DATA>::SetHEVertexIDToElementLocation ()
00373 {
00374     if ( !m_pHEModel )  return;
00375 
00376     std::list< HEVertex<T> * > pVList;
00377     // Store all vertices for linking
00378     HEVertex<T> * V = m_pHEModel->GetVertexList()->Head();
00379     while ( V ) {
00380         pVList.push_back( &(*V) );
00381         V = V->Next();
00382     }
00383 
00384     //std::cout << __FILE__ << "\n";
00385     
00386     // Do the link
00387     int c = 0;
00388     for ( unsigned int i = 0; i < m_BaryCoords.size(); ++i ) {
00389         std::list< HEVertex<T> * >::iterator it = pVList.begin();
00390         while ( it != pVList.end() ) {
00391             if ( (void *)(m_BaryCoords[i].RetVertexPtr()) == (void *)((**it).RefToPosition()) ) {
00392                 //(**it).SetID( m_ElementID[i] );
00393                 (**it).SetID( m_BaryCoords[i].GetElementID() );
00394                 pVList.erase( it );
00395 
00396                 //std::cout << ++c << ": " << m_ElementID[i] << "\n";
00397 
00398                 break;
00399             }
00400             ++it;
00401         }
00402     }
00403 }
00404 
00405 //-----------------------------------------------------------------------------
00406 template <typename T, typename DATA>
00407 bool ModelDefBasedOnFEMHex<T,DATA>::InitCD ()
00408 {
00409     if ( ModelDefBasedOnFEM<T,DATA>::InitCD() ) {
00410         m_CD.Init( m_pHEModel, &m_FEMMesh );
00411         return true;
00412     }
00413     return false;
00414 }
00415 
00416 //-----------------------------------------------------------------------------
00417 template <typename T, typename DATA>
00418 HEVertex<T> * ModelDefBasedOnFEMHex<T,DATA>::AddExtraVertexInLocalSpace (
00419     Vector3<T> location,                    
00420     int elementID,                          
00421     FEM::Element<T> * elementPtr,           
00422     Vector3<unsigned int> gridLocations,    
00423     Vector3<T> coordinates                  
00424 )
00425 {
00426     FEM::Hexahedron<T> * hexPtr = dynamic_cast< FEM::Hexahedron<T> * >( elementPtr );
00427     if ( !hexPtr ) {
00428         std::cout << "Error: elementPtr cannot be converted to Hexahedron<T> *" << std::endl;
00429         return NULL;
00430     }
00431 
00432     HEVertex<T> * pV = new HEVertex<T>( location );
00433     HexBarycentricCoordsForVertexRef<T,DATA> * pBC = 
00434         new HexBarycentricCoordsForVertexRef<T,DATA>( 
00435                 pV->RefToPosition(), 
00436                 gridLocations[0], gridLocations[1], gridLocations[2],   // grid locations (col, row, & depth) (i.e. the hexahedral element's relative to the FEM mesh
00437                 coordinates[0], coordinates[1], coordinates[2]  // parametric coordinates
00438             );
00439     pBC->SetElementID( elementID );
00440     pBC->SetPtrToHexahedron( hexPtr );
00441     pV->SetBarycentricPtr( pBC );
00442     pV->SetID( elementID ); // The id is for identifying the hexahedral element (i.e. the element id)
00443 
00444     m_SetOfExtraVertices.push_back( pV );
00445     m_SetOfExtraVertexCoords.push_back( pBC );
00446 
00447     return pV;
00448 }
00449 
00450 //-----------------------------------------------------------------------------
00451 template <typename T, typename DATA>
00452 bool ModelDefBasedOnFEMHex<T,DATA>::FindElementThatContainsPointInLocalSpace (
00453     Vector3<T> const & point,               
00454     unsigned int & elementID,               
00455     Vector3<unsigned int> & gridLocations,  
00456     Vector3<T> & coordinates                
00457 )
00458 {
00459     //std::cout << "START: FindElementThatContainsPointInLocalSpace" << std::endl;
00460 
00461     //std::cout << "GetNumberOfElementsPerGridSize_X: " << GetNumberOfElementsPerGridSize_X() << std::endl;
00462     //std::cout << "GetNumberOfElementsPerGridSize_Y: " << GetNumberOfElementsPerGridSize_Y() << std::endl;
00463     //std::cout << "GetNumberOfElementsPerGridSize_Z: " << GetNumberOfElementsPerGridSize_Z() << std::endl;
00464 
00465     bool bFound = false;
00466     for ( unsigned int x = 0; !bFound && x < GetNumberOfElementsPerGridSize_X(); ++x ) {
00467         //std::cout << "x: " << x << std::endl;
00468         for ( unsigned int y = 0; !bFound && y < GetNumberOfElementsPerGridSize_Y(); ++y ) {
00469             //std::cout << "\ty: " << y << std::endl;
00470             for ( unsigned int z = 0; !bFound && z < GetNumberOfElementsPerGridSize_Z(); ++z ) {
00471                 //std::cout << "\t\tz: " << z << std::endl;
00472                 int ID = GetElementIDFromGridLocation( x, y, z );
00473 
00474                 //std::cout << "elementID: " << ID << std::endl;
00475 
00476                 //*
00477                 if ( ID >= 0 ) {
00478                     elementID = ID;
00479                     bFound = RefToFEMMesh().RefToElement( elementID ).EstimateParametricCoords( 
00480                         point[0], point[1], point[2], 
00481                         coordinates[0], coordinates[1], coordinates[2] ) 
00482                         > 0 ? true : false;
00483                     if ( bFound ) {
00484                         gridLocations[0] = x;
00485                         gridLocations[1] = y;
00486                         gridLocations[2] = z;
00487                         return true;
00488                     }
00489                 }
00490                 //*/
00491             }
00492         }
00493     }
00494 
00495     //std::cout << "END: FindElementThatContainsPointInLocalSpace" << std::endl;
00496 
00497     return bFound;
00498 }
00499 
00500 //-----------------------------------------------------------------------------
00501 template <typename T, typename DATA>
00502 void ModelDefBasedOnFEMHex<T,DATA>::FixOrUnfixNodesByRowColumnDepthRange (
00503     unsigned int x0,    
00504     unsigned int x1,    
00505     unsigned int y0,    
00506     unsigned int y1,    
00507     unsigned int z0,    
00508     unsigned int z1,    
00509     bool    doFix       
00510 )
00511 {
00512     unsigned int x, y, z;
00513     std::vector< HexBarycentricCoordsForVertexRef<T,DATA> >::iterator it = m_BaryCoords.begin();
00514     while ( it != m_BaryCoords.end() ) {
00515         it->GetGridLocations( x, y, z );
00516         if ( x0 <= x && x <= x1 ) {
00517             if ( y0 <= y && y <= y1 ) {
00518                 if ( z0 <= z && z <= z1 ) {
00519                     Vector3<T> const * const pNode = it->RetHexahedron()->UndeformedNode( 0 );
00520                     std::vector< Vector3<T> >::iterator NodeList = m_FEMMesh.RetListOfUndeformedMeshNodes().begin();
00521                     unsigned int i = 0;
00522                     while ( NodeList != m_FEMMesh.RetListOfUndeformedMeshNodes().end() ) {
00523                         if ( pNode == &(*NodeList) ) {
00524                             m_FEMMesh.FixNode( i, doFix );
00525                             break;
00526                         }
00527                         ++NodeList;
00528                         ++i;
00529                     }
00530                 }
00531             }
00532         }
00533         ++it;
00534     }
00535 }
00536 
00537 
00538 //=============================================================================
00539 #if defined(__gl_h_) || defined(__GL_H__)
00540 //-----------------------------------------------------------------------------
00541     template <typename T, typename DATA>
00542     void ModelDefBasedOnFEMHex<T,DATA>::DrawUndeformedFEMMesh ()
00543     {
00544         m_FEMMesh.DrawUndeformedMesh();
00545     }
00546 
00547     template <typename T, typename DATA>
00548     void ModelDefBasedOnFEMHex<T,DATA>::DrawDeformedFEMMesh ()
00549     {
00550         m_FEMMesh.DrawDeformedMesh();
00551     }
00552 
00553     template <typename T, typename DATA>
00554     void ModelDefBasedOnFEMHex<T,DATA>::DrawCollidedMeshParts ()
00555     {
00556         glPushMatrix();
00557         m_pHEModel->GetTransform().TransformByOpenGLForDrawing();
00558         for ( unsigned int i = 0; i < m_CD.RefToCollidedMeshParts().size(); ++i ) {
00559             m_CD.RefToCollidedMeshParts()[i].pHEVertex->Draw();
00560         }
00561         glPopMatrix();
00562     }
00563 //-----------------------------------------------------------------------------
00564 #endif // #if defined(__gl_h_) || defined(__GL_H__)
00565 //=============================================================================
00566 
00567 //=============================================================================
00568 END_NAMESPACE_TAPs
00569 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00570 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines