Reducing more memory

This commit is contained in:
Nico Kruithof 2006-05-19 10:07:25 +00:00
parent 50462f8d82
commit 4cef8e20fc
7 changed files with 130 additions and 63 deletions

View File

@ -13,7 +13,7 @@ include $(CGAL_MAKEFILE)
# compiler flags
#---------------------------------------------------------------------#
CXXFLAGS = -g\
CXXFLAGS = -O2\
-I.\
-Idsrpdb/include\
-I../../include \
@ -30,7 +30,7 @@ LIBPATH = \
$(TESTSUITE_LIBPATH) \
$(CGAL_LIBPATH)
LDFLAGS = -g \
LDFLAGS = -O2 \
$(TESTSUITE_LDFLAGS) \
$(LONG_NAME_PROBLEM_LDFLAGS) \
$(CGAL_LDFLAGS)

View File

@ -17,7 +17,10 @@ typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
typedef CGAL::Skin_surface_3<Traits> Skin_surface_3;
typedef Skin_surface_3::FT FT;
typedef Skin_surface_3::Weighted_point Weighted_point;
typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::Simple_cartesian<float> Poly_K;
typedef Skin_surface_3::Triangulated_mixed_complex TMC;
typedef CGAL::Skin_surface_polyhedral_items_3<TMC> Poly_items;
typedef CGAL::Polyhedron_3<Poly_K,Poly_items> Polyhedron;
int main(int argc, char *argv[]) {
if (argc < 2) {

View File

@ -0,0 +1,55 @@
#ifndef CGAL_SKIN_SURFACE_WRITER_H
#define CGAL_SKIN_SURFACE_WRITER_H
#include <fstream>
#include <CGAL/IO/Polyhedron_iostream.h>
template <class Polyhedron, class SkinSurface>
/// Write polyhedron with normals:
void write_polyhedron_with_normals(Polyhedron &p,
SkinSurface &skin,
std::ostream &out)
{
typedef typename Polyhedron::Vertex_iterator Vertex_iterator;
typedef typename Polyhedron::Facet_iterator Facet_iterator;
typedef typename Polyhedron::Halfedge_around_facet_circulator HFC;
typedef typename Polyhedron::Vertex_handle Vertex_handle;
typedef typename Polyhedron::Traits::Vector_3 Vector_3;
// Write header
out << "NOFF " << p.size_of_vertices ()
<< " " << p.size_of_facets()
<< " " << p.size_of_halfedges()
<< std::endl;
// Write vertices
typedef CGAL::Skin_surface_subdivision_policy_base_3<Polyhedron, SkinSurface>
Subdivision_policy;
Subdivision_policy *policy = get_subdivision_policy(p, skin);
for (Vertex_iterator vit = p.vertices_begin();
vit != p.vertices_end(); vit ++) {
Vector_3 n = policy->normal(vit);
n = n/sqrt(n*n);
out << vit->point() << " "
<< n
<< std::endl;
}
// Write faces
CGAL::Inverse_index<Vertex_handle> index(p.vertices_begin(),
p.vertices_end());
for(Facet_iterator fi = p.facets_begin();
fi != p.facets_end(); ++fi) {
HFC hc = fi->facet_begin();
HFC hc_end = hc;
std::size_t n = circulator_size( hc);
out << n;
do {
Vertex_handle vh = (*hc).vertex();
out << " " << index[vh];
} while (++hc != hc_end);
out << "\n";
}
}
#endif // CGAL_SKIN_SURFACE_WRITER_H

View File

@ -58,13 +58,14 @@ private:
typedef typename Triangulation::Geom_traits::Point_3 Triang_point;
// Additional functions, not belonging to the traits concept:
HDS_RT value(const Cell_handle &ch, const HDS_point &p) const {
return ch->surf->value(p);
}
// HDS_RT value(const Cell_handle &ch, const Triang_point &p) const {
// // NGHK: Remove the to_double later ...
// return CGAL::to_double(ch->surf->value(converter(p)));
// HDS_RT value(const Cell_handle &ch, const HDS_point &p) const {
// return ch->surf->value(p);
// }
template <class Point>
HDS_RT value(const Cell_handle &ch, const Point &p) const {
// NGHK: Remove the to_double later ...
return ch->surf->value(converter(p));
}
Converter converter;
HDS_RT iso_value;

View File

@ -133,11 +133,12 @@ public:
std::cerr << "Vertices: " << _tmc.number_of_vertices() << std::endl;
std::cerr << "Cells: " << _tmc.number_of_cells() << std::endl;
}
// std::ofstream out("vertices.txt");
// for (typename Triangulated_mixed_complex::Finite_vertices_iterator
// vit = _tmc.finite_vertices_begin();
// vit != _tmc.finite_vertices_end(); vit ++) {
// out << vit->point().x().exact() << std::endl;
// std::ofstream out("edgelength.txt");
// for (typename Triangulated_mixed_complex::Finite_edges_iterator
// eit = _tmc.finite_edges_begin();
// eit != _tmc.finite_edges_end(); eit ++) {
// out << sqrt(_tmc.segment(eit).squared_length()) << std::endl;
// }
}
const Triangulated_mixed_complex &triangulated_mixed_complex() const {

View File

@ -108,24 +108,6 @@ public:
return P2T_converter();
}
// NGHK: Not in current implementation
// template <class Kernel>
// Construct_weighted_circumcenter_3<
// Regular_triangulation_euclidean_traits_3<Kernel> >
// construct_weighted_circumcenter_3_object() const {
// return Regular_triangulation_euclidean_traits_3<Kernel>().
// construct_weighted_circumcenter_3_object();
// }
// NGHK: Not in current implementation
// template <class Kernel>
// In_smallest_orthogonal_sphere_3<
// Regular_triangulation_euclidean_traits_3<Kernel> >
// in_smallest_orthogonal_sphere_3_object() const {
// return Regular_triangulation_euclidean_traits_3<Kernel>().
// in_smallest_orthogonal_sphere_3_object();
// }
Regular_RT shrink_factor() const {
return shrink;
}

View File

@ -95,8 +95,16 @@ private:
typedef Compute_anchor_3<Regular> Compute_anchor;
typedef std::pair<Rt_Simplex,Rt_Simplex> Symb_anchor;
typedef std::map<Rt_Simplex, Rt_Simplex> Anchor_map;
typedef typename Anchor_map::iterator Anchor_map_iterator;
// You might get type differences here:
struct Anchor_map_iterator_tmp;
typedef std::map<Rt_Simplex, Anchor_map_iterator_tmp> Anchor_map;
struct Anchor_map_iterator_tmp : Anchor_map::iterator {
Anchor_map_iterator_tmp()
: Anchor_map::iterator() {}
Anchor_map_iterator_tmp(typename Anchor_map::iterator const &it)
: Anchor_map::iterator(it) {}
};
typedef typename Anchor_map::iterator Anchor_map_iterator;
public:
Mixed_complex_triangulator_3(
@ -165,19 +173,25 @@ private:
void construct_anchor_vor(Rt_Simplex const &sVor);
void construct_anchors();
Rt_Simplex get_anchor_del(Rt_Simplex const &sDel) {
return find_anchor(anchor_del2, sDel);
return find_anchor(anchor_del2, sDel)->first;
}
Rt_Simplex get_anchor_vor(Rt_Simplex const &sVor) {
return find_anchor(anchor_vor2, sVor);
return find_anchor(anchor_vor2, sVor)->first;
}
Rt_Simplex find_anchor(Anchor_map &a_map, Rt_Simplex const&s) {
Anchor_map_iterator it = a_map.find(s);
Anchor_map_iterator find_anchor(Anchor_map &a_map, Rt_Simplex const&s) {
return find_anchor(a_map, a_map.find(s));
}
Anchor_map_iterator find_anchor(Anchor_map &a_map,
Anchor_map_iterator const&it) {
CGAL_assertion(it != a_map.end());
if (it->second == s) return s;
Rt_Simplex result = find_anchor(a_map,it->second);
it->second = result;
return result;
Anchor_map_iterator it2 = it->second;
while (it2 != it2->second) {
it->second = it2->second;
// NGHK: changed the type for the map-iterator-hack
it2->second = it;
it2 = it->second;
}
return it2;
}
void construct_vertices();
@ -256,27 +270,32 @@ Mixed_complex_triangulator_3<
TriangulatedMixedComplexObserver_3>::
construct_anchor_del(Rt_Simplex const &sDel) {
Rt_Simplex s = compute_anchor_obj.anchor_del(sDel);
anchor_del2.insert(std::pair<Rt_Simplex,Rt_Simplex>(sDel, s));
anchor_del2[sDel] = Anchor_map_iterator();
Anchor_map_iterator it = anchor_del2.find(sDel);
Anchor_map_iterator it2 = anchor_del2.find(s);
CGAL_assertion(it != anchor_del2.end());
CGAL_assertion(it2 != anchor_del2.end());
it->second = it2;
// degenerate simplices:
if (compute_anchor_obj.is_degenerate()) {
s = find_anchor(anchor_del2, sDel);
it = find_anchor(anchor_del2, it);
typename Compute_anchor::Simplex_iterator degenerate_it;
for (degenerate_it = compute_anchor_obj.equivalent_anchors_begin();
degenerate_it != compute_anchor_obj.equivalent_anchors_end();
degenerate_it++) {
Anchor_map_iterator it = anchor_del2.find(*degenerate_it);
CGAL_assertion(it != anchor_del2.end());
Anchor_map_iterator it2 = anchor_del2.find(it->second);
Anchor_map_iterator tmp;
it2 = anchor_del2.find(*degenerate_it);
CGAL_assertion(it2 != anchor_del2.end());
// Merge sets:
while (it != it2) {
it->second = s;
it = it2;
it2 = anchor_del2.find(it->second);
while (it2 != it2->second) {
tmp = it2->second;
it2->second = it->second;
it2 = tmp;
CGAL_assertion(it2 != anchor_del2.end());
}
it->second = s;
it2->second = it->second;
}
}
}
@ -292,30 +311,36 @@ Mixed_complex_triangulator_3<
TriangulatedMixedComplexObserver_3>::
construct_anchor_vor(Rt_Simplex const &sVor) {
Rt_Simplex s = compute_anchor_obj.anchor_vor(sVor);
anchor_vor2.insert(std::pair<Rt_Simplex,Rt_Simplex>(sVor, s));
anchor_vor2[sVor] = Anchor_map_iterator();
Anchor_map_iterator it = anchor_vor2.find(sVor);
Anchor_map_iterator it2 = anchor_vor2.find(s);
CGAL_assertion(it != anchor_vor2.end());
CGAL_assertion(it2 != anchor_vor2.end());
it->second = it2;
// degenerate simplices:
if (compute_anchor_obj.is_degenerate()) {
s = find_anchor(anchor_vor2, sVor);
it = find_anchor(anchor_vor2, it);
typename Compute_anchor::Simplex_iterator degenerate_it;
for (degenerate_it = compute_anchor_obj.equivalent_anchors_begin();
degenerate_it != compute_anchor_obj.equivalent_anchors_end();
degenerate_it++) {
Anchor_map_iterator tmp;
it2 = anchor_vor2.find(*degenerate_it);
// Possibly not found for 2 Voronoi vertices with the same center,
// If the first vertex is inserted and the second is already found.
// see compute_anchor_obj.anchor_vor(Cell_handle)
Anchor_map_iterator it = anchor_vor2.find(*degenerate_it);
if (it != anchor_vor2.end()) {
Anchor_map_iterator it2 = anchor_vor2.find(it->second);
if (it2 != anchor_vor2.end()) {
CGAL_assertion(it2 != anchor_vor2.end());
// Merge sets:
while (it != it2) {
it->second = s;
it = it2;
it2 = anchor_vor2.find(it->second);
while (it2 != it2->second) {
tmp = it2->second;
it2->second = it->second;
it2 = tmp;
CGAL_assertion(it2 != anchor_vor2.end());
}
it->second = s;
it2->second = it->second;
}
}
}