Skip to content

Commit

Permalink
[nV] 解决Linux/gcc下各种编译警告
Browse files Browse the repository at this point in the history
  • Loading branch information
baritono committed Nov 10, 2012
1 parent 687f6e7 commit 30527f1
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 115 deletions.
1 change: 1 addition & 0 deletions CMake/PCHSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp
# ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use
# ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp
# TODO: add support for clang

IF(CMAKE_COMPILER_IS_GNUCXX)

Expand Down
49 changes: 19 additions & 30 deletions Include/mU/Var.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,40 +56,29 @@ using std::flush;
}

#ifdef _MSC_VER
#include <hash_set>
#include <hash_map>
#pragma comment(lib,"gmp")
#else
#include <ext/hash_set>
#include <ext/hash_map>
namespace __gnu_cxx {
template <>
struct hash<mU::Var>
{
size_t operator()(const mU::Var &x) const
{
return (size_t)x;
}
};
template <>
struct hash<std::string>
#endif

#include <boost/unordered_set.hpp>
#include <boost/unordered_map.hpp>

inline std::size_t hash_value(const mU::Var &x)
{
size_t operator()(const std::string &x) const
{
return __stl_hash_string(x.c_str());
}
};
template <>
struct hash<std::wstring>
return reinterpret_cast<std::size_t>(x);
}

namespace stdext
{
size_t operator()(const std::wstring &x) const
{
return __stl_hash_string((const char*)x.c_str());
}
};
template<typename T>
class hash_set : public boost::unordered_set<T>
{
};

template<typename TKey, typename TValue>
class hash_map : public boost::unordered_map<TKey, TValue>
{
};
}
namespace stdext = __gnu_cxx;
#endif

#undef DLL
#ifdef _WIN32
Expand Down
3 changes: 3 additions & 0 deletions Include/nV/Graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ namespace nV {

namespace Graphics {

#define MIN_GRAPHSCALE_MINIMUM_CURVE 0.01
#define MIN_GRAPHSCALE_MINIMUM_SURFACE 0.1

#define HUE_HUEBASIC 67
#define HUE_SBASIC 0.6
#define HUE_BBASIC 0.7
Expand Down
6 changes: 3 additions & 3 deletions nVGraphics/CommonCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ namespace nV{
while (i < lineStrip->vert.size() - 1) {
double dis = std::sqrt(((lineStrip->vert[i+1]->x - lineStrip->vert[i]->x) / spx) * ((lineStrip->vert[i+1]->x - lineStrip->vert[i]->x) / spx) + ((lineStrip->vert[i+1]->y - lineStrip->vert[i]->y) / spy) * ((lineStrip->vert[i+1]->y - lineStrip->vert[i]->y) / spy));
double disx=lineStrip->vert[i+1]->x - lineStrip->vert[i]->x;
if (dis < MIN_DELTA_DIS || std::abs(disx)<=MIN_X_DIS) {
if (dis < MIN_DELTA_DIS_COMMON_CURVE || std::abs(disx)<=MIN_X_DIS) {
i++;
derivative = f->getDerivative(lineStrip->vert[i]->x, dx);
if(!isNaN(derivative)) {
Expand All @@ -91,7 +91,7 @@ namespace nV{
netk2 = MAX_DERIVATIVE;
}
double dangle = std::acos((1 + netk1 * netk2) / std::sqrt(1 + netk1 * netk1) / std::sqrt(1 + netk2 * netk2));
if (dangle > ADD_POINT_ANGLE) { //need to add points
if (dangle > ADD_POINT_ANGLE_COMMON_CURVE) { //need to add points
double x = (lineStrip->vert[i]->x + lineStrip->vert[i+1]->x) / 2;
double y = f->getSingleData(x);
if(!isNaN(y)) {
Expand All @@ -117,7 +117,7 @@ namespace nV{
double disx1=std::abs(x - lineStrip->vert[i]->x);
double disx2=std::abs(x - lineStrip->vert[i+1]->x);

if (((netk3 < netk1 && netk3 < netk2) || (netk3 > netk1 && netk3 > netk2)) && (dis1>MIN_DELTA_DIS&&dis2>MIN_DELTA_DIS) && (disx1>MIN_X_DIS&&disx2>MIN_X_DIS)) {
if (((netk3 < netk1 && netk3 < netk2) || (netk3 > netk1 && netk3 > netk2)) && (dis1>MIN_DELTA_DIS_COMMON_CURVE&&dis2>MIN_DELTA_DIS_COMMON_CURVE) && (disx1>MIN_X_DIS&&disx2>MIN_X_DIS)) {
double y = f->getSingleData(x);
if(!isNaN(y)) {
lineStrip->vert.add(i + 1, new Point2d(x, y));
Expand Down
4 changes: 2 additions & 2 deletions nVGraphics/CommonCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@



#define ADD_POINT_ANGLE 0.05
#define MIN_DELTA_DIS 0.001
#define ADD_POINT_ANGLE_COMMON_CURVE ADD_POINT_ANGLE_CURVE
#define MIN_DELTA_DIS_COMMON_CURVE MIN_DELTA_DIS_CURVE
#define MIN_X_DIS 0.001
#define MAX_DERIVATIVE 20

Expand Down
3 changes: 1 addition & 2 deletions nVGraphics/CommonCurveWithPlotRange.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ namespace nV {
#define MAX_DERIVATIVE 20
#define MAX_GRAPHSCALE 3
#define MIN_GRAPHSCALE 0.1
#define MIN_GRAPHSCALE_MINIMUM 0.01

class CommonCurveWithPlotRange : public CommonCurve {

Expand All @@ -30,4 +29,4 @@ namespace nV {
double getPointOnRangeFromRight(double x1, double x2, int depth);
};
}
}
}
4 changes: 2 additions & 2 deletions nVGraphics/Curve.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace nV {
namespace Graphics {
#define ADD_POINT_ANGLE_CURVE 0.05
#define MIN_DELTA_DIS 0.001
#define MIN_DELTA_DIS_CURVE 0.001

typedef struct {
double x;
Expand Down Expand Up @@ -70,4 +70,4 @@ namespace nV {
Domains.clear();
}
}
}
}
6 changes: 3 additions & 3 deletions nVGraphics/Curve3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

namespace nV {
namespace Graphics {
#define ADD_POINT_ANGLE_3D 0.05
#define MIN_DELTA_DIS_3D 0.001
#define ADD_POINT_ANGLE_CURVE_3D 0.05
#define MIN_DELTA_DIS_CURVE_3D 0.001

class Curve3D {

Expand All @@ -18,4 +18,4 @@ namespace nV {
~Curve3D();
};
}
}
}
10 changes: 5 additions & 5 deletions nVGraphics/DiscretePlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace nV {
namespace Graphics {
DiscretePlot::DiscretePlot(Kernel& k, const Tuple& cmd) : k(k)
{
filling=FILL_AXIS;
filling=FILL_AXIS_DISCRETE;
//filling = FILL_NULL;
colorFunctionSet=false;
joined=false;
Expand Down Expand Up @@ -593,15 +593,15 @@ void DiscretePlot::setRule(var title, var rule)
fillcur1 = toD(N(k, k.eval(rule.tuple()[1])).object());
fillcur2 = toD(N(k, k.eval(rule.tuple()[2])).object());
} else if (title == SYS(FillToAxis)) {
filling = FILL_AXIS;
filling = FILL_AXIS_DISCRETE;
fillcur1 = toD(N(k, k.eval(rule.tuple()[1])).object());
} else if(title==SYS(NoFilling))
{
// rule.print();
if(rule==SYS(True))
filling=FILL_NULL;
else
filling=FILL_AXIS;
filling=FILL_AXIS_DISCRETE;
}else if (title == SYS(ColorFunction)) { //has color function
colorFunctionSet = true;
var fun = rule;
Expand Down Expand Up @@ -706,7 +706,7 @@ void DiscretePlot::makePointList( )
}
spy = ymax - ymin;
graphScale = spy / spx;
if(graphScale < MIN_GRAPHSCALE_MINIMUM) {
if(graphScale < MIN_GRAPHSCALE_MINIMUM_CURVE) {
break;
}
if(count >= MAX_DELETE_AMOUNT) {
Expand Down Expand Up @@ -751,4 +751,4 @@ void DiscretePlot::makePointList( )
}
}
}
}
}
6 changes: 3 additions & 3 deletions nVGraphics/DiscretePlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace nV {
namespace Graphics {
#define FILL_NULL 0
#define FILL_AXIS 2
#define FILL_AXIS_DISCRETE 2
#define FILL_CURVE 1
#define MAX_DERIVATIVE 20
#define MIN_STEP 0.00000001
Expand All @@ -15,7 +15,7 @@ namespace nV {
#define MAX_GRAPHSCALE 3
#define MIN_GRAPHSCALE 0.1
#define MAX_DELETE_AMOUNT 5
#define MIN_GRAPHSCALE_MINIMUM 0.01

class DiscretePlot : public GraphicsMaker2D {

private:
Expand Down Expand Up @@ -59,4 +59,4 @@ class DiscretePlot : public GraphicsMaker2D {
void setRule(var title, var rule);
};
}
}
}
14 changes: 7 additions & 7 deletions nVGraphics/ImplicitCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ namespace nV {
spy = ymax - ymin;
m_start.x = (xmax + xmin) / 2;
m_start.y = (ymax + ymin) / 2;
sizex = spx / CUBE_NUM;
sizey = spy / CUBE_NUM;
m_bounds = (CUBE_NUM - 1) / 2;
sizex = spx / CUBE_NUM_CURVE;
sizey = spy / CUBE_NUM_CURVE;
m_bounds = (CUBE_NUM_CURVE - 1) / 2;
/* allocate hash tables and build cube polygon table: */
m_centers = new CENTERLIST*[HASHSIZE*2];
for (int i = 0; i < HASHSIZE*2; i++) {
Expand Down Expand Up @@ -47,9 +47,9 @@ namespace nV {
/* test six face directions, maybe add to stack: */
//
testface(c.i - 1, c.j, &c, _L, LB, LT);
testface(c.i + 1, c.j, &c, _R, RB, RT);
testface(c.i, c.j - 1, &c, _B, LB, RB);
testface(c.i, c.j + 1, &c, _T, LT, RT);
testface(c.i + 1, c.j, &c, _R, RB_CURVE, RT_CURVE);
testface(c.i, c.j - 1, &c, _B, LB, RB_CURVE);
testface(c.i, c.j + 1, &c, _T, LT, RT_CURVE);
}
}

Expand Down Expand Up @@ -299,7 +299,7 @@ namespace nV {
while (1) {
p->x = 0.5 * (pos.x + neg.x);
p->y = 0.5 * (pos.y + neg.y);
if (i++ == RES) return;
if (i++ == RES_CURVE) return;
if ((getFunctionValueSafely(f, p->x, p->y)) > 0.0) {
pos.x = p->x;
pos.y = p->y;
Expand Down
10 changes: 5 additions & 5 deletions nVGraphics/ImplicitCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

namespace nV {
namespace Graphics {
#define RES 30 /* # converge iterations */
#define RES_CURVE 30 /* # converge iterations */
#define _L 0 /* left direction: -x, -i */
#define _R 1 /* right direction: +x, +i */
#define _B 2 /* bottom direction: -y, -j */
#define _T 3 /* top direction: +y, +j */
#define LB 0 /* left bottom corner */
#define LT 1 /* left top corner */
#define RB 2 /* right bottom corner */
#define RT 3 /* right top corner */
#define RB_CURVE 2 /* right bottom corner */
#define RT_CURVE 3 /* right top corner */

#define RAND() ((rand()&32767)/32767.) /* random number between 0 and 1 */
#define HASHBIT (5)
Expand All @@ -29,7 +29,7 @@ namespace nV {
#define BE 2 /* bottom edge */
#define TE 3 /* top edge */

#define CUBE_NUM 29
#define CUBE_NUM_CURVE 29

double getFunctionValueSafely(F2P *f_s, double x, double y);

Expand Down Expand Up @@ -113,4 +113,4 @@ namespace nV {
};

}
}
}
24 changes: 12 additions & 12 deletions nVGraphics/ImplicitSurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace nV {
namespace Graphics {
/* edge: LB, LT, LN, LF, RB, RT, RN, RF, BN, BF, TN, TF */
/* edge: LB, LT, LN, LF, RB_SURFACE, RT_SURFACE, RN, RF, BN, BF, TN, TF */
//static int corner1[12] = {LBN,LTN,LBN,LBF,RBN,RTN,RBN,RBF,LBN,LBF,LTN,LTF};
//static int corner2[12] = {LBF,LTF,LTN,LTF,RBF,RTF,RTN,RTF,RBN,RBF,RTN,RTF};
static int leftface[12] = {_B, _L, _L, _F, _R, _T, _N, _R, _N, _B, _T, _F};
Expand All @@ -20,10 +20,10 @@ ImplicitSurface::ImplicitSurface(F3P* f3p, double xmin, double xmax, double ymin
m_start.x = (xmax + xmin) / 2;
m_start.y = (ymax + ymin) / 2;
m_start.z = (zmax + zmin) / 2;
sizex = spx / CUBE_NUM;
sizey = spy / CUBE_NUM;
sizez = spz / CUBE_NUM;
m_bounds = (CUBE_NUM - 1) / 2;
sizex = spx / CUBE_NUM_SURFACE;
sizey = spy / CUBE_NUM_SURFACE;
sizez = spz / CUBE_NUM_SURFACE;
m_bounds = (CUBE_NUM_SURFACE - 1) / 2;
/* allocate hash tables and build cube polygon table: */
m_centers = new CENTERLIST*[HASHSIZE*2];
for (int i = 0; i < HASHSIZE*2; i++) {
Expand Down Expand Up @@ -393,22 +393,22 @@ int ImplicitSurface::nextcwedge (int edge, int face) {
return (face == _L) ? LB : TN;
case LF:
return (face == _L) ? LT : BF;
case RB:
case RB_SURFACE:
return (face == _R) ? RN : BF;
case RT:
case RT_SURFACE:
return (face == _R) ? RF : TN;
case RN:
return (face == _R) ? RT : BN;
return (face == _R) ? RT_SURFACE : BN;
case RF:
return (face == _R) ? RB : TF;
return (face == _R) ? RB_SURFACE : TF;
case BN:
return (face == _B) ? RB : LN;
return (face == _B) ? RB_SURFACE : LN;
case BF:
return (face == _B) ? LB : RF;
case TN:
return (face == _T) ? LT : RN;
case TF:
return (face == _T) ? RT : LF;
return (face == _T) ? RT_SURFACE : LF;
}
}

Expand Down Expand Up @@ -471,7 +471,7 @@ void ImplicitSurface::converge (Point3d *p1, Point3d *p2, double v, Point3d *p)
p->x = 0.5 * (pos.x + neg.x);
p->y = 0.5 * (pos.y + neg.y);
p->z = 0.5 * (pos.z + neg.z);
if (i++ == RES) return;
if (i++ == RES_SURFACE) return;
if ((getFunctionValueSafely(f, p->x, p->y, p->z)) > 0.0) {
pos.x = p->x;
pos.y = p->y;
Expand Down
Loading

0 comments on commit 30527f1

Please sign in to comment.