MOAB: Mesh Oriented datABase  (version 5.4.1)
SMF_State.cpp
Go to the documentation of this file.
00001 #include "SMF_State.hpp"
00002 #include <cstring>
00003 #include <cstdlib>
00004 
00005 // static inline int streq(const char *a,const char *b) { return std::strcmp(a,b)==0; }
00006 
00007 namespace moab
00008 {
00009 
00010 SMF_State::SMF_State( const SMF_ivars& ivar, SMF_State* next )
00011 {
00012     first_vertex = ivar.next_vertex;
00013     if( next )
00014     {
00015         vertex_correction = next->vertex_correction;
00016         xform             = next->xform;
00017     }
00018     else
00019     {
00020         vertex_correction = 0;
00021         AffineXform identity;
00022         xform = identity;
00023     }
00024 }
00025 
00026 void SMF_State::vertex( double v[3] )
00027 {
00028     xform.xform_point( v );
00029 }
00030 
00031 void SMF_State::normal( double nrm[3] )
00032 {
00033     xform.xform_vector( nrm );
00034 }
00035 
00036 void SMF_State::face( int* verts, const SMF_ivars& ivar )
00037 {
00038     for( int i = 0; i < 3; i++ )
00039     {
00040         if( verts[i] < 0 )
00041             verts[i] += ivar.next_vertex;
00042         else
00043             verts[i] += vertex_correction + ( first_vertex - 1 );
00044     }
00045 }
00046 
00047 void SMF_State::set_vertex_correction( int i )
00048 {
00049     vertex_correction = i;
00050 }
00051 
00052 void SMF_State::mmult( const AffineXform& M )
00053 {
00054     // initially, we tried this:
00055     // xform.accumulate(M);
00056     // maybe we should do M.accumulate(xform)
00057     AffineXform tmp = M;
00058     tmp.accumulate( xform );
00059     xform = tmp;
00060 }
00061 
00062 void SMF_State::mload( const AffineXform& M )
00063 {
00064     xform = M;
00065 }
00066 
00067 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines