00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef OPENMESH_KERNELOSG_ARRAY_KERNEL_HH
00040 #define OPENMEHS_KERNELOSG_ARRAY_KERNEL_HH
00041
00042
00043
00044
00045 #include <vector>
00046
00047 #include <OpenMesh/Core/System/config.hh>
00048 #include <OpenMesh/Core/Utils/GenProg.hh>
00049 #include <OpenMesh/Core/Mesh/Kernels/ArrayKernel/ArrayKernelT.hh>
00050
00051 #include <OpenMesh/Tools/Kernel_OSG/AttribKernelT.hh>
00052
00053
00054
00055
00056
00057
00058 namespace OpenMesh {
00059 namespace Kernel_OSG {
00060
00061
00062
00063
00074
00075
00076
00077
00078 template <class AttribKernel, class FinalMeshItems>
00079 class ArrayKernelT
00080 : public OpenMesh::ArrayKernelT<AttribKernel, FinalMeshItems>
00081 {
00082 public:
00083
00084 typedef ArrayKernelT<AttribKernel, FinalMeshItems> This;
00085 typedef OpenMesh::ArrayKernelT<AttribKernel, FinalMeshItems> Base;
00086
00087
00088
00089
00090
00091
00092 typedef typename Base::HasPrevHalfedge HasPrevHalfedge;
00093
00094
00095
00096
00097
00098
00099 typedef typename FinalMeshItems::Vertex Vertex;
00100 typedef typename FinalMeshItems::Halfedge Halfedge;
00101 typedef typename FinalMeshItems::Edge Edge;
00102 typedef typename FinalMeshItems::Face Face;
00103 typedef typename FinalMeshItems::Point Point;
00104 typedef typename FinalMeshItems::Normal Normal;
00105 typedef typename FinalMeshItems::Color Color;
00106 typedef typename FinalMeshItems::TexCoord2D TexCoord2D;
00107 typedef typename FinalMeshItems::Scalar Scalar;
00108
00109
00110
00111
00112
00113
00114
00115
00116 typedef std::vector<Vertex> VertexContainer;
00117 typedef std::vector<Edge> EdgeContainer;
00118 typedef std::vector<Face> FaceContainer;
00119 typedef typename VertexContainer::iterator KernelVertexIter;
00120 typedef typename VertexContainer::const_iterator KernelConstVertexIter;
00121 typedef typename EdgeContainer::iterator KernelEdgeIter;
00122 typedef typename EdgeContainer::const_iterator KernelConstEdgeIter;
00123 typedef typename FaceContainer::iterator KernelFaceIter;
00124 typedef typename FaceContainer::const_iterator KernelConstFaceIter;
00125
00126 public:
00127
00128 ArrayKernelT() : Base()
00129 { }
00130
00131 virtual ~ArrayKernelT()
00132 { }
00133
00134 public:
00135
00136 void set_halfedge_handle(VertexHandle _vh, HalfedgeHandle _heh) {
00137 Base::set_halfedge_handle( _vh, _heh );
00138 }
00139
00140 void set_halfedge_handle(FaceHandle _fh, HalfedgeHandle _heh) {
00141 Base::set_halfedge_handle( _fh, _heh );
00142 osg_sync( _fh );
00143 }
00144
00145 void set_next_halfedge_handle(HalfedgeHandle _heh, HalfedgeHandle _nheh) {
00146 Base::set_next_halfedge_handle( _heh, _nheh );
00147 osg_sync( face_handle( _heh ) );
00148 }
00149
00150 void garbage_collection(bool _v=true, bool _e=true, bool _f=true);
00151
00152 protected:
00153
00154 bool osg_sync( FaceHandle _fh )
00155 {
00156 return _fh.is_valid()
00157 ? osg_sync( _fh, typename Face::IsTriangle() )
00158 : false;
00159 }
00160
00161 private:
00162
00163 bool osg_sync( FaceHandle _fh, GenProg::Bool2Type<true> )
00164 {
00165 HalfedgeHandle hh( halfedge_handle(_fh) );
00166 if ( !hh.is_valid() ) return false;
00167 FaceHandle f1( _fh.idx() * 3 );
00168 set_face_indices( f1, to_vertex_handle(hh).idx() );
00169
00170 hh = next_halfedge_handle(hh);
00171 if ( !hh.is_valid() ) return false;
00172 FaceHandle f2( f1.idx()+1 );
00173 set_face_indices( f2, to_vertex_handle(hh).idx() );
00174
00175 hh = next_halfedge_handle(hh);
00176 if ( !hh.is_valid() ) return false;
00177 FaceHandle f3( f1.idx()+2 );
00178 set_face_indices( f3, to_vertex_handle(hh).idx() );
00179
00180 set_face_types ( _fh, GL_TRIANGLES );
00181 set_face_lengths( _fh, 3 );
00182
00183 return true;
00184 }
00185
00186 bool osg_sync( FaceHandle _fh, GenProg::Bool2Type<false> )
00187 {
00188 return false;
00189 }
00190
00191 };
00192
00193
00194 template <class AttribKernel, class FinalMeshItems>
00195 void
00196 ArrayKernelT<AttribKernel, FinalMeshItems>::
00197 garbage_collection(bool _v, bool _e, bool _f)
00198 {
00199 Base::garbage_collection(_v, _e, _f);
00200 for (size_t fidx=0; fidx < n_faces(); ++fidx)
00201 osg_sync( FaceHandle(fidx) );
00202 }
00203
00204
00205 }
00206 }
00207
00208 #endif // OPENMESH_ARRAY_KERNEL_HH defined
00209