![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsAdvSimConstraint_HEVertexVsHEVertex.cpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (04/30/2010) 00009 UPDATE (10/06/2010) 00010 ******************************************************************************/ 00011 #include "TAPsAdvSimConstraint_HEVertexVsHEVertex.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 // Constructors 00019 //----------------------------------------------------------------------------- 00020 template <typename T> 00021 AdvSimConstraint_HEVertexVsHEVertex<T>::AdvSimConstraint_HEVertexVsHEVertex ( 00022 HEVertex<T> * pV1, 00023 HEVertex<T> * pV2, 00024 T forceRatio, 00025 T forceScaleForModelA, 00026 T forceScaleForModelB, 00027 T forceThresholdForModelA, 00028 T forceThresholdForModelB, 00029 bool bEnforceVertexOfModelA, 00030 bool bEnforceVertexOfModelB 00031 ) 00032 : AdvSimConstraint_Base_AvsB( forceRatio, forceScaleForModelA, forceScaleForModelB, forceThresholdForModelA, forceThresholdForModelB, bEnforceVertexOfModelA, bEnforceVertexOfModelB ), 00033 m_pV1( pV1 ), 00034 m_pV2( pV2 ) 00035 {} 00036 //----------------------------------------------------------------------------- 00037 template <typename T> 00038 AdvSimConstraint_HEVertexVsHEVertex<T>::AdvSimConstraint_HEVertexVsHEVertex ( AdvSimConstraint_HEVertexVsHEVertex<T> const &orig ) 00039 : AdvSimConstraint_Base_AvsB( orig ), 00040 m_pV1( orig.m_pV1 ), 00041 m_pV2( orig.m_pV2 ) 00042 {} 00043 //----------------------------------------------------------------------------- 00044 template <typename T> 00045 AdvSimConstraint_HEVertexVsHEVertex<T>::~AdvSimConstraint_HEVertexVsHEVertex () 00046 {} 00047 //----------------------------------------------------------------------------- 00048 template <typename T> 00049 std::string AdvSimConstraint_HEVertexVsHEVertex<T>::StrInfo () const 00050 { 00051 std::ostringstream ss; 00052 ss << "AdvSimConstraint_HEVertexVsHEVertex<" << typeid(T).name() << ">"; 00053 ss << "\n\tpHEVertex from modelA: " << GetPtrToVertexFromModel_1(); 00054 ss << "\n\tpHEVertex from modelB: " << GetPtrToVertexFromModel_2(); 00055 ss << "\n" << AdvSimConstraint_Base_AvsB<T>::StrInfo(); 00056 return ss.str(); 00057 } 00058 //----------------------------------------------------------------------------- 00059 //============================================================================= 00060 // Assignment Operator 00061 //----------------------------------------------------------------------------- 00062 template <typename T> 00063 AdvSimConstraint_HEVertexVsHEVertex<T> & AdvSimConstraint_HEVertexVsHEVertex<T>::operator= ( AdvSimConstraint_HEVertexVsHEVertex<T> const &orig ) 00064 { 00065 *dynamic_cast< AdvSimConstraint_Base_AvsB<T>* >( this ) = orig; 00066 m_pV1 = orig.m_pV1; 00067 m_pV2 = orig.m_pV2; 00068 return *this; 00069 } 00070 //----------------------------------------------------------------------------- 00071 00072 //----------------------------------------------------------------------------- 00073 template <typename T> 00074 void AdvSimConstraint_HEVertexVsHEVertex<T>::EnforceConstraint () 00075 { 00076 Vector3<T> C = m_ForceRatio*m_pV1->GetPosition() + (1.0 - m_ForceRatio)*m_pV2->GetPosition(); 00077 m_pV1->SetPosition( C ); 00078 m_pV2->SetPosition( C ); 00079 } 00080 //----------------------------------------------------------------------------- 00081 template <typename T> 00082 void AdvSimConstraint_HEVertexVsHEVertex<T>::ClearConstraint () 00083 { 00084 m_pV1->SimFlags.ClearAllSimulationConstraints(); 00085 m_pV2->SimFlags.ClearAllSimulationConstraints(); 00086 } 00087 //----------------------------------------------------------------------------- 00088 00089 00090 //----------------------------------------------------------------------------- 00091 #if defined(__gl_h_) || defined(__GL_H__) 00092 template <typename T> 00093 void AdvSimConstraint_HEVertexVsHEVertex<T>::Draw () const 00094 { 00095 Vector3<T> & v1 = m_pV1->RefToPosition(); 00096 Vector3<T> & v2 = m_pV2->RefToPosition(); 00097 glPushAttrib( GL_ALL_ATTRIB_BITS ); 00098 glDisable( GL_LIGHTING ); 00099 glLineWidth( 3 ); 00100 glColor3f( 1, 0, 0 ); 00101 glBegin( GL_LINES ); 00102 glVertex3fv( v1.GetDataFloat() ); 00103 glVertex3fv( v2.GetDataFloat() ); 00104 glEnd(); 00105 glPopAttrib(); 00106 } 00107 #endif 00108 //----------------------------------------------------------------------------- 00109 //============================================================================= 00110 END_NAMESPACE_TAPs 00111 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00112 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----