- some small fixes

git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@714 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
Isaak Lim
2012-09-28 13:15:38 +00:00
parent e0ed6ad954
commit 0f5235c28e
2 changed files with 20 additions and 20 deletions

View File

@@ -4,10 +4,10 @@
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org * * www.openmesh.org *
* * * *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
* This file is part of OpenMesh. * * This file is part of OpenMesh. *
* * * *
* OpenMesh is free software: you can redistribute it and/or modify * * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of * * published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the * * the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, * * License along with OpenMesh. If not, *
* see <http://www.gnu.org/licenses/>. * * see <http://www.gnu.org/licenses/>. *
* * * *
\*===========================================================================*/ \*===========================================================================*/
/*===========================================================================*\ /*===========================================================================*\
* * * *
* $Revision: 362 $ * * $Revision: 362 $ *
* $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ * * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ *
* * * *
@@ -52,6 +52,7 @@
#include <OpenMesh/Core/Utils/RandomNumberGenerator.hh> #include <OpenMesh/Core/Utils/RandomNumberGenerator.hh>
#include <cstdlib>
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
@@ -68,13 +69,13 @@ RandomNumberGenerator::RandomNumberGenerator(const double _resolution) :
maxNum_(RAND_MAX) maxNum_(RAND_MAX)
{ {
double tmp = resolution_; double tmp = resolution_;
while (tmp > (double(RAND_MAX) + 1) ) { while (tmp > (double(RAND_MAX) + 1.0) ) {
iterations_++; iterations_++;
tmp /= (double(RAND_MAX) + 1); tmp /= (double(RAND_MAX) + 1.0);
} }
for ( unsigned int i = 0 ; i < iterations_ - 1; ++i ) { for ( unsigned int i = 0 ; i < iterations_ - 1; ++i ) {
maxNum_ *= (RAND_MAX + 1); maxNum_ *= (RAND_MAX + 1.0);
} }
} }
@@ -83,13 +84,13 @@ RandomNumberGenerator::RandomNumberGenerator(const double _resolution) :
double RandomNumberGenerator::getRand() const { double RandomNumberGenerator::getRand() const {
double randNum = 0.0; double randNum = 0.0;
for ( unsigned int i = 0 ; i < iterations_; ++i ) { for ( unsigned int i = 0 ; i < iterations_; ++i ) {
randNum *= (RAND_MAX + 1); randNum *= (RAND_MAX + 1.0);
randNum += rand(); randNum += rand();
} }
return randNum / maxNum_; return randNum / maxNum_;
} }
//============================================================================= //=============================================================================
} // namespace OpenMesh } // namespace OpenMesh
//============================================================================= //=============================================================================

View File

@@ -4,10 +4,10 @@
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openmesh.org * * www.openmesh.org *
* * * *
*---------------------------------------------------------------------------* *---------------------------------------------------------------------------*
* This file is part of OpenMesh. * * This file is part of OpenMesh. *
* * * *
* OpenMesh is free software: you can redistribute it and/or modify * * OpenMesh is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of * * published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the * * the License, or (at your option) any later version with the *
@@ -30,10 +30,10 @@
* License along with OpenMesh. If not, * * License along with OpenMesh. If not, *
* see <http://www.gnu.org/licenses/>. * * see <http://www.gnu.org/licenses/>. *
* * * *
\*===========================================================================*/ \*===========================================================================*/
/*===========================================================================*\ /*===========================================================================*\
* * * *
* $Revision: 693 $ * * $Revision: 693 $ *
* $Date: 2012-09-23 16:25:16 +0200 (So, 23 Sep 2012) $ * * $Date: 2012-09-23 16:25:16 +0200 (So, 23 Sep 2012) $ *
* * * *
@@ -56,7 +56,6 @@
#include <OpenMesh/Core/System/config.h> #include <OpenMesh/Core/System/config.h>
#include <iostream>
//== NAMESPACES =============================================================== //== NAMESPACES ===============================================================
@@ -72,19 +71,19 @@ namespace OpenMesh {
*/ */
class OPENMESHDLLEXPORT RandomNumberGenerator class OPENMESHDLLEXPORT RandomNumberGenerator
{ {
public: public:
/** \brief Constructor /** \brief Constructor
* *
* @param _resolution specifies the desired resolution for the random number generated * @param _resolution specifies the desired resolution for the random number generated
*/ */
RandomNumberGenerator(const double _resolution); RandomNumberGenerator(const double _resolution);
/// returns a random double between 0.0 and 1.0 with a garantueed resolution /// returns a random double between 0.0 and 1.0 with a garantueed resolution
double getRand() const; double getRand() const;
private: private:
/// desired resolution /// desired resolution
const double resolution_; const double resolution_;