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
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #ifndef OPENMESH_KERNELOSG_ARRAY_KERNEL_HH
00051 #define OPENMEHS_KERNELOSG_ARRAY_KERNEL_HH
00052
00053
00054
00055
00056 #include <vector>
00057
00058 #include <OpenMesh/Core/System/config.h>
00059 #include <OpenMesh/Core/Utils/GenProg.hh>
00060 #include <OpenMesh/Core/Mesh/ArrayKernel.hh>
00061
00062 #include <OpenMesh/Tools/Kernel_OSG/AttribKernelT.hh>
00063
00064
00065
00066
00067
00068
00069 namespace OpenMesh {
00070 namespace Kernel_OSG {
00071
00072
00073
00074
00085
00086
00087
00088
00089 template <class AttribKernel, class FinalMeshItems>
00090 class ArrayKernelT
00091 : public OpenMesh::ArrayKernelT<AttribKernel, FinalMeshItems>
00092 {
00093 public:
00094
00095 typedef ArrayKernelT<AttribKernel, FinalMeshItems> This;
00096 typedef OpenMesh::ArrayKernelT<AttribKernel, FinalMeshItems> Base;
00097
00098
00099
00100
00101
00102
00103 typedef typename Base::HasPrevHalfedge HasPrevHalfedge;
00104
00105
00106
00107
00108
00109
00110 typedef typename FinalMeshItems::Vertex Vertex;
00111 typedef typename FinalMeshItems::Halfedge Halfedge;
00112 typedef typename FinalMeshItems::Edge Edge;
00113 typedef typename FinalMeshItems::Face Face;
00114 typedef typename FinalMeshItems::Point Point;
00115 typedef typename FinalMeshItems::Normal Normal;
00116 typedef typename FinalMeshItems::Color Color;
00117 typedef typename FinalMeshItems::TexCoord TexCoord;
00118 typedef typename FinalMeshItems::Scalar Scalar;
00119
00120
00121
00122
00123
00124
00125
00126
00127 typedef std::vector<Vertex> VertexContainer;
00128 typedef std::vector<Edge> EdgeContainer;
00129 typedef std::vector<Face> FaceContainer;
00130 typedef typename VertexContainer::iterator KernelVertexIter;
00131 typedef typename VertexContainer::const_iterator KernelConstVertexIter;
00132 typedef typename EdgeContainer::iterator KernelEdgeIter;
00133 typedef typename EdgeContainer::const_iterator KernelConstEdgeIter;
00134 typedef typename FaceContainer::iterator KernelFaceIter;
00135 typedef typename FaceContainer::const_iterator KernelConstFaceIter;
00136
00137 public:
00138
00139 ArrayKernelT() : Base()
00140 { }
00141
00142 virtual ~ArrayKernelT()
00143 { }
00144
00145 public:
00146
00147 void set_halfedge_handle(VertexHandle _vh, HalfedgeHandle _heh) {
00148 Base::set_halfedge_handle( _vh, _heh );
00149 }
00150
00151 void set_halfedge_handle(FaceHandle _fh, HalfedgeHandle _heh) {
00152 Base::set_halfedge_handle( _fh, _heh );
00153 osg_sync( _fh );
00154 }
00155
00156 void set_next_halfedge_handle(HalfedgeHandle _heh, HalfedgeHandle _nheh) {
00157 Base::set_next_halfedge_handle( _heh, _nheh );
00158 osg_sync( face_handle( _heh ) );
00159 }
00160
00161 void garbage_collection(bool _v=true, bool _e=true, bool _f=true);
00162
00163 protected:
00164
00165 bool osg_sync( FaceHandle _fh )
00166 {
00167 return _fh.is_valid()
00168 ? osg_sync( _fh, typename Face::IsTriangle() )
00169 : false;
00170 }
00171
00172 private:
00173
00174 bool osg_sync( FaceHandle _fh, GenProg::Bool2Type<true> )
00175 {
00176 HalfedgeHandle hh( halfedge_handle(_fh) );
00177 if ( !hh.is_valid() ) return false;
00178 FaceHandle f1( _fh.idx() * 3 );
00179 set_face_indices( f1, to_vertex_handle(hh).idx() );
00180
00181 hh = next_halfedge_handle(hh);
00182 if ( !hh.is_valid() ) return false;
00183 FaceHandle f2( f1.idx()+1 );
00184 set_face_indices( f2, to_vertex_handle(hh).idx() );
00185
00186 hh = next_halfedge_handle(hh);
00187 if ( !hh.is_valid() ) return false;
00188 FaceHandle f3( f1.idx()+2 );
00189 set_face_indices( f3, to_vertex_handle(hh).idx() );
00190
00191 set_face_types ( _fh, GL_TRIANGLES );
00192 set_face_lengths( _fh, 3 );
00193
00194 return true;
00195 }
00196
00197 bool osg_sync( FaceHandle _fh, GenProg::Bool2Type<false> )
00198 {
00199 return false;
00200 }
00201
00202 };
00203
00204
00205 template <class AttribKernel, class FinalMeshItems>
00206 void
00207 ArrayKernelT<AttribKernel, FinalMeshItems>::
00208 garbage_collection(bool _v, bool _e, bool _f)
00209 {
00210 Base::garbage_collection(_v, _e, _f);
00211 for (size_t fidx=0; fidx < n_faces(); ++fidx)
00212 osg_sync( FaceHandle(fidx) );
00213 }
00214
00215
00216 }
00217 }
00218
00219 #endif // OPENMESH_ARRAY_KERNEL_HH defined
00220