28 #ifndef _math_isosurf_surf_h
29 #define _math_isosurf_surf_h
32 #include <mpqc_config.h>
39 #include <math/isosurf/triangle.h>
40 #include <math/isosurf/volume.h>
41 #include <util/render/render.h>
45 template <
class C,
class I>
47 erase_elements_by_value(C &container, I begin, I end)
49 for (I i=begin; i!=end; i++) {
59 int _completed_surface;
62 std::set<Ref<Vertex> > _vertices;
63 std::set<Ref<Edge> > _edges;
64 std::set<Ref<Triangle> > _triangles;
67 std::map<Ref<Vertex>,
int> _vertex_to_index;
68 std::map<Ref<Edge>,
int> _edge_to_index;
69 std::map<Ref<Triangle>,
int> _triangle_to_index;
72 std::vector<Ref<Vertex> > _index_to_vertex;
73 std::vector<Ref<Edge> > _index_to_edge;
74 std::vector<Ref<Triangle> > _index_to_triangle;
77 int** _triangle_vertex;
83 std::vector<double> _values;
92 void clear_int_arrays();
94 void complete_ref_arrays();
95 void complete_int_arrays();
97 void recompute_index_maps();
110 int orientation)
const;
114 std::map<Ref<Vertex>,std::set<Ref<Edge> > > _tmp_edges;
121 int verbose()
const {
return _verbose; }
122 void verbose(
int v) { _verbose = v; }
137 virtual void complete_surface();
140 virtual void remove_short_edges(
double cutoff_length = 1.0e-6,
142 virtual void remove_slender_triangles(
143 int remove_slender,
double height_cutoff,
144 int remove_small,
double area_cutoff,
146 virtual void fix_orientation();
147 virtual void clear();
150 int nvertex()
const {
return _vertices.size(); };
151 Ref<Vertex> vertex(
int i)
const {
return _index_to_vertex[i]; };
153 std::map<Ref<Vertex>,
int>::iterator i = _vertex_to_index.find(o);
154 if (i != _vertex_to_index.end())
return i->second;
157 int nedge()
const {
return _edges.size(); };
158 Ref<Edge> edge(
int i)
const {
return _index_to_edge[i]; };
160 std::map<Ref<Edge>,
int>::iterator i = _edge_to_index.find(o);
161 if (i != _edge_to_index.end())
return i->second;
164 int ntriangle()
const {
return _triangles.size(); };
165 Ref<Triangle> triangle(
int i)
const {
return _index_to_triangle[i]; }
167 std::map<Ref<Triangle>,
int>::iterator i = _triangle_to_index.find(o);
168 if (i != _triangle_to_index.end())
return i->second;
173 int triangle_vertex(
int i,
int j)
const {
return _triangle_vertex[i][j]; };
174 int triangle_edge(
int i,
int j)
const {
return _triangle_edge[i][j]; };
175 int edge_vertex(
int i,
int j)
const {
return _edge_vertex[i][j]; };
182 virtual double flat_area();
183 virtual double flat_volume();
184 virtual double area();
185 virtual double volume();
189 virtual void print_vertices_and_triangles(std::ostream&o=
ExEnv::out0())
const;
190 virtual void print_geomview_format(std::ostream&o=
ExEnv::out0())
const;
195 void topology_info(
int nvertex,
int nedge,
int ntri, std::ostream&o=
ExEnv::out0());
207 double _surface_element;
229 int vertex_number(
int i);
230 inline double r()
const {
return _r; }
231 inline double s()
const {
return _s; }
232 inline double w()
const {
return _weight*_surface_element; }
233 double surface_element()
const {
return _surface_element; }
234 double weight()
const {
return _weight; }
235 const SCVector3& dA()
const {
return _dA; }
245 return _itri<i._itri?1:(_itri>i._itri?0:(_irs<i._irs?1:0));
249 inline void operator++(
int) { operator++(); }
251 int operator = (
int);
252 int itri()
const {
return _itri; }
253 int irs()
const {
return _irs; }
255 int n_in_tri()
const {
return (_ts.
pointer()->*_integrator)(_itri)->n(); }
257 void use_fast_integrator();
258 void use_accurate_integrator();
259 void use_default_integrator();
268 int fix_orientation_;
269 int remove_short_edges_;
270 double short_edge_factor_;
271 int remove_slender_triangles_;
272 double slender_triangle_factor_;
273 int remove_small_triangles_;
274 double small_triangle_factor_;
285 double isovalue()
const {
return isovalue_; }
288 int inited()
const {
return inited_; }