Merge pull request #20496 from hyarion/refactor/cppify-constants
This commit is contained in:
+5
-7
@@ -33,10 +33,6 @@
|
||||
|
||||
#include "Datums.h"
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
using namespace App;
|
||||
|
||||
PROPERTY_SOURCE(App::DatumElement, App::GeoFeature)
|
||||
@@ -243,14 +239,16 @@ App::DocumentObjectExecReturn* LocalCoordinateSystem::execute()
|
||||
|
||||
const std::vector<LocalCoordinateSystem::SetupData>& LocalCoordinateSystem::getSetupData()
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
static const std::vector<SetupData> setupData = {
|
||||
// clang-format off
|
||||
{App::Line::getClassTypeId(), AxisRoles[0], tr("X-axis"), Base::Rotation()},
|
||||
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
|
||||
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation(Base::Vector3d(1,-1, 1), M_PI * 2 / 3)},
|
||||
{App::Line::getClassTypeId(), AxisRoles[1], tr("Y-axis"), Base::Rotation(Base::Vector3d(1, 1, 1), pi * 2 / 3)},
|
||||
{App::Line::getClassTypeId(), AxisRoles[2], tr("Z-axis"), Base::Rotation(Base::Vector3d(1,-1, 1), pi * 2 / 3)},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[0], tr("XY-plane"), Base::Rotation()},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[1], tr("XZ-plane"), Base::Rotation(1.0, 0.0, 0.0, 1.0)},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[2], tr("YZ-plane"), Base::Rotation(Base::Vector3d(1, 1, 1), M_PI * 2 / 3)},
|
||||
{App::Plane::getClassTypeId(), PlaneRoles[2], tr("YZ-plane"), Base::Rotation(Base::Vector3d(1, 1, 1), pi * 2 / 3)},
|
||||
{App::Point::getClassTypeId(), PointRoles[0], tr("Origin"), Base::Rotation()}
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
+16
-25
@@ -34,6 +34,8 @@
|
||||
#include <boost/math/special_functions/round.hpp>
|
||||
#include <boost/math/special_functions/trunc.hpp>
|
||||
|
||||
#include <numbers>
|
||||
#include <limits>
|
||||
#include <sstream>
|
||||
#include <stack>
|
||||
#include <string>
|
||||
@@ -57,19 +59,6 @@ using namespace App;
|
||||
|
||||
FC_LOG_LEVEL_INIT("Expression", true, true)
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
#ifndef M_E
|
||||
#define M_E 2.71828182845904523536
|
||||
#endif
|
||||
#ifndef DOUBLE_MAX
|
||||
# define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
#ifndef DOUBLE_MIN
|
||||
# define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define strtoll _strtoi64
|
||||
#pragma warning(disable : 4003)
|
||||
@@ -331,22 +320,22 @@ static inline int essentiallyInteger(double a, long &l, int &i) {
|
||||
double intpart;
|
||||
if (std::modf(a,&intpart) == 0.0) {
|
||||
if (intpart<0.0) {
|
||||
if (intpart >= INT_MIN) {
|
||||
if (intpart >= std::numeric_limits<int>::min()) {
|
||||
i = static_cast<int>(intpart);
|
||||
l = i;
|
||||
return 1;
|
||||
}
|
||||
if (intpart >= LONG_MIN) {
|
||||
if (intpart >= std::numeric_limits<long>::min()) {
|
||||
l = static_cast<long>(intpart);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if (intpart <= INT_MAX) {
|
||||
else if (intpart <= std::numeric_limits<int>::max()) {
|
||||
i = static_cast<int>(intpart);
|
||||
l = i;
|
||||
return 1;
|
||||
}
|
||||
else if (intpart <= static_cast<double>(LONG_MAX)) {
|
||||
else if (intpart <= static_cast<double>(std::numeric_limits<long>::max())) {
|
||||
l = static_cast<int>(intpart);
|
||||
return 2;
|
||||
}
|
||||
@@ -358,12 +347,12 @@ static inline bool essentiallyInteger(double a, long &l) {
|
||||
double intpart;
|
||||
if (std::modf(a,&intpart) == 0.0) {
|
||||
if (intpart<0.0) {
|
||||
if (intpart >= LONG_MIN) {
|
||||
if (intpart >= std::numeric_limits<long>::min()) {
|
||||
l = static_cast<long>(intpart);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (intpart <= static_cast<double>(LONG_MAX)) {
|
||||
else if (intpart <= static_cast<double>(std::numeric_limits<long>::max())) {
|
||||
l = static_cast<long>(intpart);
|
||||
return true;
|
||||
}
|
||||
@@ -2145,6 +2134,8 @@ Base::Vector3d FunctionExpression::extractVectorArgument(
|
||||
|
||||
Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std::vector<Expression*> &args)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if(!expr || !expr->getOwner())
|
||||
_EXPR_THROW("Invalid owner.", expr);
|
||||
|
||||
@@ -2181,7 +2172,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
Py::Object pyobj = args[0]->getPyValue();
|
||||
if (PyObject_TypeCheck(pyobj.ptr(), &Base::MatrixPy::Type)) {
|
||||
auto m = static_cast<Base::MatrixPy*>(pyobj.ptr())->value();
|
||||
if (fabs(m.determinant()) <= DBL_EPSILON)
|
||||
if (fabs(m.determinant()) <= std::numeric_limits<double>::epsilon())
|
||||
_EXPR_THROW("Cannot invert singular matrix.", expr);
|
||||
m.inverseGauss();
|
||||
return Py::asObject(new Base::MatrixPy(m));
|
||||
@@ -2222,7 +2213,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
|
||||
Rotation rotation = Base::Rotation(
|
||||
Vector3d(static_cast<double>(f == MROTATEX), static_cast<double>(f == MROTATEY), static_cast<double>(f == MROTATEZ)),
|
||||
rotationAngle.getValue() * M_PI / 180.0);
|
||||
rotationAngle.getValue() * pi / 180.0);
|
||||
Base::Matrix4D rotationMatrix;
|
||||
rotation.getValue(rotationMatrix);
|
||||
|
||||
@@ -2361,7 +2352,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
|
||||
switch (f) {
|
||||
case VANGLE:
|
||||
return Py::asObject(new QuantityPy(new Quantity(vector1.GetAngle(vector2) * 180 / M_PI, Unit::Angle)));
|
||||
return Py::asObject(new QuantityPy(new Quantity(vector1.GetAngle(vector2) * 180 / pi, Unit::Angle)));
|
||||
case VCROSS:
|
||||
return Py::asObject(new Base::VectorPy(vector1.Cross(vector2)));
|
||||
case VDOT:
|
||||
@@ -2420,7 +2411,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
_EXPR_THROW("Unit must be either empty or an angle.", expr);
|
||||
|
||||
// Convert value to radians
|
||||
value *= M_PI / 180.0;
|
||||
value *= pi / 180.0;
|
||||
unit = Unit();
|
||||
break;
|
||||
case ACOS:
|
||||
@@ -2429,7 +2420,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
if (!v1.isDimensionless())
|
||||
_EXPR_THROW("Unit must be empty.", expr);
|
||||
unit = Unit::Angle;
|
||||
scaler = 180.0 / M_PI;
|
||||
scaler = 180.0 / pi;
|
||||
break;
|
||||
case EXP:
|
||||
case LOG:
|
||||
@@ -2461,7 +2452,7 @@ Py::Object FunctionExpression::evaluate(const Expression *expr, int f, const std
|
||||
if (v1.getUnit() != v2.getUnit())
|
||||
_EXPR_THROW("Units must be equal.",expr);
|
||||
unit = Unit::Angle;
|
||||
scaler = 180.0 / M_PI;
|
||||
scaler = 180.0 / pi;
|
||||
break;
|
||||
case MOD:
|
||||
if (e2.isNone())
|
||||
|
||||
@@ -341,15 +341,15 @@ EXPO [eE][-+]?[0-9]+
|
||||
{DIGIT}+{EXPO} COUNTCHARS; yylval.fvalue = num_change(yytext,',','.'); return yylval.fvalue == 1 ? ONE : NUM;
|
||||
{DIGIT}+ { COUNTCHARS;
|
||||
yylval.ivalue = strtoll( yytext, NULL, 10 );
|
||||
if (yylval.ivalue == LLONG_MIN)
|
||||
if (yylval.ivalue == std::numeric_limits<long long>::min())
|
||||
throw Base::UnderflowError("Integer underflow");
|
||||
else if (yylval.ivalue == LLONG_MAX)
|
||||
else if (yylval.ivalue == std::numeric_limits<long long>::max())
|
||||
throw Base::OverflowError("Integer overflow");
|
||||
if (yylval.ivalue == 1) { yylval.fvalue = 1; return ONE; } else return INTEGER;
|
||||
}
|
||||
|
||||
"pi" COUNTCHARS; yylval.constant.fvalue = M_PI; yylval.constant.name = "pi"; return CONSTANT; // constant pi
|
||||
"e" COUNTCHARS; yylval.constant.fvalue = M_E; yylval.constant.name = "e"; return CONSTANT; // constant e
|
||||
"pi" COUNTCHARS; yylval.constant.fvalue = std::numbers::pi; yylval.constant.name = "pi"; return CONSTANT; // constant pi
|
||||
"e" COUNTCHARS; yylval.constant.fvalue = std::numbers::e; yylval.constant.name = "e"; return CONSTANT; // constant e
|
||||
|
||||
"None" COUNTCHARS; yylval.constant.fvalue = 0; yylval.constant.name = "None"; return CONSTANT;
|
||||
"True" COUNTCHARS; yylval.constant.fvalue = 1; yylval.constant.name = "True"; return CONSTANT;
|
||||
|
||||
+2
-1
@@ -2624,7 +2624,8 @@ Link::Link()
|
||||
{
|
||||
LINK_PROPS_ADD(LINK_PARAMS_LINK);
|
||||
LinkExtension::initExtension(this);
|
||||
static const PropertyIntegerConstraint::Constraints s_constraints = {0, INT_MAX, 1};
|
||||
static const PropertyIntegerConstraint::Constraints s_constraints = {
|
||||
0, std::numeric_limits<int>::max(), 1};
|
||||
ElementCount.setConstraints(&s_constraints);
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ ObjectIdentifier::ObjectIdentifier(const App::PropertyContainer* _owner,
|
||||
}
|
||||
if (!property.empty()) {
|
||||
addComponent(SimpleComponent(property));
|
||||
if (index != INT_MAX) {
|
||||
if (index != std::numeric_limits<int>::max()) {
|
||||
addComponent(ArrayComponent(index));
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ ObjectIdentifier::ObjectIdentifier(const Property& prop, int index)
|
||||
setDocumentObjectName(docObj);
|
||||
|
||||
addComponent(SimpleComponent(String(prop.getName())));
|
||||
if (index != INT_MAX) {
|
||||
if (index != std::numeric_limits<int>::max()) {
|
||||
addComponent(ArrayComponent(index));
|
||||
}
|
||||
}
|
||||
@@ -703,8 +703,9 @@ Py::Object ObjectIdentifier::Component::get(const Py::Object& pyobj) const
|
||||
}
|
||||
else {
|
||||
assert(isRange());
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
|
||||
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
|
||||
end != max ? Py::Long(end).ptr() : nullptr,
|
||||
step != 1 ? Py::Long(step).ptr() : nullptr),
|
||||
true);
|
||||
PyObject* r = PyObject_GetItem(pyobj.ptr(), slice.ptr());
|
||||
@@ -742,8 +743,9 @@ void ObjectIdentifier::Component::set(Py::Object& pyobj, const Py::Object& value
|
||||
}
|
||||
else {
|
||||
assert(isRange());
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
|
||||
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
|
||||
end != max ? Py::Long(end).ptr() : nullptr,
|
||||
step != 1 ? Py::Long(step).ptr() : nullptr),
|
||||
true);
|
||||
if (PyObject_SetItem(pyobj.ptr(), slice.ptr(), value.ptr()) < 0) {
|
||||
@@ -770,8 +772,9 @@ void ObjectIdentifier::Component::del(Py::Object& pyobj) const
|
||||
}
|
||||
else {
|
||||
assert(isRange());
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
Py::Object slice(PySlice_New(Py::Long(begin).ptr(),
|
||||
end != INT_MAX ? Py::Long(end).ptr() : nullptr,
|
||||
end != max ? Py::Long(end).ptr() : nullptr,
|
||||
step != 1 ? Py::Long(step).ptr() : nullptr),
|
||||
true);
|
||||
if (PyObject_DelItem(pyobj.ptr(), slice.ptr()) < 0) {
|
||||
@@ -897,11 +900,11 @@ void ObjectIdentifier::Component::toString(std::ostream& ss, bool toPython) cons
|
||||
break;
|
||||
case Component::RANGE:
|
||||
ss << '[';
|
||||
if (begin != INT_MAX) {
|
||||
if (begin != std::numeric_limits<int>::max()) {
|
||||
ss << begin;
|
||||
}
|
||||
ss << ':';
|
||||
if (end != INT_MAX) {
|
||||
if (end != std::numeric_limits<int>::max()) {
|
||||
ss << end;
|
||||
}
|
||||
if (step != 1) {
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <bitset>
|
||||
#include <map>
|
||||
#include <limits>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -211,13 +212,13 @@ public:
|
||||
|
||||
Component(const String& _name = String(),
|
||||
typeEnum _type = SIMPLE,
|
||||
int begin = INT_MAX,
|
||||
int end = INT_MAX,
|
||||
int begin = std::numeric_limits<int>::max(),
|
||||
int end = std::numeric_limits<int>::max(),
|
||||
int step = 1); // explicit bombs
|
||||
Component(String&& _name,
|
||||
typeEnum _type = SIMPLE,
|
||||
int begin = INT_MAX,
|
||||
int end = INT_MAX,
|
||||
int begin = std::numeric_limits<int>::max(),
|
||||
int end = std::numeric_limits<int>::max(),
|
||||
int step = 1); // explicit bombs
|
||||
|
||||
static Component SimpleComponent(const char* _component);
|
||||
@@ -227,7 +228,9 @@ public:
|
||||
|
||||
static Component ArrayComponent(int _index);
|
||||
|
||||
static Component RangeComponent(int _begin, int _end = INT_MAX, int _step = 1);
|
||||
static Component RangeComponent(int _begin,
|
||||
int _end = std::numeric_limits<int>::max(),
|
||||
int _step = 1);
|
||||
|
||||
static Component MapComponent(const String& _key);
|
||||
static Component MapComponent(String&& _key);
|
||||
@@ -325,7 +328,9 @@ public:
|
||||
return Component::ArrayComponent(_index);
|
||||
}
|
||||
|
||||
static Component RangeComponent(int _begin, int _end = INT_MAX, int _step = 1)
|
||||
static Component RangeComponent(int _begin,
|
||||
int _end = std::numeric_limits<int>::max(),
|
||||
int _step = 1)
|
||||
{
|
||||
return Component::RangeComponent(_begin, _end, _step);
|
||||
}
|
||||
@@ -342,11 +347,12 @@ public:
|
||||
|
||||
explicit ObjectIdentifier(const App::PropertyContainer* _owner = nullptr,
|
||||
const std::string& property = std::string(),
|
||||
int index = INT_MAX);
|
||||
int index = std::numeric_limits<int>::max());
|
||||
|
||||
ObjectIdentifier(const App::PropertyContainer* _owner, bool localProperty);
|
||||
|
||||
ObjectIdentifier(const App::Property& prop, int index = INT_MAX); // explicit bombs
|
||||
ObjectIdentifier(const App::Property& prop,
|
||||
int index = std::numeric_limits<int>::max()); // explicit bombs
|
||||
|
||||
FC_DEFAULT_CTORS(ObjectIdentifier)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,6 @@
|
||||
#include <csignal>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cfloat>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <crtdbg.h>
|
||||
@@ -74,6 +73,7 @@
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
@@ -1250,7 +1250,7 @@ void PropertyFloatConstraint::setPyObject(PyObject* value)
|
||||
|
||||
double stepSize = valConstr[3];
|
||||
// need a value > 0
|
||||
if (stepSize < DBL_EPSILON) {
|
||||
if (stepSize < std::numeric_limits<double>::epsilon()) {
|
||||
throw Base::ValueError("Step size must be greater than zero");
|
||||
}
|
||||
|
||||
@@ -1282,7 +1282,8 @@ TYPESYSTEM_SOURCE(App::PropertyPrecision, App::PropertyFloatConstraint)
|
||||
//**************************************************************************
|
||||
// Construction/Destruction
|
||||
//
|
||||
const PropertyFloatConstraint::Constraints PrecisionStandard = {0.0, DBL_MAX, 0.001};
|
||||
const PropertyFloatConstraint::Constraints PrecisionStandard = {
|
||||
0.0, std::numeric_limits<double>::max(), 0.001};
|
||||
|
||||
PropertyPrecision::PropertyPrecision()
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
#endif
|
||||
|
||||
#include <Base/QuantityPy.h>
|
||||
@@ -37,7 +36,8 @@ using namespace Base;
|
||||
using namespace std;
|
||||
|
||||
|
||||
const PropertyQuantityConstraint::Constraints LengthStandard = {0.0, DBL_MAX, 1.0};
|
||||
const PropertyQuantityConstraint::Constraints LengthStandard = {
|
||||
0.0, std::numeric_limits<double>::max(), 1.0};
|
||||
const PropertyQuantityConstraint::Constraints AngleStandard = {-360, 360, 1.0};
|
||||
|
||||
//**************************************************************************
|
||||
|
||||
@@ -9583,12 +9583,12 @@ YY_RULE_SETUP
|
||||
case 138:
|
||||
YY_RULE_SETUP
|
||||
#line 351 "ExpressionParser.l"
|
||||
COUNTCHARS; yylval.constant.fvalue = M_PI; yylval.constant.name = "pi"; return CONSTANT; // constant pi
|
||||
COUNTCHARS; yylval.constant.fvalue = std::numbers::pi; yylval.constant.name = "pi"; return CONSTANT; // constant pi
|
||||
YY_BREAK
|
||||
case 139:
|
||||
YY_RULE_SETUP
|
||||
#line 352 "ExpressionParser.l"
|
||||
COUNTCHARS; yylval.constant.fvalue = M_E; yylval.constant.name = "e"; return CONSTANT; // constant e
|
||||
COUNTCHARS; yylval.constant.fvalue = std::numbers::e; yylval.constant.name = "e"; return CONSTANT; // constant e
|
||||
YY_BREAK
|
||||
case 140:
|
||||
YY_RULE_SETUP
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#if defined(FC_OS_LINUX) || defined(FC_OS_CYGWIN) || defined(FC_OS_MACOSX) || defined(FC_OS_BSD)
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#elif defined(FC_OS_WIN32)
|
||||
#include <io.h>
|
||||
#include <Windows.h>
|
||||
|
||||
+3
-3
@@ -429,7 +429,7 @@ bool Matrix4D::toAxisAngle(Vector3d& rclBase,
|
||||
rfAngle = acos(fCos); // in [0,PI]
|
||||
|
||||
if (rfAngle > 0.0) {
|
||||
if (rfAngle < D_PI) {
|
||||
if (rfAngle < std::numbers::pi) {
|
||||
rclDir.x = (dMtrx4D[2][1] - dMtrx4D[1][2]);
|
||||
rclDir.y = (dMtrx4D[0][2] - dMtrx4D[2][0]);
|
||||
rclDir.z = (dMtrx4D[1][0] - dMtrx4D[0][1]);
|
||||
@@ -1013,8 +1013,8 @@ std::array<Matrix4D, 4> Matrix4D::decompose() const
|
||||
residualMatrix = rotationMatrix * residualMatrix;
|
||||
// To keep signs of the scale factors equal
|
||||
if (residualMatrix.determinant() < 0) {
|
||||
rotationMatrix.rotZ(D_PI);
|
||||
residualMatrix.rotZ(D_PI);
|
||||
rotationMatrix.rotZ(std::numbers::pi);
|
||||
residualMatrix.rotZ(std::numbers::pi);
|
||||
}
|
||||
rotationMatrix.inverseGauss();
|
||||
// extract scale
|
||||
|
||||
@@ -218,7 +218,7 @@ PyObject* MatrixPy::number_power_handler(PyObject* self, PyObject* other, PyObje
|
||||
}
|
||||
|
||||
if (b < 0) {
|
||||
if (fabs(a.determinant()) > DBL_EPSILON) {
|
||||
if (fabs(a.determinant()) > std::numeric_limits<double>::epsilon()) {
|
||||
a.inverseGauss();
|
||||
}
|
||||
else {
|
||||
@@ -667,7 +667,7 @@ PyObject* MatrixPy::invert()
|
||||
{
|
||||
PY_TRY
|
||||
{
|
||||
if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) {
|
||||
if (fabs(getMatrixPtr()->determinant()) > std::numeric_limits<double>::epsilon()) {
|
||||
getMatrixPtr()->inverseGauss();
|
||||
Py_Return;
|
||||
}
|
||||
@@ -682,7 +682,7 @@ PyObject* MatrixPy::inverse()
|
||||
{
|
||||
PY_TRY
|
||||
{
|
||||
if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) {
|
||||
if (fabs(getMatrixPtr()->determinant()) > std::numeric_limits<double>::epsilon()) {
|
||||
Base::Matrix4D m = *getMatrixPtr();
|
||||
m.inverseGauss();
|
||||
return new MatrixPy(m);
|
||||
|
||||
@@ -99,7 +99,8 @@ int PlacementPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
&angle)) {
|
||||
// NOTE: The first parameter defines the translation, the second the rotation axis
|
||||
// and the last parameter defines the rotation angle in degree.
|
||||
Base::Rotation rot(static_cast<Base::VectorPy*>(d)->value(), angle / 180.0 * D_PI);
|
||||
Base::Rotation rot(static_cast<Base::VectorPy*>(d)->value(),
|
||||
angle / 180.0 * std::numbers::pi);
|
||||
*getPlacementPtr() = Base::Placement(static_cast<Base::VectorPy*>(o)->value(), rot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -36,13 +36,8 @@
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <ctime>
|
||||
#include <cfloat>
|
||||
#include <chrono>
|
||||
#ifdef FC_OS_WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif // FC_OS_WIN32
|
||||
#include <cmath>
|
||||
#include <climits>
|
||||
#include <codecvt>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
@@ -61,7 +56,6 @@
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <limits.h>
|
||||
#endif
|
||||
|
||||
// STL
|
||||
@@ -69,6 +63,7 @@
|
||||
#include <string_view>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <numbers>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <cmath>
|
||||
#include <array>
|
||||
#include <numbers>
|
||||
#endif
|
||||
|
||||
#include <fmt/format.h>
|
||||
@@ -443,8 +443,8 @@ const Quantity Quantity::AngSecond(1.0 / 3600.0, Unit(0, 0, 0, 0, 0, 0, 0, 1));
|
||||
const Quantity
|
||||
Quantity::Degree(1.0,
|
||||
Unit(0, 0, 0, 0, 0, 0, 0, 1)); // degree (internal standard angle)
|
||||
const Quantity Quantity::Radian(180 / M_PI, Unit(0, 0, 0, 0, 0, 0, 0, 1)); // radian
|
||||
const Quantity Quantity::Gon(360.0 / 400.0, Unit(0, 0, 0, 0, 0, 0, 0, 1)); // gon
|
||||
const Quantity Quantity::Radian(180 / std::numbers::pi, Unit(0, 0, 0, 0, 0, 0, 0, 1)); // radian
|
||||
const Quantity Quantity::Gon(360.0 / 400.0, Unit(0, 0, 0, 0, 0, 0, 0, 1)); // gon
|
||||
|
||||
|
||||
// === Parser & Scanner stuff ===============================================
|
||||
@@ -568,7 +568,7 @@ Quantity Quantity::parse(const std::string& string)
|
||||
QuantityParser::yy_scan_string(string.c_str());
|
||||
QuantityParser::StringBufferCleaner cleaner(my_string_buffer);
|
||||
// set the global return variables
|
||||
QuantResult = Quantity(DOUBLE_MIN);
|
||||
QuantResult = Quantity(std::numeric_limits<double>::min());
|
||||
// run the parser
|
||||
QuantityParser::yyparse();
|
||||
|
||||
|
||||
@@ -27,15 +27,6 @@
|
||||
#include "Unit.h"
|
||||
#include <string>
|
||||
|
||||
// NOLINTBEGIN
|
||||
#ifndef DOUBLE_MAX
|
||||
#define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
#ifndef DOUBLE_MIN
|
||||
#define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
// NOLINTEND
|
||||
|
||||
namespace Base
|
||||
{
|
||||
class UnitsSchema;
|
||||
|
||||
@@ -1613,12 +1613,12 @@ YY_RULE_SETUP
|
||||
case 135:
|
||||
YY_RULE_SETUP
|
||||
#line 228 "QuantityParser.l"
|
||||
{yylval = Quantity(M_PI) ; return NUM;} // constant pi
|
||||
{yylval = Quantity(std::numbers::pi) ; return NUM;} // constant pi
|
||||
YY_BREAK
|
||||
case 136:
|
||||
YY_RULE_SETUP
|
||||
#line 229 "QuantityParser.l"
|
||||
{yylval = Quantity(M_E) ; return NUM;} // constant e
|
||||
{yylval = Quantity(std::numbers::e) ; return NUM;} // constant e
|
||||
YY_BREAK
|
||||
case 137:
|
||||
YY_RULE_SETUP
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
#define YYSTYPE Quantity
|
||||
#define yyparse Quantity_yyparse
|
||||
#define yyerror Quantity_yyerror
|
||||
#ifndef DOUBLE_MAX
|
||||
# define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
#ifndef DOUBLE_MIN
|
||||
# define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line 79 "QuantityParser.c" /* yacc.c:339 */
|
||||
@@ -1301,7 +1301,7 @@ yyreduce:
|
||||
{
|
||||
case 2:
|
||||
#line 34 "QuantityParser.y" /* yacc.c:1646 */
|
||||
{ QuantResult = Quantity(DOUBLE_MIN); /* empty input */ }
|
||||
{ QuantResult = Quantity(std::numeric_limits<double>::min()); /* empty input */ }
|
||||
#line 1305 "QuantityParser.c" /* yacc.c:1646 */
|
||||
break;
|
||||
|
||||
|
||||
@@ -225,8 +225,8 @@ CGRP '\,'[0-9][0-9][0-9]
|
||||
","?{DIGIT}+{EXPO}? { yylval = Quantity(num_change(yytext,',','.'));return NUM; }
|
||||
|
||||
|
||||
"pi" {yylval = Quantity(M_PI) ; return NUM;} // constant pi
|
||||
"e" {yylval = Quantity(M_E) ; return NUM;} // constant e
|
||||
"pi" {yylval = Quantity(std::numbers::pi) ; return NUM;} // constant pi
|
||||
"e" {yylval = Quantity(std::numbers::e) ; return NUM;} // constant e
|
||||
|
||||
"acos" return ACOS;
|
||||
"asin" return ASIN;
|
||||
|
||||
@@ -25,12 +25,12 @@
|
||||
#define YYSTYPE Quantity
|
||||
#define yyparse Quantity_yyparse
|
||||
#define yyerror Quantity_yyerror
|
||||
#ifndef DOUBLE_MAX
|
||||
# define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
#ifndef DOUBLE_MIN
|
||||
# define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
%%
|
||||
|
||||
input: { QuantResult = Quantity(DOUBLE_MIN); /* empty input */ }
|
||||
input: { QuantResult = Quantity(std::numeric_limits<double>::min()); /* empty input */ }
|
||||
| num { QuantResult = $1 ; }
|
||||
| unit { QuantResult = $1 ; }
|
||||
| quantity { QuantResult = $1 ; }
|
||||
|
||||
@@ -88,7 +88,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
}
|
||||
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
double f = DOUBLE_MAX;
|
||||
double f = std::numeric_limits<double>::max();
|
||||
if (PyArg_ParseTuple(args, "dO!", &f, &(Base::UnitPy::Type), &object)) {
|
||||
*self = Quantity(f, *(static_cast<Base::UnitPy*>(object)->getUnitPtr()));
|
||||
return 0;
|
||||
@@ -110,7 +110,7 @@ int QuantityPy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
int i8 = 0;
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
if (PyArg_ParseTuple(args, "|diiiiiiii", &f, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8)) {
|
||||
if (f < DOUBLE_MAX) {
|
||||
if (f < std::numeric_limits<double>::max()) {
|
||||
*self = Quantity(f,
|
||||
Unit {static_cast<int8_t>(i1),
|
||||
static_cast<int8_t>(i2),
|
||||
@@ -207,7 +207,7 @@ PyObject* QuantityPy::getValueAs(PyObject* args)
|
||||
}
|
||||
|
||||
if (!quant.isValid()) {
|
||||
double f = DOUBLE_MAX;
|
||||
double f = std::numeric_limits<double>::max();
|
||||
int i1 = 0;
|
||||
int i2 = 0;
|
||||
int i3 = 0;
|
||||
@@ -218,7 +218,7 @@ PyObject* QuantityPy::getValueAs(PyObject* args)
|
||||
int i8 = 0;
|
||||
PyErr_Clear();
|
||||
if (PyArg_ParseTuple(args, "d|iiiiiiii", &f, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8)) {
|
||||
if (f < DOUBLE_MAX) {
|
||||
if (f < std::numeric_limits<double>::max()) {
|
||||
quant = Quantity(f,
|
||||
Unit {static_cast<int8_t>(i1),
|
||||
static_cast<int8_t>(i2),
|
||||
|
||||
+27
-21
@@ -245,11 +245,12 @@ void Rotation::setValue(const Matrix4D& m)
|
||||
|
||||
void Rotation::setValue(const Vector3d& axis, double fAngle)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
// Taken from <http://de.wikipedia.org/wiki/Quaternionen>
|
||||
//
|
||||
// normalization of the angle to be in [0, 2pi[
|
||||
_angle = fAngle;
|
||||
double theAngle = fAngle - floor(fAngle / (2.0 * D_PI)) * (2.0 * D_PI);
|
||||
double theAngle = fAngle - floor(fAngle / (2.0 * pi)) * (2.0 * pi);
|
||||
this->quat[3] = cos(theAngle / 2.0);
|
||||
|
||||
Vector3d norm = axis;
|
||||
@@ -691,9 +692,9 @@ void Rotation::setYawPitchRoll(double y, double p, double r)
|
||||
{
|
||||
// The Euler angles (yaw,pitch,roll) are in XY'Z''-notation
|
||||
// convert to radians
|
||||
y = (y / 180.0) * D_PI;
|
||||
p = (p / 180.0) * D_PI;
|
||||
r = (r / 180.0) * D_PI;
|
||||
y = (y / 180.0) * std::numbers::pi;
|
||||
p = (p / 180.0) * std::numbers::pi;
|
||||
r = (r / 180.0) * std::numbers::pi;
|
||||
|
||||
double c1 = cos(y / 2.0);
|
||||
double s1 = sin(y / 2.0);
|
||||
@@ -710,6 +711,8 @@ void Rotation::setYawPitchRoll(double y, double p, double r)
|
||||
|
||||
void Rotation::getYawPitchRoll(double& y, double& p, double& r) const
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
double q00 = quat[0] * quat[0];
|
||||
double q11 = quat[1] * quat[1];
|
||||
double q22 = quat[2] * quat[2];
|
||||
@@ -722,30 +725,31 @@ void Rotation::getYawPitchRoll(double& y, double& p, double& r) const
|
||||
double q23 = quat[2] * quat[3];
|
||||
double qd2 = 2.0 * (q13 - q02);
|
||||
|
||||
// Tolerance copied from OCC "gp_Quaternion.cxx"
|
||||
constexpr double tolerance = 16 * std::numeric_limits<double>::epsilon();
|
||||
// handle gimbal lock
|
||||
if (fabs(qd2 - 1.0) <= 16 * DBL_EPSILON) { // Tolerance copied from OCC "gp_Quaternion.cxx"
|
||||
if (fabs(qd2 - 1.0) <= tolerance) {
|
||||
// north pole
|
||||
y = 0.0;
|
||||
p = D_PI / 2.0;
|
||||
p = pi / 2.0;
|
||||
r = 2.0 * atan2(quat[0], quat[3]);
|
||||
}
|
||||
else if (fabs(qd2 + 1.0)
|
||||
<= 16 * DBL_EPSILON) { // Tolerance copied from OCC "gp_Quaternion.cxx"
|
||||
else if (fabs(qd2 + 1.0) <= tolerance) {
|
||||
// south pole
|
||||
y = 0.0;
|
||||
p = -D_PI / 2.0;
|
||||
p = -pi / 2.0;
|
||||
r = 2.0 * atan2(quat[0], quat[3]);
|
||||
}
|
||||
else {
|
||||
y = atan2(2.0 * (q01 + q23), (q00 + q33) - (q11 + q22));
|
||||
p = qd2 > 1.0 ? D_PI / 2.0 : (qd2 < -1.0 ? -D_PI / 2.0 : asin(qd2));
|
||||
p = qd2 > 1.0 ? pi / 2.0 : (qd2 < -1.0 ? -pi / 2.0 : asin(qd2));
|
||||
r = atan2(2.0 * (q12 + q03), (q22 + q33) - (q00 + q11));
|
||||
}
|
||||
|
||||
// convert to degree
|
||||
y = (y / D_PI) * 180;
|
||||
p = (p / D_PI) * 180;
|
||||
r = (r / D_PI) * 180;
|
||||
y = (y / pi) * 180;
|
||||
p = (p / pi) * 180;
|
||||
r = (r / pi) * 180;
|
||||
}
|
||||
|
||||
bool Rotation::isSame(const Rotation& q) const
|
||||
@@ -978,15 +982,17 @@ void Rotation::setEulerAngles(EulerSequence theOrder,
|
||||
double theBeta,
|
||||
double theGamma)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
if (theOrder == Invalid || theOrder >= EulerSequenceLast) {
|
||||
throw Base::ValueError("invalid euler sequence");
|
||||
}
|
||||
|
||||
EulerSequence_Parameters o = translateEulerSequence(theOrder);
|
||||
|
||||
theAlpha *= D_PI / 180.0;
|
||||
theBeta *= D_PI / 180.0;
|
||||
theGamma *= D_PI / 180.0;
|
||||
theAlpha *= pi / 180.0;
|
||||
theBeta *= pi / 180.0;
|
||||
theGamma *= pi / 180.0;
|
||||
|
||||
double a = theAlpha;
|
||||
double b = theBeta;
|
||||
@@ -1048,7 +1054,7 @@ void Rotation::getEulerAngles(EulerSequence theOrder,
|
||||
EulerSequence_Parameters o = translateEulerSequence(theOrder);
|
||||
if (o.isTwoAxes) {
|
||||
double sy = sqrt(M(o.i, o.j) * M(o.i, o.j) + M(o.i, o.k) * M(o.i, o.k));
|
||||
if (sy > 16 * DBL_EPSILON) {
|
||||
if (sy > 16 * std::numeric_limits<double>::epsilon()) {
|
||||
theAlpha = atan2(M(o.i, o.j), M(o.i, o.k));
|
||||
theGamma = atan2(M(o.j, o.i), -M(o.k, o.i));
|
||||
}
|
||||
@@ -1060,7 +1066,7 @@ void Rotation::getEulerAngles(EulerSequence theOrder,
|
||||
}
|
||||
else {
|
||||
double cy = sqrt(M(o.i, o.i) * M(o.i, o.i) + M(o.j, o.i) * M(o.j, o.i));
|
||||
if (cy > 16 * DBL_EPSILON) {
|
||||
if (cy > 16 * std::numeric_limits<double>::epsilon()) {
|
||||
theAlpha = atan2(M(o.k, o.j), M(o.k, o.k));
|
||||
theGamma = atan2(M(o.j, o.i), M(o.i, o.i));
|
||||
}
|
||||
@@ -1081,7 +1087,7 @@ void Rotation::getEulerAngles(EulerSequence theOrder,
|
||||
theGamma = aFirst;
|
||||
}
|
||||
|
||||
theAlpha *= 180.0 / D_PI;
|
||||
theBeta *= 180.0 / D_PI;
|
||||
theGamma *= 180.0 / D_PI;
|
||||
theAlpha *= 180.0 / std::numbers::pi;
|
||||
theBeta *= 180.0 / std::numbers::pi;
|
||||
theGamma *= 180.0 / std::numbers::pi;
|
||||
}
|
||||
|
||||
+3
-6
@@ -28,6 +28,7 @@
|
||||
#include <FCGlobal.h>
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -127,20 +128,16 @@ inline T sgn(T t)
|
||||
return (t > 0) ? T(1) : T(-1);
|
||||
}
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
inline T toRadians(T d)
|
||||
{
|
||||
return static_cast<T>((d * M_PI) / 180.0);
|
||||
return static_cast<T>((d * std::numbers::pi) / 180.0);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline T toDegrees(T r)
|
||||
{
|
||||
return static_cast<T>((r / M_PI) * 180.0);
|
||||
return static_cast<T>((r / std::numbers::pi) * 180.0);
|
||||
}
|
||||
|
||||
inline float fromPercent(const long value)
|
||||
|
||||
@@ -43,7 +43,7 @@ double Vector2d::GetAngle(const Vector2d& vec) const
|
||||
if ((fDivid < -1e-10) || (fDivid > 1e-10)) {
|
||||
fNum = (*this * vec) / fDivid;
|
||||
if (fNum < -1) {
|
||||
return D_PI;
|
||||
return std::numbers::pi;
|
||||
}
|
||||
if (fNum > 1) {
|
||||
return 0.0;
|
||||
@@ -52,7 +52,7 @@ double Vector2d::GetAngle(const Vector2d& vec) const
|
||||
return acos(fNum);
|
||||
}
|
||||
|
||||
return -FLOAT_MAX; // division by zero
|
||||
return -std::numeric_limits<double>::max(); // division by zero
|
||||
}
|
||||
|
||||
void Vector2d::ProjectToLine(const Vector2d& point, const Vector2d& line)
|
||||
@@ -173,13 +173,13 @@ bool Line2d::Intersect(const Line2d& rclLine, Vector2d& rclV) const
|
||||
m1 = (clV2.y - clV1.y) / (clV2.x - clV1.x);
|
||||
}
|
||||
else {
|
||||
m1 = DOUBLE_MAX;
|
||||
m1 = std::numeric_limits<double>::max();
|
||||
}
|
||||
if (fabs(rclLine.clV2.x - rclLine.clV1.x) > 1e-10) {
|
||||
m2 = (rclLine.clV2.y - rclLine.clV1.y) / (rclLine.clV2.x - rclLine.clV1.x);
|
||||
}
|
||||
else {
|
||||
m2 = DOUBLE_MAX;
|
||||
m2 = std::numeric_limits<double>::max();
|
||||
}
|
||||
if (m1 == m2) { /****** RETURN ERR (parallel lines) *************/
|
||||
return false;
|
||||
@@ -189,11 +189,11 @@ bool Line2d::Intersect(const Line2d& rclLine, Vector2d& rclV) const
|
||||
b2 = rclLine.clV1.y - m2 * rclLine.clV1.x;
|
||||
|
||||
// calc intersection
|
||||
if (m1 == DOUBLE_MAX) {
|
||||
if (m1 == std::numeric_limits<double>::max()) {
|
||||
rclV.x = clV1.x;
|
||||
rclV.y = m2 * rclV.x + b2;
|
||||
}
|
||||
else if (m2 == DOUBLE_MAX) {
|
||||
else if (m2 == std::numeric_limits<double>::max()) {
|
||||
rclV.x = rclLine.clV1.x;
|
||||
rclV.y = m1 * rclV.x + b1;
|
||||
}
|
||||
|
||||
+6
-14
@@ -32,15 +32,6 @@
|
||||
#include <FCGlobal.h>
|
||||
#endif
|
||||
|
||||
// NOLINTBEGIN
|
||||
#ifndef DOUBLE_MAX
|
||||
#define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
#ifndef DOUBLE_MIN
|
||||
#define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
// NOLINTEND
|
||||
|
||||
|
||||
namespace Base
|
||||
{
|
||||
@@ -462,8 +453,8 @@ inline bool Line2d::Contains(const Vector2d& rclV) const
|
||||
|
||||
inline BoundBox2d::BoundBox2d()
|
||||
{
|
||||
MinX = MinY = DOUBLE_MAX;
|
||||
MaxX = MaxY = -DOUBLE_MAX;
|
||||
MinX = MinY = std::numeric_limits<double>::max();
|
||||
MaxX = MaxY = -std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
inline BoundBox2d::BoundBox2d(double fX1, double fY1, double fX2, double fY2)
|
||||
@@ -480,7 +471,8 @@ inline bool BoundBox2d::IsValid() const
|
||||
|
||||
inline bool BoundBox2d::IsInfinite() const
|
||||
{
|
||||
return MaxX >= DOUBLE_MAX && MaxY >= DOUBLE_MAX && MinX <= -DOUBLE_MAX && MinY <= -DOUBLE_MAX;
|
||||
constexpr double max = std::numeric_limits<double>::max();
|
||||
return MaxX >= max && MaxY >= max && MinX <= -max && MinY <= -max;
|
||||
}
|
||||
|
||||
inline bool BoundBox2d::IsEqual(const BoundBox2d& bbox, double tolerance) const
|
||||
@@ -525,8 +517,8 @@ inline Vector2d BoundBox2d::GetCenter() const
|
||||
|
||||
inline void BoundBox2d::SetVoid()
|
||||
{
|
||||
MinX = MinY = DOUBLE_MAX;
|
||||
MaxX = MaxY = -DOUBLE_MAX;
|
||||
MinX = MinY = std::numeric_limits<double>::max();
|
||||
MaxX = MaxY = -std::numeric_limits<double>::max();
|
||||
}
|
||||
|
||||
inline void BoundBox2d::Add(const Vector2d& v)
|
||||
|
||||
+16
-40
@@ -24,34 +24,9 @@
|
||||
#ifndef BASE_VECTOR3D_H
|
||||
#define BASE_VECTOR3D_H
|
||||
|
||||
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
|
||||
#ifndef F_PI
|
||||
#define F_PI 3.1415926f
|
||||
#endif
|
||||
|
||||
#ifndef D_PI
|
||||
#define D_PI 3.141592653589793
|
||||
#endif
|
||||
|
||||
#ifndef FLOAT_MAX
|
||||
#define FLOAT_MAX 3.402823466E+38F
|
||||
#endif
|
||||
|
||||
#ifndef FLOAT_MIN
|
||||
#define FLOAT_MIN 1.175494351E-38F
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_MAX
|
||||
#define DOUBLE_MAX 1.7976931348623157E+308 /* max decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_MIN
|
||||
#define DOUBLE_MIN 2.2250738585072014E-308 /* min decimal value of a "double"*/
|
||||
#endif
|
||||
|
||||
#include <numbers>
|
||||
|
||||
namespace Base
|
||||
{
|
||||
@@ -60,21 +35,22 @@ struct float_traits
|
||||
{
|
||||
};
|
||||
|
||||
// TODO: Remove these specializations and use the default implementation for all types.
|
||||
template<>
|
||||
struct float_traits<float>
|
||||
{
|
||||
using float_type = float;
|
||||
[[nodiscard]] static constexpr float_type pi()
|
||||
[[nodiscard]] static consteval float_type pi()
|
||||
{
|
||||
return F_PI;
|
||||
return std::numbers::pi_v<float_type>;
|
||||
}
|
||||
[[nodiscard]] static constexpr float_type epsilon()
|
||||
[[nodiscard]] static consteval float_type epsilon()
|
||||
{
|
||||
return FLT_EPSILON;
|
||||
return std::numeric_limits<float_type>::epsilon();
|
||||
}
|
||||
[[nodiscard]] static constexpr float_type maximum()
|
||||
[[nodiscard]] static consteval float_type maximum()
|
||||
{
|
||||
return FLT_MAX;
|
||||
return std::numeric_limits<float_type>::max();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -82,17 +58,17 @@ template<>
|
||||
struct float_traits<double>
|
||||
{
|
||||
using float_type = double;
|
||||
[[nodiscard]] static constexpr float_type pi()
|
||||
[[nodiscard]] static consteval float_type pi()
|
||||
{
|
||||
return D_PI;
|
||||
return std::numbers::pi_v<float_type>;
|
||||
}
|
||||
[[nodiscard]] static constexpr float_type epsilon()
|
||||
[[nodiscard]] static consteval float_type epsilon()
|
||||
{
|
||||
return DBL_EPSILON;
|
||||
return std::numeric_limits<float_type>::epsilon();
|
||||
}
|
||||
[[nodiscard]] static constexpr float_type maximum()
|
||||
[[nodiscard]] static consteval float_type maximum()
|
||||
{
|
||||
return DBL_MAX;
|
||||
return std::numeric_limits<float_type>::max();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -275,7 +251,7 @@ template<class float_type>
|
||||
float_type x = v1.x - v2.x;
|
||||
float_type y = v1.y - v2.y;
|
||||
float_type z = v1.z - v2.z;
|
||||
return static_cast<float_type>(sqrt((x * x) + (y * y) + (z * z)));
|
||||
return static_cast<float_type>(std::sqrt((x * x) + (y * y) + (z * z)));
|
||||
}
|
||||
|
||||
/// Returns the squared distance between two points
|
||||
|
||||
@@ -748,7 +748,7 @@ QString CallTipsList::stripWhiteSpace(const QString& str) const
|
||||
{
|
||||
QString stripped = str;
|
||||
QStringList lines = str.split(QLatin1String("\n"));
|
||||
int minspace=INT_MAX;
|
||||
int minspace=std::numeric_limits<int>::max();
|
||||
int line=0;
|
||||
for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it, ++line) {
|
||||
if (it->size() > 0 && line > 0) {
|
||||
@@ -766,7 +766,7 @@ QString CallTipsList::stripWhiteSpace(const QString& str) const
|
||||
}
|
||||
|
||||
// remove all leading tabs from each line
|
||||
if (minspace > 0 && minspace < INT_MAX) {
|
||||
if (minspace > 0 && minspace < std::numeric_limits<int>::max()) {
|
||||
int line=0;
|
||||
QStringList strippedlines;
|
||||
for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it, ++line) {
|
||||
|
||||
@@ -109,20 +109,21 @@ Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
||||
d->ui.setupUi(this);
|
||||
setupConnections();
|
||||
|
||||
d->ui.clipView->setRange(-INT_MAX, INT_MAX);
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
d->ui.clipView->setRange(-max, max);
|
||||
d->ui.clipView->setSingleStep(0.1f);
|
||||
d->ui.clipX->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipX->setRange(-max, max);
|
||||
d->ui.clipX->setSingleStep(0.1f);
|
||||
d->ui.clipY->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipY->setRange(-max, max);
|
||||
d->ui.clipY->setSingleStep(0.1f);
|
||||
d->ui.clipZ->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipZ->setRange(-max, max);
|
||||
d->ui.clipZ->setSingleStep(0.1f);
|
||||
|
||||
d->ui.dirX->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirX->setRange(-max, max);
|
||||
d->ui.dirX->setSingleStep(0.1f);
|
||||
d->ui.dirY->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirY->setRange(-max, max);
|
||||
d->ui.dirY->setSingleStep(0.1f);
|
||||
d->ui.dirZ->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirZ->setRange(-max, max);
|
||||
d->ui.dirZ->setSingleStep(0.1f);
|
||||
d->ui.dirZ->setValue(1.0f);
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ SbVec3f DemoMode::getDirection(Gui::View3DInventor* view) const
|
||||
SbRotation inv = rot.inverse();
|
||||
SbVec3f vec(this->viewAxis);
|
||||
inv.multVec(vec, vec);
|
||||
if (vec.length() < FLT_EPSILON) {
|
||||
if (vec.length() < std::numeric_limits<float>::epsilon()) {
|
||||
vec = this->viewAxis;
|
||||
}
|
||||
vec.normalize();
|
||||
|
||||
@@ -905,7 +905,7 @@ void ParameterValue::onCreateUIntItem()
|
||||
DlgInputDialogImp::UIntBox);
|
||||
dlg.setWindowTitle(QObject::tr("New unsigned item"));
|
||||
UIntSpinBox* edit = dlg.getUIntBox();
|
||||
edit->setRange(0, UINT_MAX);
|
||||
edit->setRange(0, std::numeric_limits<unsigned>::max());
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QString value = edit->text();
|
||||
unsigned long val = value.toULong(&ok);
|
||||
@@ -1249,7 +1249,7 @@ void ParameterUInt::changeValue()
|
||||
DlgInputDialogImp::UIntBox);
|
||||
dlg.setWindowTitle(QObject::tr("Change value"));
|
||||
UIntSpinBox* edit = dlg.getUIntBox();
|
||||
edit->setRange(0, UINT_MAX);
|
||||
edit->setRange(0, std::numeric_limits<unsigned>::max());
|
||||
edit->setValue(text(2).toULong());
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QString value = edit->text();
|
||||
|
||||
@@ -152,8 +152,8 @@ void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj, bool
|
||||
|
||||
spinBox = new QuantitySpinBox(mdi);
|
||||
spinBox->setUnit(Base::Unit::Length);
|
||||
spinBox->setMinimum(-INT_MAX);
|
||||
spinBox->setMaximum(INT_MAX);
|
||||
spinBox->setMinimum(-std::numeric_limits<int>::max());
|
||||
spinBox->setMaximum(std::numeric_limits<int>::max());
|
||||
spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||
spinBox->setKeyboardTracking(false);
|
||||
spinBox->setFocusPolicy(Qt::ClickFocus); // prevent passing focus with tab.
|
||||
|
||||
@@ -71,8 +71,8 @@ InputField::InputField(QWidget * parent)
|
||||
ExpressionWidget(),
|
||||
validInput(true),
|
||||
actUnitValue(0),
|
||||
Maximum(DOUBLE_MAX),
|
||||
Minimum(-DOUBLE_MAX),
|
||||
Maximum(std::numeric_limits<double>::max()),
|
||||
Minimum(-std::numeric_limits<double>::max()),
|
||||
StepSize(1.0),
|
||||
HistorySize(5),
|
||||
SaveSize(5)
|
||||
|
||||
@@ -25,10 +25,8 @@
|
||||
#ifndef _PreComp_
|
||||
#include <array>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#ifdef FC_OS_WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#ifdef FC_OS_MACOSX
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
@@ -39,17 +37,23 @@
|
||||
#include "SoFCBackgroundGradient.h"
|
||||
|
||||
static const std::array <GLfloat[2], 32> big_circle = []{
|
||||
static const float pi2 = boost::math::constants::two_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
constexpr float sqrt2 = std::numbers::sqrt2_v<float>;
|
||||
std::array <GLfloat[2], 32> result; int c = 0;
|
||||
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
|
||||
result[c][0] = M_SQRT2*cosf(i); result[c][1] = M_SQRT2*sinf(i);
|
||||
for (GLfloat i = 0; i < 2 * pi; i += 2 * pi / 32, c++) {
|
||||
result[c][0] = sqrt2 * cosf(i);
|
||||
result[c][1] = sqrt2 * sinf(i);
|
||||
}
|
||||
return result; }();
|
||||
static const std::array <GLfloat[2], 32> small_oval = []{
|
||||
static const float pi2 = boost::math::constants::two_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
constexpr float sqrt2 = std::numbers::sqrt2_v<float>;
|
||||
static const float sqrt1_2 = std::sqrt(1 / 2.F);
|
||||
|
||||
std::array <GLfloat[2], 32> result; int c = 0;
|
||||
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
|
||||
result[c][0] = 0.3*M_SQRT2*cosf(i); result[c][1] = M_SQRT1_2*sinf(i);
|
||||
for (GLfloat i = 0; i < 2 * pi; i += 2 * pi / 32, c++) {
|
||||
result[c][0] = 0.3 * sqrt2 * cosf(i);
|
||||
result[c][1] = sqrt1_2 * sinf(i);
|
||||
}
|
||||
return result; }();
|
||||
|
||||
|
||||
+24
-28
@@ -23,7 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <numbers>
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
@@ -553,7 +553,7 @@ void NaviCubeImplementation::addButtonFace(PickId pickId, const SbVec3f& directi
|
||||
case PickId::DotBackside: {
|
||||
int steps = 16;
|
||||
for (int i = 0; i < steps; i++) {
|
||||
float angle = 2.0f * M_PI * ((float)i+0.5) / (float)steps;
|
||||
float angle = 2.0f * std::numbers::pi_v<float> * ((float)i+0.5) / (float)steps;
|
||||
pointData.emplace_back(10. * cos(angle) + 87.);
|
||||
pointData.emplace_back(10. * sin(angle) - 87.);
|
||||
}
|
||||
@@ -659,8 +659,8 @@ void NaviCubeImplementation::setSize(int size)
|
||||
|
||||
void NaviCubeImplementation::prepare()
|
||||
{
|
||||
static const float pi = boost::math::constants::pi<float>();
|
||||
static const float pi1_2 = boost::math::constants::half_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
constexpr float pi1_2 = pi / 2;
|
||||
|
||||
createCubeFaceTextures();
|
||||
|
||||
@@ -817,7 +817,7 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode, float opacity)
|
||||
glOrtho(-2.1, 2.1, -2.1, 2.1, NEARVAL, FARVAL);
|
||||
}
|
||||
else {
|
||||
const float dim = NEARVAL * float(tan(M_PI / 8.0)) * 1.1;
|
||||
const float dim = NEARVAL * float(tan(std::numbers::pi / 8.0)) * 1.1;
|
||||
glFrustum(-dim, dim, -dim, dim, NEARVAL, FARVAL);
|
||||
}
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@@ -1010,15 +1010,11 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
|
||||
angle *= -1;
|
||||
}
|
||||
|
||||
static const float pi = boost::math::constants::pi<float>();
|
||||
static const float pi2 = boost::math::constants::two_pi<float>();
|
||||
static const float pi1_2 = boost::math::constants::half_pi<float>();
|
||||
static const float pi1_3 = boost::math::constants::third_pi<float>();
|
||||
static const float pi2_3 = boost::math::constants::two_thirds_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
|
||||
// Make angle positive
|
||||
if (angle < 0) {
|
||||
angle += pi2;
|
||||
angle += 2 * pi;
|
||||
}
|
||||
|
||||
// f is a small value used to control orientation priority when the camera is almost exactly between two
|
||||
@@ -1030,23 +1026,23 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
|
||||
// Find the angle to rotate to the nearest orientation
|
||||
if (m_Faces[pickId].type == ShapeId::Corner) {
|
||||
// 6 possible orientations for the corners
|
||||
if (angle <= (M_PI / 6 + f)) {
|
||||
if (angle <= (pi / 6 + f)) {
|
||||
angle = 0;
|
||||
}
|
||||
else if (angle <= (M_PI_2 + f)) {
|
||||
angle = pi1_3;
|
||||
else if (angle <= (pi / 2 + f)) {
|
||||
angle = pi / 3;
|
||||
}
|
||||
else if (angle < (5 * M_PI / 6 - f)) {
|
||||
angle = pi2_3;
|
||||
else if (angle < (5 * pi / 6 - f)) {
|
||||
angle = 2 * pi / 3;
|
||||
}
|
||||
else if (angle <= (M_PI + M_PI / 6 + f)) {
|
||||
else if (angle <= (pi + pi / 6 + f)) {
|
||||
angle = pi;
|
||||
}
|
||||
else if (angle < (M_PI + M_PI_2 - f)) {
|
||||
angle = pi + pi1_3;
|
||||
else if (angle < (pi + pi / 2 - f)) {
|
||||
angle = pi + pi / 3;
|
||||
}
|
||||
else if (angle < (M_PI + 5 * M_PI / 6 - f)) {
|
||||
angle = pi + pi2_3;
|
||||
else if (angle < (pi + 5 * pi / 6 - f)) {
|
||||
angle = pi + 2 * pi / 3;
|
||||
}
|
||||
else {
|
||||
angle = 0;
|
||||
@@ -1054,17 +1050,17 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
|
||||
}
|
||||
else {
|
||||
// 4 possible orientations for the main and edge faces
|
||||
if (angle <= (M_PI_4 + f)) {
|
||||
if (angle <= (pi / 4 + f)) {
|
||||
angle = 0;
|
||||
}
|
||||
else if (angle <= (3 * M_PI_4 + f)) {
|
||||
angle = pi1_2;
|
||||
else if (angle <= (3 * pi / 4 + f)) {
|
||||
angle = pi / 2;
|
||||
}
|
||||
else if (angle < (M_PI + M_PI_4 - f)) {
|
||||
else if (angle < (pi + pi / 4 - f)) {
|
||||
angle = pi;
|
||||
}
|
||||
else if (angle < (M_PI + 3 * M_PI_4 - f)) {
|
||||
angle = pi + pi1_2;
|
||||
else if (angle < (pi + 3 * pi / 4 - f)) {
|
||||
angle = pi + pi / 2;
|
||||
}
|
||||
else {
|
||||
angle = 0;
|
||||
@@ -1089,7 +1085,7 @@ bool NaviCubeImplementation::mouseReleased(short x, short y)
|
||||
} else {
|
||||
PickId pickId = pickFace(x, y);
|
||||
long step = Base::clamp(long(m_NaviStepByTurn), 4L, 36L);
|
||||
float rotStepAngle = (2 * M_PI) / step;
|
||||
float rotStepAngle = (2 * std::numbers::pi) / step;
|
||||
|
||||
if (m_Faces[pickId].type == ShapeId::Main || m_Faces[pickId].type == ShapeId::Edge || m_Faces[pickId].type == ShapeId::Corner) {
|
||||
// Handle the cube faces
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "NavigationAnimation.h"
|
||||
#include <Inventor/nodes/SoCamera.h>
|
||||
|
||||
#include <numbers>
|
||||
|
||||
using namespace Gui;
|
||||
|
||||
NavigationAnimation::NavigationAnimation(NavigationStyle* navigation)
|
||||
@@ -69,8 +71,8 @@ void FixedTimeAnimation::initialize()
|
||||
SbVec3f rotationAxisPost;
|
||||
float angle;
|
||||
SbRotation(navigation->getCamera()->orientation.getValue().inverse() * targetOrientation).getValue(rotationAxisPost, angle);
|
||||
if (angle > M_PI) {
|
||||
angle -= float(2 * M_PI);
|
||||
if (angle > std::numbers::pi) {
|
||||
angle -= float(2 * std::numbers::pi);
|
||||
}
|
||||
|
||||
// Convert post-multiplication axis to a pre-multiplication axis
|
||||
@@ -130,9 +132,9 @@ SpinningAnimation::SpinningAnimation(NavigationStyle* navigation, const SbVec3f&
|
||||
: NavigationAnimation(navigation)
|
||||
, rotationAxis(axis)
|
||||
{
|
||||
setDuration((2 * M_PI / velocity) * 1000.0);
|
||||
setDuration((2 * std::numbers::pi / velocity) * 1000.0);
|
||||
setStartValue(0.0);
|
||||
setEndValue(2 * M_PI);
|
||||
setEndValue(2 * std::numbers::pi);
|
||||
setLoopCount(-1);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
# include <QMenu>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
|
||||
#include <Base/Interpreter.h>
|
||||
#include <App/Application.h>
|
||||
|
||||
@@ -719,7 +722,8 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue)
|
||||
const float distorigo = newpos.length();
|
||||
// sqrt(FLT_MAX) == ~ 1e+19, which should be both safe for further
|
||||
// calculations and ok for the end-user and app-programmer.
|
||||
if (distorigo > float(sqrt(FLT_MAX))) {
|
||||
float maxDistance = std::sqrt(std::numeric_limits<float>::max());
|
||||
if (distorigo > maxDistance) {
|
||||
// do nothing here
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -1819,7 +1819,7 @@ bool OverlayManager::eventFilter(QObject *o, QEvent *ev)
|
||||
}
|
||||
|
||||
if (hit <= 0) {
|
||||
d->_lastPos.setX(INT_MAX);
|
||||
d->_lastPos.setX(std::numeric_limits<int>::max());
|
||||
if (ev->type() == QEvent::Wheel) {
|
||||
d->wheelDelay = QTime::currentTime().addMSecs(OverlayParams::getDockOverlayWheelDelay());
|
||||
d->wheelPos = pos;
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <cctype>
|
||||
#include <typeinfo>
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <Windows.h>
|
||||
@@ -69,6 +67,7 @@
|
||||
#include <bitset>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <numbers>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <set>
|
||||
|
||||
@@ -182,7 +182,7 @@ void ApplicationCache::setPeriod(ApplicationCache::Period period)
|
||||
numDays = 365;
|
||||
break;
|
||||
case Period::Never:
|
||||
numDays = INT_MAX;
|
||||
numDays = std::numeric_limits<int>::max();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ DlgSettingsDocumentImp::DlgSettingsDocumentImp(QWidget* parent)
|
||||
ui->prefSaveBackupDateFormat->setToolTip(tip);
|
||||
ui->FormatTimeDocsLabel->setText(link);
|
||||
|
||||
ui->prefCountBackupFiles->setMaximum(INT_MAX);
|
||||
ui->prefCountBackupFiles->setMaximum(std::numeric_limits<int>::max());
|
||||
ui->prefCompression->setMinimum(Z_NO_COMPRESSION);
|
||||
ui->prefCompression->setMaximum(Z_BEST_COMPRESSION);
|
||||
connect(ui->prefLicenseType, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
pendingEmit(false),
|
||||
checkRangeInExpression(false),
|
||||
unitValue(0),
|
||||
maximum(DOUBLE_MAX),
|
||||
minimum(-DOUBLE_MAX),
|
||||
maximum(std::numeric_limits<double>::max()),
|
||||
minimum(-std::numeric_limits<double>::max()),
|
||||
singleStep(1.0),
|
||||
q_ptr(q)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Inventor/SbLine.h>
|
||||
#include <Inventor/SbPlane.h>
|
||||
@@ -303,7 +305,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertOrtho2Perspective(const So
|
||||
|
||||
SbRotation camrot = in->orientation.getValue();
|
||||
|
||||
float focaldist = float(in->height.getValue() / (2.0*tan(M_PI / 8.0))); // NOLINT
|
||||
float focaldist = float(in->height.getValue() / (2.0*tan(std::numbers::pi / 8.0))); // NOLINT
|
||||
|
||||
SbVec3f offset(0,0,focaldist-in->focalDistance.getValue());
|
||||
|
||||
@@ -313,7 +315,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertOrtho2Perspective(const So
|
||||
out->focalDistance.setValue(focaldist);
|
||||
|
||||
// 45° is the default value of this field in SoPerspectiveCamera.
|
||||
out->heightAngle = (float)(M_PI / 4.0); // NOLINT
|
||||
out->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertPerspective2Ortho(const SoPerspectiveCamera* in,
|
||||
@@ -568,7 +570,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seeksensorCB(void* data, SoSensor
|
||||
|
||||
bool end = (par == 1.0F);
|
||||
|
||||
par = (float)((1.0 - cos(M_PI * par)) * 0.5); // NOLINT
|
||||
par = (float)((1.0 - cos(std::numbers::pi * par)) * 0.5); // NOLINT
|
||||
|
||||
thisp->getSoRenderManager()->getCamera()->position = thisp->m_camerastartposition +
|
||||
(thisp->m_cameraendposition - thisp->m_camerastartposition) * par;
|
||||
|
||||
@@ -172,8 +172,9 @@ private:
|
||||
|
||||
struct Node_Slice
|
||||
{
|
||||
explicit Node_Slice(int min=1,int max=INT_MAX):Min(min),Max(max){}
|
||||
int Min,Max;
|
||||
explicit Node_Slice(int min = 1, int max = std::numeric_limits<int>::max())
|
||||
: Min(min), Max(max) {}
|
||||
int Min, Max;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef GUI_SOFCSELECTIONCONTEXT_H
|
||||
#define GUI_SOFCSELECTIONCONTEXT_H
|
||||
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
@@ -79,11 +78,11 @@ struct GuiExport SoFCSelectionContext : SoFCSelectionContextBase
|
||||
}
|
||||
|
||||
bool isHighlightAll() const{
|
||||
return highlightIndex==INT_MAX && (selectionIndex.empty() || isSelectAll());
|
||||
return highlightIndex == std::numeric_limits<int>::max() && (selectionIndex.empty() || isSelectAll());
|
||||
}
|
||||
|
||||
void highlightAll() {
|
||||
highlightIndex = INT_MAX;
|
||||
highlightIndex = std::numeric_limits<int>::max();
|
||||
}
|
||||
|
||||
void removeHighlight() {
|
||||
|
||||
@@ -409,7 +409,7 @@ void ShortcutManager::onTimer()
|
||||
timer.stop();
|
||||
|
||||
QAction *found = nullptr;
|
||||
int priority = -INT_MAX;
|
||||
int priority = -std::numeric_limits<int>::max();
|
||||
int seq_length = 0;
|
||||
for (const auto &info : pendingActions) {
|
||||
if (info.action) {
|
||||
|
||||
+51
-39
@@ -34,8 +34,8 @@
|
||||
# endif
|
||||
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <cmath>
|
||||
# include <numbers>
|
||||
# include <QFontMetrics>
|
||||
# include <QPainter>
|
||||
|
||||
@@ -78,11 +78,12 @@ void glDrawLine(const SbVec3f& p1, const SbVec3f& p2){
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void glDrawArc(const SbVec3f& center, float radius, float startAngle=0., float endAngle=2.0*M_PI, int countSegments=0){
|
||||
void glDrawArc(const SbVec3f& center, float radius, float startAngle=0.,
|
||||
float endAngle=2.0*std::numbers::pi, int countSegments=0){
|
||||
float range = endAngle - startAngle;
|
||||
|
||||
if (countSegments == 0){
|
||||
countSegments = std::max(6, abs(int(25.0 * range / M_PI)));
|
||||
countSegments = std::max(6, abs(int(25.0 * range / std::numbers::pi)));
|
||||
}
|
||||
|
||||
float segment = range / (countSegments-1);
|
||||
@@ -238,11 +239,12 @@ public:
|
||||
private:
|
||||
void getBBox(const std::vector<SbVec3f>& corners, SbBox3f& box, SbVec3f& center) const
|
||||
{
|
||||
constexpr float floatMax = std::numeric_limits<float>::max();
|
||||
if (corners.size() > 1) {
|
||||
float minX = FLT_MAX;
|
||||
float minY = FLT_MAX;
|
||||
float maxX = -FLT_MAX;
|
||||
float maxY = -FLT_MAX;
|
||||
float minX = floatMax;
|
||||
float minY = floatMax;
|
||||
float maxX = -floatMax;
|
||||
float maxY = -floatMax;
|
||||
for (SbVec3f it : corners) {
|
||||
minX = (it[0] < minX) ? it[0] : minX;
|
||||
minY = (it[1] < minY) ? it[1] : minY;
|
||||
@@ -288,14 +290,15 @@ private:
|
||||
|
||||
SbVec3f dir;
|
||||
SbVec3f normal;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (label->datumtype.getValue() == SoDatumLabel::DISTANCE) {
|
||||
dir = (p2-p1);
|
||||
}
|
||||
else if (label->datumtype.getValue() == SoDatumLabel::DISTANCEX) {
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
}
|
||||
else if (label->datumtype.getValue() == SoDatumLabel::DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -546,11 +549,11 @@ private:
|
||||
float startangle = atan2f(vc1[1], vc1[0]);
|
||||
float endangle = atan2f(vc2[1], vc2[0]);
|
||||
if (endangle < startangle) {
|
||||
endangle += 2. * M_PI;
|
||||
endangle += 2. * std::numbers::pi;
|
||||
}
|
||||
|
||||
SbVec3f textCenter;
|
||||
if (endangle - startangle <= M_PI) {
|
||||
if (endangle - startangle <= std::numbers::pi) {
|
||||
textCenter = ctr + vm * (length + imgHeight);
|
||||
} else {
|
||||
textCenter = ctr - vm * (length + 2. * imgHeight);
|
||||
@@ -628,14 +631,16 @@ SbVec3f SoDatumLabel::getLabelTextCenterDistance(const SbVec3f& p1, const SbVec3
|
||||
|
||||
SbVec3f dir;
|
||||
SbVec3f normal;
|
||||
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (datumtype.getValue() == SoDatumLabel::DISTANCE) {
|
||||
dir = (p2 - p1);
|
||||
}
|
||||
else if (datumtype.getValue() == SoDatumLabel::DISTANCEX) {
|
||||
dir = SbVec3f((p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f((p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
}
|
||||
else if (datumtype.getValue() == SoDatumLabel::DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -689,7 +694,7 @@ SbVec3f SoDatumLabel::getLabelTextCenterArcLength(const SbVec3f& ctr, const SbVe
|
||||
float endangle = atan2f(vc2[1], vc2[0]);
|
||||
|
||||
if (endangle < startangle) {
|
||||
endangle += 2. * M_PI;
|
||||
endangle += 2. * std::numbers::pi;
|
||||
}
|
||||
|
||||
// Text location
|
||||
@@ -697,7 +702,7 @@ SbVec3f SoDatumLabel::getLabelTextCenterArcLength(const SbVec3f& ctr, const SbVe
|
||||
vm.normalize();
|
||||
|
||||
SbVec3f textCenter;
|
||||
if (endangle - startangle <= M_PI) {
|
||||
if (endangle - startangle <= std::numbers::pi) {
|
||||
textCenter = ctr + vm * (length + this->imgHeight);
|
||||
} else {
|
||||
textCenter = ctr - vm * (length + 2. * this->imgHeight);
|
||||
@@ -709,12 +714,13 @@ SbVec3f SoDatumLabel::getLabelTextCenterArcLength(const SbVec3f& ctr, const SbVe
|
||||
void SoDatumLabel::generateDistancePrimitives(SoAction * action, const SbVec3f& p1, const SbVec3f& p2)
|
||||
{
|
||||
SbVec3f dir;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (this->datumtype.getValue() == DISTANCE) {
|
||||
dir = (p2-p1);
|
||||
} else if (this->datumtype.getValue() == DISTANCEX) {
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
} else if (this->datumtype.getValue() == DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -957,7 +963,8 @@ void SoDatumLabel::generateArcLengthPrimitives(SoAction * action, const SbVec3f&
|
||||
void SoDatumLabel::generatePrimitives(SoAction * action)
|
||||
{
|
||||
// Initialisation check (needs something more sensible) prevents an infinite loop bug
|
||||
if (this->imgHeight <= FLT_EPSILON || this->imgWidth <= FLT_EPSILON) {
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (this->imgHeight <= floatEpsilon | this->imgWidth <= floatEpsilon) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1161,6 +1168,8 @@ void SoDatumLabel::getDimension(float scale, int& srcw, int& srch)
|
||||
|
||||
void SoDatumLabel::drawDistance(const SbVec3f* points, float scale, int srch, float& angle, SbVec3f& textOffset)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
float length = this->param1.getValue();
|
||||
float length2 = this->param2.getValue();
|
||||
|
||||
@@ -1168,12 +1177,13 @@ void SoDatumLabel::drawDistance(const SbVec3f* points, float scale, int srch, fl
|
||||
SbVec3f p2 = points[1];
|
||||
|
||||
SbVec3f dir;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (this->datumtype.getValue() == DISTANCE) {
|
||||
dir = (p2-p1);
|
||||
} else if (this->datumtype.getValue() == DISTANCEX) {
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
} else if (this->datumtype.getValue() == DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -1192,10 +1202,10 @@ void SoDatumLabel::drawDistance(const SbVec3f* points, float scale, int srch, fl
|
||||
|
||||
// Get magnitude of angle between horizontal
|
||||
angle = atan2f(dir[1],dir[0]);
|
||||
if (angle > M_PI_2+M_PI/12) {
|
||||
angle -= (float)M_PI;
|
||||
} else if (angle <= -M_PI_2+M_PI/12) {
|
||||
angle += (float)M_PI;
|
||||
if (angle > pi/2 + pi/12) {
|
||||
angle -= (float)pi;
|
||||
} else if (angle <= -pi/2 + pi/12) {
|
||||
angle += (float)pi;
|
||||
}
|
||||
|
||||
textOffset = midpos + normal * length + dir * length2;
|
||||
@@ -1291,7 +1301,7 @@ void SoDatumLabel::drawDistance(const SbVec3f* points)
|
||||
float startangle1 = this->param3.getValue();
|
||||
float radius1 = this->param5.getValue();
|
||||
SbVec3f center = points[2];
|
||||
int countSegments = std::max(6, abs(int(50.0 * range1 / (2 * M_PI))));
|
||||
int countSegments = std::max(6, abs(int(50.0 * range1 / (2 * std::numbers::pi))));
|
||||
double segment = range1 / (countSegments - 1);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -1307,7 +1317,7 @@ void SoDatumLabel::drawDistance(const SbVec3f* points)
|
||||
float startangle2 = this->param6.getValue();
|
||||
float radius2 = this->param8.getValue();
|
||||
SbVec3f center = points[3];
|
||||
int countSegments = std::max(6, abs(int(50.0 * range2 / (2 * M_PI))));
|
||||
int countSegments = std::max(6, abs(int(50.0 * range2 / (2 * std::numbers::pi))));
|
||||
double segment = range2 / (countSegments - 1);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -1342,10 +1352,10 @@ void SoDatumLabel::drawRadiusOrDiameter(const SbVec3f* points, float& angle, SbV
|
||||
|
||||
// Get magnitude of angle between horizontal
|
||||
angle = atan2f(dir[1],dir[0]);
|
||||
if (angle > M_PI_2+M_PI/12) {
|
||||
angle -= (float)M_PI;
|
||||
} else if (angle <= -M_PI_2+M_PI/12) {
|
||||
angle += (float)M_PI;
|
||||
if (angle > std::numbers::pi/2 + std::numbers::pi/12) {
|
||||
angle -= (float)std::numbers::pi;
|
||||
} else if (angle <= -std::numbers::pi/2 + std::numbers::pi/12) {
|
||||
angle += (float)std::numbers::pi;
|
||||
}
|
||||
|
||||
textOffset = pos;
|
||||
@@ -1401,7 +1411,7 @@ void SoDatumLabel::drawRadiusOrDiameter(const SbVec3f* points, float& angle, SbV
|
||||
float startangle = this->param3.getValue();
|
||||
float range = this->param4.getValue();
|
||||
if (range != 0.0) {
|
||||
int countSegments = std::max(6, abs(int(50.0 * range / (2 * M_PI))));
|
||||
int countSegments = std::max(6, abs(int(50.0 * range / (2 * std::numbers::pi))));
|
||||
double segment = range / (countSegments - 1);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -1521,6 +1531,8 @@ void SoDatumLabel::drawSymmetric(const SbVec3f* points)
|
||||
|
||||
void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& textOffset)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
SbVec3f ctr = points[0];
|
||||
SbVec3f p1 = points[1];
|
||||
SbVec3f p2 = points[2];
|
||||
@@ -1535,7 +1547,7 @@ void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& t
|
||||
float startangle = atan2f(vc1[1], vc1[0]);
|
||||
float endangle = atan2f(vc2[1], vc2[0]);
|
||||
if (endangle < startangle) {
|
||||
endangle += 2.0F * (float)M_PI;
|
||||
endangle += 2.0F * (float)pi;
|
||||
}
|
||||
|
||||
float range = endangle - startangle;
|
||||
@@ -1547,10 +1559,10 @@ void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& t
|
||||
dir.normalize();
|
||||
// Get magnitude of angle between horizontal
|
||||
angle = atan2f(dir[1],dir[0]);
|
||||
if (angle > M_PI_2+M_PI/12) {
|
||||
angle -= (float)M_PI;
|
||||
} else if (angle <= -M_PI_2+M_PI/12) {
|
||||
angle += (float)M_PI;
|
||||
if (angle > pi/2 + pi/12) {
|
||||
angle -= (float)pi;
|
||||
} else if (angle <= -pi/2 + pi/12) {
|
||||
angle += (float)pi;
|
||||
}
|
||||
// Text location
|
||||
textOffset = getLabelTextCenterArcLength(ctr, p1, p2);
|
||||
@@ -1566,7 +1578,7 @@ void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& t
|
||||
SbVec3f pnt4 = p2 + (length-radius) * vm;
|
||||
|
||||
// Draw arc
|
||||
if (range <= M_PI) {
|
||||
if (range <= pi) {
|
||||
glDrawArc(ctr + (length-radius)*vm, radius, startangle, endangle);
|
||||
}
|
||||
else {
|
||||
@@ -1606,7 +1618,7 @@ void SoDatumLabel::drawText(SoState *state, int srcw, int srch, float angle, con
|
||||
const SbViewVolume & vv = SoViewVolumeElement::get(state);
|
||||
SbVec3f z = vv.zVector();
|
||||
|
||||
bool flip = norm.getValue().dot(z) > FLT_EPSILON;
|
||||
bool flip = norm.getValue().dot(z) > std::numeric_limits<float>::epsilon();
|
||||
|
||||
static bool init = false;
|
||||
static bool npot = false;
|
||||
@@ -1678,7 +1690,7 @@ void SoDatumLabel::drawText(SoState *state, int srcw, int srch, float angle, con
|
||||
|
||||
// Apply a rotation and translation matrix
|
||||
glTranslatef(textOffset[0], textOffset[1], textOffset[2]);
|
||||
glRotatef((GLfloat) angle * 180 / M_PI, 0,0,1);
|
||||
glRotatef((GLfloat) angle * 180 / std::numbers::pi, 0,0,1);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glColor3f(1.F, 1.F, 1.F);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cassert>
|
||||
#include <numbers>
|
||||
|
||||
#include <Inventor/SbRotation.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
@@ -743,7 +744,7 @@ RDragger::RDragger()
|
||||
}
|
||||
|
||||
SO_KIT_ADD_FIELD(rotation, (SbVec3f(0.0, 0.0, 1.0), 0.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (M_PI / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (std::numbers::pi / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCount, (0));
|
||||
|
||||
SO_KIT_INIT_INSTANCE();
|
||||
@@ -808,7 +809,7 @@ SoGroup* RDragger::buildGeometry()
|
||||
|
||||
unsigned int segments = 15;
|
||||
|
||||
float angleIncrement = static_cast<float>(M_PI / 2.0) / static_cast<float>(segments);
|
||||
float angleIncrement = (std::numbers::pi_v<float> / 2.f) / static_cast<float>(segments);
|
||||
SbRotation rotation(SbVec3f(0.0, 0.0, 1.0), angleIncrement);
|
||||
SbVec3f point(arcRadius, 0.0, 0.0);
|
||||
for (unsigned int index = 0; index <= segments; ++index) {
|
||||
@@ -965,9 +966,10 @@ void RDragger::drag()
|
||||
appendRotation(getStartMotionMatrix(), localRotation, SbVec3f(0.0, 0.0, 0.0)));
|
||||
}
|
||||
|
||||
Base::Quantity quantity(static_cast<double>(rotationIncrementCount.getValue()) * (180.0 / M_PI)
|
||||
* rotationIncrement.getValue(),
|
||||
Base::Unit::Angle);
|
||||
Base::Quantity quantity(
|
||||
static_cast<double>(rotationIncrementCount.getValue())
|
||||
* (180.0 / std::numbers::pi)* rotationIncrement.getValue(),
|
||||
Base::Unit::Angle);
|
||||
|
||||
QString message =
|
||||
QStringLiteral("%1 %2").arg(QObject::tr("Rotation:"), QString::fromStdString(quantity.getUserString()));
|
||||
@@ -1179,7 +1181,7 @@ SoFCCSysDragger::SoFCCSysDragger()
|
||||
SO_KIT_ADD_FIELD(translationIncrementCountZ, (0));
|
||||
|
||||
SO_KIT_ADD_FIELD(rotation, (SbVec3f(0.0, 0.0, 1.0), 0.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (M_PI / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (std::numbers::pi / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCountX, (0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCountY, (0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCountZ, (0));
|
||||
@@ -1272,7 +1274,7 @@ SoFCCSysDragger::SoFCCSysDragger()
|
||||
|
||||
SoRotation* localRotation;
|
||||
SbRotation tempRotation;
|
||||
auto angle = static_cast<float>(M_PI / 2.0);
|
||||
auto angle = static_cast<float>(std::numbers::pi / 2.0);
|
||||
// Translator
|
||||
localRotation = SO_GET_ANY_PART(this, "xTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbVec3f(0.0, 0.0, -1.0), angle);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <cfloat>
|
||||
# include <QFontMetrics>
|
||||
# include <QPainter>
|
||||
# include <QPen>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGestureEvent>
|
||||
#include <QWidget>
|
||||
@@ -86,8 +88,8 @@ SoGesturePinchEvent::SoGesturePinchEvent(QPinchGesture* qpinch, QWidget *widget)
|
||||
deltaZoom = qpinch->scaleFactor();
|
||||
totalZoom = qpinch->totalScaleFactor();
|
||||
|
||||
deltaAngle = -unbranchAngle((qpinch->rotationAngle()-qpinch->lastRotationAngle()) / 180.0 * M_PI);
|
||||
totalAngle = -qpinch->totalRotationAngle() / 180 * M_PI;
|
||||
deltaAngle = -unbranchAngle((qpinch->rotationAngle()-qpinch->lastRotationAngle()) / 180.0 * std::numbers::pi);
|
||||
totalAngle = -qpinch->totalRotationAngle() / 180 * std::numbers::pi;
|
||||
|
||||
state = SbGestureState(qpinch->state());
|
||||
|
||||
@@ -111,7 +113,9 @@ SbBool SoGesturePinchEvent::isSoGesturePinchEvent(const SoEvent *ev) const
|
||||
*/
|
||||
double SoGesturePinchEvent::unbranchAngle(double ang)
|
||||
{
|
||||
return ang - 2.0 * M_PI * floor((ang + M_PI) / (2.0 * M_PI));
|
||||
using std::numbers::pi;
|
||||
|
||||
return ang - 2.0 * pi * floor((ang + pi) / (2.0 * pi));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+16
-12
@@ -238,7 +238,7 @@ UnsignedValidator::UnsignedValidator( QObject * parent )
|
||||
: QValidator( parent )
|
||||
{
|
||||
b = 0;
|
||||
t = UINT_MAX;
|
||||
t = std::numeric_limits<unsigned>::max();
|
||||
}
|
||||
|
||||
UnsignedValidator::UnsignedValidator( uint minimum, uint maximum, QObject * parent )
|
||||
@@ -295,27 +295,31 @@ public:
|
||||
uint mapToUInt( int v ) const
|
||||
{
|
||||
uint ui;
|
||||
if ( v == INT_MIN ) {
|
||||
if ( v == std::numeric_limits<int>::min() ) {
|
||||
ui = 0;
|
||||
} else if ( v == INT_MAX ) {
|
||||
ui = UINT_MAX;
|
||||
} else if ( v == std::numeric_limits<int>::max() ) {
|
||||
ui = std::numeric_limits<unsigned>::max();
|
||||
} else if ( v < 0 ) {
|
||||
v -= INT_MIN; ui = (uint)v;
|
||||
v -= std::numeric_limits<int>::min();
|
||||
ui = static_cast<uint>(v);
|
||||
} else {
|
||||
ui = (uint)v; ui -= INT_MIN;
|
||||
ui = static_cast<uint>(v);
|
||||
ui -= std::numeric_limits<int>::min();
|
||||
} return ui;
|
||||
}
|
||||
int mapToInt( uint v ) const
|
||||
{
|
||||
int in;
|
||||
if ( v == UINT_MAX ) {
|
||||
in = INT_MAX;
|
||||
if ( v == std::numeric_limits<unsigned>::max() ) {
|
||||
in = std::numeric_limits<int>::max();
|
||||
} else if ( v == 0 ) {
|
||||
in = INT_MIN;
|
||||
} else if ( v > INT_MAX ) {
|
||||
v += INT_MIN; in = (int)v;
|
||||
in = std::numeric_limits<int>::min();
|
||||
} else if ( v > std::numeric_limits<int>::max() ) {
|
||||
v += std::numeric_limits<int>::min();
|
||||
in = static_cast<int>(v);
|
||||
} else {
|
||||
in = v; in += INT_MIN;
|
||||
in = v;
|
||||
in += std::numeric_limits<int>::min();
|
||||
} return in;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -378,6 +378,7 @@ Base::Vector3d Transform::getDirection() const
|
||||
|
||||
Base::Placement Transform::getPlacementData() const
|
||||
{
|
||||
using std::numbers::pi;
|
||||
int index = ui->rotationInput->currentIndex();
|
||||
Base::Rotation rot;
|
||||
Base::Vector3d pos;
|
||||
@@ -388,7 +389,7 @@ Base::Placement Transform::getPlacementData() const
|
||||
|
||||
if (index == 0) {
|
||||
Base::Vector3d dir = getDirection();
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value().getValue()*D_PI/180.0);
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value().getValue()*pi/180.0);
|
||||
}
|
||||
else if (index == 1) {
|
||||
rot.setYawPitchRoll(
|
||||
|
||||
@@ -255,8 +255,8 @@ QWidget *VectorTableDelegate::createEditor(QWidget *parent, const QStyleOptionVi
|
||||
{
|
||||
auto editor = new QDoubleSpinBox(parent);
|
||||
editor->setDecimals(decimals);
|
||||
editor->setMinimum(INT_MIN);
|
||||
editor->setMaximum(INT_MAX);
|
||||
editor->setMinimum(std::numeric_limits<int>::min());
|
||||
editor->setMaximum(std::numeric_limits<int>::max());
|
||||
editor->setSingleStep(0.1);
|
||||
|
||||
return editor;
|
||||
@@ -299,11 +299,14 @@ VectorListEditor::VectorListEditor(int decimals, QWidget* parent)
|
||||
ui->tableWidget->setModel(model);
|
||||
ui->widget->hide();
|
||||
|
||||
ui->coordX->setRange(INT_MIN, INT_MAX);
|
||||
ui->coordX->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
ui->coordX->setDecimals(decimals);
|
||||
ui->coordY->setRange(INT_MIN, INT_MAX);
|
||||
ui->coordY->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
ui->coordY->setDecimals(decimals);
|
||||
ui->coordZ->setRange(INT_MIN, INT_MAX);
|
||||
ui->coordZ->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
ui->coordZ->setDecimals(decimals);
|
||||
|
||||
ui->toolButtonMouse->setDisabled(true);
|
||||
|
||||
@@ -43,7 +43,7 @@ View3DInventorRiftViewer::View3DInventorRiftViewer() : CoinRiftWidget()
|
||||
|
||||
rotation1 = new SoRotationXYZ ;
|
||||
rotation1->axis.setValue(SoRotationXYZ::X);
|
||||
rotation1->angle.setValue(-M_PI/2);
|
||||
rotation1->angle.setValue(-std::numbers::pi/2);
|
||||
workplace->addChild(rotation1);
|
||||
|
||||
rotation2 = new SoRotationXYZ ;
|
||||
@@ -104,7 +104,7 @@ void View3DInventorRiftViewer::setSceneGraph(SoNode *sceneGraph)
|
||||
void View3DInventorRiftViewer::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
static const float increment = 0.02; // move two centimeter per key
|
||||
static const float rotIncrement = M_PI/4; // move two 90° per key
|
||||
static const float rotIncrement = std::numbers::pi / 4; // move two 90° per key
|
||||
|
||||
|
||||
if (event->key() == Qt::Key_Plus) {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
@@ -3262,7 +3261,7 @@ void View3DInventorViewer::setCameraType(SoType type)
|
||||
// heightAngle. Setting it to 45 deg also causes an issue with a too
|
||||
// close camera but we don't have this other ugly effect.
|
||||
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(M_PI / 4.0); // NOLINT
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT
|
||||
}
|
||||
|
||||
lightRotation->rotation.connectFrom(&cam->orientation);
|
||||
@@ -3421,7 +3420,7 @@ void View3DInventorViewer::viewAll()
|
||||
SoCamera* cam = this->getSoRenderManager()->getCamera();
|
||||
|
||||
if (cam && cam->getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId())) {
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(M_PI / 4.0); // NOLINT
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT
|
||||
}
|
||||
|
||||
if (isAnimationEnabled()) {
|
||||
@@ -3605,26 +3604,28 @@ void View3DInventorViewer::alignToSelection()
|
||||
angle *= -1;
|
||||
}
|
||||
|
||||
using std::numbers::pi;
|
||||
|
||||
// Make angle positive
|
||||
if (angle < 0) {
|
||||
angle += 2 * M_PI;
|
||||
angle += 2 * pi;
|
||||
}
|
||||
|
||||
// Find the angle to rotate to the nearest horizontal or vertical alignment with directionX.
|
||||
// f is a small value used to get more deterministic behavior when the camera is at directionX +- 45 degrees.
|
||||
const float f = 0.00001F;
|
||||
|
||||
if (angle <= M_PI_4 + f) {
|
||||
if (angle <= pi/4 + f) {
|
||||
angle = 0;
|
||||
}
|
||||
else if (angle <= 3 * M_PI_4 + f) {
|
||||
angle = M_PI_2;
|
||||
else if (angle <= 3 * pi/4 + f) {
|
||||
angle = pi/2;
|
||||
}
|
||||
else if (angle < M_PI + M_PI_4 - f) {
|
||||
angle = M_PI;
|
||||
else if (angle < pi + pi/4 - f) {
|
||||
angle = pi;
|
||||
}
|
||||
else if (angle < M_PI + 3 * M_PI_4 - f) {
|
||||
angle = M_PI + M_PI_2;
|
||||
else if (angle < pi + 3 * pi/4 - f) {
|
||||
angle = pi + pi/2;
|
||||
}
|
||||
else {
|
||||
angle = 0;
|
||||
@@ -3933,7 +3934,7 @@ void View3DInventorViewer::drawAxisCross()
|
||||
|
||||
const float NEARVAL = 0.1F;
|
||||
const float FARVAL = 10.0F;
|
||||
const float dim = NEARVAL * float(tan(M_PI / 8.0)); // FOV is 45 deg (45/360 = 1/8)
|
||||
const float dim = NEARVAL * float(tan(std::numbers::pi / 8.0)); // FOV is 45 deg (45/360 = 1/8)
|
||||
glFrustum(-dim, dim, -dim, dim, NEARVAL, FARVAL);
|
||||
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ Py::Object View3DInventorPy::viewRotateLeft()
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vdir(0, 0, -1);
|
||||
rot.multVec(vdir, vdir);
|
||||
SbRotation nrot(vdir, (float)M_PI/2);
|
||||
SbRotation nrot(vdir, (float)std::numbers::pi/2);
|
||||
cam->orientation.setValue(rot*nrot);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
@@ -681,7 +681,7 @@ Py::Object View3DInventorPy::viewRotateRight()
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vdir(0, 0, -1);
|
||||
rot.multVec(vdir, vdir);
|
||||
SbRotation nrot(vdir, (float)-M_PI/2);
|
||||
SbRotation nrot(vdir, (float)-std::numbers::pi/2);
|
||||
cam->orientation.setValue(rot*nrot);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
|
||||
@@ -155,7 +155,7 @@ void ViewProviderAnnotation::onChanged(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
else if (prop == &Rotation) {
|
||||
pRotationXYZ->angle = (Rotation.getValue()/360)*(2*M_PI);
|
||||
pRotationXYZ->angle = (Rotation.getValue()/360)*(2*std::numbers::pi);
|
||||
}
|
||||
else {
|
||||
ViewProviderDocumentObject::onChanged(prop);
|
||||
|
||||
@@ -968,7 +968,8 @@ QWidget* PropertyIntegerItem::createEditor(QWidget* parent,
|
||||
void PropertyIntegerItem::setEditorData(QWidget* editor, const QVariant& data) const
|
||||
{
|
||||
auto sb = qobject_cast<QSpinBox*>(editor);
|
||||
sb->setRange(INT_MIN, INT_MAX);
|
||||
sb->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
sb->setValue(data.toInt());
|
||||
}
|
||||
|
||||
@@ -1128,7 +1129,8 @@ QWidget* PropertyFloatItem::createEditor(QWidget* parent, const std::function<vo
|
||||
void PropertyFloatItem::setEditorData(QWidget* editor, const QVariant& data) const
|
||||
{
|
||||
auto sb = qobject_cast<QDoubleSpinBox*>(editor);
|
||||
sb->setRange((double)INT_MIN, (double)INT_MAX);
|
||||
sb->setRange(static_cast<double>(std::numeric_limits<int>::min()),
|
||||
static_cast<double>(std::numeric_limits<int>::max()));
|
||||
sb->setValue(data.toDouble());
|
||||
}
|
||||
|
||||
|
||||
@@ -360,8 +360,8 @@ protected:
|
||||
PropertyIntegerConstraintItem();
|
||||
|
||||
private:
|
||||
int min = INT_MIN;
|
||||
int max = INT_MAX;
|
||||
int min = std::numeric_limits<int>::min();
|
||||
int max = std::numeric_limits<int>::max();
|
||||
int steps = 1;
|
||||
};
|
||||
|
||||
@@ -434,8 +434,8 @@ protected:
|
||||
PropertyUnitConstraintItem();
|
||||
|
||||
private:
|
||||
double min = double(INT_MIN);
|
||||
double max = double(INT_MAX);
|
||||
double min = static_cast<double>(std::numeric_limits<int>::min());
|
||||
double max = static_cast<double>(std::numeric_limits<int>::max());
|
||||
double steps = 0.1;
|
||||
};
|
||||
|
||||
@@ -472,8 +472,8 @@ protected:
|
||||
PropertyFloatConstraintItem();
|
||||
|
||||
private:
|
||||
double min = double(INT_MIN);
|
||||
double max = double(INT_MAX);
|
||||
double min = static_cast<double>(std::numeric_limits<int>::min());
|
||||
double max = static_cast<double>(std::numeric_limits<int>::max());
|
||||
double steps = 0.1;
|
||||
};
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant& value, int
|
||||
// now?
|
||||
double d = data.toDouble();
|
||||
double v = value.toDouble();
|
||||
if (fabs(d - v) > DBL_EPSILON) {
|
||||
if (fabs(d - v) > std::numeric_limits<double>::epsilon()) {
|
||||
return item->setData(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1120,7 +1120,7 @@ std::shared_ptr<ASMTJoint> AssemblyObject::makeMbdJointOfType(App::DocumentObjec
|
||||
}
|
||||
else if (type == JointType::Angle) {
|
||||
double angle = fabs(Base::toRadians(getJointDistance(joint)));
|
||||
if (fmod(angle, 2 * M_PI) < Precision::Confusion()) {
|
||||
if (fmod(angle, 2 * std::numbers::pi) < Precision::Confusion()) {
|
||||
return CREATE<ASMTParallelAxesJoint>::With();
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
#define BOOST_GEOMETRY_DISABLE_DEPRECATED_03_WARNING
|
||||
|
||||
#ifndef _PreComp_
|
||||
#include <cfloat>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
@@ -452,7 +451,7 @@ void Area::addWire(CArea& area,
|
||||
if (reversed) {
|
||||
type = -type;
|
||||
}
|
||||
if (fabs(first - last) > M_PI) {
|
||||
if (fabs(first - last) > std::numbers::pi) {
|
||||
// Split arc(circle) larger than half circle. Because gcode
|
||||
// can't handle full circle?
|
||||
gp_Pnt mid = curve.Value((last - first) * 0.5 + first);
|
||||
@@ -1221,7 +1220,8 @@ struct WireJoiner
|
||||
info.iEnd[i] = info.iStart[i] = (int)adjacentList.size();
|
||||
|
||||
// populate adjacent list
|
||||
for (auto vit = vmap.qbegin(bgi::nearest(pt[i], INT_MAX)); vit != vmap.qend();
|
||||
constexpr int intMax = std::numeric_limits<int>::max();
|
||||
for (auto vit = vmap.qbegin(bgi::nearest(pt[i], intMax)); vit != vmap.qend();
|
||||
++vit) {
|
||||
++rcount;
|
||||
if (vit->pt().SquareDistance(pt[i]) > tol) {
|
||||
@@ -2631,7 +2631,7 @@ TopoDS_Shape Area::makePocket(int index, PARAM_ARGS(PARAM_FARG, AREA_PARAMS_POCK
|
||||
for (int j = 0; j < steps; ++j, offset += stepover) {
|
||||
Point p1(-r, offset), p2(r, offset);
|
||||
if (a > Precision::Confusion()) {
|
||||
double r = a * M_PI / 180.0;
|
||||
double r = a * std::numbers::pi / 180.0;
|
||||
p1.Rotate(r);
|
||||
p2.Rotate(r);
|
||||
}
|
||||
@@ -3703,7 +3703,7 @@ std::list<TopoDS_Shape> Area::sortWires(const std::list<TopoDS_Shape>& shapes,
|
||||
double max_dist = sort_mode == SortModeGreedy ? threshold * threshold : 0;
|
||||
while (!shape_list.empty()) {
|
||||
AREA_TRACE("sorting " << shape_list.size() << ' ' << AREA_XYZ(pstart));
|
||||
double best_d = DBL_MAX;
|
||||
double best_d = std::numeric_limits<double>::max();
|
||||
auto best_it = shape_list.begin();
|
||||
for (auto it = best_it; it != shape_list.end(); ++it) {
|
||||
double d;
|
||||
@@ -4155,7 +4155,7 @@ void Area::toPath(Toolpath& path,
|
||||
}
|
||||
}
|
||||
|
||||
if (fabs(first - last) > M_PI) {
|
||||
if (fabs(first - last) > std::numbers::pi) {
|
||||
// Split arc(circle) larger than half circle.
|
||||
gp_Pnt mid = curve.Value((last - first) * 0.5 + first);
|
||||
addGArc(verbose,
|
||||
|
||||
@@ -31,14 +31,6 @@
|
||||
|
||||
#define ARC_MIN_SEGMENTS 20.0 // minimum # segments to interpolate an arc
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846 /* pi */
|
||||
#endif
|
||||
|
||||
#ifndef M_PI_2
|
||||
#define M_PI_2 1.57079632679489661923 /* pi/2 */
|
||||
#endif
|
||||
|
||||
|
||||
namespace Path
|
||||
{
|
||||
@@ -195,7 +187,7 @@ void PathSegmentWalker::walk(PathSegmentVisitor& cb, const Base::Vector3d& start
|
||||
if (nrot != lrot) {
|
||||
double amax = std::max(fmod(fabs(a - A), 360),
|
||||
std::max(fmod(fabs(b - B), 360), fmod(fabs(c - C), 360)));
|
||||
double angle = amax / 180 * M_PI;
|
||||
double angle = amax / 180 * std::numbers::pi;
|
||||
int segments = std::max(ARC_MIN_SEGMENTS, 3.0 / (deviation / angle));
|
||||
|
||||
double da = (a - A) / segments;
|
||||
@@ -257,16 +249,16 @@ void PathSegmentWalker::walk(PathSegmentVisitor& cb, const Base::Vector3d& start
|
||||
Base::Vector3d anorm = (last0 - center0) % (next0 - center0);
|
||||
if (anorm.*pz < 0) {
|
||||
if (name == "G3" || name == "G03") {
|
||||
angle = M_PI * 2 - angle;
|
||||
angle = std::numbers::pi * 2 - angle;
|
||||
}
|
||||
}
|
||||
else if (anorm.*pz > 0) {
|
||||
if (name == "G2" || name == "G02") {
|
||||
angle = M_PI * 2 - angle;
|
||||
angle = std::numbers::pi * 2 - angle;
|
||||
}
|
||||
}
|
||||
else if (angle == 0) {
|
||||
angle = M_PI * 2;
|
||||
angle = std::numbers::pi * 2;
|
||||
}
|
||||
|
||||
double amax = std::max(fmod(fabs(a - A), 360),
|
||||
@@ -337,7 +329,7 @@ void PathSegmentWalker::walk(PathSegmentVisitor& cb, const Base::Vector3d& start
|
||||
if (nrot != lrot) {
|
||||
double amax = std::max(fmod(fabs(a - A), 360),
|
||||
std::max(fmod(fabs(b - B), 360), fmod(fabs(c - C), 360)));
|
||||
double angle = amax / 180 * M_PI;
|
||||
double angle = amax / 180 * std::numbers::pi;
|
||||
int segments = std::max(ARC_MIN_SEGMENTS, 3.0 / (deviation / angle));
|
||||
|
||||
double da = (a - A) / segments;
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#endif
|
||||
|
||||
#include <Base/Vector3D.h>
|
||||
@@ -260,10 +258,10 @@ double Voronoi::diagram_type::angleOfSegment(int i, Voronoi::diagram_type::angle
|
||||
double ang = 0;
|
||||
if (p0.x() == p1.x()) {
|
||||
if (p0.y() < p1.y()) {
|
||||
ang = M_PI_2;
|
||||
ang = std::numbers::pi / 2;
|
||||
}
|
||||
else {
|
||||
ang = -M_PI_2;
|
||||
ang = -std::numbers::pi / 2;
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -292,7 +290,8 @@ bool Voronoi::diagram_type::segmentsAreConnected(int i, int j) const
|
||||
|
||||
void Voronoi::colorColinear(Voronoi::color_type color, double degree)
|
||||
{
|
||||
double rad = degree * M_PI / 180;
|
||||
using std::numbers::pi;
|
||||
double rad = degree * pi / 180;
|
||||
|
||||
Voronoi::diagram_type::angle_map_t angle;
|
||||
int psize = vd->points.size();
|
||||
@@ -306,11 +305,11 @@ void Voronoi::colorColinear(Voronoi::color_type color, double degree)
|
||||
double a0 = vd->angleOfSegment(i0, &angle);
|
||||
double a1 = vd->angleOfSegment(i1, &angle);
|
||||
double a = a0 - a1;
|
||||
if (a > M_PI_2) {
|
||||
a -= M_PI;
|
||||
if (a > pi / 2) {
|
||||
a -= pi;
|
||||
}
|
||||
else if (a < -M_PI_2) {
|
||||
a += M_PI;
|
||||
else if (a < -pi / 2) {
|
||||
a += pi;
|
||||
}
|
||||
if (fabs(a) < rad) {
|
||||
it->color(color);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#ifndef PATH_VORONOI_H
|
||||
#define PATH_VORONOI_H
|
||||
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <Base/BaseClass.h>
|
||||
@@ -33,11 +32,6 @@
|
||||
#include <boost/polygon/polygon.hpp>
|
||||
#include <boost/polygon/voronoi.hpp>
|
||||
|
||||
#if (SIZE_MAX == UINT_MAX)
|
||||
#define PATH_VORONOI_COLOR_MASK 0x07FFFFFFul
|
||||
#else
|
||||
#define PATH_VORONOI_COLOR_MASK 0x07FFFFFFFFFFFFFFul
|
||||
#endif
|
||||
|
||||
namespace Path
|
||||
{
|
||||
@@ -51,8 +45,8 @@ public:
|
||||
~Voronoi() override;
|
||||
|
||||
using color_type = std::size_t;
|
||||
static const int InvalidIndex = INT_MAX;
|
||||
static const color_type ColorMask = PATH_VORONOI_COLOR_MASK;
|
||||
static const int InvalidIndex = std::numeric_limits<int>::max();
|
||||
static const color_type ColorMask = std::numeric_limits<color_type>::max() >> 5;
|
||||
|
||||
// types
|
||||
using coordinate_type = double;
|
||||
|
||||
@@ -466,12 +466,12 @@ PyObject* VoronoiEdgePy::isBorderline(PyObject* args)
|
||||
PyObject* VoronoiEdgePy::toShape(PyObject* args)
|
||||
{
|
||||
double z0 = 0.0;
|
||||
double z1 = DBL_MAX;
|
||||
double z1 = std::numeric_limits<double>::max();
|
||||
int dbg = 0;
|
||||
if (!PyArg_ParseTuple(args, "|ddp", &z0, &z1, &dbg)) {
|
||||
throw Py::RuntimeError("no, one or two arguments of type double accepted");
|
||||
}
|
||||
if (z1 == DBL_MAX) {
|
||||
if (z1 == std::numeric_limits<double>::max()) {
|
||||
z1 = z0;
|
||||
}
|
||||
VoronoiEdge* e = getVoronoiEdgePtr();
|
||||
@@ -688,6 +688,8 @@ PyObject* VoronoiEdgePy::getDistances(PyObject* args)
|
||||
|
||||
PyObject* VoronoiEdgePy::getSegmentAngle(PyObject* args)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
VoronoiEdge* e = getVoronoiEdgeFromPy(this, args);
|
||||
|
||||
if (e->ptr->cell()->contains_segment() && e->ptr->twin()->cell()->contains_segment()) {
|
||||
@@ -697,11 +699,11 @@ PyObject* VoronoiEdgePy::getSegmentAngle(PyObject* args)
|
||||
double a0 = e->dia->angleOfSegment(i0);
|
||||
double a1 = e->dia->angleOfSegment(i1);
|
||||
double a = a0 - a1;
|
||||
if (a > M_PI_2) {
|
||||
a -= M_PI;
|
||||
if (a > pi / 2) {
|
||||
a -= pi;
|
||||
}
|
||||
else if (a < -M_PI_2) {
|
||||
a += M_PI;
|
||||
else if (a < -pi / 2) {
|
||||
a += pi;
|
||||
}
|
||||
return Py::new_reference_to(Py::Float(a));
|
||||
}
|
||||
|
||||
@@ -183,11 +183,11 @@ ViewProviderPath::ViewProviderPath()
|
||||
|
||||
|
||||
ShowCountConstraints.LowerBound = 0;
|
||||
ShowCountConstraints.UpperBound = INT_MAX;
|
||||
ShowCountConstraints.UpperBound = std::numeric_limits<int>::max();
|
||||
ShowCountConstraints.StepSize = 1;
|
||||
ShowCount.setConstraints(&ShowCountConstraints);
|
||||
StartIndexConstraints.LowerBound = 0;
|
||||
StartIndexConstraints.UpperBound = INT_MAX;
|
||||
StartIndexConstraints.UpperBound = std::numeric_limits<int>::max();
|
||||
StartIndexConstraints.StepSize = 1;
|
||||
StartIndex.setConstraints(&StartIndexConstraints);
|
||||
ADD_PROPERTY_TYPE(StartPosition,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define LINMATH_H
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
#ifdef LINMATH_NO_INLINE
|
||||
#define LINMATH_H_FUNC static
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <algorithm>
|
||||
#include <numbers>
|
||||
|
||||
namespace ClipperLib
|
||||
{
|
||||
@@ -116,7 +117,7 @@ inline double Angle3Points(const DoublePoint& p1, const DoublePoint& p2, const D
|
||||
double t1 = atan2(p2.Y - p1.Y, p2.X - p1.X);
|
||||
double t2 = atan2(p3.Y - p2.Y, p3.X - p2.X);
|
||||
double a = fabs(t2 - t1);
|
||||
return min(a, 2 * M_PI - a);
|
||||
return min(a, 2 * std::numbers::pi - a);
|
||||
}
|
||||
|
||||
inline DoublePoint DirectionV(const IntPoint& pt1, const IntPoint& pt2)
|
||||
@@ -1096,8 +1097,8 @@ private:
|
||||
class Interpolation
|
||||
{
|
||||
public:
|
||||
const double MIN_ANGLE = -M_PI / 4;
|
||||
const double MAX_ANGLE = M_PI / 4;
|
||||
const double MIN_ANGLE = -std::numbers::pi / 4;
|
||||
const double MAX_ANGLE = std::numbers::pi / 4;
|
||||
|
||||
void clear()
|
||||
{
|
||||
@@ -1542,7 +1543,7 @@ double Adaptive2d::CalcCutArea(Clipper& clip,
|
||||
double minFi = fi1;
|
||||
double maxFi = fi2;
|
||||
if (maxFi < minFi) {
|
||||
maxFi += 2 * M_PI;
|
||||
maxFi += 2 * std::numbers::pi;
|
||||
}
|
||||
|
||||
if (preventConventional && interPathLen >= RESOLUTION_FACTOR) {
|
||||
@@ -2359,7 +2360,7 @@ bool Adaptive2d::MakeLeadPath(bool leadIn,
|
||||
IntPoint(currentPoint.X + nextDir.X * stepSize, currentPoint.Y + nextDir.Y * stepSize);
|
||||
Path checkPath;
|
||||
double adaptFactor = 0.4;
|
||||
double alfa = M_PI / 64;
|
||||
double alfa = std::numbers::pi / 64;
|
||||
double pathLen = 0;
|
||||
checkPath.push_back(nextPoint);
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
@@ -2802,7 +2803,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths)
|
||||
IntPoint clp; // to store closest point
|
||||
vector<DoublePoint> gyro; // used to average tool direction
|
||||
vector<double> angleHistory; // use to predict deflection angle
|
||||
double angle = M_PI;
|
||||
double angle = std::numbers::pi;
|
||||
engagePoint = toolPos;
|
||||
Interpolation interp; // interpolation instance
|
||||
|
||||
@@ -2846,7 +2847,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths)
|
||||
}
|
||||
}
|
||||
|
||||
angle = M_PI / 4; // initial pass angle
|
||||
angle = std::numbers::pi / 4; // initial pass angle
|
||||
bool recalcArea = false;
|
||||
double cumulativeCutArea = 0;
|
||||
// init gyro
|
||||
@@ -2991,7 +2992,7 @@ void Adaptive2d::ProcessPolyNode(Paths boundPaths, Paths toolBoundPaths)
|
||||
rotateStep++;
|
||||
// if new tool pos. outside boundary rotate until back in
|
||||
recalcArea = true;
|
||||
newToolDir = rotate(newToolDir, M_PI / 90);
|
||||
newToolDir = rotate(newToolDir, std::numbers::pi / 90);
|
||||
newToolPos = IntPoint(long(toolPos.X + newToolDir.X * stepScaled),
|
||||
long(toolPos.Y + newToolDir.Y * stepScaled));
|
||||
}
|
||||
|
||||
@@ -36,10 +36,6 @@
|
||||
#define __LONG_MAX__ 2147483647
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141592653589793238
|
||||
#endif
|
||||
|
||||
// #define DEV_MODE
|
||||
|
||||
#define NTOL 1.0e-7 // numeric tolerance
|
||||
|
||||
@@ -29,7 +29,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#pragma once
|
||||
|
||||
#include <string.h> // for memcpy() prototype
|
||||
#include <math.h> // for sqrt() prototype
|
||||
#include <cmath> // for sqrt() prototype
|
||||
|
||||
class CBox2D
|
||||
{
|
||||
|
||||
@@ -31,7 +31,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include "Point.h"
|
||||
#include "Box2D.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
@@ -207,9 +207,10 @@ void SVGOutput::printCircle(const BRepAdaptor_Curve& c, std::ostream& out)
|
||||
}
|
||||
// arc of circle
|
||||
else {
|
||||
using std::numbers::pi;
|
||||
// See also https://developer.mozilla.org/en/SVG/Tutorial/Paths
|
||||
char xar = '0'; // x-axis-rotation
|
||||
char las = (l - f > D_PI) ? '1' : '0'; // large-arc-flag
|
||||
char xar = '0'; // x-axis-rotation
|
||||
char las = (l - f > pi) ? '1' : '0'; // large-arc-flag
|
||||
char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1)
|
||||
out << "<path d=\"M" << s.X() << " " << s.Y() << " A" << r << " " << r << " " << xar << " "
|
||||
<< las << " " << swp << " " << e.X() << " " << e.Y() << "\" />";
|
||||
@@ -255,7 +256,8 @@ void SVGOutput::printEllipse(const BRepAdaptor_Curve& c, int id, std::ostream& o
|
||||
}
|
||||
// arc of ellipse
|
||||
else {
|
||||
char las = (l - f > D_PI) ? '1' : '0'; // large-arc-flag
|
||||
using std::numbers::pi;
|
||||
char las = (l - f > pi) ? '1' : '0'; // large-arc-flag
|
||||
char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1)
|
||||
out << "<path d=\"M" << s.X() << " " << s.Y() << " A" << r1 << " " << r2 << " " << angle
|
||||
<< " " << las << " " << swp << " " << e.X() << " " << e.Y() << "\" />" << std::endl;
|
||||
@@ -460,6 +462,8 @@ void DXFOutput::printHeader(std::ostream& out)
|
||||
|
||||
void DXFOutput::printCircle(const BRepAdaptor_Curve& c, std::ostream& out)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
gp_Circ circ = c.Circle();
|
||||
const gp_Pnt& p = circ.Location();
|
||||
double r = circ.Radius();
|
||||
@@ -502,8 +506,8 @@ void DXFOutput::printCircle(const BRepAdaptor_Curve& c, std::ostream& out)
|
||||
double bx = e.X() - p.X();
|
||||
double by = e.Y() - p.Y();
|
||||
|
||||
double start_angle = atan2(ay, ax) * 180 / D_PI;
|
||||
double end_angle = atan2(by, bx) * 180 / D_PI;
|
||||
double start_angle = atan2(ay, ax) * 180 / pi;
|
||||
double end_angle = atan2(by, bx) * 180 / pi;
|
||||
|
||||
if (a > 0) {
|
||||
double temp = start_angle;
|
||||
|
||||
@@ -256,7 +256,7 @@ void orthoview::set_projection(const gp_Ax2& cs)
|
||||
// angle between desired projection and actual projection
|
||||
float rotation = X_dir.Angle(actual_X);
|
||||
|
||||
if (rotation != 0 && abs(M_PI - rotation) > 0.05) {
|
||||
if (rotation != 0 && abs(std::numbers::pi - rotation) > 0.05) {
|
||||
if (!Z_dir.IsEqual(actual_X.Crossed(X_dir), 0.05)) {
|
||||
rotation = -rotation;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ void orthoview::set_projection(const gp_Ax2& cs)
|
||||
|
||||
// this_view->Direction.setValue(Z_dir.X(), Z_dir.Y(), Z_dir.Z());
|
||||
this_view->Direction.setValue(x, y, z);
|
||||
this_view->Rotation.setValue(180 * rotation / M_PI);
|
||||
this_view->Rotation.setValue(180 * rotation / std::numbers::pi);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -613,8 +613,8 @@ void OrthoViews::set_orientation(int index) // set orientation of single view
|
||||
dir = primary.XDirection();
|
||||
n = -views[index]->rel_y;
|
||||
}
|
||||
|
||||
rotation = n * rotate_coeff * M_PI / 2; // rotate_coeff is -1 or 1 for 1st or 3rd angle
|
||||
// rotate_coeff is -1 or 1 for 1st or 3rd angle
|
||||
rotation = n * rotate_coeff * std::numbers::pi / 2;
|
||||
cs = primary.Rotated(gp_Ax1(gp_Pnt(0, 0, 0), dir), rotation);
|
||||
views[index]->set_projection(cs);
|
||||
}
|
||||
@@ -780,7 +780,7 @@ void OrthoViews::set_Axo(int rel_x,
|
||||
rotations[1] = -0.6156624905260762;
|
||||
}
|
||||
else {
|
||||
rotations[0] = 1.3088876392502007 - M_PI / 2;
|
||||
rotations[0] = 1.3088876392502007 - std::numbers::pi / 2;
|
||||
rotations[1] = -0.6156624905260762;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,10 @@ using Adaptor3d_HSurface = Adaptor3d_Surface;
|
||||
using BRepAdaptor_HSurface = BRepAdaptor_Surface;
|
||||
#endif
|
||||
|
||||
static const App::PropertyFloatConstraint::Constraints scaleConstraint = {0.0, DBL_MAX, 0.1};
|
||||
static const App::PropertyFloatConstraint::Constraints scaleConstraint = {
|
||||
0.0,
|
||||
std::numeric_limits<double>::max(),
|
||||
0.1};
|
||||
|
||||
PROPERTY_SOURCE(Fem::Constraint, App::DocumentObject)
|
||||
|
||||
|
||||
@@ -116,12 +116,14 @@ namespace
|
||||
|
||||
Base::Rotation anglesToRotation(double xAngle, double yAngle, double zAngle)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
static Base::Vector3d a(1, 0, 0);
|
||||
static Base::Vector3d b(0, 1, 0);
|
||||
static int count = 0;
|
||||
double xRad = xAngle * D_PI / 180.0;
|
||||
double yRad = yAngle * D_PI / 180.0;
|
||||
double zRad = zAngle * D_PI / 180.0;
|
||||
double xRad = xAngle * pi / 180.0;
|
||||
double yRad = yAngle * pi / 180.0;
|
||||
double zRad = zAngle * pi / 180.0;
|
||||
if (xAngle != 0) {
|
||||
a[1] = 0;
|
||||
a[2] = 0;
|
||||
|
||||
@@ -43,8 +43,8 @@ DlgSettingsFemCcxImp::DlgSettingsFemCcxImp(QWidget* parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
// set ranges
|
||||
ui->dsb_ccx_analysis_time->setMaximum(FLOAT_MAX);
|
||||
ui->dsb_ccx_initial_time_step->setMaximum(FLOAT_MAX);
|
||||
ui->dsb_ccx_analysis_time->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->dsb_ccx_initial_time_step->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
connect(ui->fc_ccx_binary_path,
|
||||
&Gui::PrefFileChooser::fileNameChanged,
|
||||
|
||||
@@ -66,18 +66,19 @@ TaskFemConstraintBearing::TaskFemConstraintBearing(ViewProviderFemConstraint* Co
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
// setup ranges
|
||||
ui->spinDiameter->setMinimum(-FLOAT_MAX);
|
||||
ui->spinDiameter->setMaximum(FLOAT_MAX);
|
||||
ui->spinOtherDiameter->setMinimum(-FLOAT_MAX);
|
||||
ui->spinOtherDiameter->setMaximum(FLOAT_MAX);
|
||||
ui->spinCenterDistance->setMinimum(-FLOAT_MAX);
|
||||
ui->spinCenterDistance->setMaximum(FLOAT_MAX);
|
||||
ui->spinForce->setMinimum(-FLOAT_MAX);
|
||||
ui->spinForce->setMaximum(FLOAT_MAX);
|
||||
ui->spinTensionForce->setMinimum(-FLOAT_MAX);
|
||||
ui->spinTensionForce->setMaximum(FLOAT_MAX);
|
||||
ui->spinDistance->setMinimum(-FLOAT_MAX);
|
||||
ui->spinDistance->setMaximum(FLOAT_MAX);
|
||||
constexpr float max = std::numeric_limits<float>::max();
|
||||
ui->spinDiameter->setMinimum(-max);
|
||||
ui->spinDiameter->setMaximum(max);
|
||||
ui->spinOtherDiameter->setMinimum(-max);
|
||||
ui->spinOtherDiameter->setMaximum(max);
|
||||
ui->spinCenterDistance->setMinimum(-max);
|
||||
ui->spinCenterDistance->setMaximum(max);
|
||||
ui->spinForce->setMinimum(-max);
|
||||
ui->spinForce->setMaximum(max);
|
||||
ui->spinTensionForce->setMinimum(-max);
|
||||
ui->spinTensionForce->setMaximum(max);
|
||||
ui->spinDistance->setMinimum(-max);
|
||||
ui->spinDistance->setMaximum(max);
|
||||
|
||||
// Get the feature data
|
||||
Fem::ConstraintBearing* pcConstraint = ConstraintView->getObject<Fem::ConstraintBearing>();
|
||||
|
||||
@@ -96,27 +96,27 @@ TaskFemConstraintContact::TaskFemConstraintContact(ViewProviderFemConstraintCont
|
||||
// Fill data into dialog elements
|
||||
ui->spbSlope->setUnit(pcConstraint->Slope.getUnit());
|
||||
ui->spbSlope->setMinimum(0);
|
||||
ui->spbSlope->setMaximum(FLOAT_MAX);
|
||||
ui->spbSlope->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spbSlope->setValue(pcConstraint->Slope.getQuantityValue());
|
||||
ui->spbSlope->bind(pcConstraint->Slope);
|
||||
|
||||
ui->spbAdjust->setUnit(pcConstraint->Adjust.getUnit());
|
||||
ui->spbAdjust->setMinimum(0);
|
||||
ui->spbAdjust->setMaximum(FLOAT_MAX);
|
||||
ui->spbAdjust->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spbAdjust->setValue(pcConstraint->Adjust.getQuantityValue());
|
||||
ui->spbAdjust->bind(pcConstraint->Adjust);
|
||||
|
||||
ui->ckbFriction->setChecked(friction);
|
||||
|
||||
ui->spbFrictionCoeff->setMinimum(0);
|
||||
ui->spbFrictionCoeff->setMaximum(FLOAT_MAX);
|
||||
ui->spbFrictionCoeff->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spbFrictionCoeff->setValue(pcConstraint->FrictionCoefficient.getValue());
|
||||
ui->spbFrictionCoeff->setEnabled(friction);
|
||||
ui->spbFrictionCoeff->bind(pcConstraint->FrictionCoefficient);
|
||||
|
||||
ui->spbStickSlope->setUnit(pcConstraint->StickSlope.getUnit());
|
||||
ui->spbStickSlope->setMinimum(0);
|
||||
ui->spbStickSlope->setMaximum(FLOAT_MAX);
|
||||
ui->spbStickSlope->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spbStickSlope->setValue(pcConstraint->StickSlope.getQuantityValue());
|
||||
ui->spbStickSlope->setEnabled(friction);
|
||||
ui->spbStickSlope->bind(pcConstraint->StickSlope);
|
||||
|
||||
@@ -74,18 +74,19 @@ TaskFemConstraintDisplacement::TaskFemConstraintDisplacement(
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
// setup ranges
|
||||
ui->spinxDisplacement->setMinimum(-FLOAT_MAX);
|
||||
ui->spinxDisplacement->setMaximum(FLOAT_MAX);
|
||||
ui->spinyDisplacement->setMinimum(-FLOAT_MAX);
|
||||
ui->spinyDisplacement->setMaximum(FLOAT_MAX);
|
||||
ui->spinzDisplacement->setMinimum(-FLOAT_MAX);
|
||||
ui->spinzDisplacement->setMaximum(FLOAT_MAX);
|
||||
ui->spinxRotation->setMinimum(-FLOAT_MAX);
|
||||
ui->spinxRotation->setMaximum(FLOAT_MAX);
|
||||
ui->spinyRotation->setMinimum(-FLOAT_MAX);
|
||||
ui->spinyRotation->setMaximum(FLOAT_MAX);
|
||||
ui->spinzRotation->setMinimum(-FLOAT_MAX);
|
||||
ui->spinzRotation->setMaximum(FLOAT_MAX);
|
||||
constexpr float max = std::numeric_limits<float>::max();
|
||||
ui->spinxDisplacement->setMinimum(-max);
|
||||
ui->spinxDisplacement->setMaximum(max);
|
||||
ui->spinyDisplacement->setMinimum(-max);
|
||||
ui->spinyDisplacement->setMaximum(max);
|
||||
ui->spinzDisplacement->setMinimum(-max);
|
||||
ui->spinzDisplacement->setMaximum(max);
|
||||
ui->spinxRotation->setMinimum(-max);
|
||||
ui->spinxRotation->setMaximum(max);
|
||||
ui->spinyRotation->setMinimum(-max);
|
||||
ui->spinyRotation->setMaximum(max);
|
||||
ui->spinzRotation->setMinimum(-max);
|
||||
ui->spinzRotation->setMaximum(max);
|
||||
|
||||
// Get the feature data
|
||||
Fem::ConstraintDisplacement* pcConstraint =
|
||||
|
||||
@@ -145,18 +145,19 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(
|
||||
&TaskFemConstraintFluidBoundary::onReferenceDeleted);
|
||||
|
||||
// setup ranges
|
||||
ui->spinBoundaryValue->setMinimum(-FLOAT_MAX);
|
||||
ui->spinBoundaryValue->setMaximum(FLOAT_MAX);
|
||||
constexpr float max = std::numeric_limits<float>::max();
|
||||
ui->spinBoundaryValue->setMinimum(-max);
|
||||
ui->spinBoundaryValue->setMaximum(max);
|
||||
ui->spinTurbulentIntensityValue->setMinimum(0.0);
|
||||
ui->spinTurbulentIntensityValue->setMaximum(FLOAT_MAX);
|
||||
ui->spinTurbulentIntensityValue->setMaximum(max);
|
||||
ui->spinTurbulentLengthValue->setMinimum(0.0);
|
||||
ui->spinTurbulentLengthValue->setMaximum(FLOAT_MAX);
|
||||
ui->spinTurbulentLengthValue->setMaximum(max);
|
||||
ui->spinTemperatureValue->setMinimum(-273.15);
|
||||
ui->spinTemperatureValue->setMaximum(FLOAT_MAX);
|
||||
ui->spinTemperatureValue->setMaximum(max);
|
||||
ui->spinHeatFluxValue->setMinimum(0.0);
|
||||
ui->spinHeatFluxValue->setMaximum(FLOAT_MAX);
|
||||
ui->spinHeatFluxValue->setMaximum(max);
|
||||
ui->spinHTCoeffValue->setMinimum(0.0);
|
||||
ui->spinHTCoeffValue->setMaximum(FLOAT_MAX);
|
||||
ui->spinHTCoeffValue->setMaximum(max);
|
||||
|
||||
connect(ui->comboBoundaryType,
|
||||
qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
@@ -352,8 +353,8 @@ TaskFemConstraintFluidBoundary::TaskFemConstraintFluidBoundary(
|
||||
|
||||
// Fill data into dialog elements
|
||||
double f = pcConstraint->BoundaryValue.getValue();
|
||||
ui->spinBoundaryValue->setMinimum(FLOAT_MIN); // previous set the min to ZERO is not flexible
|
||||
ui->spinBoundaryValue->setMaximum(FLOAT_MAX);
|
||||
ui->spinBoundaryValue->setMinimum(std::numeric_limits<float>::min()); // ZERO is not flexible
|
||||
ui->spinBoundaryValue->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinBoundaryValue->setValue(f);
|
||||
ui->listReferences->clear();
|
||||
for (std::size_t i = 0; i < Objects.size(); i++) {
|
||||
|
||||
@@ -75,7 +75,7 @@ TaskFemConstraintForce::TaskFemConstraintForce(ViewProviderFemConstraintForce* C
|
||||
// Fill data into dialog elements
|
||||
ui->spinForce->setUnit(pcConstraint->Force.getUnit());
|
||||
ui->spinForce->setMinimum(0);
|
||||
ui->spinForce->setMaximum(FLOAT_MAX);
|
||||
ui->spinForce->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinForce->setValue(force);
|
||||
ui->listReferences->clear();
|
||||
for (std::size_t i = 0; i < Objects.size(); i++) {
|
||||
|
||||
@@ -87,10 +87,10 @@ TaskFemConstraintGear::TaskFemConstraintGear(ViewProviderFemConstraint* Constrai
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->spinDiameter->setMinimum(0);
|
||||
ui->spinDiameter->setMaximum(FLOAT_MAX);
|
||||
ui->spinDiameter->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinDiameter->setValue(dia);
|
||||
ui->spinForce->setMinimum(0);
|
||||
ui->spinForce->setMaximum(FLOAT_MAX);
|
||||
ui->spinForce->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinForce->setValue(force);
|
||||
ui->spinForceAngle->setMinimum(-360);
|
||||
ui->spinForceAngle->setMaximum(360);
|
||||
|
||||
@@ -119,16 +119,16 @@ TaskFemConstraintHeatflux::TaskFemConstraintHeatflux(
|
||||
ui->sw_heatflux->setCurrentIndex(constrType->getValue());
|
||||
|
||||
ui->qsb_ambienttemp_conv->setMinimum(0);
|
||||
ui->qsb_ambienttemp_conv->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_ambienttemp_conv->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
ui->qsb_film_coef->setMinimum(0);
|
||||
ui->qsb_film_coef->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_film_coef->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
ui->dsb_emissivity->setMinimum(0);
|
||||
ui->dsb_emissivity->setMaximum(FLOAT_MAX);
|
||||
ui->dsb_emissivity->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
ui->qsb_ambienttemp_rad->setMinimum(0);
|
||||
ui->qsb_ambienttemp_rad->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_ambienttemp_rad->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
ui->qsb_ambienttemp_conv->setValue(pcConstraint->AmbientTemp.getQuantityValue());
|
||||
ui->qsb_film_coef->setValue(pcConstraint->FilmCoef.getQuantityValue());
|
||||
|
||||
@@ -64,7 +64,7 @@ TaskFemConstraintPressure::TaskFemConstraintPressure(
|
||||
// Fill data into dialog elements
|
||||
ui->if_pressure->setUnit(pcConstraint->Pressure.getUnit());
|
||||
ui->if_pressure->setMinimum(0);
|
||||
ui->if_pressure->setMaximum(FLOAT_MAX);
|
||||
ui->if_pressure->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->if_pressure->setValue(pcConstraint->Pressure.getQuantityValue());
|
||||
ui->if_pressure->bind(pcConstraint->Pressure);
|
||||
|
||||
|
||||
@@ -76,15 +76,15 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->spinOtherDiameter->setMinimum(0);
|
||||
ui->spinOtherDiameter->setMaximum(FLOAT_MAX);
|
||||
ui->spinOtherDiameter->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinOtherDiameter->setValue(otherdia);
|
||||
ui->spinCenterDistance->setMinimum(0);
|
||||
ui->spinCenterDistance->setMaximum(FLOAT_MAX);
|
||||
ui->spinCenterDistance->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinCenterDistance->setValue(centerdist);
|
||||
ui->checkIsDriven->setChecked(isdriven);
|
||||
ui->spinForce->setMinimum(-FLOAT_MAX);
|
||||
ui->spinForce->setMinimum(-std::numeric_limits<float>::max());
|
||||
ui->spinTensionForce->setMinimum(0);
|
||||
ui->spinTensionForce->setMaximum(FLOAT_MAX);
|
||||
ui->spinTensionForce->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->spinTensionForce->setValue(tensionforce);
|
||||
|
||||
// Adjust ui
|
||||
|
||||
@@ -48,6 +48,7 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
QWidget* parent)
|
||||
: TaskFemConstraintOnBoundary(ConstraintView, parent, "FEM_ConstraintRigidBody")
|
||||
{ // Note change "RigidBody" in line above to new constraint name
|
||||
constexpr float floatMax = std::numeric_limits<float>::max();
|
||||
proxy = new QWidget(this);
|
||||
ui = new Ui_TaskFemConstraintRigidBody();
|
||||
ui->setupUi(proxy);
|
||||
@@ -137,12 +138,12 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
App::ObjectIdentifier::parse(pcConstraint, std::string("ReferenceNode.y")));
|
||||
ui->qsb_ref_node_z->bind(
|
||||
App::ObjectIdentifier::parse(pcConstraint, std::string("ReferenceNode.z")));
|
||||
ui->qsb_ref_node_x->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_ref_node_x->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_ref_node_y->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_ref_node_y->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_ref_node_z->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_ref_node_z->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_ref_node_x->setMinimum(-floatMax);
|
||||
ui->qsb_ref_node_x->setMaximum(floatMax);
|
||||
ui->qsb_ref_node_y->setMinimum(-floatMax);
|
||||
ui->qsb_ref_node_y->setMaximum(floatMax);
|
||||
ui->qsb_ref_node_z->setMinimum(-floatMax);
|
||||
ui->qsb_ref_node_z->setMaximum(floatMax);
|
||||
|
||||
ui->qsb_disp_x->setValue(disp.x);
|
||||
ui->qsb_disp_y->setValue(disp.y);
|
||||
@@ -150,12 +151,12 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
ui->qsb_disp_x->bind(App::ObjectIdentifier::parse(pcConstraint, std::string("Displacement.x")));
|
||||
ui->qsb_disp_y->bind(App::ObjectIdentifier::parse(pcConstraint, std::string("Displacement.y")));
|
||||
ui->qsb_disp_z->bind(App::ObjectIdentifier::parse(pcConstraint, std::string("Displacement.z")));
|
||||
ui->qsb_disp_x->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_disp_x->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_disp_y->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_disp_y->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_disp_z->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_disp_z->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_disp_x->setMinimum(-floatMax);
|
||||
ui->qsb_disp_x->setMaximum(floatMax);
|
||||
ui->qsb_disp_y->setMinimum(-floatMax);
|
||||
ui->qsb_disp_y->setMaximum(floatMax);
|
||||
ui->qsb_disp_z->setMinimum(-floatMax);
|
||||
ui->qsb_disp_z->setMaximum(floatMax);
|
||||
|
||||
ui->spb_rot_axis_x->setValue(rotDir.x);
|
||||
ui->spb_rot_axis_y->setValue(rotDir.y);
|
||||
@@ -169,14 +170,14 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
App::ObjectIdentifier::parse(pcConstraint, std::string("Rotation.Axis.z")));
|
||||
ui->qsb_rot_angle->bind(
|
||||
App::ObjectIdentifier::parse(pcConstraint, std::string("Rotation.Angle")));
|
||||
ui->spb_rot_axis_x->setMinimum(-FLOAT_MAX);
|
||||
ui->spb_rot_axis_x->setMaximum(FLOAT_MAX);
|
||||
ui->spb_rot_axis_y->setMinimum(-FLOAT_MAX);
|
||||
ui->spb_rot_axis_y->setMaximum(FLOAT_MAX);
|
||||
ui->spb_rot_axis_z->setMinimum(-FLOAT_MAX);
|
||||
ui->spb_rot_axis_z->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_rot_angle->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_rot_angle->setMaximum(FLOAT_MAX);
|
||||
ui->spb_rot_axis_x->setMinimum(-floatMax);
|
||||
ui->spb_rot_axis_x->setMaximum(floatMax);
|
||||
ui->spb_rot_axis_y->setMinimum(-floatMax);
|
||||
ui->spb_rot_axis_y->setMaximum(floatMax);
|
||||
ui->spb_rot_axis_z->setMinimum(-floatMax);
|
||||
ui->spb_rot_axis_z->setMaximum(floatMax);
|
||||
ui->qsb_rot_angle->setMinimum(-floatMax);
|
||||
ui->qsb_rot_angle->setMaximum(floatMax);
|
||||
|
||||
ui->qsb_force_x->setValue(forceX);
|
||||
ui->qsb_force_y->setValue(forceY);
|
||||
@@ -184,12 +185,12 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
ui->qsb_force_x->bind(pcConstraint->ForceX);
|
||||
ui->qsb_force_y->bind(pcConstraint->ForceY);
|
||||
ui->qsb_force_z->bind(pcConstraint->ForceZ);
|
||||
ui->qsb_force_x->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_force_x->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_force_y->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_force_y->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_force_z->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_force_z->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_force_x->setMinimum(-floatMax);
|
||||
ui->qsb_force_x->setMaximum(floatMax);
|
||||
ui->qsb_force_y->setMinimum(-floatMax);
|
||||
ui->qsb_force_y->setMaximum(floatMax);
|
||||
ui->qsb_force_z->setMinimum(-floatMax);
|
||||
ui->qsb_force_z->setMaximum(floatMax);
|
||||
|
||||
ui->qsb_moment_x->setValue(momentX);
|
||||
ui->qsb_moment_y->setValue(momentY);
|
||||
@@ -197,12 +198,12 @@ TaskFemConstraintRigidBody::TaskFemConstraintRigidBody(
|
||||
ui->qsb_moment_x->bind(pcConstraint->MomentX);
|
||||
ui->qsb_moment_y->bind(pcConstraint->MomentY);
|
||||
ui->qsb_moment_z->bind(pcConstraint->MomentZ);
|
||||
ui->qsb_moment_x->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_moment_x->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_moment_y->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_moment_y->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_moment_z->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_moment_z->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_moment_x->setMinimum(-floatMax);
|
||||
ui->qsb_moment_x->setMaximum(floatMax);
|
||||
ui->qsb_moment_y->setMinimum(-floatMax);
|
||||
ui->qsb_moment_y->setMaximum(floatMax);
|
||||
ui->qsb_moment_z->setMinimum(-floatMax);
|
||||
ui->qsb_moment_z->setMaximum(floatMax);
|
||||
|
||||
QStringList modeList;
|
||||
|
||||
|
||||
@@ -76,11 +76,11 @@ TaskFemConstraintSpring::TaskFemConstraintSpring(ViewProviderFemConstraintSpring
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->qsb_norm->setUnit(pcConstraint->NormalStiffness.getUnit());
|
||||
ui->qsb_norm->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_norm->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->qsb_norm->setValue(pcConstraint->NormalStiffness.getQuantityValue());
|
||||
|
||||
ui->qsb_tan->setUnit(pcConstraint->TangentialStiffness.getUnit());
|
||||
ui->qsb_tan->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_tan->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->qsb_tan->setValue(pcConstraint->TangentialStiffness.getQuantityValue());
|
||||
|
||||
ui->cb_elmer_stiffness->clear();
|
||||
|
||||
@@ -68,9 +68,9 @@ TaskFemConstraintTemperature::TaskFemConstraintTemperature(
|
||||
|
||||
// Fill data into dialog elements
|
||||
ui->qsb_temperature->setMinimum(0);
|
||||
ui->qsb_temperature->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_cflux->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_cflux->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_temperature->setMaximum(std::numeric_limits<float>::max());
|
||||
ui->qsb_cflux->setMinimum(-std::numeric_limits<float>::max());
|
||||
ui->qsb_cflux->setMaximum(std::numeric_limits<float>::max());
|
||||
|
||||
App::PropertyEnumeration* constrType = &pcConstraint->ConstraintType;
|
||||
QStringList qTypeList;
|
||||
|
||||
@@ -130,14 +130,15 @@ TaskFemConstraintTransform::TaskFemConstraintTransform(
|
||||
ui->qsb_rot_angle->bind(
|
||||
App::ObjectIdentifier::parse(pcConstraint, std::string("Rotation.Angle")));
|
||||
|
||||
ui->spb_rot_axis_x->setMinimum(-FLOAT_MAX);
|
||||
ui->spb_rot_axis_x->setMaximum(FLOAT_MAX);
|
||||
ui->spb_rot_axis_y->setMinimum(-FLOAT_MAX);
|
||||
ui->spb_rot_axis_y->setMaximum(FLOAT_MAX);
|
||||
ui->spb_rot_axis_z->setMinimum(-FLOAT_MAX);
|
||||
ui->spb_rot_axis_z->setMaximum(FLOAT_MAX);
|
||||
ui->qsb_rot_angle->setMinimum(-FLOAT_MAX);
|
||||
ui->qsb_rot_angle->setMaximum(FLOAT_MAX);
|
||||
float max = std::numeric_limits<float>::max();
|
||||
ui->spb_rot_axis_x->setMinimum(-max);
|
||||
ui->spb_rot_axis_x->setMaximum(max);
|
||||
ui->spb_rot_axis_y->setMinimum(-max);
|
||||
ui->spb_rot_axis_y->setMaximum(max);
|
||||
ui->spb_rot_axis_z->setMinimum(-max);
|
||||
ui->spb_rot_axis_z->setMaximum(max);
|
||||
ui->qsb_rot_angle->setMinimum(-max);
|
||||
ui->qsb_rot_angle->setMaximum(max);
|
||||
|
||||
std::string transform_type = pcConstraint->TransformType.getValueAsString();
|
||||
if (transform_type == "Rectangular") {
|
||||
|
||||
@@ -145,8 +145,8 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
|
||||
for (const auto& point : points) {
|
||||
SbVec3f base(point.x, point.y, point.z);
|
||||
if (forceDirection.GetAngle(normal)
|
||||
< M_PI_2) { // Move arrow so it doesn't disappear inside the solid
|
||||
if (forceDirection.GetAngle(normal) < std::numbers::pi
|
||||
/ 2) { // Move arrow so it doesn't disappear inside the solid
|
||||
base = base + dir * scaledlength; // OvG: Scaling
|
||||
}
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
@@ -191,7 +191,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
|
||||
|
||||
for (const auto& point : points) {
|
||||
SbVec3f base(point.x, point.y, point.z);
|
||||
if (forceDirection.GetAngle(normal) < M_PI_2) {
|
||||
if (forceDirection.GetAngle(normal) < std::numbers::pi / 2) {
|
||||
base = base + dir * scaledlength; // OvG: Scaling
|
||||
}
|
||||
#ifdef USE_MULTIPLE_COPY
|
||||
|
||||
@@ -88,7 +88,7 @@ void ViewProviderFemConstraintForce::transformSymbol(const Base::Vector3d& point
|
||||
// Place each symbol outside the boundary
|
||||
Base::Vector3d dir = (rev ? -1.0 : 1.0) * obj->DirectionVector.getValue();
|
||||
float symTraY = dir.Dot(normal) < 0 ? -1 * symLen : 0.0f;
|
||||
float rotAngle = rev ? F_PI : 0.0f;
|
||||
float rotAngle = rev ? std::numbers::pi_v<float> : 0.0f;
|
||||
SbMatrix mat0, mat1;
|
||||
mat0.setTransform(SbVec3f(0, symTraY, 0),
|
||||
SbRotation(SbVec3f(0, 0, 1), rotAngle),
|
||||
|
||||
@@ -88,7 +88,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
|
||||
if (dia < 2 * radius) {
|
||||
dia = 2 * radius;
|
||||
}
|
||||
double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
|
||||
double angle = pcConstraint->ForceAngle.getValue() / 180 * std::numbers::pi;
|
||||
|
||||
SbVec3f b(base.x, base.y, base.z);
|
||||
SbVec3f ax(axis.x, axis.y, axis.z);
|
||||
@@ -118,7 +118,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
|
||||
if (dia < 2 * radius) {
|
||||
dia = 2 * radius;
|
||||
}
|
||||
double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
|
||||
double angle = pcConstraint->ForceAngle.getValue() / 180 * std::numbers::pi;
|
||||
|
||||
SbVec3f ax(axis.x, axis.y, axis.z);
|
||||
SbVec3f dir(direction.x, direction.y, direction.z);
|
||||
@@ -143,7 +143,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
|
||||
direction = Base::Vector3d(0, 1, 0);
|
||||
}
|
||||
double dia = pcConstraint->Diameter.getValue();
|
||||
double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
|
||||
double angle = pcConstraint->ForceAngle.getValue() / 180 * std::numbers::pi;
|
||||
|
||||
SbVec3f ax(axis.x, axis.y, axis.z);
|
||||
SbVec3f dir(direction.x, direction.y, direction.z);
|
||||
|
||||
@@ -82,7 +82,7 @@ void ViewProviderFemConstraintPressure::transformSymbol(const Base::Vector3d& po
|
||||
SbMatrix& mat) const
|
||||
{
|
||||
auto obj = this->getObject<const Fem::ConstraintPressure>();
|
||||
float rotAngle = obj->Reversed.getValue() ? F_PI : 0.0f;
|
||||
float rotAngle = obj->Reversed.getValue() ? std::numbers::pi_v<float> : 0.0f;
|
||||
float s = obj->getScaleFactor();
|
||||
// Symbol length from .iv file
|
||||
float symLen = 4.0f;
|
||||
|
||||
@@ -66,6 +66,8 @@ bool ViewProviderFemConstraintPulley::setEdit(int ModNum)
|
||||
|
||||
void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
// Gets called whenever a property of the attached object changes
|
||||
Fem::ConstraintPulley* pcConstraint = this->getObject<Fem::ConstraintPulley>();
|
||||
|
||||
@@ -82,7 +84,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
if (dia < 2 * radius) {
|
||||
dia = 2 * radius;
|
||||
}
|
||||
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
|
||||
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * pi;
|
||||
double beltAngle = pcConstraint->BeltAngle.getValue();
|
||||
double rat1 = 0.8, rat2 = 0.2;
|
||||
double f1 = pcConstraint->BeltForce1.getValue();
|
||||
@@ -106,9 +108,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
0,
|
||||
dia / 2 * cos(forceAngle + beltAngle)),
|
||||
SbRotation(SbVec3f(0, 1, 0),
|
||||
SbVec3f(sin(forceAngle + beltAngle + M_PI_2),
|
||||
SbVec3f(sin(forceAngle + beltAngle + pi / 2),
|
||||
0,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
cos(forceAngle + beltAngle + pi / 2))));
|
||||
GuiTools::createPlacement(sep, SbVec3f(0, dia / 8 + dia / 2 * rat1, 0), SbRotation());
|
||||
sep->addChild(GuiTools::createArrow(dia / 8 + dia / 2 * rat1, dia / 8));
|
||||
pShapeSep->addChild(sep); // child 3
|
||||
@@ -118,9 +120,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
0,
|
||||
-dia / 2 * cos(forceAngle - beltAngle)),
|
||||
SbRotation(SbVec3f(0, 1, 0),
|
||||
SbVec3f(-sin(forceAngle - beltAngle - M_PI_2),
|
||||
SbVec3f(-sin(forceAngle - beltAngle - pi / 2),
|
||||
0,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
-cos(forceAngle - beltAngle - pi / 2))));
|
||||
GuiTools::createPlacement(sep, SbVec3f(0, dia / 8 + dia / 2 * rat2, 0), SbRotation());
|
||||
sep->addChild(GuiTools::createArrow(dia / 8 + dia / 2 * rat2, dia / 8));
|
||||
pShapeSep->addChild(sep); // child 4
|
||||
@@ -134,7 +136,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
if (dia < 2 * radius) {
|
||||
dia = 2 * radius;
|
||||
}
|
||||
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
|
||||
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * pi;
|
||||
double beltAngle = pcConstraint->BeltAngle.getValue();
|
||||
double rat1 = 0.8, rat2 = 0.2;
|
||||
double f1 = pcConstraint->BeltForce1.getValue();
|
||||
@@ -153,9 +155,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
0,
|
||||
dia / 2 * cos(forceAngle + beltAngle)),
|
||||
SbRotation(SbVec3f(0, 1, 0),
|
||||
SbVec3f(sin(forceAngle + beltAngle + M_PI_2),
|
||||
SbVec3f(sin(forceAngle + beltAngle + pi / 2),
|
||||
0,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
cos(forceAngle + beltAngle + pi / 2))));
|
||||
GuiTools::updatePlacement(sep,
|
||||
2,
|
||||
SbVec3f(0, dia / 8 + dia / 2 * rat1, 0),
|
||||
@@ -169,9 +171,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
0,
|
||||
-dia / 2 * cos(forceAngle - beltAngle)),
|
||||
SbRotation(SbVec3f(0, 1, 0),
|
||||
SbVec3f(-sin(forceAngle - beltAngle - M_PI_2),
|
||||
SbVec3f(-sin(forceAngle - beltAngle - pi / 2),
|
||||
0,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
-cos(forceAngle - beltAngle - pi / 2))));
|
||||
GuiTools::updatePlacement(sep,
|
||||
2,
|
||||
SbVec3f(0, dia / 8 + dia / 2 * rat2, 0),
|
||||
@@ -187,7 +189,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
if (dia < 2 * radius) {
|
||||
dia = 2 * radius;
|
||||
}
|
||||
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
|
||||
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * pi;
|
||||
double beltAngle = pcConstraint->BeltAngle.getValue();
|
||||
|
||||
const SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(3));
|
||||
@@ -197,9 +199,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
0,
|
||||
dia / 2 * cos(forceAngle + beltAngle)),
|
||||
SbRotation(SbVec3f(0, 1, 0),
|
||||
SbVec3f(sin(forceAngle + beltAngle + M_PI_2),
|
||||
SbVec3f(sin(forceAngle + beltAngle + pi / 2),
|
||||
0,
|
||||
cos(forceAngle + beltAngle + M_PI_2))));
|
||||
cos(forceAngle + beltAngle + pi / 2))));
|
||||
sep = static_cast<SoSeparator*>(pShapeSep->getChild(4));
|
||||
GuiTools::updatePlacement(sep,
|
||||
0,
|
||||
@@ -207,9 +209,9 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
|
||||
0,
|
||||
-dia / 2 * cos(forceAngle - beltAngle)),
|
||||
SbRotation(SbVec3f(0, 1, 0),
|
||||
SbVec3f(-sin(forceAngle - beltAngle - M_PI_2),
|
||||
SbVec3f(-sin(forceAngle - beltAngle - pi / 2),
|
||||
0,
|
||||
-cos(forceAngle - beltAngle - M_PI_2))));
|
||||
-cos(forceAngle - beltAngle - pi / 2))));
|
||||
}
|
||||
}
|
||||
else if ((prop == &pcConstraint->BeltForce1) || (prop == &pcConstraint->BeltForce2)) {
|
||||
|
||||
@@ -756,7 +756,10 @@ void CylinderWidget::radiusChanged(double)
|
||||
|
||||
PROPERTY_SOURCE(FemGui::ViewProviderFemPostPlaneFunction, FemGui::ViewProviderFemPostFunction)
|
||||
// NOTE: The technical lower limit is at 1e-4 that the Coin3D manipulator can handle
|
||||
static const App::PropertyFloatConstraint::Constraints scaleConstraint = {1e-4, DBL_MAX, 1.0};
|
||||
static const App::PropertyFloatConstraint::Constraints scaleConstraint = {
|
||||
1e-4,
|
||||
std::numeric_limits<double>::max(),
|
||||
1.0};
|
||||
|
||||
ViewProviderFemPostPlaneFunction::ViewProviderFemPostPlaneFunction()
|
||||
: m_detectscale(false)
|
||||
@@ -1178,6 +1181,8 @@ SoGroup* postBox()
|
||||
|
||||
SoGroup* postCylinder()
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
SoCoordinate3* points = new SoCoordinate3();
|
||||
int nCirc = 20;
|
||||
const int nSide = 8;
|
||||
@@ -1189,8 +1194,8 @@ SoGroup* postCylinder()
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < nCirc + 1; ++j) {
|
||||
points->point.set1Value(idx,
|
||||
SbVec3f(std::cos(2 * M_PI / nCirc * j),
|
||||
std::sin(2 * M_PI / nCirc * j),
|
||||
SbVec3f(std::cos(2 * pi / nCirc * j),
|
||||
std::sin(2 * pi / nCirc * j),
|
||||
-h / 2. + h * i));
|
||||
++idx;
|
||||
}
|
||||
@@ -1199,8 +1204,8 @@ SoGroup* postCylinder()
|
||||
for (int i = 0; i < nSide; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
points->point.set1Value(idx,
|
||||
SbVec3f(std::cos(2 * M_PI / nSide * i),
|
||||
std::sin(2 * M_PI / nSide * i),
|
||||
SbVec3f(std::cos(2 * pi / nSide * i),
|
||||
std::sin(2 * pi / nSide * i),
|
||||
-h / 2. + h * j));
|
||||
++idx;
|
||||
}
|
||||
@@ -1243,24 +1248,26 @@ SoGroup* postPlane()
|
||||
|
||||
SoGroup* postSphere()
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
SoCoordinate3* points = new SoCoordinate3();
|
||||
points->point.setNum(2 * 84);
|
||||
int idx = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 21; j++) {
|
||||
points->point.set1Value(idx,
|
||||
SbVec3f(std::sin(2 * M_PI / 20 * j) * std::cos(M_PI / 4 * i),
|
||||
std::sin(2 * M_PI / 20 * j) * std::sin(M_PI / 4 * i),
|
||||
std::cos(2 * M_PI / 20 * j)));
|
||||
SbVec3f(std::sin(2 * pi / 20 * j) * std::cos(pi / 4 * i),
|
||||
std::sin(2 * pi / 20 * j) * std::sin(pi / 4 * i),
|
||||
std::cos(2 * pi / 20 * j)));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for (int j = 0; j < 21; j++) {
|
||||
points->point.set1Value(idx,
|
||||
SbVec3f(std::sin(M_PI / 4 * i) * std::cos(2 * M_PI / 20 * j),
|
||||
std::sin(M_PI / 4 * i) * std::sin(2 * M_PI / 20 * j),
|
||||
std::cos(M_PI / 4 * i)));
|
||||
SbVec3f(std::sin(pi / 4 * i) * std::cos(2 * pi / 20 * j),
|
||||
std::sin(pi / 4 * i) * std::sin(2 * pi / 20 * j),
|
||||
std::cos(pi / 4 * i)));
|
||||
++idx;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#ifndef _PreComp_
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/range/adaptor/indexed.hpp>
|
||||
#include <climits>
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_Location.hxx>
|
||||
#include <climits>
|
||||
#include <gp_Ax1.hxx>
|
||||
#include <gp_Dir.hxx>
|
||||
#include <gp_Pln.hxx> // for Precision::Confusion()
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef IMPORT_EXPORTOCAF_H
|
||||
#define IMPORT_EXPORTOCAF_H
|
||||
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user