mirror of https://github.com/CGAL/cgal
added the code for meshing a union of balls.
TODO: remove unique_hash_map from the construction of the triangulation:
This commit is contained in:
parent
9d1909403b
commit
79bb80960b
|
|
@ -20,7 +20,7 @@ typedef CGAL::Polyhedron_3<K,Poly_items> Polyhedron;
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
std::cout << "Usage: " << argv[0] << " <cin-file>" << std::endl;
|
std::cout << "Usage: " << argv[0] << " <cin-file>" << std::endl;
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<Weighted_point> l;
|
std::list<Weighted_point> l;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ typedef CGAL::Polyhedron_3<K,Poly_items> Polyhedron;
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
std::cout << "Usage: " << argv[0] << " <cin-file>" << std::endl;
|
std::cout << "Usage: " << argv[0] << " <cin-file>" << std::endl;
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<Weighted_point> l;
|
std::list<Weighted_point> l;
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ include $(CGAL_MAKEFILE)
|
||||||
# compiler flags
|
# compiler flags
|
||||||
#---------------------------------------------------------------------#
|
#---------------------------------------------------------------------#
|
||||||
|
|
||||||
CXXFLAGS = -O2\
|
CXXFLAGS = -g\
|
||||||
-I.\
|
-I.\
|
||||||
-Idsrpdb/include\
|
-Idsrpdb/include\
|
||||||
-I../../include \
|
-I../../include \
|
||||||
|
|
@ -30,7 +30,7 @@ LIBPATH = \
|
||||||
$(TESTSUITE_LIBPATH) \
|
$(TESTSUITE_LIBPATH) \
|
||||||
$(CGAL_LIBPATH)
|
$(CGAL_LIBPATH)
|
||||||
|
|
||||||
LDFLAGS = -O2\
|
LDFLAGS = -g\
|
||||||
$(TESTSUITE_LDFLAGS) \
|
$(TESTSUITE_LDFLAGS) \
|
||||||
$(LONG_NAME_PROBLEM_LDFLAGS) \
|
$(LONG_NAME_PROBLEM_LDFLAGS) \
|
||||||
$(CGAL_LDFLAGS)
|
$(CGAL_LDFLAGS)
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ typedef CGAL::Polyhedron_3<K,Poly_items> Polyhedron;
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
std::cout << "Usage: " << argv[0] << " <pdb-file>" << std::endl;
|
std::cout << "Usage: " << argv[0] << " <pdb-file>" << std::endl;
|
||||||
return 1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::list<Weighted_point> l;
|
std::list<Weighted_point> l;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
#include <CGAL/Skin_surface_3.h>
|
#include <CGAL/Skin_surface_3.h>
|
||||||
#include <CGAL/Polyhedron_3.h>
|
#include <CGAL/Polyhedron_3.h>
|
||||||
#include <CGAL/Skin_surface_polyhedral_items_3.h>
|
|
||||||
#include <CGAL/mesh_skin_surface_3.h>
|
#include <CGAL/mesh_skin_surface_3.h>
|
||||||
#include <CGAL/subdivide_skin_surface_mesh_3.h>
|
#include <CGAL/subdivide_skin_surface_mesh_3.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
@ -16,11 +15,7 @@ typedef CGAL::Skin_surface_3<Traits> Skin_surface_3;
|
||||||
typedef Skin_surface_3::FT FT;
|
typedef Skin_surface_3::FT FT;
|
||||||
typedef Skin_surface_3::Weighted_point Weighted_point;
|
typedef Skin_surface_3::Weighted_point Weighted_point;
|
||||||
typedef Skin_surface_3::Bare_point Bare_point;
|
typedef Skin_surface_3::Bare_point Bare_point;
|
||||||
|
typedef CGAL::Polyhedron_3<K> Polyhedron;
|
||||||
// Each facet has a pointer to the tetrahedron of the TMC it is contained in
|
|
||||||
typedef Skin_surface_3::Triangulated_mixed_complex TMC;
|
|
||||||
typedef CGAL::Skin_surface_polyhedral_items_3<TMC> Poly_items;
|
|
||||||
typedef CGAL::Polyhedron_3<K,Poly_items> Polyhedron;
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
std::list<Weighted_point> l;
|
std::list<Weighted_point> l;
|
||||||
|
|
|
||||||
|
|
@ -2,13 +2,12 @@
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
#include <CGAL/Skin_surface_3.h>
|
#include <CGAL/Skin_surface_3.h>
|
||||||
#include <CGAL/Polyhedron_3.h>
|
#include <CGAL/Polyhedron_3.h>
|
||||||
#include <CGAL/Skin_surface_polyhedral_items_3.h>
|
|
||||||
#include <CGAL/mesh_skin_surface_3.h>
|
#include <CGAL/mesh_skin_surface_3.h>
|
||||||
#include <CGAL/subdivide_skin_surface_mesh_3.h>
|
#include <CGAL/subdivide_skin_surface_mesh_3.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
#include "skin_surface_writer.h"
|
||||||
|
|
||||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||||
typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
|
typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
|
||||||
|
|
@ -16,69 +15,15 @@ typedef CGAL::Skin_surface_3<Traits> Skin_surface_3;
|
||||||
typedef Skin_surface_3::FT FT;
|
typedef Skin_surface_3::FT FT;
|
||||||
typedef Skin_surface_3::Weighted_point Weighted_point;
|
typedef Skin_surface_3::Weighted_point Weighted_point;
|
||||||
typedef Skin_surface_3::Bare_point Bare_point;
|
typedef Skin_surface_3::Bare_point Bare_point;
|
||||||
|
typedef CGAL::Polyhedron_3<K> Polyhedron;
|
||||||
// Each facet has a pointer to the tetrahedron of the TMC it is contained in
|
|
||||||
typedef Skin_surface_3::Triangulated_mixed_complex TMC;
|
|
||||||
typedef CGAL::Skin_surface_polyhedral_items_3<TMC> Poly_items;
|
|
||||||
typedef CGAL::Polyhedron_3<K,Poly_items> Polyhedron;
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
// 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 ++) {
|
|
||||||
out << vit->point() << " "
|
|
||||||
<< policy->normal(vit)
|
|
||||||
<< 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";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
std::list<Weighted_point> l;
|
std::list<Weighted_point> l;
|
||||||
FT shrinkfactor = 0.5;
|
FT shrinkfactor = 0.5;
|
||||||
if (argc < 2) {
|
|
||||||
std::cout << "Usage: " << argv[0] << " <infile>" << std::endl;
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ifstream in(argv[1]);
|
l.push_front(Weighted_point(Bare_point(0,0,0), 1));
|
||||||
Weighted_point wp;
|
l.push_front(Weighted_point(Bare_point(0,1,0), 2));
|
||||||
while (in >> wp) l.push_front(wp);
|
l.push_front(Weighted_point(Bare_point(0,0,2), 1));
|
||||||
|
|
||||||
Skin_surface_3 skin_surface(l.begin(), l.end(), shrinkfactor);
|
Skin_surface_3 skin_surface(l.begin(), l.end(), shrinkfactor);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,29 @@
|
||||||
// NGHK: NOT IN USE FOR NOW
|
|
||||||
|
|
||||||
// examples/Skin_surface_3/union_of_balls_simple.C
|
// examples/Skin_surface_3/union_of_balls_simple.C
|
||||||
#include <CGAL/Skin_surface_traits_3.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
#include <CGAL/skin_surface_3.h>
|
#include <CGAL/Union_of_balls_3.h>
|
||||||
#include <CGAL/Polyhedron_3.h>
|
#include <CGAL/Polyhedron_3.h>
|
||||||
|
// #include <CGAL/mesh_union_of_balls_3.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
typedef CGAL::Skin_surface_traits_3<> Skin_surface_traits;
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||||
typedef Skin_surface_traits::Regular_traits Regular_traits;
|
typedef CGAL::Regular_triangulation_euclidean_traits_3<K> Traits;
|
||||||
typedef Regular_traits::Bare_point Reg_point;
|
typedef CGAL::Union_of_balls_3<Traits> Union_of_balls_3;
|
||||||
typedef Regular_traits::Weighted_point Reg_weighted_point;
|
typedef Union_of_balls_3::FT FT;
|
||||||
typedef CGAL::Polyhedron_3<Skin_surface_traits::Polyhedron_traits> Polyhedron;
|
typedef Union_of_balls_3::Weighted_point Weighted_point;
|
||||||
|
typedef Union_of_balls_3::Bare_point Bare_point;
|
||||||
|
typedef CGAL::Polyhedron_3<K> Polyhedron;
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
return 0;
|
std::list<Weighted_point> l;
|
||||||
|
|
||||||
std::list<Reg_weighted_point> l;
|
l.push_front(Weighted_point(Bare_point(0,0,0), 1));
|
||||||
|
l.push_front(Weighted_point(Bare_point(0,1,0), 2));
|
||||||
|
l.push_front(Weighted_point(Bare_point(0,0,2), 1));
|
||||||
|
|
||||||
l.push_front(Reg_weighted_point(Reg_point(0,0,0), 1));
|
Union_of_balls_3 union_of_balls(l.begin(), l.end());
|
||||||
l.push_front(Reg_weighted_point(Reg_point(0,1,0), 2));
|
|
||||||
l.push_front(Reg_weighted_point(Reg_point(0,0,2), 1));
|
|
||||||
|
|
||||||
Polyhedron p;
|
// Polyhedron p;
|
||||||
Skin_surface_traits skin_surface_traits(1);
|
// CGAL::mesh_union_of_balls_3(union_of_balls, p);
|
||||||
CGAL::skin_surface_3(l.begin(), l.end(), p, skin_surface_traits);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,8 @@
|
||||||
//
|
//
|
||||||
// Author(s) : Nico Kruithof <Nico@cs.rug.nl>
|
// Author(s) : Nico Kruithof <Nico@cs.rug.nl>
|
||||||
|
|
||||||
#ifndef CGAL_CGAL_SKIN_SURFACE_3_H
|
#ifndef CGAL_SKIN_SURFACE_3_H
|
||||||
#define CGAL_CGAL_SKIN_SURFACE_3_H
|
#define CGAL_SKIN_SURFACE_3_H
|
||||||
|
|
||||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||||
|
|
@ -289,4 +289,4 @@ construct_bounding_box(Regular ®ular)
|
||||||
|
|
||||||
CGAL_END_NAMESPACE
|
CGAL_END_NAMESPACE
|
||||||
|
|
||||||
#endif // CGAL_CGAL_SKIN_SURFACE_TRAITS_3_H
|
#endif // CGAL_SKIN_SURFACE_3_H
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,8 @@ private:
|
||||||
protected:
|
protected:
|
||||||
Skin_surface const &skin;
|
Skin_surface const &skin;
|
||||||
SS_vertex_map triang_vertex_signs;
|
SS_vertex_map triang_vertex_signs;
|
||||||
T2P_converter const t2p_converter;
|
T2P_converter t2p_converter;
|
||||||
P2T_converter const p2t_converter;
|
P2T_converter p2t_converter;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Polyhedron_3, class SkinSurface_3>
|
template <class Polyhedron_3, class SkinSurface_3>
|
||||||
|
|
@ -225,13 +225,13 @@ public:
|
||||||
|
|
||||||
P_point to_surface(P_vertex_handle vh)
|
P_point to_surface(P_vertex_handle vh)
|
||||||
{
|
{
|
||||||
SS_cell_handle ch = Base::skin.locate(Base::p2t_converter(vh->point()));
|
SS_cell_handle ch = Base::skin.locate(p2t_converter(vh->point()));
|
||||||
return to_surface_along_transversal_segment(vh->point(),ch);
|
return to_surface_along_transversal_segment(vh->point(),ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
P_vector normal(P_vertex_handle vh)
|
P_vector normal(P_vertex_handle vh)
|
||||||
{
|
{
|
||||||
SS_cell_handle ch = Base::skin.locate(Base::p2t_converter(vh->point()));
|
SS_cell_handle ch = Base::skin.locate(p2t_converter(vh->point()));
|
||||||
return ch->surf->gradient(vh->point());
|
return ch->surf->gradient(vh->point());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -188,9 +188,9 @@ public:
|
||||||
const Surface_RT &s,
|
const Surface_RT &s,
|
||||||
const int orient) {
|
const int orient) {
|
||||||
Q[1] = Q[3] = Q[4] = 0;
|
Q[1] = Q[3] = Q[4] = 0;
|
||||||
Q[0] = Q[2] = Q[5] = orient*(1-s);
|
Q[0] = Q[2] = Q[5] = orient/s;
|
||||||
|
|
||||||
surf = new Quadratic_surface(Q, c, s*(1-s)*w);
|
surf = new Quadratic_surface(Q, c, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
void create_hyperboloid(const Surface_point &c,
|
void create_hyperboloid(const Surface_point &c,
|
||||||
|
|
@ -198,18 +198,18 @@ public:
|
||||||
const Surface_vector &t,
|
const Surface_vector &t,
|
||||||
const Surface_RT &s,
|
const Surface_RT &s,
|
||||||
const int orient) {
|
const int orient) {
|
||||||
Surface_RT den = t*t;
|
Surface_RT den = t*t*s*(1-s);
|
||||||
|
|
||||||
Q[0] = orient*(- t.x()*t.x()/den + (1-s));
|
Q[0] = orient*(- t.x()*t.x()/den + 1/s);
|
||||||
|
|
||||||
Q[1] = orient*(-2*t.y()*t.x()/den);
|
Q[1] = orient*(-2*t.y()*t.x()/den);
|
||||||
Q[2] = orient*(- t.y()*t.y()/den + (1-s));
|
Q[2] = orient*(- t.y()*t.y()/den + 1/s);
|
||||||
|
|
||||||
Q[3] = orient*(-2*t.z()*t.x()/den);
|
Q[3] = orient*(-2*t.z()*t.x()/den);
|
||||||
Q[4] = orient*(-2*t.z()*t.y()/den);
|
Q[4] = orient*(-2*t.z()*t.y()/den);
|
||||||
Q[5] = orient*(- t.z()*t.z()/den + (1-s));
|
Q[5] = orient*(- t.z()*t.z()/den + 1/s);
|
||||||
|
|
||||||
surf = new Quadratic_surface(Q, c, s*(1-s)*w);
|
surf = new Quadratic_surface(Q, c, w);
|
||||||
}
|
}
|
||||||
|
|
||||||
Surface_RT Q[6];
|
Surface_RT Q[6];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue