removed obsolete workarround for VC++ and cleanup

This commit is contained in:
Efi Fogel 2010-05-16 13:06:52 +00:00
parent 7102aa3347
commit 106fde756b
11 changed files with 106 additions and 151 deletions

View File

@ -27,23 +27,17 @@ typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
// instead of
// typedef CGAL::Cartesian<Rational> Rat_kernel;
// typedef CGAL::Cartesian<Algebraic> Alg_kernel;
// typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
// Traits_2;
// workaround for VC++
struct Rat_kernel : public CGAL::Cartesian<Rational> {};
struct Alg_kernel : public CGAL::Cartesian<Algebraic> {};
struct Traits_2 :
public CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits> {};
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
Traits_2;
typedef Rat_kernel::Point_2 Rat_point_2;
typedef Traits_2::Curve_2 Bezier_curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef CGAL::Gps_traits_2<Traits_2> Gps_traits_2;
typedef Gps_traits_2::General_polygon_2 Polygon_2;
typedef Gps_traits_2::General_polygon_with_holes_2 Polygon_with_holes_2;
typedef Gps_traits_2::General_polygon_2 Polygon_2;
typedef Gps_traits_2::General_polygon_with_holes_2 Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Polygon_set;
/*! Read a general polygon with holes, formed by Bezier curves, from the
@ -65,15 +59,14 @@ bool read_Bezier_polygon (const char* filename, Polygon_with_holes_2& P)
// Read the curves one by one, and construct the general polygon these
// curve form (the outer boundary and the holes inside it).
Traits_2 traits;
Traits_2::Make_x_monotone_2 make_x_monotone =
traits.make_x_monotone_2_object();
bool first = true;
Rat_point_2 p_0;
Traits_2 traits;
Traits_2::Make_x_monotone_2 mk_x_monotone = traits.make_x_monotone_2_object();
bool first = true;
Rat_point_2 p_0;
std::list<X_monotone_curve_2> xcvs;
Rat_kernel ker;
Rat_kernel::Equal_2 equal = ker.equal_2_object();
std::list<Polygon_2> pgns;
Rat_kernel ker;
Rat_kernel::Equal_2 equal = ker.equal_2_object();
std::list<Polygon_2> pgns;
for (k = 0; k < n_curves; k++) {
// Read the current curve and subdivide it into x-monotone subcurves.
@ -83,7 +76,7 @@ bool read_Bezier_polygon (const char* filename, Polygon_with_holes_2& P)
X_monotone_curve_2 xcv;
in_file >> B;
make_x_monotone (B, std::back_inserter (x_objs));
mk_x_monotone (B, std::back_inserter (x_objs));
for (xoit = x_objs.begin(); xoit != x_objs.end(); ++xoit) {
if (CGAL::assign (xcv, *xoit))
@ -130,12 +123,12 @@ bool read_Bezier_polygon (const char* filename, Polygon_with_holes_2& P)
}
// The main program.
int main (int argc, char *argv[])
int main (int argc, char* argv[])
{
// Get the name of the input files from the command line, or use the default
// char_g.dat and char_m.dat files if no command-line parameters are given.
const char *filename1 = (argc > 1) ? argv[1] : "char_g.dat";
const char *filename2 = (argc > 2) ? argv[2] : "char_m.dat";
const char* filename1 = (argc > 1) ? argv[1] : "char_g.dat";
const char* filename2 = (argc > 2) ? argv[2] : "char_m.dat";
// Read the general polygons from the input files.
CGAL::Timer timer;

View File

@ -28,16 +28,10 @@ typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
// instead of
// typedef CGAL::Cartesian<Rational> Rat_kernel;
// typedef CGAL::Cartesian<Algebraic> Alg_kernel;
// typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
// Traits_2;
// workaround for VC++
struct Rat_kernel : public CGAL::Cartesian<Rational> {};
struct Alg_kernel : public CGAL::Cartesian<Algebraic> {};
struct Traits_2 :
public CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits> {};
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_Bezier_curve_traits_2<Rat_kernel, Alg_kernel, Nt_traits>
Traits_2;
typedef Rat_kernel::Point_2 Bezier_rat_point;
typedef Traits_2::Curve_2 Bezier_curve;
@ -97,7 +91,8 @@ bool read_bezier ( char const* aFileName, Bezier_polygon_set& rSet )
std::string format ;
std::getline(in_file,format);
bool lDoubleFormat = ( format.length() >= 6 && format.substr(0,6) == "DOUBLE") ;
bool lDoubleFormat = ( format.length() >= 6 &&
format.substr(0,6) == "DOUBLE") ;
// Red the number of bezier polygon with holes
unsigned int n_regions ;
@ -130,7 +125,8 @@ bool read_bezier ( char const* aFileName, Bezier_polygon_set& rSet )
std::list<CGAL::Object>::const_iterator xoit;
Bezier_X_monotone_curve xcv;
Bezier_traits traits;
Bezier_traits::Make_x_monotone_2 make_x_monotone = traits.make_x_monotone_2_object();
Bezier_traits::Make_x_monotone_2 make_x_monotone =
traits.make_x_monotone_2_object();
Bezier_curve B = read_bezier_curve(in_file, lDoubleFormat);
if ( B.number_of_control_points() >= 2 )
@ -153,7 +149,8 @@ bool read_bezier ( char const* aFileName, Bezier_polygon_set& rSet )
CGAL::Orientation orient = pgn.orientation();
std::cout << " Orientation: " << orient << std::endl ;
if (( b == 0 && orient == CGAL::CLOCKWISE) || ( b > 0 && orient == CGAL::COUNTERCLOCKWISE))
if (( b == 0 && orient == CGAL::CLOCKWISE) ||
( b > 0 && orient == CGAL::COUNTERCLOCKWISE))
{
std::cout << " Reversing orientation: " << std::endl ;
pgn.reverse_orientation();
@ -168,22 +165,24 @@ bool read_bezier ( char const* aFileName, Bezier_polygon_set& rSet )
if ( polygons.size() > 1 )
{
for ( Bezier_polygon_vector::const_iterator it = CGAL::successor(polygons.begin())
; it != polygons.end()
; ++ it
)
Bezier_polygon_vector::const_iterator it;
for ( it = CGAL::successor(polygons.begin()); it != polygons.end();
++ it )
pwh.add_hole(*it);
}
if ( is_valid_polygon_with_holes(pwh, rSet.traits() ) )
{
std::cout << " Inserting bezier polygon with holes made of " << polygons.size() << " boundaries into Set." << std::endl ;
std::cout << " Inserting bezier polygon with holes made of "
<< polygons.size() << " boundaries into Set."
<< std::endl ;
rSet.join(pwh) ;
std::cout << " Done." << std::endl ;
}
else
{
std::cout << " **** Bezier polygon wiht holes IS NOT VALID ****" << std::endl ;
std::cout << " **** Bezier polygon wiht holes IS NOT VALID ****"
<< std::endl ;
}
}
@ -192,11 +191,13 @@ bool read_bezier ( char const* aFileName, Bezier_polygon_set& rSet )
}
catch( std::exception const& x )
{
std::cout << "Exception ocurred during reading of bezier polygon set:" << x.what() << std::endl ;
std::cout << "Exception ocurred during reading of bezier polygon set:"
<< x.what() << std::endl ;
}
catch(...)
{
std::cout << "Exception ocurred during reading of bezier polygon set." << std::endl ;
std::cout << "Exception ocurred during reading of bezier polygon set."
<< std::endl ;
}
}
@ -204,11 +205,11 @@ bool read_bezier ( char const* aFileName, Bezier_polygon_set& rSet )
}
// The main program.
int main (int argc, char **argv)
int main (int argc, char* argv[])
{
const char *filename1 = (argc > 1) ? argv[1] : "char_g.bps";
const char *filename2 = (argc > 2) ? argv[2] : "char_m.bps";
const char *bop = (argc > 3) ? argv[3] : "i";
const char* filename1 = (argc > 1) ? argv[1] : "char_g.bps";
const char* filename2 = (argc > 2) ? argv[2] : "char_m.bps";
const char* bop = (argc > 3) ? argv[3] : "i";
// Read the general polygons from the input files.
CGAL::Timer timer;
@ -244,11 +245,12 @@ int main (int argc, char **argv)
}
catch( std::exception const& x )
{
std::cout << "Exception ocurred during the boolean operation:" << x.what() << std::endl ;
std::cout << "Exception ocurred during the boolean operation:" << x.what()
<< std::endl ;
}
catch(...)
{
std::cout << "Exception ocurred during the boolean operation." << std::endl ;
std::cout << "Exception ocurred during the boolean operation." << std::endl;
}
timer.stop();

View File

@ -2,25 +2,23 @@
* Handling circles and linear segments concurrently.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Gps_circle_segment_traits_2.h>
#include <CGAL/General_polygon_set_2.h>
#include <CGAL/Lazy_exact_nt.h>
#include <list>
typedef CGAL::Lazy_exact_nt<Number_type> Lazy_exact_nt;
typedef CGAL::Cartesian<Lazy_exact_nt> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Circle_2 Circle_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Circle_2 Circle_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::General_polygon_set_2<Traits_2> Polygon_set_2;
typedef Traits_2::General_polygon_2 Polygon_2;
typedef Traits_2::General_polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef CGAL::General_polygon_set_2<Traits_2> Polygon_set_2;
typedef Traits_2::General_polygon_2 Polygon_2;
typedef Traits_2::General_polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
// Construct a polygon from a circle.
Polygon_2 construct_polygon (const Circle_2& circle)

View File

@ -26,16 +26,10 @@ typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
// instead of
//typedef CGAL::Cartesian<Rational> Rat_kernel;
//typedef CGAL::Cartesian<Algebraic> Alg_kernel;
//typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel,Nt_traits>
// Conic_traits_2;
// workaround for VC++
struct Rat_kernel : public CGAL::Cartesian<Rational> {};
struct Alg_kernel : public CGAL::Cartesian<Algebraic> {};
struct Conic_traits_2 :
public CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel, Nt_traits> {};
typedef CGAL::Cartesian<Rational> Rat_kernel;
typedef CGAL::Cartesian<Algebraic> Alg_kernel;
typedef CGAL::Arr_conic_traits_2<Rat_kernel, Alg_kernel,Nt_traits>
Conic_traits_2;
typedef CGAL::General_polygon_2<Conic_traits_2> Polygon_2;
typedef CGAL::Gps_traits_2<Conic_traits_2, Polygon_2> Traits_2;

View File

@ -2,31 +2,28 @@
* Connecting a polygon with holes.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/connect_holes.h>
#include <list>
typedef CGAL::Cartesian<Number_type> Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
int main (int argc, char **argv)
int main (int argc, char* argv[])
{
// Get the name of the input file from the command line, or use the default
// pgn_holes.dat file if no command-line parameters are given.
//more data files can be found under test data
//boundary no other connections are made.
const char *filename = (argc > 1) ? argv[1] : "pgn_holes.dat";
const char* filename = (argc > 1) ? argv[1] : "pgn_holes.dat";
std::ifstream input_file (filename);
if (! input_file.is_open())
{
std::cerr << "Failed to open the " << filename <<std::endl;
return (1);
return -1;
}
// Read a polygon with holes from a file.

View File

@ -2,16 +2,12 @@
* Determining whether two triangles intersect.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
// instead of
//typedef CGAL::Cartesian<Number_type> Kernel;
// workaround for VC++
struct Kernel : public CGAL::Cartesian<Number_type> {};
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
#include "print_utils.h"

View File

@ -2,9 +2,7 @@
* Computing the union of a set of circular polygons read from a DXF file.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Lazy_exact_nt.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/General_polygon_set_2.h>
#include <CGAL/Gps_circle_segment_traits_2.h>
#include <CGAL/IO/Dxf_bsop_reader.h>
@ -14,8 +12,7 @@
#include <vector>
#include <cstdlib>
typedef CGAL::Lazy_exact_nt<Number_type> Lazy_exact_nt;
typedef CGAL::Cartesian<Lazy_exact_nt> Kernel;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef Traits_2::Polygon_2 Circ_polygon_2;
typedef Traits_2::Polygon_with_holes_2 Circ_polygon_with_holes_2;
@ -27,20 +24,15 @@ static const int DEFAULT_GROUP_SIZE = 5;
// The command line should be:
// ex_dxf_union [DXF file] [simplify] [group size]
int main (int argc, char **argv)
int main (int argc, char* argv[])
{
// Open the input DXF file.
const char *filename = "test.dxf";
if (argc >= 2)
filename = argv[1];
const char* filename = (argc >= 2) ? argv[1] : "test.dxf";
std::ifstream input_file (filename);
if (! input_file.is_open())
{
std::cerr << "Failed to open the " << filename <<std::endl;
return (1);
return -1;
}
// Read the extra flags.

View File

@ -2,23 +2,18 @@
* Performing a sequence of Boolean set-operations.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Polygon_set_2.h>
#include <list>
// instead of
//typedef CGAL::Cartesian<Number_type> Kernel;
// workaround for VC++
struct Kernel : public CGAL::Cartesian<Number_type> {};
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef CGAL::Polygon_set_2<Kernel> Polygon_set_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef CGAL::Polygon_set_2<Kernel> Polygon_set_2;
#include "print_utils.h"

View File

@ -2,8 +2,7 @@
* Computing the union of a set of circles.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Gps_circle_segment_traits_2.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <CGAL/Lazy_exact_nt.h>
@ -12,17 +11,16 @@
#include <cstdlib>
#include <cmath>
typedef CGAL::Lazy_exact_nt<Number_type> Lazy_exact_nt;
typedef CGAL::Cartesian<Lazy_exact_nt> Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Circle_2 Circle_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef Kernel::Circle_2 Circle_2;
typedef CGAL::Gps_circle_segment_traits_2<Kernel> Traits_2;
typedef CGAL::General_polygon_set_2<Traits_2> Polygon_set_2;
typedef Traits_2::Polygon_2 Polygon_2;
typedef Traits_2::Polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
typedef CGAL::General_polygon_set_2<Traits_2> Polygon_set_2;
typedef Traits_2::Polygon_2 Polygon_2;
typedef Traits_2::Polygon_with_holes_2 Polygon_with_holes_2;
typedef Traits_2::Curve_2 Curve_2;
typedef Traits_2::X_monotone_curve_2 X_monotone_curve_2;
// Construct a polygon from a circle.
Polygon_2 construct_polygon (const Circle_2& circle)
@ -48,7 +46,7 @@ Polygon_2 construct_polygon (const Circle_2& circle)
}
// The main program:
int main (int argc, char * argv[])
int main (int argc, char* argv[])
{
// Read the number of circles from the command line.
unsigned int n_circles = 8;

View File

@ -2,20 +2,15 @@
* Computing the union and the intersection of two simple polygons.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <list>
// instead of
//typedef CGAL::Cartesian<Number_type> Kernel;
// workaround for VC++
struct Kernel : public CGAL::Cartesian<Number_type> {};
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Pwh_list_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Pwh_list_2;
#include "print_utils.h"

View File

@ -2,21 +2,16 @@
* Computing the symmetric difference of two polygons with holes.
*/
#include "bso_rational_nt.h"
#include <CGAL/Cartesian.h>
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <list>
// instead of
//typedef CGAL::Cartesian<Number_type> Kernel;
// workaround for VC++
struct Kernel : public CGAL::Cartesian<Number_type> {};
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Pwh_list_2;
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Polygon_2<Kernel> Polygon_2;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon_with_holes_2;
typedef std::list<Polygon_with_holes_2> Pwh_list_2;
#include "print_utils.h"