38 num_encoded_faces_(0),
39 last_encoded_point_(kInvalidPointIndex) {}
49 template <
typename OutputIteratorT,
typename IndexTypeT>
51 const Mesh &mesh, IndexTypeT primitive_restart_index,
52 OutputIteratorT out_it);
61 template <
typename OutputIteratorT>
63 OutputIteratorT out_it);
70 bool Prepare(
const Mesh &mesh) {
73 num_encoded_faces_ = 0;
75 if (corner_table_ ==
nullptr) {
86 int FindLongestStripFromFace(
FaceIndex fi) {
90 const CornerIndex first_ci = corner_table_->FirstCorner(fi);
91 int longest_strip_id = -1;
92 int longest_strip_length = 0;
93 for (
int i = 0; i < 3; ++i) {
94 GenerateStripsFromCorner(i, first_ci + i);
95 if (strip_faces_[i].
size() > longest_strip_length) {
96 longest_strip_length =
static_cast<int>(strip_faces_[i].size());
100 return longest_strip_id;
105 template <
typename OutputIteratorT>
106 void StoreStrip(
int local_strip_id, OutputIteratorT out_it) {
109 const int num_strip_faces = strip_faces_[local_strip_id].size();
110 CornerIndex ci = strip_start_corners_[local_strip_id];
111 for (
int i = 0; i < num_strip_faces; ++i) {
112 const FaceIndex fi = corner_table_->Face(ci);
113 is_face_visited_[fi] =
true;
114 ++num_encoded_faces_;
118 *out_it++ = CornerToPointIndex(ci).value();
119 *out_it++ = CornerToPointIndex(corner_table_->Next(ci)).value();
120 last_encoded_point_ = CornerToPointIndex(corner_table_->Previous(ci));
121 *out_it++ = last_encoded_point_.value();
124 last_encoded_point_ = CornerToPointIndex(ci);
125 *out_it++ = last_encoded_point_.value();
129 ci = corner_table_->Previous(ci);
131 ci = corner_table_->Next(ci);
134 ci = corner_table_->Opposite(ci);
138 PointIndex CornerToPointIndex(
CornerIndex ci)
const {
139 return mesh_->CornerToPointId(ci);
145 const CornerIndex oci = corner_table_->Opposite(ci);
147 return kInvalidCornerIndex;
151 if (CornerToPointIndex(corner_table_->Next(ci)) !=
152 CornerToPointIndex(corner_table_->Previous(oci))) {
153 return kInvalidCornerIndex;
155 if (CornerToPointIndex(corner_table_->Previous(ci)) !=
156 CornerToPointIndex(corner_table_->Next(oci))) {
157 return kInvalidCornerIndex;
162 void GenerateStripsFromCorner(
int local_strip_id,
CornerIndex ci);
165 std::unique_ptr<CornerTable> corner_table_;
168 std::vector<FaceIndex> strip_faces_[3];
171 IndexTypeVector<FaceIndex, bool> is_face_visited_;
175 int num_encoded_faces_;
177 PointIndex last_encoded_point_;
182 const Mesh &mesh, IndexTypeT primitive_restart_index,
183 OutputIteratorT out_it) {
184 if (!Prepare(mesh)) {
190 if (is_face_visited_[fi]) {
194 const int longest_strip_id = FindLongestStripFromFace(fi);
197 if (num_strips_ > 0) {
198 *out_it++ = primitive_restart_index;
201 StoreStrip(longest_strip_id, out_it);
209 const Mesh &mesh, OutputIteratorT out_it) {
210 if (!Prepare(mesh)) {
216 if (is_face_visited_[fi]) {
220 const int longest_strip_id = FindLongestStripFromFace(fi);
227 if (num_strips_ > 0) {
229 *out_it++ = last_encoded_point_.value();
234 strip_start_corners_[longest_strip_id];
235 const PointIndex new_start_point = CornerToPointIndex(new_start_corner);
236 *out_it++ = new_start_point.value();
237 num_encoded_faces_ += 2;
241 if (num_encoded_faces_ & 1) {
242 *out_it++ = new_start_point.value();
243 num_encoded_faces_ += 1;
250 StoreStrip(longest_strip_id, out_it);
n< br > font size
Definition meshpage.php:3536