BundleBaseSpaceFunctions.hpp

00001 #ifndef __FIBER_BASEOP_BUNDLEFUNCTIONS_HPP
00002 #define __FIBER_BASEOP_BUNDLEFUNCTIONS_HPP
00003 
00004 #include "gridopDllApi.h"
00005 
00006 #include <grid/Grid.hpp>
00007 #include <grid/CartesianChart.hpp>
00008 #include <bundle/Slice.hpp>
00009 
00010 namespace Fiber
00011 {
00012 
00017 inline MemCore::RefPtr<Field> GetCartesianPositions( MemCore::RefPtr<Grid> grid )
00018 {
00019         if (!grid)
00020                 return NullPtr();
00021 
00022         return grid->CartesianPositions(); 
00023 /*
00024         MemCore::RefPtr<Skeleton> skel = grid->findVertices(); 
00025         if(!skel){ puts("GetCartesianPositions() no skeleton found"); return NullPtr();} 
00026 
00027         MemCore::RefPtr< Chart > chart = grid->makeChart( typeid(Fiber::CartesianChart3D) ); 
00028         MemCore::RefPtr<Representation> rep = (*skel)( chart ); 
00029         if(!rep){ puts("GetCartesianPositions() no representation found"); return NullPtr();} 
00030 
00031         return (*rep)("Positions"); 
00032 */
00033 }
00034 
00035 
00039 inline MemCore::RefPtr<Field> GetFragments( MemCore::RefPtr<Grid> grid )
00040 {
00041         if (!grid)
00042                 return NullPtr();
00043 
00044 MemCore::RefPtr<Skeleton> source_skel = grid->findVertices(); 
00045         if(!source_skel){ puts("GetFragments() no skeleton found"); return NullPtr();} 
00046 
00047 MemCore::RefPtr<Skeleton> skel = (*grid)( SkeletonID(3, 2) ); 
00048         if(!skel){ puts("GetFragments() no skeleton found"); return NullPtr();} 
00049 
00050 MemCore::RefPtr<Representation> rep = (*skel)( source_skel ); 
00051         if(!rep){ puts("GetFragments() no representation found"); return NullPtr();} 
00052 
00053         assert(rep); 
00054         return (*rep)("Positions"); 
00055 }
00056 
00060 inline MemCore::RefPtr<Field> GetFragmentsBBs( MemCore::RefPtr<Grid> grid )
00061 {
00062         if (!grid)
00063                 return NullPtr();
00064 
00065         MemCore::RefPtr<Skeleton> skel = (*grid)( SkeletonID(3, 2) ); 
00066         if(!skel){ puts("GetFragmentsBBs() no skeleton found"); return NullPtr();} 
00067 
00068         MemCore::RefPtr< Chart > chart = grid->makeChart( typeid(CartesianChart3D) ); 
00069         MemCore::RefPtr<Representation> rep = (*skel)( chart ); 
00070         if(!rep){ puts("GetFragmentsBBs() no representation found"); return NullPtr();} 
00071 
00072         assert(rep); 
00073         return (*rep)("Positions"); 
00074 }
00075 
00076 
00081 inline MemCore::RefPtr<Field> GetUniGridMappers( MemCore::RefPtr<Slice> slice, MemCore::RefPtr<Grid> source_grid )
00082 {
00083         if (!slice)
00084                 return NullPtr();
00085 
00086         MemCore::RefPtr< Grid > unigrid = (*slice)( "UniMappers" ); 
00087         if(!unigrid){ puts("GetUniGridMappers() no grid named 'UniMappers' found!"); return NullPtr(); } 
00088         MemCore::RefPtr<Skeleton> uniskel = (*unigrid)( SkeletonID(3, 1) ); 
00089         if(!uniskel){ puts("GetUniGridMappers() no skel(dim 3,index depth 1) in unigrid found!"); return NullPtr(); } 
00090         MemCore::RefPtr<Skeleton> fragskel = (*source_grid)( SkeletonID(3, 2) ); 
00091         if(!fragskel){ puts("GetUniGridMappers() no skel(dim 3,index depth 2) in source_grid found!"); return NullPtr(); } 
00092         MemCore::RefPtr<Representation> rep = (*fragskel)( uniskel );
00093         if(!rep){ puts("GetUniGridMappers() no representation for unimappers found!"); return NullPtr(); } 
00094 
00095         return (*rep)("Positions");
00096 }
00097 
00098 } // namespace Fiber
00099 
00100 
00101 #endif // __BUNDLEFUNCTIONS_HPP