Choreonoid  1.1
Triangulator.h
説明を見る。
1 
6 #ifndef CNOID_UTIL_TRIANGULATOR_H_INCLUDED
7 #define CNOID_UTIL_TRIANGULATOR_H_INCLUDED
8 
9 #include "VrmlNodes.h"
10 #include <boost/dynamic_bitset.hpp>
11 
12 namespace cnoid {
13 
15  {
16  public:
17 
18  inline void setVertices(const MFVec3f& vertices) {
19  this->vertices = &vertices;
20  }
21 
25  int apply(const std::vector<int>& polygon);
26 
32  inline const std::vector<int>& triangles() {
33  return triangles_;
34  }
35 
36  private:
37 
38  enum Convexity { FLAT, CONVEX, CONCAVE };
39 
40  const MFVec3f* vertices;
41  const std::vector<int>* orgPolygon;
42  std::vector<int> triangles_;
43  std::vector<int> workPolygon;
44  SFVec3f ccs; // cyclic cross sum
45  boost::dynamic_bitset<> earMask;
46 
47  inline const SFVec3f& vertex(int localIndex){
48  return (*vertices)[(*orgPolygon)[localIndex]];
49  }
50 
51  inline const SFVec3f& workVertex(int workPolygonIndex){
52  return (*vertices)[(*orgPolygon)[workPolygon[workPolygonIndex]]];
53  }
54 
55  Convexity calcConvexity(int ear);
56  bool checkIfEarContainsOtherVertices(int ear);
57  };
58 
59 }
60 
61 #endif