Merge pull request #2868 from afabri/CGAL-remove_SCL_SECURE_NO_DEPRECATE-GF

Fixes after removing -D_SCL_SECURE_NO_DEPRECATE
This commit is contained in:
Laurent Rineau 2018-03-07 16:05:48 +01:00
commit a06da39885
11 changed files with 90 additions and 91 deletions

View File

@ -23,6 +23,14 @@
// enable invariant checking
#define CGAL_SEGMENT_TREE_CHECK_INVARIANTS 1
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE 1
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS 1
#endif
#include <CGAL/box_intersection_d.h>
#include <CGAL/Timer.h>
#include <iostream>

View File

@ -1,6 +1,7 @@
#ifndef CGAL_BOX_INTERSECTION_D_UTIL_H
#define CGAL_BOX_INTERSECTION_D_UTIL_H
#include <vector>
#include <algorithm> // for pair
#include <cmath>

View File

@ -3,6 +3,7 @@
#ifndef CGAL_USE_CORE
#include <iostream>
#include <sstream>
int main ()
{
@ -23,6 +24,7 @@ int main ()
#include "read_polygon.h"
#include <list>
typedef CGAL::CORE_algebraic_number_traits Nt_traits;
typedef Nt_traits::Rational Rational;
typedef Nt_traits::Algebraic Algebraic;
@ -80,9 +82,12 @@ int main (int argc, char **argv)
read_polygon (argv[i], pgn);
// Read the offset radius.
int numer, denom;
int numer=0, denom = 0;
std::istringstream iss(argv[i+1]);
char c;
iss >> numer >> c >> denom;
if (sscanf (argv[i+1], "%d/%d", &numer, &denom) != 2)
if (iss.bad())
{
std::cerr << "Invalid radius: " << argv[i+1] << std::endl;
return (1);

View File

@ -31,7 +31,7 @@
#include <CGAL/Nef_3/K3_tree.h>
#include <CGAL/Unique_hash_map.h>
#include <CGAL/Timer.h>
#include <cstring> // for std::strcpy
#include <string>
#ifdef CGAL_NEF3_TRIANGULATE_FACETS
#include <CGAL/Constrained_triangulation_2.h>
@ -70,7 +70,7 @@ class SNC_point_locator
typedef typename SNC_decorator::Decorator_traits Decorator_traits;
typedef typename SNC_decorator::SNC_structure SNC_structure;
protected:
char version_[64];
std::string version_;
// time for construction, point location, ray shooting and intersection test
mutable Timer ct_t, pl_t, rs_t, it_t;
@ -93,7 +93,7 @@ public:
typedef typename Decorator_traits::Halffacet_iterator Halffacet_iterator;
const char* version() { return version_; }
const std::string& version() const { return version_; }
virtual Object_handle locate(const Point_3& p) const = 0;
@ -308,7 +308,7 @@ public:
candidate_provider = new SNC_candidate_provider(W);
#else // CGAL_NEF_LIST_OF_TRIANGLES
CGAL_NEF_TIMER(ct_t.start());
std::strcpy( this->version_, "Point Locator by Spatial Subdivision (tm)");
this->version_ = std::string("Point Locator by Spatial Subdivision (tm)");
#ifdef CGAL_NEF3_TRIANGULATE_FACETS
CGAL_NEF_CLOG(version()<<" (with triangulated facets)");
#else
@ -1275,7 +1275,7 @@ public:
SNC_point_locator_naive() : initialized(false) {}
virtual void initialize(SNC_structure* W) {
CGAL_NEF_TIMER(ct_t.start());
std::strcpy(this->version_, "Naive Point Locator (tm)");
this->version_ = std::string("Naive Point Locator (tm)");
CGAL_NEF_CLOG(version());
CGAL_assertion( W != NULL);
Base::initialize(W);

View File

@ -34,6 +34,7 @@
#include <CGAL/Nef_S2/SM_point_locator.h>
#include <fstream>
#include <cassert>
#include <string>
#include <CGAL/disable_warnings.h>
@ -145,13 +146,10 @@ private:
}
bool does_nef3_equals_file(Nef_polyhedron& N, const char* name) {
char* fullname = new char[std::strlen(datadir)+std::strlen(name)+1];
std::strcpy(fullname, datadir);
std::strcat(fullname, name);
std::string fullname = std::string(datadir) + std::string(name);
std::ofstream out("data/temp.nef3");
out << N;
bool b = are_files_equal("data/temp.nef3",fullname);
delete [] fullname;
bool b = are_files_equal("data/temp.nef3",fullname.c_str());
return b;
}
@ -165,14 +163,11 @@ private:
}
Nef_polyhedron load_nef3(const char* name) {
char* fullname = new char[std::strlen(datadir)+std::strlen(name)+1];
std::strcpy(fullname, datadir);
std::strcat(fullname, name);
std::ifstream input(fullname);
std::string fullname = std::string(datadir) + std::string(name);
std::ifstream input(fullname.c_str());
assert(input.good());
Nef_polyhedron tmp;
input >> tmp;
delete[] fullname;
return tmp;
}

View File

@ -17,6 +17,9 @@ if ( CGAL_FOUND )
# VisualC++ optimization for applications dealing with large data
if (MSVC)
# Quit warning in the lasreader
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
if ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
# Allow Windows 32bit applications to use up to 3GB of RAM
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")

View File

@ -290,7 +290,9 @@ if(CGAL_Qt5_FOUND AND Qt5_FOUND AND OPENGL_FOUND AND QGLVIEWER_FOUND)
include_directories(${LASLIB_INCLUDE_DIR})
include_directories(${LASZIP_INCLUDE_DIR})
add_item(scene_points_with_normal_item Scene_points_with_normal_item.cpp)
if (MSVC)
target_compile_definitions( scene_points_with_normal_item PUBLIC "-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS")
endif()
target_link_libraries( scene_points_with_normal_item PUBLIC ${LASLIB_LIBRARIES})
else()
add_item(scene_points_with_normal_item Scene_points_with_normal_item.cpp)

View File

@ -44,6 +44,7 @@ typename CGAL::internal::Innermost_coefficient_type<T>::Type , 2>::Type
#include <CGAL/ipower.h>
#include <cstdio>
#include <sstream>
#include <string>
#include <CGAL/Polynomial/misc.h>
#include <CGAL/use.h>
@ -1305,7 +1306,7 @@ std::istream& operator >> (std::istream& is, Polynomial<NT>& p) {
template <class NT> inline
void print_maple_monomial(std::ostream& os, const NT& coeff,
const char *var, int expn)
const std::string& var, int expn)
{
if (expn == 0 || coeff != NT(1)) {
os << CGAL::oformat(coeff, Parens_as_product_tag());
@ -1323,24 +1324,22 @@ template <typename Polynomial_d> class Polynomial_traits_d;
template <class NT>
void Polynomial<NT>::output_maple(std::ostream& os) const {
const Polynomial<NT>& p = *this;
const char *varname;
char vnbuf[42];
std::ostringstream oss;
// use variable names x, y, z, w1, w2, w3, ...
if (Polynomial_traits_d<NT>::d < 3) {
static const char *varnames[] = { "x", "y", "z" };
varname = varnames[Polynomial_traits_d<NT>::d];
oss << varnames[Polynomial_traits_d<NT>::d];
} else {
std::sprintf(vnbuf, "w%d", Polynomial_traits_d<NT>::d - 2);
varname = vnbuf;
oss << "w" << Polynomial_traits_d<NT>::d - 2;
}
int i = p.degree();
CGAL::print_maple_monomial(os, p[i], varname, i);
CGAL::print_maple_monomial(os, p[i], oss.str(), i);
while (--i >= 0) {
if (p[i] != NT(0)) {
os << " + ";
CGAL::print_maple_monomial(os, p[i], varname, i);
CGAL::print_maple_monomial(os, p[i], oss.str(), i);
}
}
}

View File

@ -29,8 +29,10 @@
#include <CGAL/basic.h>
#include <CGAL/algorithm.h>
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <boost/format.hpp>
namespace CGAL {
@ -142,24 +144,24 @@ private:
std::string get_entity_handle()
{
char lBuff[64];
sprintf(lBuff,"%5x",mHandle++);
return std::string(lBuff);
std::ostringstream oss;
oss << boost::format("%5x") % mHandle++;
return oss.str();
}
std::string to_str ( int aN )
{
char lBuff[64];
sprintf(lBuff,"%6d",aN);
return std::string(lBuff);
std::ostringstream oss;
oss << boost::format("%6d") % aN;
return oss.str();
}
std::string to_str ( double aN )
{
char lBuff[64];
sprintf(lBuff,"%6.6f",aN);
return std::string(lBuff);
std::ostringstream oss;
oss << boost::format("%6.6f") % aN;
return oss.str();
}
void insert_line ( Line_iterator aPos, std::string aLine )

View File

@ -30,7 +30,8 @@
//== INCLUDES =================================================================
#include <string>
#include <cstdio>
#include <fstream>
#include <sstream>
#include <cstring>
#include <algorithm>
#include <vector>
@ -52,17 +53,14 @@ namespace CGAL {
namespace internal {
// helper function
template <typename T> void read(FILE* in, T& t)
template <typename T> void read(std::istream& in, T& t)
{
std::size_t err = 0;
err = fread(&t, 1, sizeof(t), in);
if(err != 0)
throw std::runtime_error("fread error");
in.read(reinterpret_cast<char*>(&t), sizeof(t));
}
template <typename Point_3>
bool read_off_binary(Surface_mesh<Point_3>& mesh,
FILE* in,
std::istream& in,
const bool has_normals,
const bool has_texcoords)
{
@ -96,7 +94,7 @@ bool read_off_binary(Surface_mesh<Point_3>& mesh,
// read vertices: pos [normal] [color] [texcoord]
for (i=0; i<nV && !feof(in); ++i)
for (i=0; i<nV && in.good(); ++i)
{
// position
internal::read(in, p);
@ -140,7 +138,7 @@ bool read_off_binary(Surface_mesh<Point_3>& mesh,
template <typename Point_3>
bool read_off_ascii(Surface_mesh<Point_3>& mesh,
FILE* in,
std::istream& in,
const bool has_normals,
const bool has_texcoords)
{
@ -151,9 +149,8 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
typedef typename K::Vector_3 Texture_coordinate;
boost::array<double, 3> buffer;
char line[100], *lp;
unsigned int i, j, items, idx;
int nc;
std::string line;
unsigned int i, j, idx;
unsigned int nV, nF, nE;
typename Mesh::Vertex_index v;
@ -164,28 +161,29 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
if (has_normals) normals = mesh.template add_property_map<typename Mesh::Vertex_index, Normal>("v:normal").first;
if (has_texcoords) texcoords = mesh.template add_property_map<typename Mesh::Vertex_index, Texture_coordinate>("v:texcoord").first;
int c;
char c;
do {
c = getc(in);
c = in.get();
if(c == '#'){
fgets(line, 100, in);
getline(in,line);
} else {
ungetc(c,in);
in.putback(c);
break;
}
}while(1);
// #Vertice, #Faces, #Edges
items = fscanf(in, "%d %d %d\n", (int*)&nV, (int*)&nF, (int*)&nE);
in >> nV >> nF >> nE;
getline(in,line); // reads eol
mesh.clear();
mesh.reserve(nV, (std::max)(3*nV, nE), nF);
// read vertices: pos [normal] [color] [texcoord]
for (i=0; i<nV && !feof(in); ++i)
for (i=0; i<nV && in.good(); ++i)
{
// read line
lp = fgets(line, 100, in);
getline(in, line);
if(line[0] == '#') // if the first column is a # we are looking at a comment line
{
--i;
@ -193,28 +191,21 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
}
// position
items = sscanf(lp, "%lf %lf %lf%n", &(buffer[0]), &buffer[1], &buffer[2], &nc);
CGAL_assertion(items==3);
std::istringstream iss(line);
iss >> iformat(buffer[0]) >> iformat(buffer[1]) >> iformat(buffer[2]);
v = mesh.add_vertex(Point_3(buffer[0], buffer[1], buffer[2]));
lp += nc;
// normal
if (has_normals)
{
if (sscanf(lp, "%lf %lf %lf%n", &buffer[0], &buffer[1], &buffer[2], &nc) == 3)
{
normals[v] = Vector_3(buffer[0], buffer[1], buffer[2]);
}
lp += nc;
iss >> iformat(buffer[0]) >> iformat(buffer[1]) >> iformat(buffer[2]);
}
// tex coord
if (has_texcoords)
{
items = sscanf(lp, "%lf %lf%n", &buffer[0], &buffer[1], &nc);
CGAL_assertion(items == 2);
iss >> iformat(buffer[0]) >> iformat(buffer[1]);
texcoords[v] = Vector_3(buffer[0], buffer[1], 0.0);
lp += nc;
}
}
@ -223,7 +214,7 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
for (i=0; i<nF; ++i)
{
// read line
lp = fgets(line, 100, in);
getline(in, line);
if(line[0] == '#') // if the first column is a # we are looking at a comment line
{
--i;
@ -231,18 +222,15 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
}
// #vertices
items = sscanf(lp, "%d%n", (int*)&nV, &nc);
CGAL_assertion(items == 1);
std::istringstream iss(line);
iss >> nV;
vertices.resize(nV);
lp += nc;
// indices
for (j=0; j<nV; ++j)
{
items = sscanf(lp, "%d%n", (int*)&idx, &nc);
CGAL_assertion(items == 1);
iss >> idx;
vertices[j] = typename Mesh::Vertex_index(idx);
lp += nc;
}
if(!mesh.add_face(vertices).is_valid()) {
@ -250,7 +238,6 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
return false;
}
}
CGAL_USE(items);
return true;
}
}
@ -280,7 +267,7 @@ bool read_off_ascii(Surface_mesh<Point_3>& mesh,
template <typename K>
bool read_off(Surface_mesh<K>& mesh, const std::string& filename)
{
char line[100];
std::string line;
bool has_texcoords = false;
bool has_normals = false;
bool has_hcoords = false;
@ -288,25 +275,24 @@ bool read_off(Surface_mesh<K>& mesh, const std::string& filename)
bool is_binary = false;
// open file (in ASCII mode)
FILE* in = std::fopen(filename.c_str(), "r");
std::ifstream in(filename.c_str());
if (!in) return false;
// read header: [ST][C][N][4][n]OFF BINARY
char *c = std::fgets(line, 100, in);
CGAL_assertion(c != NULL);
c = line;
std::getline(in,line);
const char *c = line.c_str();
if (c[0] == 'S' && c[1] == 'T') { has_texcoords = true; c += 2; }
if (c[0] == 'N') { has_normals = true; ++c; }
if (c[0] == '4') { has_hcoords = true; ++c; }
if (c[0] == 'n') { has_dim = true; ++c; }
if (strncmp(c, "OFF", 3) != 0) { std::fclose(in); return false; } // no OFF
if (strncmp(c, "OFF", 3) != 0) { in.close(); return false; } // no OFF
if (strncmp(c+4, "BINARY", 6) == 0) is_binary = true;
// homogeneous coords, and vertex dimension != 3 are not supported
if (has_hcoords || has_dim)
{
std::fclose(in);
in.close();
return false;
}
@ -314,10 +300,9 @@ bool read_off(Surface_mesh<K>& mesh, const std::string& filename)
// if binary: reopen file in binary mode
if (is_binary)
{
std::fclose(in);
in = std::fopen(filename.c_str(), "rb");
c = std::fgets(line, 100, in);
CGAL_assertion(c != NULL);
in.close();
in.open(filename.c_str(), std::ios::binary);
std::getline(in,line);
}
// read as ASCII or binary
@ -325,8 +310,7 @@ bool read_off(Surface_mesh<K>& mesh, const std::string& filename)
internal::read_off_binary(mesh, in, has_normals, has_texcoords) :
internal::read_off_ascii(mesh, in, has_normals, has_texcoords));
std::fclose(in);
in.close();
return ok;
}

View File

@ -343,10 +343,10 @@ int main(int argc, char **argv)
boost::int32_t seed0 = 42, seed1 = 43, seed2 = 42, seed3 = 42;
// You can also pass seeds on the command line.
if (argc > 1) std::sscanf (argv[1], "%d", &seed0);
if (argc > 2) std::sscanf (argv[2], "%d", &seed1);
if (argc > 3) std::sscanf (argv[3], "%d", &seed2);
if (argc > 4) std::sscanf (argv[4], "%d", &seed3);
if (argc > 1) { std::istringstream iss(argv[1]); iss >>seed0; }
if (argc > 2) { std::istringstream iss(argv[2]); iss >>seed1; }
if (argc > 3) { std::istringstream iss(argv[3]); iss >>seed2; }
if (argc > 4) { std::istringstream iss(argv[4]); iss >>seed3; }
Cls T;
point_set points;