generate.sh 5.35 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
#!/bin/bash

#------------------------------------------------------------------------------


# generate_iterator( TargetType, n_elements, has_element_status )
function generate_iterator
{
    NonConstIter=$1"IterT"
    ConstIter="Const"$NonConstIter
    TargetType="typename Mesh::"$1
    TargetHandle="typename Mesh::"$1"Handle"


    cat iterators_template.hh \
    | sed -e "s/IteratorT/$NonConstIter/; s/IteratorT/$NonConstIter/;
	      s/NonConstIterT/$NonConstIter/;
	      s/ConstIterT/$ConstIter/;
              s/TargetType/$TargetType/;
	      s/TargetHandle/$TargetHandle/;
	      s/IsConst/0/;
	      s/n_elements/$2/;
	      s/has_element_status/$3/;"


    cat iterators_template.hh \
    | sed -e "s/IteratorT/$ConstIter/; s/IteratorT/$ConstIter/;
	      s/NonConstIterT/$NonConstIter/;
	      s/ConstIterT/$ConstIter/;
              s/TargetType/$TargetType/;
	      s/TargetHandle/$TargetHandle/;
	      s/IsConst/1/;
	      s/n_elements/$2/;
	      s/has_element_status/$3/;"
}


#------------------------------------------------------------------------------


# generate_circulator( NonConstName, SourceType, TargetType, 
#                      post_init,
#                      increment, decrement,
#                      get_handle,
#                      [Name] )
function generate_circulator
{
    NonConstCirc=$1
    ConstCirc="Const"$NonConstCirc
    SourceHandle="typename Mesh::"$2"Handle"
    TargetHandle="typename Mesh::"$3"Handle"
    TargetType="typename Mesh::"$3


    cat circulators_template.hh \
    | sed -e "s/CirculatorT/$NonConstCirc/; s/CirculatorT/$NonConstCirc/;
	      s/NonConstCircT/$NonConstCirc/;
	      s/ConstCircT/$ConstCirc/;
	      s/SourceHandle/$SourceHandle/;
	      s/TargetHandle/$TargetHandle/;
              s/TargetType/$TargetType/;
	      s/IsConst/0/;
              s/post_init/$4/;
              s/increment/$5/;
              s/decrement/$6/;
	      s/get_handle/$7/;"


    cat circulators_template.hh \
    | sed -e "s/CirculatorT/$ConstCirc/; s/CirculatorT/$ConstCirc/;
	      s/NonConstCircT/$NonConstCirc/;
	      s/ConstCircT/$ConstCirc/;
	      s/SourceHandle/$SourceHandle/;
	      s/TargetHandle/$TargetHandle/;
              s/TargetType/$TargetType/;
	      s/IsConst/1/;
              s/post_init/$4/;
              s/increment/$5/;
              s/decrement/$6/;
	      s/get_handle/$7/;"
}


#------------------------------------------------------------------------------


### Generate IteratorsT.hh

cat iterators_header.hh > IteratorsT.hh

generate_iterator Vertex   n_vertices   has_vertex_status    >> IteratorsT.hh
generate_iterator Halfedge n_halfedges  has_halfedge_status  >> IteratorsT.hh
generate_iterator Edge     n_edges      has_edge_status      >> IteratorsT.hh
generate_iterator Face     n_faces      has_face_status      >> IteratorsT.hh

cat footer.hh >> IteratorsT.hh


#------------------------------------------------------------------------------


### Generate CirculatorsT.hh

cat circulators_header.hh > CirculatorsT.hh


generate_circulator VertexVertexIterT Vertex Vertex \
    " " \
    "heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
    "heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
    "mesh_->to_vertex_handle(heh_);" \
    >> CirculatorsT.hh

generate_circulator VertexOHalfedgeIterT Vertex Halfedge \
    " " \
    "heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
    "heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
    "heh_" \
    >> CirculatorsT.hh

generate_circulator VertexIHalfedgeIterT Vertex Halfedge \
    " " \
    "heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
    "heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
    "mesh_->opposite_halfedge_handle(heh_)" \
    >> CirculatorsT.hh

generate_circulator VertexEdgeIterT Vertex Edge \
    " " \
    "heh_=mesh_->cw_rotated_halfedge_handle(heh_);" \
    "heh_=mesh_->ccw_rotated_halfedge_handle(heh_);" \
    "mesh_->edge_handle(heh_)" \
    >> CirculatorsT.hh

generate_circulator VertexFaceIterT Vertex Face \
    "if (heh_.is_valid() \&\& !handle().is_valid()) operator++();" \
    "do heh_=mesh_->cw_rotated_halfedge_handle(heh_);  while ((*this) \&\& (!handle().is_valid()));" \
    "do	heh_=mesh_->ccw_rotated_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
    "mesh_->face_handle(heh_)" \
    >> CirculatorsT.hh


generate_circulator FaceVertexIterT Face Vertex \
    " " \
    "heh_=mesh_->next_halfedge_handle(heh_);" \
    "heh_=mesh_->prev_halfedge_handle(heh_);" \
    "mesh_->to_vertex_handle(heh_)" \
    >> CirculatorsT.hh

generate_circulator FaceHalfedgeIterT Face Halfedge \
    " " \
    "heh_=mesh_->next_halfedge_handle(heh_);" \
    "heh_=mesh_->prev_halfedge_handle(heh_);" \
    "heh_" \
    >> CirculatorsT.hh

generate_circulator FaceEdgeIterT Face Edge \
    " " \
    "heh_=mesh_->next_halfedge_handle(heh_);" \
    "heh_=mesh_->prev_halfedge_handle(heh_);" \
    "mesh_->edge_handle(heh_)" \
    >> CirculatorsT.hh

generate_circulator FaceFaceIterT Face Face \
    "if (heh_.is_valid() \&\& !handle().is_valid()) operator++();" \
    "do heh_=mesh_->next_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
    "do heh_=mesh_->prev_halfedge_handle(heh_); while ((*this) \&\& (!handle().is_valid()));" \
    "mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_))" \
    >> CirculatorsT.hh


cat footer.hh >> CirculatorsT.hh


#------------------------------------------------------------------------------