diff --git a/src/Mod/Fem/App/HypothesisPy.cpp b/src/Mod/Fem/App/HypothesisPy.cpp index 755e8a539..7dbe2f722 100644 --- a/src/Mod/Fem/App/HypothesisPy.cpp +++ b/src/Mod/Fem/App/HypothesisPy.cpp @@ -1,1056 +1,1056 @@ -/*************************************************************************** - * Copyright (c) 2010 Werner Mayer * - * * - * 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" -#include "HypothesisPy.h" -#include "FemMeshPy.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -//#include -#include - -using namespace Fem; - - -HypothesisPy::HypothesisPy(boost::shared_ptr h) - : hyp(h) -{ -} - -HypothesisPy::~HypothesisPy() -{ -} - -// ---------------------------------------------------------------------------- - -template -void SMESH_HypothesisPy::init_type(PyObject* module) -{ - // you must have overwritten the virtual functions - SMESH_HypothesisPy::behaviors().supportRepr(); - SMESH_HypothesisPy::behaviors().supportGetattr(); - SMESH_HypothesisPy::behaviors().supportSetattr(); - SMESH_HypothesisPy::behaviors().type_object()->tp_new = &PyMake; - - add_varargs_method("setLibName", &SMESH_HypothesisPy::setLibName, "setLibName(String)"); - add_varargs_method("getLibName", &SMESH_HypothesisPy::getLibName, "String getLibName()"); - add_varargs_method("setParameters", &SMESH_HypothesisPy::setParameters, "setParameters(String)"); - add_varargs_method("getParameters", &SMESH_HypothesisPy::getParameters, "String getParameters()"); - add_varargs_method("setLastParameters", &SMESH_HypothesisPy::setLastParameters, "setLastParameters(String)"); - add_varargs_method("getLastParameters", &SMESH_HypothesisPy::getLastParameters, "String getLastParameters()"); - add_varargs_method("clearParameters", &SMESH_HypothesisPy::clearParameters, "clearParameters()"); - add_varargs_method("isAuxiliary", &SMESH_HypothesisPy::isAuxiliary, "Bool isAuxiliary()"); - add_varargs_method("setParametersByMesh", &SMESH_HypothesisPy::setParametersByMesh, "setParametersByMesh(Mesh,Shape)"); - Base::Interpreter().addType(SMESH_HypothesisPy::behaviors().type_object(), - module,SMESH_HypothesisPy::behaviors().getName()); -} - -template -SMESH_HypothesisPy::SMESH_HypothesisPy(SMESH_Hypothesis* h) : hyp(h) -{ -} - -template -SMESH_HypothesisPy::~SMESH_HypothesisPy() -{ -} - -template -Py::Object SMESH_HypothesisPy::getattr(const char *name) -{ - if (strcmp(name,"this") == 0) - return Hypothesis(Py::asObject(new HypothesisPy(this->getHypothesis()))); - return Py::PythonExtension::getattr(name); -} - -template -Py::Object SMESH_HypothesisPy::repr() -{ - std::stringstream str; - str << hyp->GetName() << ", " << hyp->GetID(); - return Py::String(str.str()); -} - -template -Py::Object SMESH_HypothesisPy::setLibName(const Py::Tuple& args) -{ - std::string libName = (std::string)Py::String(args[0]); - hypothesis()->SetLibName(libName.c_str()); - return Py::None(); -} - -template -Py::Object SMESH_HypothesisPy::getLibName(const Py::Tuple& args) -{ - return Py::String(hypothesis()->GetLibName()); -} - -template -Py::Object SMESH_HypothesisPy::setParameters(const Py::Tuple& args) -{ - std::string paramName = (std::string)Py::String(args[0]); - hypothesis()->SetParameters(paramName.c_str()); - return Py::None(); -} - -template -Py::Object SMESH_HypothesisPy::getParameters(const Py::Tuple& args) -{ - return Py::String(hypothesis()->GetParameters()); -} - -template -Py::Object SMESH_HypothesisPy::setLastParameters(const Py::Tuple& args) -{ - std::string paramName = (std::string)Py::String(args[0]); - hypothesis()->SetLastParameters(paramName.c_str()); - return Py::None(); -} - -template -Py::Object SMESH_HypothesisPy::getLastParameters(const Py::Tuple& args) -{ - return Py::String(hypothesis()->GetLastParameters()); -} - -template -Py::Object SMESH_HypothesisPy::clearParameters(const Py::Tuple& args) -{ - hypothesis()->ClearParameters(); - return Py::None(); -} - -template -Py::Object SMESH_HypothesisPy::setParametersByMesh(const Py::Tuple& args) -{ - PyObject *mesh, *shape; - if (!PyArg_ParseTuple(args.ptr(), "O!O!", - &(Fem::FemMeshPy::Type), &mesh, - &(Part::TopoShapePy::Type), &shape)) - throw Py::Exception(); - Fem::FemMesh* m = static_cast(mesh)->getFemMeshPtr(); - const TopoDS_Shape& s = static_cast(shape)->getTopoShapePtr()->_Shape; - return Py::Boolean(hypothesis()->SetParametersByMesh(m->getSMesh(), s)); -} - -template -Py::Object SMESH_HypothesisPy::isAuxiliary(const Py::Tuple& args) -{ - return Py::Boolean(hypothesis()->IsAuxiliary()); -} - -template -PyObject *SMESH_HypothesisPy::PyMake(struct _typeobject *type, PyObject * args, PyObject * kwds) -{ - int hypId; - PyObject* obj; - if (!PyArg_ParseTuple(args, "iO!",&hypId,&(FemMeshPy::Type),&obj)) - return 0; - FemMesh* mesh = static_cast(obj)->getFemMeshPtr(); - return new T(hypId, 1, mesh->getGenerator()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Arithmetic1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Arithmetic1D"); - behaviors().doc("StdMeshers_Arithmetic1D"); - - add_varargs_method("setLength", &StdMeshers_Arithmetic1DPy::setLength, "setLength()"); - add_varargs_method("getLength", &StdMeshers_Arithmetic1DPy::getLength, "getLength()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Arithmetic1DPy::StdMeshers_Arithmetic1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Arithmetic1D(hypId, studyId, gen)) -{ -} - -StdMeshers_Arithmetic1DPy::~StdMeshers_Arithmetic1DPy() -{ -} - -Py::Object StdMeshers_Arithmetic1DPy::setLength(const Py::Tuple& args) -{ - hypothesis()-> - SetLength((double)Py::Float(args[0]), (bool)Py::Boolean(args[1])); - return Py::None(); -} - -Py::Object StdMeshers_Arithmetic1DPy::getLength(const Py::Tuple& args) -{ - int start; - if (!PyArg_ParseTuple(args.ptr(), "i",&start)) - throw Py::Exception(); - return Py::Float(hypothesis()-> - GetLength(start ? true : false)); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_AutomaticLengthPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_AutomaticLength"); - behaviors().doc("StdMeshers_AutomaticLength"); - - add_varargs_method("setFineness", &StdMeshers_AutomaticLengthPy::setFineness, "setFineness()"); - add_varargs_method("getFineness", &StdMeshers_AutomaticLengthPy::getFineness, "getFineness()"); - add_varargs_method("getLength", &StdMeshers_AutomaticLengthPy::getLength, "getLength()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_AutomaticLengthPy::StdMeshers_AutomaticLengthPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(0) -{ -} - -StdMeshers_AutomaticLengthPy::~StdMeshers_AutomaticLengthPy() -{ -} - -Py::Object StdMeshers_AutomaticLengthPy::setFineness(const Py::Tuple& args) -{ - double fine = (double)Py::Float(args[0]); - hypothesis()->SetFineness(fine); - return Py::None(); -} - -Py::Object StdMeshers_AutomaticLengthPy::getFineness(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetFineness()); -} - -namespace Py { - typedef ExtensionObject FemMesh; - typedef ExtensionObject TopoShape; - template<> bool FemMesh::accepts (PyObject *pyob) const - { - return (pyob && PyObject_TypeCheck(pyob, &(Fem::FemMeshPy::Type))); - } - template<> bool TopoShape::accepts (PyObject *pyob) const - { - return (pyob && PyObject_TypeCheck(pyob, &(Part::TopoShapePy::Type))); - } -} - -Py::Object StdMeshers_AutomaticLengthPy::getLength(const Py::Tuple& args) -{ - Py::FemMesh mesh(args[0]); - Py::Object shape_or_double(args[1]); - - Fem::FemMesh* m = mesh.extensionObject()->getFemMeshPtr(); - if (shape_or_double.type() == Py::Float().type()) { - double len = (double)Py::Float(shape_or_double); - return Py::Float(hypothesis()->GetLength(m->getSMesh(),len)); - } - else { - Py::TopoShape shape(shape_or_double); - const TopoDS_Shape& s = shape.extensionObject()->getTopoShapePtr()->_Shape; - return Py::Float(hypothesis()->GetLength(m->getSMesh(),s)); - } - - throw Py::Exception(); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_NotConformAllowedPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_NotConformAllowed"); - behaviors().doc("StdMeshers_NotConformAllowed"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_NotConformAllowedPy::StdMeshers_NotConformAllowedPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_NotConformAllowed(hypId, studyId, gen)) -{ -} - -StdMeshers_NotConformAllowedPy::~StdMeshers_NotConformAllowedPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_MaxLengthPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_MaxLength"); - behaviors().doc("StdMeshers_MaxLength"); - - add_varargs_method("setLength", &StdMeshers_MaxLengthPy::setLength, "setLength()"); - add_varargs_method("getLength", &StdMeshers_MaxLengthPy::getLength, "getLength()"); - add_varargs_method("havePreestimatedLength", &StdMeshers_MaxLengthPy::havePreestimatedLength, "havePreestimatedLength()"); - add_varargs_method("getPreestimatedLength", &StdMeshers_MaxLengthPy::getPreestimatedLength, "getPreestimatedLength()"); - add_varargs_method("setPreestimatedLength", &StdMeshers_MaxLengthPy::setPreestimatedLength, "setPreestimatedLength()"); - add_varargs_method("setUsePreestimatedLength", &StdMeshers_MaxLengthPy::setUsePreestimatedLength, "setUsePreestimatedLength()"); - add_varargs_method("getUsePreestimatedLength", &StdMeshers_MaxLengthPy::getUsePreestimatedLength, "getUsePreestimatedLength()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_MaxLengthPy::StdMeshers_MaxLengthPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_MaxLength(hypId, studyId, gen)) -{ -} - -StdMeshers_MaxLengthPy::~StdMeshers_MaxLengthPy() -{ -} - -Py::Object StdMeshers_MaxLengthPy::setLength(const Py::Tuple& args) -{ - hypothesis()->SetLength((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_MaxLengthPy::getLength(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetLength()); -} - -Py::Object StdMeshers_MaxLengthPy::havePreestimatedLength(const Py::Tuple& args) -{ - return Py::Boolean(hypothesis()->HavePreestimatedLength()); -} - -Py::Object StdMeshers_MaxLengthPy::getPreestimatedLength(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetPreestimatedLength()); -} - -Py::Object StdMeshers_MaxLengthPy::setPreestimatedLength(const Py::Tuple& args) -{ - hypothesis()->SetPreestimatedLength((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_MaxLengthPy::setUsePreestimatedLength(const Py::Tuple& args) -{ - hypothesis()->SetUsePreestimatedLength((bool)Py::Boolean(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_MaxLengthPy::getUsePreestimatedLength(const Py::Tuple& args) -{ - return Py::Boolean(hypothesis()->GetUsePreestimatedLength()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_LocalLengthPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_LocalLength"); - behaviors().doc("StdMeshers_LocalLength"); - - add_varargs_method("setLength", &StdMeshers_LocalLengthPy::setLength, "setLength()"); - add_varargs_method("getLength", &StdMeshers_LocalLengthPy::getLength, "getLength()"); - add_varargs_method("setPrecision", &StdMeshers_LocalLengthPy::setPrecision, "setPrecision()"); - add_varargs_method("getPrecision", &StdMeshers_LocalLengthPy::getPrecision, "getPrecision()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_LocalLengthPy::StdMeshers_LocalLengthPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_LocalLength(hypId, studyId, gen)) -{ -} - -StdMeshers_LocalLengthPy::~StdMeshers_LocalLengthPy() -{ -} - -Py::Object StdMeshers_LocalLengthPy::setLength(const Py::Tuple& args) -{ - hypothesis()->SetLength((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_LocalLengthPy::getLength(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetLength()); -} - -Py::Object StdMeshers_LocalLengthPy::setPrecision(const Py::Tuple& args) -{ - hypothesis()->SetPrecision((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_LocalLengthPy::getPrecision(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetPrecision()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_MaxElementAreaPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_MaxElementArea"); - behaviors().doc("StdMeshers_MaxElementArea"); - - add_varargs_method("setMaxArea", &StdMeshers_MaxElementAreaPy::setMaxArea, "setMaxArea()"); - add_varargs_method("getMaxArea", &StdMeshers_MaxElementAreaPy::getMaxArea, "getMaxArea()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_MaxElementAreaPy::StdMeshers_MaxElementAreaPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_MaxElementArea(hypId, studyId, gen)) -{ -} - -StdMeshers_MaxElementAreaPy::~StdMeshers_MaxElementAreaPy() -{ -} - -Py::Object StdMeshers_MaxElementAreaPy::setMaxArea(const Py::Tuple& args) -{ - hypothesis()->SetMaxArea((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_MaxElementAreaPy::getMaxArea(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetMaxArea()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_QuadranglePreferencePy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_QuadranglePreference"); - behaviors().doc("StdMeshers_QuadranglePreference"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_QuadranglePreferencePy::StdMeshers_QuadranglePreferencePy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_QuadranglePreference(hypId, studyId, gen)) -{ -} - -StdMeshers_QuadranglePreferencePy::~StdMeshers_QuadranglePreferencePy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Quadrangle_2DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Quadrangle_2D"); - behaviors().doc("StdMeshers_Quadrangle_2D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Quadrangle_2DPy::StdMeshers_Quadrangle_2DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Quadrangle_2D(hypId, studyId, gen)) -{ -} - -StdMeshers_Quadrangle_2DPy::~StdMeshers_Quadrangle_2DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Regular_1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Regular_1D"); - behaviors().doc("StdMeshers_Regular_1D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Regular_1DPy::StdMeshers_Regular_1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Regular_1D(hypId, studyId, gen)) -{ -} - -StdMeshers_Regular_1DPy::~StdMeshers_Regular_1DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_UseExisting_1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_UseExisting_1D"); - behaviors().doc("StdMeshers_UseExisting_1D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_UseExisting_1DPy::StdMeshers_UseExisting_1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_UseExisting_1D(hypId, studyId, gen)) -{ -} - -StdMeshers_UseExisting_1DPy::~StdMeshers_UseExisting_1DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_UseExisting_2DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_UseExisting_2D"); - behaviors().doc("StdMeshers_UseExisting_2D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_UseExisting_2DPy::StdMeshers_UseExisting_2DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_UseExisting_2D(hypId, studyId, gen)) -{ -} - -StdMeshers_UseExisting_2DPy::~StdMeshers_UseExisting_2DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_CompositeSegment_1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_CompositeSegment_1D"); - behaviors().doc("StdMeshers_CompositeSegment_1D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_CompositeSegment_1DPy::StdMeshers_CompositeSegment_1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_CompositeSegment_1D(hypId, studyId, gen)) -{ -} - -StdMeshers_CompositeSegment_1DPy::~StdMeshers_CompositeSegment_1DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Deflection1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Deflection1D"); - behaviors().doc("StdMeshers_Deflection1D"); - - add_varargs_method("setDeflection", &StdMeshers_Deflection1DPy::setDeflection, "setDeflection()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Deflection1DPy::StdMeshers_Deflection1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Deflection1D(hypId, studyId, gen)) -{ -} - -StdMeshers_Deflection1DPy::~StdMeshers_Deflection1DPy() -{ -} - -Py::Object StdMeshers_Deflection1DPy::setDeflection(const Py::Tuple& args) -{ - double fine = (double)Py::Float(args[0]); - hypothesis()->SetDeflection(fine); - return Py::None(); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Hexa_3DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Hexa_3D"); - behaviors().doc("StdMeshers_Hexa_3D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Hexa_3DPy::StdMeshers_Hexa_3DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Hexa_3D(hypId, studyId, gen)) -{ -} - -StdMeshers_Hexa_3DPy::~StdMeshers_Hexa_3DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_TrianglePreferencePy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_TrianglePreference"); - behaviors().doc("StdMeshers_TrianglePreference"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_TrianglePreferencePy::StdMeshers_TrianglePreferencePy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_TrianglePreference(hypId, studyId, gen)) -{ -} - -StdMeshers_TrianglePreferencePy::~StdMeshers_TrianglePreferencePy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_StartEndLengthPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_StartEndLength"); - behaviors().doc("StdMeshers_StartEndLength"); - add_varargs_method("setLength", &StdMeshers_StartEndLengthPy::setLength, "setLength()"); - add_varargs_method("getLength", &StdMeshers_StartEndLengthPy::getLength, "getLength()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_StartEndLengthPy::StdMeshers_StartEndLengthPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_StartEndLength(hypId, studyId, gen)) -{ -} - -StdMeshers_StartEndLengthPy::~StdMeshers_StartEndLengthPy() -{ -} - -Py::Object StdMeshers_StartEndLengthPy::setLength(const Py::Tuple& args) -{ - hypothesis()->SetLength((double)Py::Float(args[0]),(bool)Py::Boolean(args[1])); - return Py::None(); -} - -Py::Object StdMeshers_StartEndLengthPy::getLength(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetLength((bool)Py::Boolean(args[0]))); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_SegmentLengthAroundVertexPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_SegmentLengthAroundVertex"); - behaviors().doc("StdMeshers_SegmentLengthAroundVertex"); - add_varargs_method("setLength", &StdMeshers_SegmentLengthAroundVertexPy::setLength, "setLength()"); - add_varargs_method("getLength", &StdMeshers_SegmentLengthAroundVertexPy::getLength, "getLength()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_SegmentLengthAroundVertexPy::StdMeshers_SegmentLengthAroundVertexPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_SegmentLengthAroundVertex(hypId, studyId, gen)) -{ -} - -StdMeshers_SegmentLengthAroundVertexPy::~StdMeshers_SegmentLengthAroundVertexPy() -{ -} - -Py::Object StdMeshers_SegmentLengthAroundVertexPy::setLength(const Py::Tuple& args) -{ - hypothesis()->SetLength((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_SegmentLengthAroundVertexPy::getLength(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetLength()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_SegmentAroundVertex_0DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_SegmentAroundVertex_0D"); - behaviors().doc("StdMeshers_SegmentAroundVertex_0D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_SegmentAroundVertex_0DPy::StdMeshers_SegmentAroundVertex_0DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_SegmentAroundVertex_0D(hypId, studyId, gen)) -{ -} - -StdMeshers_SegmentAroundVertex_0DPy::~StdMeshers_SegmentAroundVertex_0DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_RadialPrism_3DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_RadialPrism_3D"); - behaviors().doc("StdMeshers_RadialPrism_3D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_RadialPrism_3DPy::StdMeshers_RadialPrism_3DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_RadialPrism_3D(hypId, studyId, gen)) -{ -} - -StdMeshers_RadialPrism_3DPy::~StdMeshers_RadialPrism_3DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_QuadraticMeshPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_QuadraticMesh"); - behaviors().doc("StdMeshers_QuadraticMesh"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_QuadraticMeshPy::StdMeshers_QuadraticMeshPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_QuadraticMesh(hypId, studyId, gen)) -{ -} - -StdMeshers_QuadraticMeshPy::~StdMeshers_QuadraticMeshPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_ProjectionSource3DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_ProjectionSource3D"); - behaviors().doc("StdMeshers_ProjectionSource3D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_ProjectionSource3DPy::StdMeshers_ProjectionSource3DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_ProjectionSource3D(hypId, studyId, gen)) -{ -} - -StdMeshers_ProjectionSource3DPy::~StdMeshers_ProjectionSource3DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_ProjectionSource2DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_ProjectionSource2D"); - behaviors().doc("StdMeshers_ProjectionSource2D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_ProjectionSource2DPy::StdMeshers_ProjectionSource2DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_ProjectionSource2D(hypId, studyId, gen)) -{ -} - -StdMeshers_ProjectionSource2DPy::~StdMeshers_ProjectionSource2DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_ProjectionSource1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_ProjectionSource1D"); - behaviors().doc("StdMeshers_ProjectionSource1D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_ProjectionSource1DPy::StdMeshers_ProjectionSource1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_ProjectionSource1D(hypId, studyId, gen)) -{ -} - -StdMeshers_ProjectionSource1DPy::~StdMeshers_ProjectionSource1DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Projection_3DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Projection_3D"); - behaviors().doc("StdMeshers_Projection_3D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Projection_3DPy::StdMeshers_Projection_3DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Projection_3D(hypId, studyId, gen)) -{ -} - -StdMeshers_Projection_3DPy::~StdMeshers_Projection_3DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Projection_2DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Projection_2D"); - behaviors().doc("StdMeshers_Projection_2D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Projection_2DPy::StdMeshers_Projection_2DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Projection_2D(hypId, studyId, gen)) -{ -} - -StdMeshers_Projection_2DPy::~StdMeshers_Projection_2DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Projection_1DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Projection_1D"); - behaviors().doc("StdMeshers_Projection_1D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Projection_1DPy::StdMeshers_Projection_1DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Projection_1D(hypId, studyId, gen)) -{ -} - -StdMeshers_Projection_1DPy::~StdMeshers_Projection_1DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_Prism_3DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_Prism_3D"); - behaviors().doc("StdMeshers_Prism_3D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_Prism_3DPy::StdMeshers_Prism_3DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_Prism_3D(hypId, studyId, gen)) -{ -} - -StdMeshers_Prism_3DPy::~StdMeshers_Prism_3DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_NumberOfSegmentsPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_NumberOfSegments"); - behaviors().doc("StdMeshers_NumberOfSegments"); - add_varargs_method("setNumberOfSegments",&StdMeshers_NumberOfSegmentsPy::setNumSegm,"setNumberOfSegments()"); - add_varargs_method("getNumberOfSegments",&StdMeshers_NumberOfSegmentsPy::getNumSegm,"getNumberOfSegments()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_NumberOfSegmentsPy::StdMeshers_NumberOfSegmentsPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_NumberOfSegments(hypId, studyId, gen)) -{ -} - -StdMeshers_NumberOfSegmentsPy::~StdMeshers_NumberOfSegmentsPy() -{ -} - -Py::Object StdMeshers_NumberOfSegmentsPy::setNumSegm(const Py::Tuple& args) -{ - hypothesis()->SetNumberOfSegments((int)Py::Int(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_NumberOfSegmentsPy::getNumSegm(const Py::Tuple& args) -{ - return Py::Int(hypothesis()->GetNumberOfSegments()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_NumberOfLayersPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_NumberOfLayers"); - behaviors().doc("StdMeshers_NumberOfLayers"); - add_varargs_method("setNumberOfLayers",&StdMeshers_NumberOfLayersPy::setNumLayers,"setNumberOfLayers()"); - add_varargs_method("getNumberOfLayers",&StdMeshers_NumberOfLayersPy::getNumLayers,"getNumberOfLayers()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_NumberOfLayersPy::StdMeshers_NumberOfLayersPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_NumberOfLayers(hypId, studyId, gen)) -{ -} - -StdMeshers_NumberOfLayersPy::~StdMeshers_NumberOfLayersPy() -{ -} - -Py::Object StdMeshers_NumberOfLayersPy::setNumLayers(const Py::Tuple& args) -{ - hypothesis()->SetNumberOfLayers((int)Py::Int(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_NumberOfLayersPy::getNumLayers(const Py::Tuple& args) -{ - return Py::Int(hypothesis()->GetNumberOfLayers()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_MEFISTO_2DPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_MEFISTO_2D"); - behaviors().doc("StdMeshers_MEFISTO_2D"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_MEFISTO_2DPy::StdMeshers_MEFISTO_2DPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_MEFISTO_2D(hypId, studyId, gen)) -{ -} - -StdMeshers_MEFISTO_2DPy::~StdMeshers_MEFISTO_2DPy() -{ -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_MaxElementVolumePy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_MaxElementVolume"); - behaviors().doc("StdMeshers_MaxElementVolume"); - add_varargs_method("setMaxVolume",&StdMeshers_MaxElementVolumePy::setMaxVolume,"setMaxVolume()"); - add_varargs_method("getMaxVolume",&StdMeshers_MaxElementVolumePy::getMaxVolume,"getMaxVolume()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_MaxElementVolumePy::StdMeshers_MaxElementVolumePy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_MaxElementVolume(hypId, studyId, gen)) -{ -} - -StdMeshers_MaxElementVolumePy::~StdMeshers_MaxElementVolumePy() -{ -} - -Py::Object StdMeshers_MaxElementVolumePy::setMaxVolume(const Py::Tuple& args) -{ - hypothesis()->SetMaxVolume((double)Py::Float(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_MaxElementVolumePy::getMaxVolume(const Py::Tuple& args) -{ - return Py::Float(hypothesis()->GetMaxVolume()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_LengthFromEdgesPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_LengthFromEdges"); - behaviors().doc("StdMeshers_LengthFromEdges"); - add_varargs_method("setMode",&StdMeshers_LengthFromEdgesPy::setMode,"setMode()"); - add_varargs_method("getMode",&StdMeshers_LengthFromEdgesPy::getMode,"getMode()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_LengthFromEdgesPy::StdMeshers_LengthFromEdgesPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_LengthFromEdges(hypId, studyId, gen)) -{ -} - -StdMeshers_LengthFromEdgesPy::~StdMeshers_LengthFromEdgesPy() -{ -} - -Py::Object StdMeshers_LengthFromEdgesPy::setMode(const Py::Tuple& args) -{ - hypothesis()->SetMode((int)Py::Int(args[0])); - return Py::None(); -} - -Py::Object StdMeshers_LengthFromEdgesPy::getMode(const Py::Tuple& args) -{ - return Py::Int(hypothesis()->GetMode()); -} - -// ---------------------------------------------------------------------------- - -void StdMeshers_LayerDistributionPy::init_type(PyObject* module) -{ - behaviors().name("StdMeshers_LayerDistribution"); - behaviors().doc("StdMeshers_LayerDistribution"); - add_varargs_method("setLayerDistribution", - &StdMeshers_LayerDistributionPy::setLayerDistribution, - "setLayerDistribution()"); - add_varargs_method("getLayerDistribution", - &StdMeshers_LayerDistributionPy::getLayerDistribution, - "getLayerDistribution()"); - SMESH_HypothesisPyBase::init_type(module); -} - -StdMeshers_LayerDistributionPy::StdMeshers_LayerDistributionPy(int hypId, int studyId, SMESH_Gen* gen) - : SMESH_HypothesisPyBase(new StdMeshers_LayerDistribution(hypId, studyId, gen)) -{ -} - -StdMeshers_LayerDistributionPy::~StdMeshers_LayerDistributionPy() -{ -} - -Py::Object StdMeshers_LayerDistributionPy::setLayerDistribution(const Py::Tuple& args) -{ - return Py::None(); -} - -Py::Object StdMeshers_LayerDistributionPy::getLayerDistribution(const Py::Tuple& args) -{ - //return hypothesis()->GetLayerDistribution(); - return Py::None(); -} +/*************************************************************************** + * Copyright (c) 2010 Werner Mayer * + * * + * 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" +#include "HypothesisPy.h" +#include "FemMeshPy.h" +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include + +using namespace Fem; + + +HypothesisPy::HypothesisPy(boost::shared_ptr h) + : hyp(h) +{ +} + +HypothesisPy::~HypothesisPy() +{ +} + +// ---------------------------------------------------------------------------- + +template +void SMESH_HypothesisPy::init_type(PyObject* module) +{ + // you must have overwritten the virtual functions + SMESH_HypothesisPy::behaviors().supportRepr(); + SMESH_HypothesisPy::behaviors().supportGetattr(); + SMESH_HypothesisPy::behaviors().supportSetattr(); + SMESH_HypothesisPy::behaviors().type_object()->tp_new = &PyMake; + + SMESH_HypothesisPy::add_varargs_method("setLibName", &SMESH_HypothesisPy::setLibName, "setLibName(String)"); + SMESH_HypothesisPy::add_varargs_method("getLibName", &SMESH_HypothesisPy::getLibName, "String getLibName()"); + SMESH_HypothesisPy::add_varargs_method("setParameters", &SMESH_HypothesisPy::setParameters, "setParameters(String)"); + SMESH_HypothesisPy::add_varargs_method("getParameters", &SMESH_HypothesisPy::getParameters, "String getParameters()"); + SMESH_HypothesisPy::add_varargs_method("setLastParameters", &SMESH_HypothesisPy::setLastParameters, "setLastParameters(String)"); + SMESH_HypothesisPy::add_varargs_method("getLastParameters", &SMESH_HypothesisPy::getLastParameters, "String getLastParameters()"); + SMESH_HypothesisPy::add_varargs_method("clearParameters", &SMESH_HypothesisPy::clearParameters, "clearParameters()"); + SMESH_HypothesisPy::add_varargs_method("isAuxiliary", &SMESH_HypothesisPy::isAuxiliary, "Bool isAuxiliary()"); + SMESH_HypothesisPy::add_varargs_method("setParametersByMesh", &SMESH_HypothesisPy::setParametersByMesh, "setParametersByMesh(Mesh,Shape)"); + Base::Interpreter().addType(SMESH_HypothesisPy::behaviors().type_object(), + module,SMESH_HypothesisPy::behaviors().getName()); +} + +template +SMESH_HypothesisPy::SMESH_HypothesisPy(SMESH_Hypothesis* h) : hyp(h) +{ +} + +template +SMESH_HypothesisPy::~SMESH_HypothesisPy() +{ +} + +template +Py::Object SMESH_HypothesisPy::getattr(const char *name) +{ + if (strcmp(name,"this") == 0) + return Hypothesis(Py::asObject(new HypothesisPy(this->getHypothesis()))); + return Py::PythonExtension::getattr(name); +} + +template +Py::Object SMESH_HypothesisPy::repr() +{ + std::stringstream str; + str << hyp->GetName() << ", " << hyp->GetID(); + return Py::String(str.str()); +} + +template +Py::Object SMESH_HypothesisPy::setLibName(const Py::Tuple& args) +{ + std::string libName = (std::string)Py::String(args[0]); + hypothesis()->SetLibName(libName.c_str()); + return Py::None(); +} + +template +Py::Object SMESH_HypothesisPy::getLibName(const Py::Tuple& args) +{ + return Py::String(hypothesis()->GetLibName()); +} + +template +Py::Object SMESH_HypothesisPy::setParameters(const Py::Tuple& args) +{ + std::string paramName = (std::string)Py::String(args[0]); + hypothesis()->SetParameters(paramName.c_str()); + return Py::None(); +} + +template +Py::Object SMESH_HypothesisPy::getParameters(const Py::Tuple& args) +{ + return Py::String(hypothesis()->GetParameters()); +} + +template +Py::Object SMESH_HypothesisPy::setLastParameters(const Py::Tuple& args) +{ + std::string paramName = (std::string)Py::String(args[0]); + hypothesis()->SetLastParameters(paramName.c_str()); + return Py::None(); +} + +template +Py::Object SMESH_HypothesisPy::getLastParameters(const Py::Tuple& args) +{ + return Py::String(hypothesis()->GetLastParameters()); +} + +template +Py::Object SMESH_HypothesisPy::clearParameters(const Py::Tuple& args) +{ + hypothesis()->ClearParameters(); + return Py::None(); +} + +template +Py::Object SMESH_HypothesisPy::setParametersByMesh(const Py::Tuple& args) +{ + PyObject *mesh, *shape; + if (!PyArg_ParseTuple(args.ptr(), "O!O!", + &(Fem::FemMeshPy::Type), &mesh, + &(Part::TopoShapePy::Type), &shape)) + throw Py::Exception(); + Fem::FemMesh* m = static_cast(mesh)->getFemMeshPtr(); + const TopoDS_Shape& s = static_cast(shape)->getTopoShapePtr()->_Shape; + return Py::Boolean(hypothesis()->SetParametersByMesh(m->getSMesh(), s)); +} + +template +Py::Object SMESH_HypothesisPy::isAuxiliary(const Py::Tuple& args) +{ + return Py::Boolean(hypothesis()->IsAuxiliary()); +} + +template +PyObject *SMESH_HypothesisPy::PyMake(struct _typeobject *type, PyObject * args, PyObject * kwds) +{ + int hypId; + PyObject* obj; + if (!PyArg_ParseTuple(args, "iO!",&hypId,&(FemMeshPy::Type),&obj)) + return 0; + FemMesh* mesh = static_cast(obj)->getFemMeshPtr(); + return new T(hypId, 1, mesh->getGenerator()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Arithmetic1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Arithmetic1D"); + behaviors().doc("StdMeshers_Arithmetic1D"); + + add_varargs_method("setLength", &StdMeshers_Arithmetic1DPy::setLength, "setLength()"); + add_varargs_method("getLength", &StdMeshers_Arithmetic1DPy::getLength, "getLength()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Arithmetic1DPy::StdMeshers_Arithmetic1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Arithmetic1D(hypId, studyId, gen)) +{ +} + +StdMeshers_Arithmetic1DPy::~StdMeshers_Arithmetic1DPy() +{ +} + +Py::Object StdMeshers_Arithmetic1DPy::setLength(const Py::Tuple& args) +{ + hypothesis()-> + SetLength((double)Py::Float(args[0]), (bool)Py::Boolean(args[1])); + return Py::None(); +} + +Py::Object StdMeshers_Arithmetic1DPy::getLength(const Py::Tuple& args) +{ + int start; + if (!PyArg_ParseTuple(args.ptr(), "i",&start)) + throw Py::Exception(); + return Py::Float(hypothesis()-> + GetLength(start ? true : false)); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_AutomaticLengthPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_AutomaticLength"); + behaviors().doc("StdMeshers_AutomaticLength"); + + add_varargs_method("setFineness", &StdMeshers_AutomaticLengthPy::setFineness, "setFineness()"); + add_varargs_method("getFineness", &StdMeshers_AutomaticLengthPy::getFineness, "getFineness()"); + add_varargs_method("getLength", &StdMeshers_AutomaticLengthPy::getLength, "getLength()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_AutomaticLengthPy::StdMeshers_AutomaticLengthPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(0) +{ +} + +StdMeshers_AutomaticLengthPy::~StdMeshers_AutomaticLengthPy() +{ +} + +Py::Object StdMeshers_AutomaticLengthPy::setFineness(const Py::Tuple& args) +{ + double fine = (double)Py::Float(args[0]); + hypothesis()->SetFineness(fine); + return Py::None(); +} + +Py::Object StdMeshers_AutomaticLengthPy::getFineness(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetFineness()); +} + +namespace Py { + typedef ExtensionObject FemMesh; + typedef ExtensionObject TopoShape; + template<> bool FemMesh::accepts (PyObject *pyob) const + { + return (pyob && PyObject_TypeCheck(pyob, &(Fem::FemMeshPy::Type))); + } + template<> bool TopoShape::accepts (PyObject *pyob) const + { + return (pyob && PyObject_TypeCheck(pyob, &(Part::TopoShapePy::Type))); + } +} + +Py::Object StdMeshers_AutomaticLengthPy::getLength(const Py::Tuple& args) +{ + Py::FemMesh mesh(args[0]); + Py::Object shape_or_double(args[1]); + + Fem::FemMesh* m = mesh.extensionObject()->getFemMeshPtr(); + if (shape_or_double.type() == Py::Float().type()) { + double len = (double)Py::Float(shape_or_double); + return Py::Float(hypothesis()->GetLength(m->getSMesh(),len)); + } + else { + Py::TopoShape shape(shape_or_double); + const TopoDS_Shape& s = shape.extensionObject()->getTopoShapePtr()->_Shape; + return Py::Float(hypothesis()->GetLength(m->getSMesh(),s)); + } + + throw Py::Exception(); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_NotConformAllowedPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_NotConformAllowed"); + behaviors().doc("StdMeshers_NotConformAllowed"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_NotConformAllowedPy::StdMeshers_NotConformAllowedPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_NotConformAllowed(hypId, studyId, gen)) +{ +} + +StdMeshers_NotConformAllowedPy::~StdMeshers_NotConformAllowedPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_MaxLengthPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_MaxLength"); + behaviors().doc("StdMeshers_MaxLength"); + + add_varargs_method("setLength", &StdMeshers_MaxLengthPy::setLength, "setLength()"); + add_varargs_method("getLength", &StdMeshers_MaxLengthPy::getLength, "getLength()"); + add_varargs_method("havePreestimatedLength", &StdMeshers_MaxLengthPy::havePreestimatedLength, "havePreestimatedLength()"); + add_varargs_method("getPreestimatedLength", &StdMeshers_MaxLengthPy::getPreestimatedLength, "getPreestimatedLength()"); + add_varargs_method("setPreestimatedLength", &StdMeshers_MaxLengthPy::setPreestimatedLength, "setPreestimatedLength()"); + add_varargs_method("setUsePreestimatedLength", &StdMeshers_MaxLengthPy::setUsePreestimatedLength, "setUsePreestimatedLength()"); + add_varargs_method("getUsePreestimatedLength", &StdMeshers_MaxLengthPy::getUsePreestimatedLength, "getUsePreestimatedLength()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_MaxLengthPy::StdMeshers_MaxLengthPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_MaxLength(hypId, studyId, gen)) +{ +} + +StdMeshers_MaxLengthPy::~StdMeshers_MaxLengthPy() +{ +} + +Py::Object StdMeshers_MaxLengthPy::setLength(const Py::Tuple& args) +{ + hypothesis()->SetLength((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_MaxLengthPy::getLength(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetLength()); +} + +Py::Object StdMeshers_MaxLengthPy::havePreestimatedLength(const Py::Tuple& args) +{ + return Py::Boolean(hypothesis()->HavePreestimatedLength()); +} + +Py::Object StdMeshers_MaxLengthPy::getPreestimatedLength(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetPreestimatedLength()); +} + +Py::Object StdMeshers_MaxLengthPy::setPreestimatedLength(const Py::Tuple& args) +{ + hypothesis()->SetPreestimatedLength((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_MaxLengthPy::setUsePreestimatedLength(const Py::Tuple& args) +{ + hypothesis()->SetUsePreestimatedLength((bool)Py::Boolean(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_MaxLengthPy::getUsePreestimatedLength(const Py::Tuple& args) +{ + return Py::Boolean(hypothesis()->GetUsePreestimatedLength()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_LocalLengthPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_LocalLength"); + behaviors().doc("StdMeshers_LocalLength"); + + add_varargs_method("setLength", &StdMeshers_LocalLengthPy::setLength, "setLength()"); + add_varargs_method("getLength", &StdMeshers_LocalLengthPy::getLength, "getLength()"); + add_varargs_method("setPrecision", &StdMeshers_LocalLengthPy::setPrecision, "setPrecision()"); + add_varargs_method("getPrecision", &StdMeshers_LocalLengthPy::getPrecision, "getPrecision()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_LocalLengthPy::StdMeshers_LocalLengthPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_LocalLength(hypId, studyId, gen)) +{ +} + +StdMeshers_LocalLengthPy::~StdMeshers_LocalLengthPy() +{ +} + +Py::Object StdMeshers_LocalLengthPy::setLength(const Py::Tuple& args) +{ + hypothesis()->SetLength((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_LocalLengthPy::getLength(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetLength()); +} + +Py::Object StdMeshers_LocalLengthPy::setPrecision(const Py::Tuple& args) +{ + hypothesis()->SetPrecision((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_LocalLengthPy::getPrecision(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetPrecision()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_MaxElementAreaPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_MaxElementArea"); + behaviors().doc("StdMeshers_MaxElementArea"); + + add_varargs_method("setMaxArea", &StdMeshers_MaxElementAreaPy::setMaxArea, "setMaxArea()"); + add_varargs_method("getMaxArea", &StdMeshers_MaxElementAreaPy::getMaxArea, "getMaxArea()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_MaxElementAreaPy::StdMeshers_MaxElementAreaPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_MaxElementArea(hypId, studyId, gen)) +{ +} + +StdMeshers_MaxElementAreaPy::~StdMeshers_MaxElementAreaPy() +{ +} + +Py::Object StdMeshers_MaxElementAreaPy::setMaxArea(const Py::Tuple& args) +{ + hypothesis()->SetMaxArea((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_MaxElementAreaPy::getMaxArea(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetMaxArea()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_QuadranglePreferencePy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_QuadranglePreference"); + behaviors().doc("StdMeshers_QuadranglePreference"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_QuadranglePreferencePy::StdMeshers_QuadranglePreferencePy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_QuadranglePreference(hypId, studyId, gen)) +{ +} + +StdMeshers_QuadranglePreferencePy::~StdMeshers_QuadranglePreferencePy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Quadrangle_2DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Quadrangle_2D"); + behaviors().doc("StdMeshers_Quadrangle_2D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Quadrangle_2DPy::StdMeshers_Quadrangle_2DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Quadrangle_2D(hypId, studyId, gen)) +{ +} + +StdMeshers_Quadrangle_2DPy::~StdMeshers_Quadrangle_2DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Regular_1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Regular_1D"); + behaviors().doc("StdMeshers_Regular_1D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Regular_1DPy::StdMeshers_Regular_1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Regular_1D(hypId, studyId, gen)) +{ +} + +StdMeshers_Regular_1DPy::~StdMeshers_Regular_1DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_UseExisting_1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_UseExisting_1D"); + behaviors().doc("StdMeshers_UseExisting_1D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_UseExisting_1DPy::StdMeshers_UseExisting_1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_UseExisting_1D(hypId, studyId, gen)) +{ +} + +StdMeshers_UseExisting_1DPy::~StdMeshers_UseExisting_1DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_UseExisting_2DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_UseExisting_2D"); + behaviors().doc("StdMeshers_UseExisting_2D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_UseExisting_2DPy::StdMeshers_UseExisting_2DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_UseExisting_2D(hypId, studyId, gen)) +{ +} + +StdMeshers_UseExisting_2DPy::~StdMeshers_UseExisting_2DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_CompositeSegment_1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_CompositeSegment_1D"); + behaviors().doc("StdMeshers_CompositeSegment_1D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_CompositeSegment_1DPy::StdMeshers_CompositeSegment_1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_CompositeSegment_1D(hypId, studyId, gen)) +{ +} + +StdMeshers_CompositeSegment_1DPy::~StdMeshers_CompositeSegment_1DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Deflection1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Deflection1D"); + behaviors().doc("StdMeshers_Deflection1D"); + + add_varargs_method("setDeflection", &StdMeshers_Deflection1DPy::setDeflection, "setDeflection()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Deflection1DPy::StdMeshers_Deflection1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Deflection1D(hypId, studyId, gen)) +{ +} + +StdMeshers_Deflection1DPy::~StdMeshers_Deflection1DPy() +{ +} + +Py::Object StdMeshers_Deflection1DPy::setDeflection(const Py::Tuple& args) +{ + double fine = (double)Py::Float(args[0]); + hypothesis()->SetDeflection(fine); + return Py::None(); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Hexa_3DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Hexa_3D"); + behaviors().doc("StdMeshers_Hexa_3D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Hexa_3DPy::StdMeshers_Hexa_3DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Hexa_3D(hypId, studyId, gen)) +{ +} + +StdMeshers_Hexa_3DPy::~StdMeshers_Hexa_3DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_TrianglePreferencePy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_TrianglePreference"); + behaviors().doc("StdMeshers_TrianglePreference"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_TrianglePreferencePy::StdMeshers_TrianglePreferencePy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_TrianglePreference(hypId, studyId, gen)) +{ +} + +StdMeshers_TrianglePreferencePy::~StdMeshers_TrianglePreferencePy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_StartEndLengthPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_StartEndLength"); + behaviors().doc("StdMeshers_StartEndLength"); + add_varargs_method("setLength", &StdMeshers_StartEndLengthPy::setLength, "setLength()"); + add_varargs_method("getLength", &StdMeshers_StartEndLengthPy::getLength, "getLength()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_StartEndLengthPy::StdMeshers_StartEndLengthPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_StartEndLength(hypId, studyId, gen)) +{ +} + +StdMeshers_StartEndLengthPy::~StdMeshers_StartEndLengthPy() +{ +} + +Py::Object StdMeshers_StartEndLengthPy::setLength(const Py::Tuple& args) +{ + hypothesis()->SetLength((double)Py::Float(args[0]),(bool)Py::Boolean(args[1])); + return Py::None(); +} + +Py::Object StdMeshers_StartEndLengthPy::getLength(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetLength((bool)Py::Boolean(args[0]))); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_SegmentLengthAroundVertexPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_SegmentLengthAroundVertex"); + behaviors().doc("StdMeshers_SegmentLengthAroundVertex"); + add_varargs_method("setLength", &StdMeshers_SegmentLengthAroundVertexPy::setLength, "setLength()"); + add_varargs_method("getLength", &StdMeshers_SegmentLengthAroundVertexPy::getLength, "getLength()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_SegmentLengthAroundVertexPy::StdMeshers_SegmentLengthAroundVertexPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_SegmentLengthAroundVertex(hypId, studyId, gen)) +{ +} + +StdMeshers_SegmentLengthAroundVertexPy::~StdMeshers_SegmentLengthAroundVertexPy() +{ +} + +Py::Object StdMeshers_SegmentLengthAroundVertexPy::setLength(const Py::Tuple& args) +{ + hypothesis()->SetLength((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_SegmentLengthAroundVertexPy::getLength(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetLength()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_SegmentAroundVertex_0DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_SegmentAroundVertex_0D"); + behaviors().doc("StdMeshers_SegmentAroundVertex_0D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_SegmentAroundVertex_0DPy::StdMeshers_SegmentAroundVertex_0DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_SegmentAroundVertex_0D(hypId, studyId, gen)) +{ +} + +StdMeshers_SegmentAroundVertex_0DPy::~StdMeshers_SegmentAroundVertex_0DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_RadialPrism_3DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_RadialPrism_3D"); + behaviors().doc("StdMeshers_RadialPrism_3D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_RadialPrism_3DPy::StdMeshers_RadialPrism_3DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_RadialPrism_3D(hypId, studyId, gen)) +{ +} + +StdMeshers_RadialPrism_3DPy::~StdMeshers_RadialPrism_3DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_QuadraticMeshPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_QuadraticMesh"); + behaviors().doc("StdMeshers_QuadraticMesh"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_QuadraticMeshPy::StdMeshers_QuadraticMeshPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_QuadraticMesh(hypId, studyId, gen)) +{ +} + +StdMeshers_QuadraticMeshPy::~StdMeshers_QuadraticMeshPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_ProjectionSource3DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_ProjectionSource3D"); + behaviors().doc("StdMeshers_ProjectionSource3D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_ProjectionSource3DPy::StdMeshers_ProjectionSource3DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_ProjectionSource3D(hypId, studyId, gen)) +{ +} + +StdMeshers_ProjectionSource3DPy::~StdMeshers_ProjectionSource3DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_ProjectionSource2DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_ProjectionSource2D"); + behaviors().doc("StdMeshers_ProjectionSource2D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_ProjectionSource2DPy::StdMeshers_ProjectionSource2DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_ProjectionSource2D(hypId, studyId, gen)) +{ +} + +StdMeshers_ProjectionSource2DPy::~StdMeshers_ProjectionSource2DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_ProjectionSource1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_ProjectionSource1D"); + behaviors().doc("StdMeshers_ProjectionSource1D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_ProjectionSource1DPy::StdMeshers_ProjectionSource1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_ProjectionSource1D(hypId, studyId, gen)) +{ +} + +StdMeshers_ProjectionSource1DPy::~StdMeshers_ProjectionSource1DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Projection_3DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Projection_3D"); + behaviors().doc("StdMeshers_Projection_3D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Projection_3DPy::StdMeshers_Projection_3DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Projection_3D(hypId, studyId, gen)) +{ +} + +StdMeshers_Projection_3DPy::~StdMeshers_Projection_3DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Projection_2DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Projection_2D"); + behaviors().doc("StdMeshers_Projection_2D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Projection_2DPy::StdMeshers_Projection_2DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Projection_2D(hypId, studyId, gen)) +{ +} + +StdMeshers_Projection_2DPy::~StdMeshers_Projection_2DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Projection_1DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Projection_1D"); + behaviors().doc("StdMeshers_Projection_1D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Projection_1DPy::StdMeshers_Projection_1DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Projection_1D(hypId, studyId, gen)) +{ +} + +StdMeshers_Projection_1DPy::~StdMeshers_Projection_1DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_Prism_3DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_Prism_3D"); + behaviors().doc("StdMeshers_Prism_3D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_Prism_3DPy::StdMeshers_Prism_3DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_Prism_3D(hypId, studyId, gen)) +{ +} + +StdMeshers_Prism_3DPy::~StdMeshers_Prism_3DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_NumberOfSegmentsPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_NumberOfSegments"); + behaviors().doc("StdMeshers_NumberOfSegments"); + add_varargs_method("setNumberOfSegments",&StdMeshers_NumberOfSegmentsPy::setNumSegm,"setNumberOfSegments()"); + add_varargs_method("getNumberOfSegments",&StdMeshers_NumberOfSegmentsPy::getNumSegm,"getNumberOfSegments()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_NumberOfSegmentsPy::StdMeshers_NumberOfSegmentsPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_NumberOfSegments(hypId, studyId, gen)) +{ +} + +StdMeshers_NumberOfSegmentsPy::~StdMeshers_NumberOfSegmentsPy() +{ +} + +Py::Object StdMeshers_NumberOfSegmentsPy::setNumSegm(const Py::Tuple& args) +{ + hypothesis()->SetNumberOfSegments((int)Py::Int(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_NumberOfSegmentsPy::getNumSegm(const Py::Tuple& args) +{ + return Py::Int(hypothesis()->GetNumberOfSegments()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_NumberOfLayersPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_NumberOfLayers"); + behaviors().doc("StdMeshers_NumberOfLayers"); + add_varargs_method("setNumberOfLayers",&StdMeshers_NumberOfLayersPy::setNumLayers,"setNumberOfLayers()"); + add_varargs_method("getNumberOfLayers",&StdMeshers_NumberOfLayersPy::getNumLayers,"getNumberOfLayers()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_NumberOfLayersPy::StdMeshers_NumberOfLayersPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_NumberOfLayers(hypId, studyId, gen)) +{ +} + +StdMeshers_NumberOfLayersPy::~StdMeshers_NumberOfLayersPy() +{ +} + +Py::Object StdMeshers_NumberOfLayersPy::setNumLayers(const Py::Tuple& args) +{ + hypothesis()->SetNumberOfLayers((int)Py::Int(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_NumberOfLayersPy::getNumLayers(const Py::Tuple& args) +{ + return Py::Int(hypothesis()->GetNumberOfLayers()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_MEFISTO_2DPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_MEFISTO_2D"); + behaviors().doc("StdMeshers_MEFISTO_2D"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_MEFISTO_2DPy::StdMeshers_MEFISTO_2DPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_MEFISTO_2D(hypId, studyId, gen)) +{ +} + +StdMeshers_MEFISTO_2DPy::~StdMeshers_MEFISTO_2DPy() +{ +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_MaxElementVolumePy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_MaxElementVolume"); + behaviors().doc("StdMeshers_MaxElementVolume"); + add_varargs_method("setMaxVolume",&StdMeshers_MaxElementVolumePy::setMaxVolume,"setMaxVolume()"); + add_varargs_method("getMaxVolume",&StdMeshers_MaxElementVolumePy::getMaxVolume,"getMaxVolume()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_MaxElementVolumePy::StdMeshers_MaxElementVolumePy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_MaxElementVolume(hypId, studyId, gen)) +{ +} + +StdMeshers_MaxElementVolumePy::~StdMeshers_MaxElementVolumePy() +{ +} + +Py::Object StdMeshers_MaxElementVolumePy::setMaxVolume(const Py::Tuple& args) +{ + hypothesis()->SetMaxVolume((double)Py::Float(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_MaxElementVolumePy::getMaxVolume(const Py::Tuple& args) +{ + return Py::Float(hypothesis()->GetMaxVolume()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_LengthFromEdgesPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_LengthFromEdges"); + behaviors().doc("StdMeshers_LengthFromEdges"); + add_varargs_method("setMode",&StdMeshers_LengthFromEdgesPy::setMode,"setMode()"); + add_varargs_method("getMode",&StdMeshers_LengthFromEdgesPy::getMode,"getMode()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_LengthFromEdgesPy::StdMeshers_LengthFromEdgesPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_LengthFromEdges(hypId, studyId, gen)) +{ +} + +StdMeshers_LengthFromEdgesPy::~StdMeshers_LengthFromEdgesPy() +{ +} + +Py::Object StdMeshers_LengthFromEdgesPy::setMode(const Py::Tuple& args) +{ + hypothesis()->SetMode((int)Py::Int(args[0])); + return Py::None(); +} + +Py::Object StdMeshers_LengthFromEdgesPy::getMode(const Py::Tuple& args) +{ + return Py::Int(hypothesis()->GetMode()); +} + +// ---------------------------------------------------------------------------- + +void StdMeshers_LayerDistributionPy::init_type(PyObject* module) +{ + behaviors().name("StdMeshers_LayerDistribution"); + behaviors().doc("StdMeshers_LayerDistribution"); + add_varargs_method("setLayerDistribution", + &StdMeshers_LayerDistributionPy::setLayerDistribution, + "setLayerDistribution()"); + add_varargs_method("getLayerDistribution", + &StdMeshers_LayerDistributionPy::getLayerDistribution, + "getLayerDistribution()"); + SMESH_HypothesisPyBase::init_type(module); +} + +StdMeshers_LayerDistributionPy::StdMeshers_LayerDistributionPy(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_HypothesisPyBase(new StdMeshers_LayerDistribution(hypId, studyId, gen)) +{ +} + +StdMeshers_LayerDistributionPy::~StdMeshers_LayerDistributionPy() +{ +} + +Py::Object StdMeshers_LayerDistributionPy::setLayerDistribution(const Py::Tuple& args) +{ + return Py::None(); +} + +Py::Object StdMeshers_LayerDistributionPy::getLayerDistribution(const Py::Tuple& args) +{ + //return hypothesis()->GetLayerDistribution(); + return Py::None(); +} diff --git a/src/Mod/Mesh/App/WildMagic4/Wm4Query2Filtered.inl b/src/Mod/Mesh/App/WildMagic4/Wm4Query2Filtered.inl index 772c4c325..8306c72c3 100644 --- a/src/Mod/Mesh/App/WildMagic4/Wm4Query2Filtered.inl +++ b/src/Mod/Mesh/App/WildMagic4/Wm4Query2Filtered.inl @@ -1,105 +1,105 @@ -// Wild Magic Source Code -// David Eberly -// http://www.geometrictools.com -// Copyright (c) 1998-2007 -// -// This library is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or (at -// your option) any later version. The license is available for reading at -// either of the locations: -// http://www.gnu.org/copyleft/lgpl.html -// http://www.geometrictools.com/License/WildMagicLicense.pdf -// The license applies to versions 0 through 4 of Wild Magic. -// -// Version: 4.0.0 (2006/06/28) - -namespace Wm4 -{ -//---------------------------------------------------------------------------- -template -Query2Filtered::Query2Filtered (int iVQuantity, - const Vector2* akVertex, Real fUncertainty) - : - Query2(iVQuantity,akVertex), - m_kRQuery(iVQuantity,akVertex) -{ - assert((Real)0.0 <= fUncertainty && fUncertainty <= (Real)1.0); - m_fUncertainty = fUncertainty; -} -//---------------------------------------------------------------------------- -template -Query2Filtered::~Query2Filtered () -{ -} -//---------------------------------------------------------------------------- -template -Query::Type Query2Filtered::GetType () const -{ - return Query::QT_FILTERED; -} -//---------------------------------------------------------------------------- -template -int Query2Filtered::ToLine (const Vector2& rkP, int iV0, int iV1) - const -{ - const Vector2& rkV0 = m_akVertex[iV0]; - const Vector2& rkV1 = m_akVertex[iV1]; - - Real fX0 = rkP[0] - rkV0[0]; - Real fY0 = rkP[1] - rkV0[1]; - Real fX1 = rkV1[0] - rkV0[0]; - Real fY1 = rkV1[1] - rkV0[1]; - - Real fLen0 = Math::Sqrt(fX0*fX0 + fY0*fY0); - Real fLen1 = Math::Sqrt(fX1*fX1 + fY1*fY1); - Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1; - - Real fDet2 = Det2(fX0,fY0,fX1,fY1); - if (Math::FAbs(fDet2) >= fScaledUncertainty) - { - return (fDet2 > (Real)0.0 ? +1 : (fDet2 < (Real)0.0 ? -1 : 0)); - } - - return m_kRQuery.ToLine(rkP,iV0,iV1); -} -//---------------------------------------------------------------------------- -template -int Query2Filtered::ToCircumcircle (const Vector2& rkP, int iV0, - int iV1, int iV2) const -{ - const Vector2& rkV0 = m_akVertex[iV0]; - const Vector2& rkV1 = m_akVertex[iV1]; - const Vector2& rkV2 = m_akVertex[iV2]; - - Real fS0x = rkV0[0] + rkP[0]; - Real fD0x = rkV0[0] - rkP[0]; - Real fS0y = rkV0[1] + rkP[1]; - Real fD0y = rkV0[1] - rkP[1]; - Real fS1x = rkV1[0] + rkP[0]; - Real fD1x = rkV1[0] - rkP[0]; - Real fS1y = rkV1[1] + rkP[1]; - Real fD1y = rkV1[1] - rkP[1]; - Real fS2x = rkV2[0] + rkP[0]; - Real fD2x = rkV2[0] - rkP[0]; - Real fS2y = rkV2[1] + rkP[1]; - Real fD2y = rkV2[1] - rkP[1]; - Real fZ0 = fS0x*fD0x + fS0y*fD0y; - Real fZ1 = fS1x*fD1x + fS1y*fD1y; - Real fZ2 = fS2x*fD2x + fS2y*fD2y; - - Real fLen0 = Math::Sqrt(fD0x*fD0x + fD0y*fD0y + fZ0*fZ0); - Real fLen1 = Math::Sqrt(fD1x*fD1x + fD1y*fD1y + fZ1*fZ1); - Real fLen2 = Math::Sqrt(fD2x*fD2x + fD2y*fD2y + fZ2*fZ2); - Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2; - - Real fDet3 = Det3(fD0x,fD0y,fZ0,fD1x,fD1y,fZ1,fD2x,fD2y,fZ2); - if (Math::FAbs(fDet3) >= fScaledUncertainty) - { - return (fDet3 < (Real)0.0 ? 1 : (fDet3 > (Real)0.0 ? -1 : 0)); - } - - return m_kRQuery.ToCircumcircle(rkP,iV0,iV1,iV2); -} -//---------------------------------------------------------------------------- -} //namespace Wm4 +// Wild Magic Source Code +// David Eberly +// http://www.geometrictools.com +// Copyright (c) 1998-2007 +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or (at +// your option) any later version. The license is available for reading at +// either of the locations: +// http://www.gnu.org/copyleft/lgpl.html +// http://www.geometrictools.com/License/WildMagicLicense.pdf +// The license applies to versions 0 through 4 of Wild Magic. +// +// Version: 4.0.0 (2006/06/28) + +namespace Wm4 +{ +//---------------------------------------------------------------------------- +template +Query2Filtered::Query2Filtered (int iVQuantity, + const Vector2* akVertex, Real fUncertainty) + : + Query2(iVQuantity,akVertex), + m_kRQuery(iVQuantity,akVertex) +{ + assert((Real)0.0 <= fUncertainty && fUncertainty <= (Real)1.0); + m_fUncertainty = fUncertainty; +} +//---------------------------------------------------------------------------- +template +Query2Filtered::~Query2Filtered () +{ +} +//---------------------------------------------------------------------------- +template +Query::Type Query2Filtered::GetType () const +{ + return Query::QT_FILTERED; +} +//---------------------------------------------------------------------------- +template +int Query2Filtered::ToLine (const Vector2& rkP, int iV0, int iV1) + const +{ + const Vector2& rkV0 = m_akVertex[iV0]; + const Vector2& rkV1 = m_akVertex[iV1]; + + Real fX0 = rkP[0] - rkV0[0]; + Real fY0 = rkP[1] - rkV0[1]; + Real fX1 = rkV1[0] - rkV0[0]; + Real fY1 = rkV1[1] - rkV0[1]; + + Real fLen0 = Math::Sqrt(fX0*fX0 + fY0*fY0); + Real fLen1 = Math::Sqrt(fX1*fX1 + fY1*fY1); + Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1; + + Real fDet2 = this->Det2(fX0,fY0,fX1,fY1); + if (Math::FAbs(fDet2) >= fScaledUncertainty) + { + return (fDet2 > (Real)0.0 ? +1 : (fDet2 < (Real)0.0 ? -1 : 0)); + } + + return m_kRQuery.ToLine(rkP,iV0,iV1); +} +//---------------------------------------------------------------------------- +template +int Query2Filtered::ToCircumcircle (const Vector2& rkP, int iV0, + int iV1, int iV2) const +{ + const Vector2& rkV0 = m_akVertex[iV0]; + const Vector2& rkV1 = m_akVertex[iV1]; + const Vector2& rkV2 = m_akVertex[iV2]; + + Real fS0x = rkV0[0] + rkP[0]; + Real fD0x = rkV0[0] - rkP[0]; + Real fS0y = rkV0[1] + rkP[1]; + Real fD0y = rkV0[1] - rkP[1]; + Real fS1x = rkV1[0] + rkP[0]; + Real fD1x = rkV1[0] - rkP[0]; + Real fS1y = rkV1[1] + rkP[1]; + Real fD1y = rkV1[1] - rkP[1]; + Real fS2x = rkV2[0] + rkP[0]; + Real fD2x = rkV2[0] - rkP[0]; + Real fS2y = rkV2[1] + rkP[1]; + Real fD2y = rkV2[1] - rkP[1]; + Real fZ0 = fS0x*fD0x + fS0y*fD0y; + Real fZ1 = fS1x*fD1x + fS1y*fD1y; + Real fZ2 = fS2x*fD2x + fS2y*fD2y; + + Real fLen0 = Math::Sqrt(fD0x*fD0x + fD0y*fD0y + fZ0*fZ0); + Real fLen1 = Math::Sqrt(fD1x*fD1x + fD1y*fD1y + fZ1*fZ1); + Real fLen2 = Math::Sqrt(fD2x*fD2x + fD2y*fD2y + fZ2*fZ2); + Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2; + + Real fDet3 = this->Det3(fD0x,fD0y,fZ0,fD1x,fD1y,fZ1,fD2x,fD2y,fZ2); + if (Math::FAbs(fDet3) >= fScaledUncertainty) + { + return (fDet3 < (Real)0.0 ? 1 : (fDet3 > (Real)0.0 ? -1 : 0)); + } + + return m_kRQuery.ToCircumcircle(rkP,iV0,iV1,iV2); +} +//---------------------------------------------------------------------------- +} //namespace Wm4 diff --git a/src/Mod/Mesh/App/WildMagic4/Wm4Query3Filtered.inl b/src/Mod/Mesh/App/WildMagic4/Wm4Query3Filtered.inl index 45a723996..75224ee52 100644 --- a/src/Mod/Mesh/App/WildMagic4/Wm4Query3Filtered.inl +++ b/src/Mod/Mesh/App/WildMagic4/Wm4Query3Filtered.inl @@ -1,129 +1,129 @@ -// Wild Magic Source Code -// David Eberly -// http://www.geometrictools.com -// Copyright (c) 1998-2007 -// -// This library is free software; you can redistribute it and/or modify it -// under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation; either version 2.1 of the License, or (at -// your option) any later version. The license is available for reading at -// either of the locations: -// http://www.gnu.org/copyleft/lgpl.html -// http://www.geometrictools.com/License/WildMagicLicense.pdf -// The license applies to versions 0 through 4 of Wild Magic. -// -// Version: 4.0.0 (2006/06/28) - -namespace Wm4 -{ -//---------------------------------------------------------------------------- -template -Query3Filtered::Query3Filtered (int iVQuantity, - const Vector3* akVertex, Real fUncertainty) - : - Query3(iVQuantity,akVertex), - m_kRQuery(iVQuantity,akVertex) -{ - assert((Real)0.0 <= fUncertainty && fUncertainty <= (Real)1.0); - m_fUncertainty = fUncertainty; -} -//---------------------------------------------------------------------------- -template -Query3Filtered::~Query3Filtered () -{ -} -//---------------------------------------------------------------------------- -template -Query::Type Query3Filtered::GetType () const -{ - return Query::QT_FILTERED; -} -//---------------------------------------------------------------------------- -template -int Query3Filtered::ToPlane (const Vector3& rkP, int iV0, int iV1, - int iV2) const -{ - const Vector3& rkV0 = m_akVertex[iV0]; - const Vector3& rkV1 = m_akVertex[iV1]; - const Vector3& rkV2 = m_akVertex[iV2]; - - Real fX0 = rkP[0] - rkV0[0]; - Real fY0 = rkP[1] - rkV0[1]; - Real fZ0 = rkP[2] - rkV0[2]; - Real fX1 = rkV1[0] - rkV0[0]; - Real fY1 = rkV1[1] - rkV0[1]; - Real fZ1 = rkV1[2] - rkV0[2]; - Real fX2 = rkV2[0] - rkV0[0]; - Real fY2 = rkV2[1] - rkV0[1]; - Real fZ2 = rkV2[2] - rkV0[2]; - - Real fLen0 = Math::Sqrt(fX0*fX0 + fY0*fY0 + fZ0*fZ0); - Real fLen1 = Math::Sqrt(fX1*fX1 + fY1*fY1 + fZ1*fZ1); - Real fLen2 = Math::Sqrt(fX2*fX2 + fY2*fY2 + fZ2*fZ2); - Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2; - - Real fDet3 = Det3(fX0,fY0,fZ0,fX1,fY1,fZ1,fX2,fY2,fZ2); - if (Math::FAbs(fDet3) >= fScaledUncertainty) - { - return (fDet3 > (Real)0.0 ? +1 : (fDet3 < (Real)0.0 ? -1 : 0)); - } - - return m_kRQuery.ToPlane(rkP,iV0,iV1,iV2); -} -//---------------------------------------------------------------------------- -template -int Query3Filtered::ToCircumsphere (const Vector3& rkP, int iV0, - int iV1, int iV2, int iV3) const -{ - const Vector3& rkV0 = m_akVertex[iV0]; - const Vector3& rkV1 = m_akVertex[iV1]; - const Vector3& rkV2 = m_akVertex[iV2]; - const Vector3& rkV3 = m_akVertex[iV3]; - - Real fS0x = rkV0[0] + rkP[0]; - Real fD0x = rkV0[0] - rkP[0]; - Real fS0y = rkV0[1] + rkP[1]; - Real fD0y = rkV0[1] - rkP[1]; - Real fS0z = rkV0[2] + rkP[2]; - Real fD0z = rkV0[2] - rkP[2]; - Real fS1x = rkV1[0] + rkP[0]; - Real fD1x = rkV1[0] - rkP[0]; - Real fS1y = rkV1[1] + rkP[1]; - Real fD1y = rkV1[1] - rkP[1]; - Real fS1z = rkV1[2] + rkP[2]; - Real fD1z = rkV1[2] - rkP[2]; - Real fS2x = rkV2[0] + rkP[0]; - Real fD2x = rkV2[0] - rkP[0]; - Real fS2y = rkV2[1] + rkP[1]; - Real fD2y = rkV2[1] - rkP[1]; - Real fS2z = rkV2[2] + rkP[2]; - Real fD2z = rkV2[2] - rkP[2]; - Real fS3x = rkV3[0] + rkP[0]; - Real fD3x = rkV3[0] - rkP[0]; - Real fS3y = rkV3[1] + rkP[1]; - Real fD3y = rkV3[1] - rkP[1]; - Real fS3z = rkV3[2] + rkP[2]; - Real fD3z = rkV3[2] - rkP[2]; - Real fW0 = fS0x*fD0x + fS0y*fD0y + fS0z*fD0z; - Real fW1 = fS1x*fD1x + fS1y*fD1y + fS1z*fD1z; - Real fW2 = fS2x*fD2x + fS2y*fD2y + fS2z*fD2z; - Real fW3 = fS3x*fD3x + fS3y*fD3y + fS3z*fD3z; - - Real fLen0 = Math::Sqrt(fD0x*fD0x+fD0y*fD0y+fD0z*fD0z+fW0*fW0); - Real fLen1 = Math::Sqrt(fD1x*fD1x+fD1y*fD1y+fD1z*fD1z+fW1*fW1); - Real fLen2 = Math::Sqrt(fD2x*fD2x+fD2y*fD2y+fD2z*fD2z+fW2*fW2); - Real fLen3 = Math::Sqrt(fD3x*fD3x+fD3y*fD3y+fD3z*fD3z+fW3*fW3); - Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2*fLen3; - - Real fDet4 = Det4(fD0x,fD0y,fD0z,fW0,fD1x,fD1y,fD1z,fW1,fD2x, - fD2y,fD2z,fW2,fD3x,fD3y,fD3z,fW3); - - if (Math::FAbs(fDet4) >= fScaledUncertainty) - { - return (fDet4 > (Real)0.0 ? 1 : (fDet4 < (Real)0.0 ? -1 : 0)); - } - - return m_kRQuery.ToCircumsphere(rkP,iV0,iV1,iV2,iV3); -} -//---------------------------------------------------------------------------- -} //namespace Wm4 +// Wild Magic Source Code +// David Eberly +// http://www.geometrictools.com +// Copyright (c) 1998-2007 +// +// This library is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or (at +// your option) any later version. The license is available for reading at +// either of the locations: +// http://www.gnu.org/copyleft/lgpl.html +// http://www.geometrictools.com/License/WildMagicLicense.pdf +// The license applies to versions 0 through 4 of Wild Magic. +// +// Version: 4.0.0 (2006/06/28) + +namespace Wm4 +{ +//---------------------------------------------------------------------------- +template +Query3Filtered::Query3Filtered (int iVQuantity, + const Vector3* akVertex, Real fUncertainty) + : + Query3(iVQuantity,akVertex), + m_kRQuery(iVQuantity,akVertex) +{ + assert((Real)0.0 <= fUncertainty && fUncertainty <= (Real)1.0); + m_fUncertainty = fUncertainty; +} +//---------------------------------------------------------------------------- +template +Query3Filtered::~Query3Filtered () +{ +} +//---------------------------------------------------------------------------- +template +Query::Type Query3Filtered::GetType () const +{ + return Query::QT_FILTERED; +} +//---------------------------------------------------------------------------- +template +int Query3Filtered::ToPlane (const Vector3& rkP, int iV0, int iV1, + int iV2) const +{ + const Vector3& rkV0 = m_akVertex[iV0]; + const Vector3& rkV1 = m_akVertex[iV1]; + const Vector3& rkV2 = m_akVertex[iV2]; + + Real fX0 = rkP[0] - rkV0[0]; + Real fY0 = rkP[1] - rkV0[1]; + Real fZ0 = rkP[2] - rkV0[2]; + Real fX1 = rkV1[0] - rkV0[0]; + Real fY1 = rkV1[1] - rkV0[1]; + Real fZ1 = rkV1[2] - rkV0[2]; + Real fX2 = rkV2[0] - rkV0[0]; + Real fY2 = rkV2[1] - rkV0[1]; + Real fZ2 = rkV2[2] - rkV0[2]; + + Real fLen0 = Math::Sqrt(fX0*fX0 + fY0*fY0 + fZ0*fZ0); + Real fLen1 = Math::Sqrt(fX1*fX1 + fY1*fY1 + fZ1*fZ1); + Real fLen2 = Math::Sqrt(fX2*fX2 + fY2*fY2 + fZ2*fZ2); + Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2; + + Real fDet3 = this->Det3(fX0,fY0,fZ0,fX1,fY1,fZ1,fX2,fY2,fZ2); + if (Math::FAbs(fDet3) >= fScaledUncertainty) + { + return (fDet3 > (Real)0.0 ? +1 : (fDet3 < (Real)0.0 ? -1 : 0)); + } + + return m_kRQuery.ToPlane(rkP,iV0,iV1,iV2); +} +//---------------------------------------------------------------------------- +template +int Query3Filtered::ToCircumsphere (const Vector3& rkP, int iV0, + int iV1, int iV2, int iV3) const +{ + const Vector3& rkV0 = m_akVertex[iV0]; + const Vector3& rkV1 = m_akVertex[iV1]; + const Vector3& rkV2 = m_akVertex[iV2]; + const Vector3& rkV3 = m_akVertex[iV3]; + + Real fS0x = rkV0[0] + rkP[0]; + Real fD0x = rkV0[0] - rkP[0]; + Real fS0y = rkV0[1] + rkP[1]; + Real fD0y = rkV0[1] - rkP[1]; + Real fS0z = rkV0[2] + rkP[2]; + Real fD0z = rkV0[2] - rkP[2]; + Real fS1x = rkV1[0] + rkP[0]; + Real fD1x = rkV1[0] - rkP[0]; + Real fS1y = rkV1[1] + rkP[1]; + Real fD1y = rkV1[1] - rkP[1]; + Real fS1z = rkV1[2] + rkP[2]; + Real fD1z = rkV1[2] - rkP[2]; + Real fS2x = rkV2[0] + rkP[0]; + Real fD2x = rkV2[0] - rkP[0]; + Real fS2y = rkV2[1] + rkP[1]; + Real fD2y = rkV2[1] - rkP[1]; + Real fS2z = rkV2[2] + rkP[2]; + Real fD2z = rkV2[2] - rkP[2]; + Real fS3x = rkV3[0] + rkP[0]; + Real fD3x = rkV3[0] - rkP[0]; + Real fS3y = rkV3[1] + rkP[1]; + Real fD3y = rkV3[1] - rkP[1]; + Real fS3z = rkV3[2] + rkP[2]; + Real fD3z = rkV3[2] - rkP[2]; + Real fW0 = fS0x*fD0x + fS0y*fD0y + fS0z*fD0z; + Real fW1 = fS1x*fD1x + fS1y*fD1y + fS1z*fD1z; + Real fW2 = fS2x*fD2x + fS2y*fD2y + fS2z*fD2z; + Real fW3 = fS3x*fD3x + fS3y*fD3y + fS3z*fD3z; + + Real fLen0 = Math::Sqrt(fD0x*fD0x+fD0y*fD0y+fD0z*fD0z+fW0*fW0); + Real fLen1 = Math::Sqrt(fD1x*fD1x+fD1y*fD1y+fD1z*fD1z+fW1*fW1); + Real fLen2 = Math::Sqrt(fD2x*fD2x+fD2y*fD2y+fD2z*fD2z+fW2*fW2); + Real fLen3 = Math::Sqrt(fD3x*fD3x+fD3y*fD3y+fD3z*fD3z+fW3*fW3); + Real fScaledUncertainty = m_fUncertainty*fLen0*fLen1*fLen2*fLen3; + + Real fDet4 = this->Det4(fD0x,fD0y,fD0z,fW0,fD1x,fD1y,fD1z,fW1,fD2x, + fD2y,fD2z,fW2,fD3x,fD3y,fD3z,fW3); + + if (Math::FAbs(fDet4) >= fScaledUncertainty) + { + return (fDet4 > (Real)0.0 ? 1 : (fDet4 < (Real)0.0 ? -1 : 0)); + } + + return m_kRQuery.ToCircumsphere(rkP,iV0,iV1,iV2,iV3); +} +//---------------------------------------------------------------------------- +} //namespace Wm4