Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
207 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd"> | ||
<PythonExport | ||
Father="PyObjectBase" | ||
Name="PrecisionPy" | ||
PythonName="Part.Precision" | ||
Twin="Precision" | ||
TwinPointer="Precision" | ||
Include="Precision.hxx" | ||
Namespace="Part" | ||
FatherInclude="Base/PyObjectBase.h" | ||
FatherNamespace="Base"> | ||
<Documentation> | ||
<Author Licence="LGPL" Name="Werner Mayer" EMail="wmayer@users.sourceforge.net" /> | ||
<DeveloperDocu>This is the Type class</DeveloperDocu> | ||
<UserDocu>This is the Type class</UserDocu> | ||
</Documentation> | ||
<Methode Name="angular" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns the recommended precision value when checking the equality of two angles (given in radians)</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="confusion" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns the recommended precision value when checking coincidence of two points in real space</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="squareConfusion" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns square of confusion</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="intersection" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns the precision value in real space, frequently used by intersection algorithms</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="approximation" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns the precision value in real space, frequently used by approximation algorithms</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="parametric" Static="true"> | ||
<Documentation> | ||
<UserDocu>Convert a real space precision to a parametric space precision</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="isInfinite" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns True if R may be considered as an infinite number</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="isPositiveInfinite" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns True if R may be considered as a positive infinite number</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="isNegativeInfinite" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns True if R may be considered as a negative infinite number</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
<Methode Name="infinite" Static="true"> | ||
<Documentation> | ||
<UserDocu>Returns a big number that can be considered as infinite</UserDocu> | ||
</Documentation> | ||
</Methode> | ||
</PythonExport> | ||
</GenerateModel> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/*************************************************************************** | ||
* Copyright (c) 2022 Werner Mayer <wmayer[at]users.sourceforge.net> * | ||
* * | ||
* This file is part of the FreeCAD CAx development system. * | ||
* * | ||
* This library is free software; you can redistribute it and/or * | ||
* modify it under the terms of the GNU Library General Public * | ||
* License as published by the Free Software Foundation; either * | ||
* version 2 of the License, or (at your option) any later version. * | ||
* * | ||
* This library is distributed in the hope that it will be useful, * | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
* GNU Library General Public License for more details. * | ||
* * | ||
* You should have received a copy of the GNU Library General Public * | ||
* License along with this library; see the file COPYING.LIB. If not, * | ||
* write to the Free Software Foundation, Inc., 59 Temple Place, * | ||
* Suite 330, Boston, MA 02111-1307, USA * | ||
* * | ||
***************************************************************************/ | ||
|
||
|
||
#include "PreCompiled.h" | ||
#ifndef _PreComp_ | ||
#endif | ||
|
||
#include "PrecisionPy.h" | ||
#include "PrecisionPy.cpp" | ||
|
||
using namespace Part; | ||
|
||
|
||
// returns a string which represents the object e.g. when printed in python | ||
std::string PrecisionPy::representation() const | ||
{ | ||
return std::string("<Precision object>"); | ||
} | ||
|
||
PyObject* PrecisionPy::angular(PyObject * /*args*/) | ||
{ | ||
Py::Float v(Precision::Angular()); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyObject* PrecisionPy::confusion(PyObject * /*args*/) | ||
{ | ||
Py::Float v(Precision::Confusion()); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyObject* PrecisionPy::squareConfusion(PyObject * /*args*/) | ||
{ | ||
Py::Float v(Precision::SquareConfusion()); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyObject* PrecisionPy::intersection(PyObject * /*args*/) | ||
{ | ||
Py::Float v(Precision::Intersection()); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyObject* PrecisionPy::approximation(PyObject * /*args*/) | ||
{ | ||
Py::Float v(Precision::Approximation()); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyObject* PrecisionPy::parametric(PyObject *args) | ||
{ | ||
double p; | ||
if (PyArg_ParseTuple(args, "d", &p)) { | ||
Py::Float v(Precision::Parametric(p)); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyErr_Clear(); | ||
double t; | ||
if (PyArg_ParseTuple(args, "dd", &p, &t)) { | ||
Py::Float v(Precision::Parametric(p, t)); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyErr_SetString(PyExc_ValueError, "one or two floats expected"); | ||
return nullptr; | ||
} | ||
|
||
PyObject* PrecisionPy::isInfinite(PyObject *args) | ||
{ | ||
double v; | ||
if (!PyArg_ParseTuple(args, "d", &v)) | ||
return nullptr; | ||
|
||
Py::Boolean b(Precision::IsInfinite(v)); | ||
return Py::new_reference_to(b); | ||
} | ||
|
||
PyObject* PrecisionPy::isPositiveInfinite(PyObject *args) | ||
{ | ||
double v; | ||
if (!PyArg_ParseTuple(args, "d", &v)) | ||
return nullptr; | ||
|
||
Py::Boolean b(Precision::IsPositiveInfinite(v)); | ||
return Py::new_reference_to(b); | ||
} | ||
|
||
PyObject* PrecisionPy::isNegativeInfinite(PyObject *args) | ||
{ | ||
double v; | ||
if (!PyArg_ParseTuple(args, "d", &v)) | ||
return nullptr; | ||
|
||
Py::Boolean b(Precision::IsNegativeInfinite(v)); | ||
return Py::new_reference_to(b); | ||
} | ||
|
||
PyObject* PrecisionPy::infinite(PyObject * /*args*/) | ||
{ | ||
Py::Float v(Precision::Infinite()); | ||
return Py::new_reference_to(v); | ||
} | ||
|
||
PyObject *PrecisionPy::getCustomAttributes(const char* /*attr*/) const | ||
{ | ||
return nullptr; | ||
} | ||
|
||
int PrecisionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) | ||
{ | ||
return 0; | ||
} |