mirror of https://github.com/CGAL/cgal
parent
a6bbefaad3
commit
0427412ef6
|
|
@ -9,29 +9,29 @@
|
||||||
<ignoreparts/>
|
<ignoreparts/>
|
||||||
<projectdirectory>.</projectdirectory>
|
<projectdirectory>.</projectdirectory>
|
||||||
<absoluteprojectpath>false</absoluteprojectpath>
|
<absoluteprojectpath>false</absoluteprojectpath>
|
||||||
<description/>
|
<description></description>
|
||||||
</general>
|
</general>
|
||||||
<kdevcustomproject>
|
<kdevcustomproject>
|
||||||
<run>
|
<run>
|
||||||
<mainprogram>simplification_demo</mainprogram>
|
<mainprogram>simplification_demo</mainprogram>
|
||||||
<directoryradio>executable</directoryradio>
|
<directoryradio>build</directoryradio>
|
||||||
<customdirectory>/</customdirectory>
|
<customdirectory>/</customdirectory>
|
||||||
<programargs/>
|
<programargs>./data/Sample0.off 1000</programargs>
|
||||||
<terminal>false</terminal>
|
<terminal>false</terminal>
|
||||||
<autocompile>true</autocompile>
|
<autocompile>true</autocompile>
|
||||||
<envvars/>
|
<envvars/>
|
||||||
</run>
|
</run>
|
||||||
<build>
|
<build>
|
||||||
<buildtool>make</buildtool>
|
<buildtool>make</buildtool>
|
||||||
<builddir/>
|
<builddir></builddir>
|
||||||
</build>
|
</build>
|
||||||
<make>
|
<make>
|
||||||
<abortonerror>false</abortonerror>
|
<abortonerror>false</abortonerror>
|
||||||
<numberofjobs>1</numberofjobs>
|
<numberofjobs>1</numberofjobs>
|
||||||
<prio>0</prio>
|
<prio>0</prio>
|
||||||
<dontact>false</dontact>
|
<dontact>false</dontact>
|
||||||
<makebin/>
|
<makebin></makebin>
|
||||||
<defaulttarget/>
|
<defaulttarget></defaulttarget>
|
||||||
<makeoptions>CGAL_MAKEFILE=/home/fcacciola/Programming/CGAL/make/makefile_i686_Linux-2.6_g++-4.0.2 DEBUGGING=yes</makeoptions>
|
<makeoptions>CGAL_MAKEFILE=/home/fcacciola/Programming/CGAL/make/makefile_i686_Linux-2.6_g++-4.0.2 DEBUGGING=yes</makeoptions>
|
||||||
<selectedenvironment>default</selectedenvironment>
|
<selectedenvironment>default</selectedenvironment>
|
||||||
<environments>
|
<environments>
|
||||||
|
|
@ -41,12 +41,12 @@
|
||||||
</kdevcustomproject>
|
</kdevcustomproject>
|
||||||
<kdevdebugger>
|
<kdevdebugger>
|
||||||
<general>
|
<general>
|
||||||
<dbgshell/>
|
<dbgshell></dbgshell>
|
||||||
<programargs/>
|
<programargs></programargs>
|
||||||
<gdbpath/>
|
<gdbpath></gdbpath>
|
||||||
<configGdbScript/>
|
<configGdbScript></configGdbScript>
|
||||||
<runShellScript/>
|
<runShellScript></runShellScript>
|
||||||
<runGdbScript/>
|
<runGdbScript></runGdbScript>
|
||||||
<breakonloadinglibs>true</breakonloadinglibs>
|
<breakonloadinglibs>true</breakonloadinglibs>
|
||||||
<separatetty>false</separatetty>
|
<separatetty>false</separatetty>
|
||||||
<floatingtoolbar>false</floatingtoolbar>
|
<floatingtoolbar>false</floatingtoolbar>
|
||||||
|
|
@ -126,7 +126,7 @@
|
||||||
<headerCompletionDelay>250</headerCompletionDelay>
|
<headerCompletionDelay>250</headerCompletionDelay>
|
||||||
</codecompletion>
|
</codecompletion>
|
||||||
<creategettersetter>
|
<creategettersetter>
|
||||||
<prefixGet/>
|
<prefixGet></prefixGet>
|
||||||
<prefixSet>set</prefixSet>
|
<prefixSet>set</prefixSet>
|
||||||
<prefixVariable>m_,_</prefixVariable>
|
<prefixVariable>m_,_</prefixVariable>
|
||||||
<parameterName>theValue</parameterName>
|
<parameterName>theValue</parameterName>
|
||||||
|
|
@ -152,8 +152,8 @@
|
||||||
</cppsupportpart>
|
</cppsupportpart>
|
||||||
<kdevvisualadvance>
|
<kdevvisualadvance>
|
||||||
<emulator>VisualBoyAdvance</emulator>
|
<emulator>VisualBoyAdvance</emulator>
|
||||||
<binary/>
|
<binary></binary>
|
||||||
<addOptions/>
|
<addOptions></addOptions>
|
||||||
<terminal>false</terminal>
|
<terminal>false</terminal>
|
||||||
<fullscreen>false</fullscreen>
|
<fullscreen>false</fullscreen>
|
||||||
<graphicFilter>-f0</graphicFilter>
|
<graphicFilter>-f0</graphicFilter>
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ int main() {
|
||||||
#include <CGAL/IO/Polyhedron_geomview_ostream.h>
|
#include <CGAL/IO/Polyhedron_geomview_ostream.h>
|
||||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||||
|
|
||||||
//#define CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE 1
|
//#define CGAL_SURFACE_SIMPLIFICATION_ENABLE_TRACE 2
|
||||||
|
|
||||||
void Surface_simplification_external_trace( std::string s )
|
void Surface_simplification_external_trace( std::string s )
|
||||||
{
|
{
|
||||||
|
|
@ -52,7 +52,7 @@ void Surface_simplification_external_trace( std::string s )
|
||||||
#include <CGAL/Surface_mesh_simplification/Policies/LindstromTurk_selection_map.h>
|
#include <CGAL/Surface_mesh_simplification/Policies/LindstromTurk_selection_map.h>
|
||||||
#include <CGAL/Surface_mesh_simplification/Policies/Edge_length_cost_map.h>
|
#include <CGAL/Surface_mesh_simplification/Policies/Edge_length_cost_map.h>
|
||||||
#include <CGAL/Surface_mesh_simplification/Policies/Midpoint_vertex_placement.h>
|
#include <CGAL/Surface_mesh_simplification/Policies/Midpoint_vertex_placement.h>
|
||||||
#include <CGAL/Surface_mesh_simplification/Policies/Count_ratio_stop_pred.h>
|
#include <CGAL/Surface_mesh_simplification/Policies/Count_stop_pred.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
@ -200,7 +200,7 @@ void error_handler ( char const* what, char const* expr, char const* file, int l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Simplify ( Polyhedron& aP )
|
void Simplify ( Polyhedron& aP, int aMax )
|
||||||
{
|
{
|
||||||
std::cout << "Simplifying surface with " << (aP.size_of_halfedges()/2) << " edges..." << std::endl ;
|
std::cout << "Simplifying surface with " << (aP.size_of_halfedges()/2) << " edges..." << std::endl ;
|
||||||
|
|
||||||
|
|
@ -217,7 +217,7 @@ void Simplify ( Polyhedron& aP )
|
||||||
Lindstrom_Turk_selection<Polyhedron> selection_map ;
|
Lindstrom_Turk_selection<Polyhedron> selection_map ;
|
||||||
Edge_length_cost_map<Polyhedron> cost_map ;
|
Edge_length_cost_map<Polyhedron> cost_map ;
|
||||||
Midpoint_vertex_placement<Polyhedron> vertex_placement ;
|
Midpoint_vertex_placement<Polyhedron> vertex_placement ;
|
||||||
Count_ratio_stop_condition<Polyhedron> stop_condition(0.5);
|
Count_stop_condition<Polyhedron> stop_condition(aMax);
|
||||||
|
|
||||||
std::cout << std::setprecision(19) ;
|
std::cout << std::setprecision(19) ;
|
||||||
|
|
||||||
|
|
@ -234,8 +234,14 @@ void Simplify ( Polyhedron& aP )
|
||||||
fi->ID = lFacetID ++ ;
|
fi->ID = lFacetID ++ ;
|
||||||
|
|
||||||
int r = vertex_pair_collapse(aP,selection_map,cost_map,vertex_placement,stop_condition);
|
int r = vertex_pair_collapse(aP,selection_map,cost_map,vertex_placement,stop_condition);
|
||||||
|
std::cout << "Finished...\n"
|
||||||
std::cout << "Finished...\nEdges removed: " << r << std::endl ;
|
<< r << " edges removed.\n"
|
||||||
|
<< aP.size_of_vertices() << " vertices.\n"
|
||||||
|
<< (aP.size_of_halfedges()/2) << " edges.\n"
|
||||||
|
<< aP.size_of_facets() << " triangles.\n"
|
||||||
|
<< ( aP.is_valid() ? " valid" : " INVALID!!" )
|
||||||
|
<< std::endl ;
|
||||||
|
;
|
||||||
|
|
||||||
#ifdef VISUALIZE
|
#ifdef VISUALIZE
|
||||||
gv << aP ;
|
gv << aP ;
|
||||||
|
|
@ -252,31 +258,34 @@ int main( int argc, char** argv )
|
||||||
|
|
||||||
Polyhedron lP;
|
Polyhedron lP;
|
||||||
|
|
||||||
char const* file = argc > 1 ? argv[1] : "./data/Eros_50000triangles_edited.off" ;
|
char const* infile = argc > 1 ? argv[1] : "./data/Sample0.off" ;
|
||||||
std::ifstream sample(file);
|
std::ifstream in(infile);
|
||||||
if ( sample )
|
if ( in )
|
||||||
{
|
{
|
||||||
sample >> lP ;
|
in >> lP ;
|
||||||
Simplify(lP);
|
|
||||||
|
int lMax = argc > 2 ? std::atoi(argv[2]) : 1000 ; //lP.size_of_halfedges() ;
|
||||||
|
|
||||||
|
Simplify(lP,lMax);
|
||||||
|
|
||||||
|
char const* of = argc > 3 ? argv[3] : 0 ;
|
||||||
|
std::string outfile = !of ? std::string(infile) + std::string(".out.off") : of ;
|
||||||
|
|
||||||
|
std::ofstream out(outfile.c_str());
|
||||||
|
if ( out )
|
||||||
|
{
|
||||||
|
out << lP ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Input file not found: " << file << std::endl ;
|
std::cerr << "Unable to open out file: " << outfile << std::endl ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cerr << "Input file not found: " << infile << std::endl ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
double lSize = 1e2 ;
|
|
||||||
|
|
||||||
Point a(lSize,0,0)
|
|
||||||
, b(0,0,lSize)
|
|
||||||
, c(0,0,0)
|
|
||||||
, d(0,lSize,0) ;
|
|
||||||
|
|
||||||
lP.make_tetrahedron(a,b,c,d) ;
|
|
||||||
|
|
||||||
for ( int i = 0 ; i < 4 ; ++ i )
|
|
||||||
subdiv(lP);
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -536,7 +536,7 @@ class T_HDS, class Alloc>
|
||||||
typename graph_traits< CGAL::Polyhedron_3< PolyhedronTraits_3, PolyhedronItems_3, T_HDS, Alloc> >::edges_size_type
|
typename graph_traits< CGAL::Polyhedron_3< PolyhedronTraits_3, PolyhedronItems_3, T_HDS, Alloc> >::edges_size_type
|
||||||
num_edges(const CGAL::Polyhedron_3< PolyhedronTraits_3, PolyhedronItems_3, T_HDS, Alloc>& p)
|
num_edges(const CGAL::Polyhedron_3< PolyhedronTraits_3, PolyhedronItems_3, T_HDS, Alloc>& p)
|
||||||
{
|
{
|
||||||
return p.size_of_halfedges();
|
return p.size_of_halfedges() / 2 ;
|
||||||
}
|
}
|
||||||
|
|
||||||
template < class PolyhedronTraits_3, class PolyhedronItems_3,
|
template < class PolyhedronTraits_3, class PolyhedronItems_3,
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,12 @@ void VertexPairCollapse<TSM,SM,CM,VP,SP>::Loop()
|
||||||
// Pairs in the queue might be "fixed", that is, marked as uncollapsable, or their cost might be undefined.
|
// Pairs in the queue might be "fixed", that is, marked as uncollapsable, or their cost might be undefined.
|
||||||
if ( !lPair->is_fixed() && lPair->cost() != boost::none )
|
if ( !lPair->is_fixed() && lPair->cost() != boost::none )
|
||||||
{
|
{
|
||||||
|
if ( boost::num_vertices(mSurface) <= 4 )
|
||||||
|
{
|
||||||
|
CGAL_TSMS_TRACE(0,"Thetrahedron reached.");
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
|
||||||
if ( stop_simplification(*lPair->cost(),lPair->p(),lPair->q(),lPair->is_edge(),mInitialPairCount,mCurrentPairCount,mSurface) )
|
if ( stop_simplification(*lPair->cost(),lPair->p(),lPair->q(),lPair->is_edge(),mInitialPairCount,mCurrentPairCount,mSurface) )
|
||||||
{
|
{
|
||||||
CGAL_TSMS_TRACE(0,"Stop condition reached with InitialCount=" << mInitialPairCount
|
CGAL_TSMS_TRACE(0,"Stop condition reached with InitialCount=" << mInitialPairCount
|
||||||
|
|
@ -145,17 +151,14 @@ bool VertexPairCollapse<TSM,SM,CM,VP,SP>::Is_collapsable( vertex_pair_ptr const&
|
||||||
edge_descriptor q_t = boost::next_edge_cw (q_p,mSurface);
|
edge_descriptor q_t = boost::next_edge_cw (q_p,mSurface);
|
||||||
edge_descriptor q_b = boost::next_edge_ccw(q_p,mSurface);
|
edge_descriptor q_b = boost::next_edge_ccw(q_p,mSurface);
|
||||||
|
|
||||||
// degree(p) and degree(q) > 3
|
// degree(p) and degree(q) >= 3
|
||||||
if ( boost::target(p_t,mSurface) != aPair->q()
|
if ( boost::target(p_t,mSurface) != aPair->q()
|
||||||
&& boost::target(p_b,mSurface) != aPair->q()
|
&& boost::target(p_b,mSurface) != aPair->q()
|
||||||
&& boost::target(q_t,mSurface) != aPair->p()
|
&& boost::target(q_t,mSurface) != aPair->p()
|
||||||
&& boost::target(q_b,mSurface) != aPair->p()
|
&& boost::target(q_b,mSurface) != aPair->p()
|
||||||
&& boost::next_edge_ccw(p_t,mSurface) != p_b
|
|
||||||
&& boost::next_edge_cw (q_t,mSurface) != q_b
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
// link('p') .intersection. link('q') == link('p_q') (that is, exactly {'t','b'})
|
// link('p') .intersection. link('q') == link('p_q') (that is, exactly {'t','b'})
|
||||||
|
|
||||||
if ( boost::target(p_t,mSurface) == boost::target(q_t,mSurface)
|
if ( boost::target(p_t,mSurface) == boost::target(q_t,mSurface)
|
||||||
&& boost::target(p_b,mSurface) == boost::target(q_b,mSurface)
|
&& boost::target(p_b,mSurface) == boost::target(q_b,mSurface)
|
||||||
)
|
)
|
||||||
|
|
@ -272,7 +275,7 @@ void VertexPairCollapse<TSM,SM,CM,VP,SP>::Collapse( vertex_pair_ptr const& aPair
|
||||||
// Updates the cost of all pairs in the PQ
|
// Updates the cost of all pairs in the PQ
|
||||||
Update_neighbors(lQ);
|
Update_neighbors(lQ);
|
||||||
|
|
||||||
-- mCurrentPairCount ;
|
mCurrentPairCount -= 3 ;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -306,7 +309,7 @@ void VertexPairCollapse<TSM,SM,CM,VP,SP>::Update_neighbors( vertex_descriptor co
|
||||||
|
|
||||||
// This is required to satisfy the transitive link_condition.
|
// This is required to satisfy the transitive link_condition.
|
||||||
// That is, the edges around the replacement vertex 'v' cannot be collapsed again.
|
// That is, the edges around the replacement vertex 'v' cannot be collapsed again.
|
||||||
lPair1->is_fixed() = true ;
|
//lPair1->is_fixed() = true ;
|
||||||
|
|
||||||
vertex_descriptor adj_v = boost::source(edge1,mSurface);
|
vertex_descriptor adj_v = boost::source(edge1,mSurface);
|
||||||
|
|
||||||
|
|
@ -338,7 +341,7 @@ void VertexPairCollapse<TSM,SM,CM,VP,SP>::Update_neighbors( vertex_descriptor co
|
||||||
for ( vertex_pair_vector_iterator it = lToUpdate.begin(), eit = lToUpdate.end() ; it != eit ; ++ it )
|
for ( vertex_pair_vector_iterator it = lToUpdate.begin(), eit = lToUpdate.end() ; it != eit ; ++ it )
|
||||||
{
|
{
|
||||||
vertex_pair_ptr lPair = *it ;
|
vertex_pair_ptr lPair = *it ;
|
||||||
CGAL_TSMS_TRACE(2,"Updating cost of " << *lPair) ;
|
CGAL_TSMS_TRACE(3,"Updating cost of " << *lPair) ;
|
||||||
|
|
||||||
// The cost of a pair can be recalculated by invalidating its cache and updating the PQ.
|
// The cost of a pair can be recalculated by invalidating its cache and updating the PQ.
|
||||||
// The PQ update will reposition the pair in the heap querying its cost(),
|
// The PQ update will reposition the pair in the heap querying its cost(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue