MeshFeaturePyImp.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2008 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
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 // inclusion of the generated files (generated out of MeshFeaturePy.xml)
00033 #include "MeshFeaturePy.h"
00034 #include "MeshFeaturePy.cpp"
00035 
00036 using namespace Mesh;
00037 
00038 
00039 // returns a string which represent the object e.g. when printed in python
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 * /*args*/)
00049 {
00050     return Py_BuildValue("i",getFeaturePtr()->Mesh.getValue().countPoints()); 
00051 }
00052 
00053 PyObject*  MeshFeaturePy::countFacets(PyObject * /*args*/)
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* /*attr*/) const
00171 {
00172     return 0;
00173 }
00174 
00175 int MeshFeaturePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
00176 {
00177     return 0; 
00178 }

Generated on Wed Nov 23 19:00:22 2011 for FreeCAD by  doxygen 1.6.1