mirror of https://github.com/CGAL/cgal
Minor fixes
This commit is contained in:
parent
692d68bffe
commit
cfe91f2e34
|
|
@ -29,6 +29,7 @@
|
|||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <boost/intrusive_ptr.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/none.hpp>
|
||||
|
||||
|
|
@ -307,7 +308,7 @@ class Trisegment_2
|
|||
{
|
||||
if ( aTrisegment.is_null() )
|
||||
{
|
||||
return os << "{null}" << endl ;
|
||||
return os << "{null}" ;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -41,17 +41,17 @@ void report( int idx, bool ok, std::string const& info = std::string("") )
|
|||
}
|
||||
}
|
||||
|
||||
Sorted_triedge create_sorted_triedge( Traits const& aTraits, triple const& aTriple )
|
||||
Seeded_trisegment create_seeded_trisegment( Traits const& aTraits, triple const& aTriple )
|
||||
{
|
||||
Triedge const& lTriedge = aTriple.triedge();
|
||||
CGAL::Triedge_collinearity lColl = CGAL::Get_ss_triedge_collinearity_2(aTraits)(lTriedge);
|
||||
return CGAL::Construct_ss_sorted_triedge_2(aTraits)(lTriedge,lColl);
|
||||
Trisegment const& lTrisegment = aTriple.trisegment();
|
||||
Trisegment lseed, rseed ;
|
||||
return CGAL::Construct_ss_seeded_trisegment_2(aTraits)(lTrisegment,lseed,rseed);
|
||||
}
|
||||
|
||||
|
||||
bool exist_event( Traits const& aTraits, triple const& aTriple )
|
||||
{
|
||||
return CGAL::Do_ss_event_exist_2(aTraits)(create_sorted_triedge(aTraits,aTriple));
|
||||
return CGAL::Do_ss_event_exist_2(aTraits)(create_seeded_trisegment(aTraits,aTriple));
|
||||
}
|
||||
|
||||
template<class Traits, class triple>
|
||||
|
|
@ -66,7 +66,7 @@ void test_exist_event( int i
|
|||
|
||||
CGAL::Comparison_result compare_events(Traits const& aTraits, triple const& aTripleA, triple const& aTripleB )
|
||||
{
|
||||
return CGAL::Compare_ss_event_times_2(aTraits)(create_sorted_triedge(aTraits,aTripleA),create_sorted_triedge(aTraits,aTripleB));
|
||||
return CGAL::Compare_ss_event_times_2(aTraits)(create_seeded_trisegment(aTraits,aTripleA),create_seeded_trisegment(aTraits,aTripleB));
|
||||
}
|
||||
|
||||
template<class Traits, class triple>
|
||||
|
|
@ -91,7 +91,7 @@ CGAL::Comparison_result compare_sdist_to_seed(Traits const& aTraits
|
|||
,triple const& aTripleB
|
||||
)
|
||||
{
|
||||
return CGAL::Compare_ss_event_distance_to_seed_2(aTraits)(aP,create_sorted_triedge(aTraits,aTripleA),create_sorted_triedge(aTraits,aTripleB));
|
||||
return CGAL::Compare_ss_event_distance_to_seed_2(aTraits)(aP,create_seeded_trisegment(aTraits,aTripleA),create_seeded_trisegment(aTraits,aTripleB));
|
||||
}
|
||||
|
||||
template<class Traits, class triple>
|
||||
|
|
@ -101,9 +101,9 @@ CGAL::Comparison_result compare_sdist_to_seed(Traits const& aTraits
|
|||
,triple const& aTripleC
|
||||
)
|
||||
{
|
||||
return CGAL::Compare_ss_event_distance_to_seed_2(aTraits)(create_sorted_triedge(aTraits,aTripleA)
|
||||
,create_sorted_triedge(aTraits,aTripleB)
|
||||
,create_sorted_triedge(aTraits,aTripleC)
|
||||
return CGAL::Compare_ss_event_distance_to_seed_2(aTraits)(create_seeded_trisegment(aTraits,aTripleA)
|
||||
,create_seeded_trisegment(aTraits,aTripleB)
|
||||
,create_seeded_trisegment(aTraits,aTripleC)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ void test_compare_sdist_to_seed( int i
|
|||
|
||||
bool is_inside_offset_zone( Traits const& aTraits, triple const& aTripleA, triple const& aTripleB )
|
||||
{
|
||||
return CGAL::Is_ss_event_inside_offset_zone_2(aTraits)(create_sorted_triedge(aTraits,aTripleA),create_sorted_triedge(aTraits,aTripleB));
|
||||
return CGAL::Is_ss_event_inside_offset_zone_2(aTraits)(create_seeded_trisegment(aTraits,aTripleA),create_seeded_trisegment(aTraits,aTripleB));
|
||||
}
|
||||
|
||||
template<class Traits, class triple>
|
||||
|
|
|
|||
|
|
@ -163,213 +163,6 @@ void dump_eps( SlsPtr sls, std::string eps )
|
|||
|
||||
dump.close();
|
||||
}
|
||||
|
||||
|
||||
void StraightSkeletonFree(int* numFace_i, double* xf, double* yf)
|
||||
{
|
||||
delete [] xf;
|
||||
delete [] yf;
|
||||
delete [] numFace_i;
|
||||
}
|
||||
|
||||
typedef Sls::Face_iterator Face_iterator ;
|
||||
typedef Sls::Face_handle Face_handle ;
|
||||
typedef Sls::Halfedge_handle Halfedge_handle ;
|
||||
|
||||
int StraightSkeleton( int np
|
||||
, int* np_i
|
||||
, double* xp
|
||||
, double* yp
|
||||
, int& numFaces
|
||||
, int& numVertices
|
||||
, int*& numFace_i
|
||||
, double*& xf
|
||||
, double*& yf
|
||||
, int dumpEPS
|
||||
)
|
||||
{
|
||||
int result = 0 ;
|
||||
|
||||
numFace_i = NULL ;
|
||||
xf = yf = NULL ;
|
||||
|
||||
try
|
||||
{
|
||||
double scale = 1.0;
|
||||
|
||||
SlsBuilder ssb ;
|
||||
|
||||
|
||||
int currentPoint = 0;
|
||||
for(int i = 0; i < np; i++)
|
||||
{
|
||||
std::vector<Point> points(np_i[i]);
|
||||
for(int j=0; j < np_i[i]; j++)
|
||||
{
|
||||
Point p(xp[currentPoint], yp[currentPoint]);
|
||||
points[j] = p;
|
||||
++currentPoint;
|
||||
}
|
||||
|
||||
if( ! CGAL::is_simple_2(points.begin(),points.end()))
|
||||
{
|
||||
std::cerr << "Polygon " << i << " is not simple" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( CGAL::orientation_2(points.begin(),points.end()) != ( i == 0 ? CGAL::COUNTERCLOCKWISE
|
||||
: CGAL::CLOCKWISE
|
||||
)
|
||||
)
|
||||
ssb.enter_contour(points.rbegin(),points.rend());
|
||||
else ssb.enter_contour(points.begin(),points.end());
|
||||
}
|
||||
|
||||
|
||||
// Construct the skeleton
|
||||
boost::shared_ptr<Sls> ss = ssb.construct_skeleton();
|
||||
|
||||
// Proceed only if the skeleton was correctly constructed.
|
||||
if ( ss )
|
||||
{
|
||||
// We first count the points
|
||||
numFaces= (int)ss->size_of_faces();
|
||||
numFace_i = new int[numFaces];
|
||||
|
||||
numVertices = 0;
|
||||
int currentFace = 0;
|
||||
for(Face_iterator fit = ss->faces_begin(); fit != ss->faces_end(); ++fit)
|
||||
{
|
||||
int count = 0;
|
||||
Halfedge_handle h = fit->halfedge();
|
||||
Halfedge_handle done;
|
||||
done = h;
|
||||
do
|
||||
{
|
||||
count++;
|
||||
h = h->next();
|
||||
} while(h != done);
|
||||
numVertices += count;
|
||||
|
||||
numFace_i[currentFace] = count;
|
||||
++currentFace;
|
||||
}
|
||||
|
||||
// Allocate the x and y array and traverse the faces again
|
||||
xf = new double[numVertices];
|
||||
yf = new double[numVertices];
|
||||
|
||||
int currentVertex = 0;
|
||||
|
||||
for(Face_iterator fit = ss->faces_begin(); fit != ss->faces_end(); ++fit)
|
||||
{
|
||||
Halfedge_handle h = fit->halfedge();
|
||||
Halfedge_handle done;
|
||||
done = h;
|
||||
do
|
||||
{
|
||||
xf[currentVertex] = h->vertex()->point().x();
|
||||
yf[currentVertex] = h->vertex()->point().y();
|
||||
++currentVertex;
|
||||
h = h->next();
|
||||
}
|
||||
while(h != done);
|
||||
}
|
||||
|
||||
//
|
||||
int vi = 0 ;
|
||||
for ( int fi = 0 ; fi < numFaces ; ++ fi )
|
||||
{
|
||||
double lastx = xf[vi] ;
|
||||
double lasty = yf[vi];
|
||||
|
||||
double firstx ;
|
||||
double firsty ;
|
||||
|
||||
for ( int fvi = 0 ; fvi < numFace_i[fi] ; ++ fvi )
|
||||
{
|
||||
firstx = xf[vi];
|
||||
firsty = yf[vi];
|
||||
++ vi ;
|
||||
}
|
||||
|
||||
|
||||
Face_iterator ff = ss->faces_begin() ;
|
||||
std::advance(ff,fi) ;
|
||||
Face_handle fh = ff;
|
||||
double _lastx = fh->halfedge()->vertex()->point().x();
|
||||
double _lasty = fh->halfedge()->vertex()->point().y();
|
||||
double _firstx = fh->halfedge()->opposite()->vertex()->point().x();
|
||||
double _firsty = fh->halfedge()->opposite()->vertex()->point().y();
|
||||
|
||||
if ( firstx != _firstx || firsty != _firsty || lastx != _lastx || lasty != _lasty )
|
||||
{
|
||||
std::cout << "face " << fi << " edge: (" << firstx << "," << firsty << ")->(" << lastx << "," << lasty << ") mismatch:"
|
||||
<< " (" << _firstx << "," << _firsty << ")->(" << _lastx << "," << _lasty << ")\n" ;
|
||||
}
|
||||
|
||||
}
|
||||
//
|
||||
|
||||
|
||||
result = 1 ;
|
||||
}
|
||||
}
|
||||
catch ( std::exception const& e )
|
||||
{
|
||||
std::cerr << "Exception thrown: " << e.what() << std::endl ;
|
||||
StraightSkeletonFree(numFace_i,xf,yf);
|
||||
}
|
||||
catch ( ... )
|
||||
{
|
||||
std::cerr << "Unknown exception thrown." << std::endl ;
|
||||
StraightSkeletonFree(numFace_i,xf,yf);
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
void TestDLL ( Region const& aRegion )
|
||||
{
|
||||
int np = 1 ;
|
||||
|
||||
int nv = 0 ;
|
||||
for( Region::const_iterator bit = aRegion.begin(), ebit = aRegion.end() ; bit != ebit ; ++ bit )
|
||||
nv += (*bit)->size();
|
||||
|
||||
int* np_i = new int [np];
|
||||
double* xp = new double[nv];
|
||||
double* yp = new double[nv];
|
||||
|
||||
int numFaces ;
|
||||
int numVertices ;
|
||||
int* numFace_i ;
|
||||
double* xf ;
|
||||
double* yf ;
|
||||
|
||||
int ci = 0 ;
|
||||
int vi = 0 ;
|
||||
for( Region::const_iterator bit = aRegion.begin(), ebit = aRegion.end() ; bit != ebit ; ++ bit )
|
||||
{
|
||||
np_i[ci] = (*bit)->size();
|
||||
|
||||
for ( Polygon::const_iterator vit = (*bit)->begin() ; vit != (*bit)->end() ; ++ vit )
|
||||
{
|
||||
xp[vi] = vit->x() ;
|
||||
yp[vi] = vit->y() ;
|
||||
++ vi ;
|
||||
}
|
||||
++ ci ;
|
||||
}
|
||||
|
||||
StraightSkeleton(np,np_i,xp,yp,numFaces,numVertices,numFace_i,xf,yf,0);
|
||||
StraightSkeletonFree(numFace_i,xf,yf);
|
||||
|
||||
delete[] np_i ;
|
||||
delete[] xp ;
|
||||
delete[] yp ;
|
||||
}
|
||||
|
||||
void test( std::string file )
|
||||
{
|
||||
RegionPtr lRegion = load_region(file);
|
||||
|
|
@ -395,7 +188,6 @@ void test( std::string file )
|
|||
(*failed_list) << file << endl ;
|
||||
++ sFailed ;
|
||||
}
|
||||
TestDLL(*lRegion);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ typedef K::Segment_2 Segment ;
|
|||
|
||||
typedef CGAL::Straight_skeleton_builder_traits_2<K> Traits ;
|
||||
|
||||
typedef Traits::Triedge_2 Triedge ;
|
||||
typedef Traits::Sorted_triedge_2 Sorted_triedge ;
|
||||
typedef Traits::Trisegment_2 Trisegment ;
|
||||
typedef Traits::Seeded_trisegment_2 Seeded_trisegment ;
|
||||
|
||||
Traits sTraits ;
|
||||
|
||||
|
|
@ -99,12 +99,12 @@ struct triple
|
|||
|
||||
int idx( char const* d, int i ) { return d[i] - 'a' ; }
|
||||
|
||||
Triedge triedge() const
|
||||
Trisegment trisegment() const
|
||||
{
|
||||
return Triedge( Segment( Point(mP[0].x(),mP[0].y()), Point(mP[1].x(),mP[1].y()))
|
||||
, Segment( Point(mP[2].x(),mP[2].y()), Point(mP[3].x(),mP[3].y()))
|
||||
, Segment( Point(mP[4].x(),mP[4].y()), Point(mP[5].x(),mP[5].y()))
|
||||
);
|
||||
return *CGAL::Construct_ss_trisegment_2(sTraits)( Segment( Point(mP[0].x(),mP[0].y()), Point(mP[1].x(),mP[1].y()))
|
||||
, Segment( Point(mP[2].x(),mP[2].y()), Point(mP[3].x(),mP[3].y()))
|
||||
, Segment( Point(mP[4].x(),mP[4].y()), Point(mP[5].x(),mP[5].y()))
|
||||
);
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<( std::ostream& os, Point const& aP )
|
||||
|
|
@ -132,7 +132,7 @@ void test_exist_event()
|
|||
// f g h i j
|
||||
// a b c d e
|
||||
|
||||
const int c = 11 ;
|
||||
const int c = 10 ;
|
||||
|
||||
const triple triples[c] = { triple("fabg")
|
||||
, triple("fbci")
|
||||
|
|
@ -142,7 +142,6 @@ void test_exist_event()
|
|||
, triple("abci")
|
||||
, triple("abcg")
|
||||
, triple("afgl")
|
||||
, triple("aght")
|
||||
, triple("agc","qr")
|
||||
, triple("acga")
|
||||
} ;
|
||||
|
|
@ -156,7 +155,6 @@ void test_exist_event()
|
|||
,true
|
||||
,true
|
||||
,false
|
||||
,false
|
||||
|
||||
,true
|
||||
,true
|
||||
|
|
|
|||
Loading…
Reference in New Issue