App: move from float to double for accuracy parameter, add a virtual method to determine a default accuracy

This commit is contained in:
wmayer
2022-09-15 09:52:14 +02:00
parent 12e2985bf3
commit 1309b86ea5
13 changed files with 46 additions and 41 deletions

View File

@@ -3487,9 +3487,16 @@ void TopoShape::getFacesFromDomains(const std::vector<Domain>& domains,
points.swap(meshPoints);
}
double TopoShape::getAccuracy() const
{
double deviation = 0.2;
Base::BoundBox3d bbox = getBoundBox();
return ((bbox.LengthX() + bbox.LengthY() + bbox.LengthZ())/300.0 * deviation);
}
void TopoShape::getFaces(std::vector<Base::Vector3d> &aPoints,
std::vector<Facet> &aTopo,
float accuracy, uint16_t /*flags*/) const
double accuracy, uint16_t /*flags*/) const
{
if (this->_Shape.IsNull())
return;
@@ -3679,14 +3686,14 @@ void TopoShape::getLinesFromSubShape(const TopoDS_Shape& shape,
void TopoShape::getLines(std::vector<Base::Vector3d> &vertices,
std::vector<TopoShape::Line> &lines,
float /*Accuracy*/, uint16_t /*flags*/) const
double /*Accuracy*/, uint16_t /*flags*/) const
{
getLinesFromSubShape(_Shape, vertices, lines);
}
void TopoShape::getPoints(std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &Normals,
float Accuracy, uint16_t /*flags*/) const
double Accuracy, uint16_t /*flags*/) const
{
if (_Shape.IsNull())
return;

View File

@@ -136,15 +136,17 @@ private:
void getFacesFromDomains(const std::vector<Domain>& domains, std::vector<Base::Vector3d>& vertices, std::vector<Facet>& faces) const;
public:
/// Get the standard accuracy to be used with getPoints, getLines or getFaces
double getAccuracy() const override;
/** Get points from object with given accuracy */
void getPoints(std::vector<Base::Vector3d> &Points,
std::vector<Base::Vector3d> &Normals,
float Accuracy, uint16_t flags=0) const override;
double Accuracy, uint16_t flags=0) const override;
/** Get lines from object with given accuracy */
void getLines(std::vector<Base::Vector3d> &Points,std::vector<Line> &lines,
float Accuracy, uint16_t flags=0) const override;
double Accuracy, uint16_t flags=0) const override;
void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &faces,
float Accuracy, uint16_t flags=0) const override;
double Accuracy, uint16_t flags=0) const override;
void setFaces(const std::vector<Base::Vector3d> &Points,
const std::vector<Facet> &faces, double tolerance=1.0e-06);
void getDomains(std::vector<Domain>&) const;

View File

@@ -1931,9 +1931,9 @@ PyObject* TopoShapePy::hashCode(PyObject *args)
PyObject* TopoShapePy::tessellate(PyObject *args)
{
float tolerance;
double tolerance;
PyObject* ok = Py_False;
if (!PyArg_ParseTuple(args, "f|O!",&tolerance,&PyBool_Type,&ok))
if (!PyArg_ParseTuple(args, "d|O!", &tolerance, &PyBool_Type, &ok))
return nullptr;
try {