General compilation fixes for VC++

This commit is contained in:
Fernando Cacciola 2008-04-08 19:33:11 +00:00
parent 17c33bcd93
commit ac82708815
6 changed files with 187 additions and 205 deletions

View File

@ -38,43 +38,43 @@ struct Visitor
{
++ mCurr ;
if ( Progress )
Progress(mCurr,mTotal);
Progress(mCurr,mTotal);
}
void on_edge_event_created( Vertex_const_handle const& lnode
, Vertex_const_handle const& rnode
) const {}
, Vertex_const_handle const& rnode
) const {}
void on_split_event_created( Vertex_const_handle const& node ) const {}
void on_pseudo_split_event_created( Vertex_const_handle const& lnode
, Vertex_const_handle const& rnode
) const {}
, Vertex_const_handle const& rnode
) const {}
void on_initialization_finished() const {}
void on_propagation_started() const {}
void on_anihiliation_event_processed ( Vertex_const_handle const& node0
, Vertex_const_handle const& node1
) const {}
, Vertex_const_handle const& node1
) const {}
void on_edge_event_processed( Vertex_const_handle const& lseed
, Vertex_const_handle const& rseed
, Vertex_const_handle const& node
) const {}
, Vertex_const_handle const& rseed
, Vertex_const_handle const& node
) const {}
void on_split_event_processed( Vertex_const_handle const& seed
, Vertex_const_handle const& node0
, Vertex_const_handle const& node1
) const {}
, Vertex_const_handle const& node0
, Vertex_const_handle const& node1
) const {}
void on_pseudo_split_event_processed( Vertex_const_handle const& lseed
, Vertex_const_handle const& rseed
, Vertex_const_handle const& node0
, Vertex_const_handle const& node1
) const {}
, Vertex_const_handle const& rseed
, Vertex_const_handle const& node0
, Vertex_const_handle const& node1
) const {}
void on_vertex_processed( Vertex_const_handle const& node ) const
{
@ -82,7 +82,7 @@ struct Visitor
{
++ mCurr ;
if ( Progress )
Progress(mCurr,mTotal);
Progress(mCurr,mTotal);
}
}
@ -119,79 +119,80 @@ typedef CGAL::Bbox_2 Bbox_2;
extern "C"
{
void STRAIGHT_SKELETON_API StraightSkeletonFree(int* numFace_i, double* xf, double* yf)
{
delete [] xf;
delete [] yf;
delete [] numFace_i;
}
int STRAIGHT_SKELETON_API StraightSkeleton( int np
, int* np_i
, double* xp
, double* yp
, int& numFaces
, int& numVertices
, int*& numFace_i
, double*& xf
, double*& yf
, int dumpEPS
, ProgressCallback progress
)
{
int result = 0 ;
numFace_i = NULL ;
xf = yf = NULL ;
try
void __declspec (dllexport) StraightSkeletonFree(int* numFace_i, double* xf, double* yf)
{
double scale = 1.0;
delete [] xf;
delete [] yf;
delete [] numFace_i;
}
SsBuilderTraits traits ;
Visitor visitor(progress) ;
SsBuilder ssb(traits,visitor) ;
int __declspec (dllexport) StraightSkeleton( int np
, int* np_i
, double* xp
, double* yp
, int& numFaces
, int& numVertices
, int*& numFace_i
, double*& xf
, double*& yf
, int dumpEPS
, ProgressCallback progress
)
{
int result = 0 ;
Bbox_2 bbox;
int currentPoint = 0;
for(int i = 0; i < np; i++)
numFace_i = NULL ;
xf = yf = NULL ;
try
{
std::vector<Point_2> points(np_i[i]);
for(int j=0; j < np_i[i]; j++)
double scale = 1.0;
SsBuilderTraits traits ;
Visitor visitor(progress) ;
SsBuilder ssb(traits,visitor) ;
Bbox_2 bbox;
int currentPoint = 0;
for(int i = 0; i < np; i++)
{
Point_2 p(xp[currentPoint], yp[currentPoint]);
if(currentPoint == 0)
bbox = p.bbox() ;
else bbox = bbox + p.bbox();
int s = np_i[i];
std::vector<Point_2> points(s);
for(int j=0; j < s; j++)
{
Point_2 p(xp[currentPoint], yp[currentPoint]);
if(currentPoint == 0)
bbox = p.bbox() ;
else bbox = bbox + p.bbox();
points[j] = p;
++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::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());
}
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());
}
visitor.set_total(currentPoint*2);
visitor.set_total(currentPoint*2);
// Construct the skeleton
boost::shared_ptr<Ss> ss = ssb.construct_skeleton();
// Construct the skeleton
boost::shared_ptr<Ss> ss = ssb.construct_skeleton();
// Proceed only if the skeleton was correctly constructed.
if ( ss )
{
// 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];
@ -200,21 +201,21 @@ int STRAIGHT_SKELETON_API StraightSkeleton( int np
int currentFace = 0;
for(Face_iterator fit = ss->faces_begin(); fit != ss->faces_end(); ++fit)
{
int count = 0;
int count = 0;
Halfedge_handle h = fit->halfedge();
Halfedge_handle done;
done = h;
do
Halfedge_handle done;
done = h;
do
{
count++;
count++;
h = h->next();
} while(h != done);
numVertices += count;
} while(h != done);
numVertices += count;
numFace_i[currentFace] = count;
++currentFace;
numFace_i[currentFace] = count;
++currentFace;
}
// Allocate the x and y array and traverse the faces again
xf = new double[numVertices];
yf = new double[numVertices];
@ -223,97 +224,75 @@ int STRAIGHT_SKELETON_API StraightSkeleton( int np
for(Face_iterator fit = ss->faces_begin(); fit != ss->faces_end(); ++fit)
{
Halfedge_handle h = fit->halfedge();
Halfedge_handle done;
done = h;
do
Halfedge_handle h = fit->halfedge();
Halfedge_handle done;
done = h;
do
{
xf[currentVertex] = h->vertex()->point().x();
yf[currentVertex] = h->vertex()->point().y();
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 firstx = xf[vi] ;
double firsty = yf[vi];
double lastx ;
double lasty ;
for ( int fvi = 0 ; fvi < numFace_i[fi] ; ++ fvi )
{
lastx = xf[vi];
lasty = yf[vi];
++ vi ;
}
std::cout << "face " << fi << " edge: (" << firstx << "," << firsty << ")->(" << lastx << "," << lasty << ")\n" ;
//Face_handle fh = *(ss->faces_begin()+fi);
}
if(dumpEPS)
{
scale = 1000 / (bbox.xmax() - bbox.xmin()) ;
std::ofstream dump("dump.eps");
dump << "%!PS-Adobe-2.0 EPSF-2.0\n%%BoundingBox:" << scale* bbox.xmin()-1 << " " << scale* bbox.ymin()-1 << " " << scale*bbox.xmax()+1 << " " << scale*bbox.ymax()+1 << std::endl;
dump << "%%EndComments\n"
"gsave\n"
"1.0 setlinewidth\n"
"/cont { 0 0 0 setrgbcolor } bind def\n"
"/cont_w { 0.1 setlinewidth } bind def\n"
"/skel { 1 0 0 setrgbcolor } bind def\n"
"/skel_w { 1.0 setlinewidth } bind def\n"
"% stroke - x1 y1 x2 y2 E\n"
"/E {newpath moveto lineto stroke} bind def\n" << std::endl;
std::ofstream dump("dump.eps");
dump << "%!PS-Adobe-2.0 EPSF-2.0\n%%BoundingBox:" << scale* bbox.xmin()-1 << " " << scale* bbox.ymin()-1 << " " << scale*bbox.xmax()+1 << " " << scale*bbox.ymax()+1 << std::endl;
dump << "%%EndComments\n"
"gsave\n"
"1.0 setlinewidth\n"
"/cont { 0 0 0 setrgbcolor } bind def\n"
"/cont_w { 0.1 setlinewidth } bind def\n"
"/skel { 1 0 0 setrgbcolor } bind def\n"
"/skel_w { 1.0 setlinewidth } bind def\n"
"% stroke - x1 y1 x2 y2 E\n"
"/E {newpath moveto lineto stroke} bind def\n" << std::endl;
for(Face_iterator fit = ss->faces_begin(); fit != ss->faces_end(); ++fit)
for(Face_iterator fit = ss->faces_begin(); fit != ss->faces_end(); ++fit)
{
Halfedge_handle h = fit->halfedge();
Halfedge_handle done;
done = h;
do
Halfedge_handle h = fit->halfedge();
Halfedge_handle done;
done = h;
do
{
if(h->is_bisector())
dump << "skel\n";
else dump << "cont\n";
dump << scale* h->vertex()->point().x() << " " << scale*h->vertex()->point().y() << " "
<< scale*h->opposite()->vertex()->point().x() << " "
if(h->is_bisector())
dump << "skel\n";
else dump << "cont\n";
dump << scale* h->vertex()->point().x() << " " << scale*h->vertex()->point().y() << " "
<< scale*h->opposite()->vertex()->point().x() << " "
<< scale*h->opposite()->vertex()->point().y() << " E\n";
h = h->next();
}
h = h->next();
}
while(h != done);
}
}
dump << "grestore\nshowpage" << std::endl;
dump << "grestore\nshowpage" << std::endl;
dump.close();
dump.close();
}
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);
}
}
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 ;
}
return result ;
}
} // extern "C"

View File

@ -1,12 +1,6 @@
#ifndef STRAIGHT_SKELETON_H
#ifndef STRAIGHT_SKELETON_H
#define STRAIGHT_SKELETON_H
#ifdef STRAIGHTSKELETONDLL_EXPORTS
# define STRAIGHT_SKELETON_API __declspec (dllexport)
#else
# define STRAIGHT_SKELETON_API __declspec (dllimport)
#endif
/*! \file StraightSkeleton.h
\brief Functions for computing the straight skeleton of a simple polygon with holes.
@ -46,18 +40,18 @@ typedef void (__stdcall *ProgressCallback) ( int aCurr, int aTotal ) ;
extern "C"
{
int STRAIGHT_SKELETON_API StraightSkeleton( int np
, int* np_i
, double* xp
, double* yp
, int& numFaces
, int& numVertices
, int*& numFace_i
, double*& xf
, double*& yf
, int dumpEPS
, ProgressCallback progress
);
int __declspec (dllexport) StraightSkeleton( int np
, int* np_i
, double* xp
, double* yp
, int& numFaces
, int& numVertices
, int*& numFace_i
, double*& xf
, double*& yf
, int dumpEPS
, ProgressCallback progress
);
/**
@ -67,7 +61,7 @@ int STRAIGHT_SKELETON_API StraightSkeleton( int np
* @param yf is a reference parameter. After the call it holds NULL.
*/
void STRAIGHT_SKELETON_API StraightSkeletonFree(int* numFace_i, double* xf, double* yf );
void __declspec (dllexport) StraightSkeletonFree(int* numFace_i, double* xf, double* yf );
} // extern "C"

View File

@ -1,4 +1,4 @@
// Copyright (c) 2006-2008 Fernando Luis Cacciola Carballal. All rights reserved.
// Copyright (c) 2006 Fernando Luis Cacciola Carballal. All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you may redistribute it under
// the terms of the Q Public License version 1.0.
@ -43,6 +43,12 @@ template<class K>
inline typename Polygon_2<K>::Vertex_const_iterator vertices_end( Polygon_2<K> const& aPoly )
{ return aPoly.vertices_end() ; }
template<class Poly>
inline typename Poly::const_iterator vertices_begin ( boost::shared_ptr<Poly> const& aPoly ) { return aPoly->begin() ; }
template<class Poly>
inline typename Poly::const_iterator vertices_end ( boost::shared_ptr<Poly> const& aPoly ) { return aPoly->end() ; }
}
template<class PointIterator, class HoleIterator, class K>

View File

@ -30,7 +30,7 @@
#include <vector>
#include <fstream>
#include <cstdio>
#include <stdio.h>
CGAL_BEGIN_NAMESPACE
@ -38,7 +38,7 @@ class Dxf_layer
{
public:
Dxf_layer( string aStr ) : mStr(aStr) {}
Dxf_layer( std::string aStr ) : mStr(aStr) {}
std::string str() const { return mStr ; }
@ -55,15 +55,15 @@ public:
typedef Kernel_ Kernel;
// Define the kernel objects.
typedef typename Kernel::FT NT;
typedef typename Kernel::Point_2 Point;
typedef typename Kernel::Segment_2 Segment;
typedef typename Kernel::Ray_2 Ray;
typedef typename Kernel::Line_2 Line;
typedef typename Kernel::Triangle_2 Triangle;
typedef typename Kernel::Iso_rectangle_2 Iso_rectangle;
typedef typename Kernel::Circle_2 Circle;
typedef CGAL::Polygon_2<Kernel> Polygon;
typedef typename Kernel::FT NT;
typedef typename Kernel::Point_2 Point_2;
typedef typename Kernel::Segment_2 Segment_2;
typedef typename Kernel::Ray_2 Ray_2;
typedef typename Kernel::Line_2 Line_2;
typedef typename Kernel::Triangle_2 Triangle_2;
typedef typename Kernel::Iso_rectangle_2 Iso_rectangle_2;
typedef Polygon_2<Kernel> Polygon_2;
typedef typename Kernel::Circle_2 Circle_2;
protected:
@ -106,7 +106,7 @@ public:
* Constructor.
* \param filename The name of the output FIG file.
*/
Dxf_stream ( ostream& out )
Dxf_stream ( std::ostream& out )
:
mWriter (out)
,mDefaultDxfColor (255)
@ -152,7 +152,7 @@ public:
/*!
* Set the current layer.
*/
void set_layer ( string aLayer ) { mLayer = aLayer ; }
void set_layer ( std::string aLayer ) { mLayer = aLayer ; }
/*!
* Set the current color.
@ -196,7 +196,7 @@ public:
/*!
* Write a 2D segment.
*/
void write_segment_2 (const Segment& seg)
void write_segment_2 (const Segment_2& seg)
{
mWriter.add_segment_2( seg.source(), seg.target(), mLayer, mDxfColor ) ;
}
@ -249,7 +249,7 @@ public:
/*!
* Write a 2D (closed) polygon.
*/
void write_polygon (const Polygon& pgn)
void write_polygon (const Polygon_2& pgn)
{
mWriter.add_polyline_2( pgn.begin(), pgn.end(), true, mLayer, mDxfColor ) ;
}
@ -283,7 +283,7 @@ public:
/*!
* Write a line segment.
*/
Dxf_stream& operator<< (const Segment& seg)
Dxf_stream& operator<< (const Segment_2& seg)
{
write_segment_2 (seg);
return (*this);
@ -292,7 +292,7 @@ public:
/*!
* Write a polygon.
*/
Dxf_stream& operator<< (const Polygon& pgn)
Dxf_stream& operator<< (const Polygon_2& pgn)
{
write_polygon_2 (pgn);
return (*this);

View File

@ -25,6 +25,7 @@
#define CGAL_IO_DXF_WRITER_H
#include <CGAL/basic.h>
#include <CGAL/algorithm.h>
#include <iostream>
#include <string>
#include <list>
@ -121,7 +122,7 @@ public:
while ( lCurrVertex != aVerticesEnd )
{
XY_Iterator lNextVertex = ( lCurrVertex == lLastVertex ? lFirstVertex : successor(lCurrVertex) ) ;
XY_Iterator lNextVertex = ( lCurrVertex == lLastVertex ? lFirstVertex : CGAL::successor(lCurrVertex) ) ;
add_segment_2 ( *lCurrVertex, *lNextVertex, aLayer, aColor ) ;

View File

@ -49,7 +49,8 @@ inline CORE::BigFloat MP_Float_to_BigFloat( MP_Float const& b )
d += d_exp * CORE::BigFloat(b.of_exp(i));
}
return d * CORE::BigFloat::exp2(exp * log_limb);
// The cast is necessary for SunPro.
return d * CORE::BigFloat::exp2(static_cast<int>(exp * log_limb));
}
#endif
@ -63,7 +64,7 @@ inline MP_Float inexact_sqrt( MP_Float const& n )
{
CGAL_precondition(n > 0);
#ifdef CGAL_USE_CORE
#ifdef CGAL_USE_CORE
CORE::BigFloat nn = MP_Float_to_BigFloat(n);
CORE::BigFloat s = CORE::sqrt(nn);
@ -89,13 +90,15 @@ inline Quotient<MP_Float> inexact_sqrt( Quotient<MP_Float> const& q )
return Quotient<MP_Float>(CGAL_SS_i::inexact_sqrt(q.numerator()*q.denominator()), q.denominator() );
}
inline Lazy_exact_nt<Gmpq> inexact_sqrt( Lazy_exact_nt<Gmpq> const& n )
template<class NT>
inline Lazy_exact_nt<NT> inexact_sqrt( Lazy_exact_nt<NT> const& n )
{
#ifdef CGAL_USE_CORE
#ifdef CGAL_USE_CORE
CORE::BigFloat nn = CGAL::to_double(n) ;
CORE::BigFloat s = CORE::sqrt(nn);
return Lazy_exact_nt<Gmpq>(s.doubleValue());
return Lazy_exact_nt<NT>(s.doubleValue());
#else
@ -108,12 +111,11 @@ inline Lazy_exact_nt<Gmpq> inexact_sqrt( Lazy_exact_nt<Gmpq> const& n )
double s = CGAL_NTS sqrt(nn);
return Lazy_exact_nt<Gmpq>(s);
return Lazy_exact_nt<NT>(s);
#endif
}
// Given an oriented 2D straight line segment 'e', computes the normalized coefficients (a,b,c) of the
// supporting line.
// POSTCONDITION: [a,b] is the leftward normal _unit_ (a<>+b<>=1) vector.