TriangularSurface.hpp

00001 #ifndef __FIBER_GRID_TYPES_TRIANGULARSURFACE_HPP
00002 #define __FIBER_GRID_TYPES_TRIANGULARSURFACE_HPP
00003 
00004 #include "gridtypesDllApi.h"
00005 #include <grid/Grid.hpp>
00006 #include <eagle/PhysicalSpace.hpp>
00007 #include <field/Cell.hpp>
00008 #include "Edges.hpp"
00009 
00010 
00011 namespace Fiber
00012 {
00013 
00042 struct  gridtypes_API   TriangularSurface : RefPtr<Grid>
00043 {
00044         typedef MemArray<1,Eagle::PhysicalSpace::point>         CoordsArray_t; 
00045         typedef MemArray<1, TriangleCell>                       CellArray_t; 
00046         typedef CellArray_t                                     ConnectivityArray_t; 
00047 
00048         typedef MemArray<1, Eagle::PhysicalSpace::bivector>     NormalVectorArray_t; 
00049 
00051         RefPtr<Field>           CoordField,
00052 
00055                                 VertexNormalField,
00056 
00058                                 CellField; 
00059 
00061         RefPtr<Representation>  CartesianVertices,
00063                                 CellsAsVertices; 
00064 
00088         TriangularSurface(const RefPtr<Grid>& = NullPtr() );
00089 
00090         TriangularSurface&operator=(const RefPtr<Grid>&); 
00091 //      TriangularSurface&operator=(const TriangularSurface&); 
00092 
00094         ~TriangularSurface();
00095 
00096 
00100 static   Eagle::PhysicalSpace::bivector NormalVector(const TriangleCell&T, 
00101                                                      const MultiArray<1, Eagle::PhysicalSpace::point>&Vertices);
00102 
00103 static  RefPtr<NormalVectorArray_t>
00104                 computeVertexNormals(const RefPtr<CoordsArray_t>&Pts,
00105                                      const RefPtr<CellArray_t>  &Cells,
00106                                      const MemBase::Creator_t&Crec = NullPtr() );
00107 
00108 
00115 static  SkeletonID ID()
00116         {
00117                 return SkeletonID(2,1);
00118         } 
00119 
00124 static  RefPtr<Skeleton> getFaceSkeleton(const RefPtr<Grid>&G, bool CreateIfNotFound);
00125 
00130 static  const char NormalVectorFieldName[]; 
00131 
00137         RefPtr<Field>   getVertexNormalField(const string&FieldName = NormalVectorFieldName); 
00138 
00139         RefPtr<NormalVectorArray_t> getVertexNormals(const string&FieldName = NormalVectorFieldName)
00140         {
00141         RefPtr<Field>   F = getVertexNormalField(NormalVectorFieldName); 
00142                 if (!F)
00143                         return NullPtr(); 
00144 
00145                 return  F->getData();   
00146         }
00147 
00152         RefPtr<CoordsArray_t> getCoords() const
00153         {
00154                 if (!CoordField)
00155                         return NullPtr();
00156 
00157                 return CoordField->getData();
00158         }
00159 
00164         RefPtr<CellArray_t> getCells() const
00165         {
00166                 if (!CellField)
00167                         return NullPtr();
00168 
00169                 return CellField->getData();
00170         }
00171 
00172         RefPtr<CoordsArray_t> getNormals(const string&FieldName = NormalVectorFieldName)
00173         {
00174         RefPtr<Field>   N = getVertexNormalField( FieldName ); 
00175                 if (!N)
00176                         return NullPtr(); 
00177 
00178                 return N->getData();
00179         } 
00180 
00181         RefPtr<Field>   getTriangleBaryCenters();
00182 
00183 static  RefPtr<CoordsArray_t>
00184                 computeBaryCenters(const RefPtr<CoordsArray_t>&Pts,
00185                                    const RefPtr<CellArray_t>  &Cells,
00186                                    const MemBase::Creator_t&Crec = NullPtr() );
00187 
00188 };
00189 
00194 class   gridtypes_API   TriangularSurfaceWithEdges : public TriangularSurface, public Edges
00195 {
00196 public:
00200         typedef MemArray<1, TriangleCell> EdgesPerFaceArray_t;
00201 
00205         typedef MemArray<1, EdgeCell_t>   EdgesArray_t;
00206 
00211 static  RefPtr<Representation>  getEdgesPerFace(const RefPtr<Grid>&, bool CreateIfNotFound); 
00212 
00218 static  RefPtr<Representation>  getFacesPerEdge(const RefPtr<Grid>&G, bool CreateIfNotFound);
00219 
00221         TriangularSurfaceWithEdges(const RefPtr<Grid>& = NullPtr() ); 
00222 
00224         ~TriangularSurfaceWithEdges();
00225 };
00226 
00227 
00228 } // namespace Fiber
00229 
00230 #endif // __FIBER_GRID_TYPES_TRIANGULARSURFACE_HPP
00231