MeshFeaturePyImp.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "PreCompiled.h"
00024
00025 #include <Base/Console.h>
00026 #include <Base/Handle.h>
00027
00028 #include "Core/Evaluation.h"
00029 #include "MeshPy.h"
00030 #include "MeshFeature.h"
00031
00032
00033 #include "MeshFeaturePy.h"
00034 #include "MeshFeaturePy.cpp"
00035
00036 using namespace Mesh;
00037
00038
00039
00040 std::string MeshFeaturePy::representation(void) const
00041 {
00042 std::stringstream str;
00043 str << getFeaturePtr()->getTypeId().getName() << " object at " << getFeaturePtr();
00044
00045 return str.str();
00046 }
00047
00048 PyObject* MeshFeaturePy::countPoints(PyObject * )
00049 {
00050 return Py_BuildValue("i",getFeaturePtr()->Mesh.getValue().countPoints());
00051 }
00052
00053 PyObject* MeshFeaturePy::countFacets(PyObject * )
00054 {
00055 return Py_BuildValue("i",getFeaturePtr()->Mesh.getValue().countFacets());
00056 }
00057
00058 PyObject* MeshFeaturePy::harmonizeNormals(PyObject *args)
00059 {
00060 if (!PyArg_ParseTuple(args, ""))
00061 return NULL;
00062
00063 PY_TRY {
00064 Mesh::MeshObject *mesh = getFeaturePtr()->Mesh.startEditing();
00065 mesh->harmonizeNormals();
00066 getFeaturePtr()->Mesh.finishEditing();
00067 } PY_CATCH;
00068
00069 Py_Return;
00070 }
00071
00072 PyObject* MeshFeaturePy::smooth(PyObject *args)
00073 {
00074 int iter=1;
00075 float d_max=FLOAT_MAX;
00076 if (!PyArg_ParseTuple(args, "|if", &iter,&d_max))
00077 return NULL;
00078
00079 PY_TRY {
00080 getFeaturePtr()->Mesh.smooth(iter, d_max);
00081 } PY_CATCH;
00082
00083 Py_Return;
00084 }
00085
00086 PyObject* MeshFeaturePy::removeNonManifolds(PyObject *args)
00087 {
00088 if (!PyArg_ParseTuple(args, ""))
00089 return NULL;
00090 getFeaturePtr()->Mesh.removeNonManifolds();
00091 Py_Return
00092 }
00093
00094 PyObject* MeshFeaturePy::fixIndices(PyObject *args)
00095 {
00096 if (!PyArg_ParseTuple(args, ""))
00097 return NULL;
00098
00099 PY_TRY {
00100 getFeaturePtr()->Mesh.validateIndices();
00101 } PY_CATCH;
00102
00103 Py_Return;
00104 }
00105
00106 PyObject* MeshFeaturePy::fixDegenerations(PyObject *args)
00107 {
00108 if (!PyArg_ParseTuple(args, ""))
00109 return NULL;
00110
00111 PY_TRY {
00112 getFeaturePtr()->Mesh.validateDegenerations();
00113 } PY_CATCH;
00114
00115 Py_Return;
00116 }
00117
00118 PyObject* MeshFeaturePy::removeDuplicatedFacets(PyObject *args)
00119 {
00120 if (!PyArg_ParseTuple(args, ""))
00121 return NULL;
00122
00123 PY_TRY {
00124 getFeaturePtr()->Mesh.removeDuplicatedFacets();
00125 } PY_CATCH;
00126
00127 Py_Return;
00128 }
00129
00130 PyObject* MeshFeaturePy::removeDuplicatedPoints(PyObject *args)
00131 {
00132 if (!PyArg_ParseTuple(args, ""))
00133 return NULL;
00134
00135 PY_TRY {
00136 getFeaturePtr()->Mesh.removeDuplicatedPoints();
00137 } PY_CATCH;
00138
00139 Py_Return;
00140 }
00141
00142 PyObject* MeshFeaturePy::fixSelfIntersections(PyObject *args)
00143 {
00144 if (!PyArg_ParseTuple(args, ""))
00145 return NULL;
00146 try {
00147 getFeaturePtr()->Mesh.removeSelfIntersections();
00148 }
00149 catch (const Base::Exception& e) {
00150 PyErr_SetString(PyExc_Exception, e.what());
00151 return NULL;
00152 }
00153 Py_Return;
00154 }
00155
00156 PyObject* MeshFeaturePy::removeFoldsOnSurface(PyObject *args)
00157 {
00158 if (!PyArg_ParseTuple(args, ""))
00159 return NULL;
00160 try {
00161 getFeaturePtr()->Mesh.removeFoldsOnSurface();
00162 }
00163 catch (const Base::Exception& e) {
00164 PyErr_SetString(PyExc_Exception, e.what());
00165 return NULL;
00166 }
00167 Py_Return;
00168 }
00169
00170 PyObject *MeshFeaturePy::getCustomAttributes(const char* ) const
00171 {
00172 return 0;
00173 }
00174
00175 int MeshFeaturePy::setCustomAttributes(const char* , PyObject* )
00176 {
00177 return 0;
00178 }