moab
SMF_State.cpp
Go to the documentation of this file.
00001 
00002 
00003 #include "SMF_State.hpp"
00004 #include <cstring>
00005 #include <cstdlib>
00006 
00007 //static inline int streq(const char *a,const char *b) { return std::strcmp(a,b)==0; }
00008 
00009 namespace moab {
00010 
00011 SMF_State::SMF_State(const SMF_ivars& ivar, SMF_State *next)
00012 {
00013     first_vertex = ivar.next_vertex;
00014     if( next )
00015     {
00016     vertex_correction = next->vertex_correction;
00017     xform = next->xform;
00018     }
00019     else
00020     {
00021     vertex_correction = 0;
00022         AffineXform identity;
00023     xform = identity;
00024     }
00025 
00026 }
00027 
00028 void SMF_State::vertex(double v[3])
00029 {
00030     xform.xform_point(v);
00031 }
00032 
00033 void SMF_State::normal(double nrm[3])
00034 {
00035     xform.xform_vector(nrm);
00036 }
00037 
00038 void SMF_State::face( int * verts, const SMF_ivars& ivar)
00039 {
00040     for(int i=0; i<3; i++)
00041     {
00042     if( verts[i] < 0 )
00043         verts[i] += ivar.next_vertex;
00044     else
00045         verts[i] += vertex_correction + (first_vertex - 1);
00046     }
00047 }
00048 
00049 void SMF_State::set_vertex_correction( int i )
00050   { vertex_correction = i; }
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