28 #ifndef _math_isosurf_surf_h
29 #define _math_isosurf_surf_h
43 #include <math/isosurf/triangle.h>
44 #include <math/isosurf/volume.h>
45 #include <util/render/render.h>
49 template <
class C,
class I>
51 erase_elements_by_value(C &container, I begin, I end)
53 for (I i=begin; i!=end; i++) {
63 int _completed_surface;
66 std::set<Ref<Vertex> > _vertices;
67 std::set<Ref<Edge> > _edges;
68 std::set<Ref<Triangle> > _triangles;
71 std::map<Ref<Vertex>,
int> _vertex_to_index;
72 std::map<Ref<Edge>,
int> _edge_to_index;
73 std::map<Ref<Triangle>,
int> _triangle_to_index;
76 std::vector<Ref<Vertex> > _index_to_vertex;
77 std::vector<Ref<Edge> > _index_to_edge;
78 std::vector<Ref<Triangle> > _index_to_triangle;
81 int** _triangle_vertex;
87 std::vector<double> _values;
96 void clear_int_arrays();
98 void complete_ref_arrays();
99 void complete_int_arrays();
101 void recompute_index_maps();
114 int orientation)
const;
118 std::map<Ref<Vertex>,std::set<Ref<Edge> > > _tmp_edges;
125 int verbose()
const {
return _verbose; }
126 void verbose(
int v) { _verbose = v; }
141 virtual void complete_surface();
144 virtual void remove_short_edges(
double cutoff_length = 1.0e-6,
146 virtual void remove_slender_triangles(
147 int remove_slender,
double height_cutoff,
148 int remove_small,
double area_cutoff,
150 virtual void fix_orientation();
151 virtual void clear();
154 int nvertex()
const {
return _vertices.size(); };
157 std::map<Ref<Vertex>,
int>::iterator i = _vertex_to_index.find(o);
158 if (i != _vertex_to_index.end())
return i->second;
161 int nedge()
const {
return _edges.size(); };
162 Ref<Edge> edge(
int i)
const {
return _index_to_edge[i]; };
164 std::map<Ref<Edge>,
int>::iterator i = _edge_to_index.find(o);
165 if (i != _edge_to_index.end())
return i->second;
168 int ntriangle()
const {
return _triangles.size(); };
169 Ref<Triangle> triangle(
int i)
const {
return _index_to_triangle[i]; }
171 std::map<Ref<Triangle>,
int>::iterator i = _triangle_to_index.find(o);
172 if (i != _triangle_to_index.end())
return i->second;
177 int triangle_vertex(
int i,
int j)
const {
return _triangle_vertex[i][j]; };
178 int triangle_edge(
int i,
int j)
const {
return _triangle_edge[i][j]; };
179 int edge_vertex(
int i,
int j)
const {
return _edge_vertex[i][j]; };
186 virtual double flat_area();
187 virtual double flat_volume();
188 virtual double area();
189 virtual double volume();
193 virtual void print_vertices_and_triangles(std::ostream&o=
ExEnv::out0())
const;
194 virtual void print_geomview_format(std::ostream&o=
ExEnv::out0())
const;
199 void topology_info(
int nvertex,
int nedge,
int ntri, std::ostream&o=
ExEnv::out0());
211 double _surface_element;
233 int vertex_number(
int i);
234 inline double r()
const {
return _r; }
235 inline double s()
const {
return _s; }
236 inline double w()
const {
return _weight*_surface_element; }
237 double surface_element()
const {
return _surface_element; }
238 double weight()
const {
return _weight; }
239 const SCVector3& dA()
const {
return _dA; }
249 return _itri<i._itri?1:(_itri>i._itri?0:(_irs<i._irs?1:0));
253 inline void operator++(
int) { operator++(); }
255 int operator = (
int);
256 int itri()
const {
return _itri; }
257 int irs()
const {
return _irs; }
259 int n_in_tri()
const {
return (_ts.
pointer()->*_integrator)(_itri)->n(); }
261 void use_fast_integrator();
262 void use_accurate_integrator();
263 void use_default_integrator();
272 int fix_orientation_;
273 int remove_short_edges_;
274 double short_edge_factor_;
275 int remove_slender_triangles_;
276 double slender_triangle_factor_;
277 int remove_small_triangles_;
278 double small_triangle_factor_;
289 double isovalue()
const {
return isovalue_; }
292 int inited()
const {
return inited_; }