From 1f34562354c095ae426a45c2c41f167f937f4e15 Mon Sep 17 00:00:00 2001 From: qingfengxia Date: Thu, 27 Oct 2016 08:07:14 +0100 Subject: [PATCH] Fem: clean debug comments in FemVTKTools.cpp and AppFemPy.cpp --- src/Mod/Fem/App/AppFemPy.cpp | 34 +++++++---------------- src/Mod/Fem/App/FemVTKTools.cpp | 48 +++------------------------------ 2 files changed, 13 insertions(+), 69 deletions(-) diff --git a/src/Mod/Fem/App/AppFemPy.cpp b/src/Mod/Fem/App/AppFemPy.cpp index b3646f211..6a6314e4b 100644 --- a/src/Mod/Fem/App/AppFemPy.cpp +++ b/src/Mod/Fem/App/AppFemPy.cpp @@ -249,25 +249,16 @@ private: #ifdef FC_USE_VTK Py::Object readCfdResult(const Py::Tuple& args) { - //the second parameter is either objName (utf8, obj.Label is unicode type) or python obj (not yet implemented) - //PyObject *pcObj; // PythonFeatureT is of python type `` or c++ type - char* fileName; - char* objName; - //if (!PyArg_ParseTuple(args.ptr(), "etO!","utf-8", &Name, &(App::DocumentObjectPy::Type), &pcObj)) - if (!PyArg_ParseTuple(args.ptr(), "etet","utf-8", &fileName, "utf-8", &objName)) + char* fileName = NULL; + char* objName = NULL; + + if (!PyArg_ParseTuple(args.ptr(), "et|et","utf-8", &fileName, "utf-8", &objName)) throw Py::Exception(); std::string EncodedName = std::string(fileName); PyMem_Free(fileName); std::string resName = std::string(objName); PyMem_Free(objName); - /* - if (pcObj) - { - // this function needs the second parameter: App::DocumentObjectPy, since it is created in python - App::DocumentObjectPy* objpy= static_cast(pcObj); - App::DocumentObject* obj = objpy->getDocumentObjectPtr(); - FemVTKTools::readFluidicResult(EncodedName.c_str(), obj); - */ + if (resName.length()) { App::Document* pcDoc = App::GetApplication().getActiveDocument(); @@ -282,21 +273,16 @@ private: Py::Object writeResult(const Py::Tuple& args) { - char* fileName; - PyObject *pcObj; // PythonFeatureT is of type - //char* objName; - if (!PyArg_ParseTuple(args.ptr(), "etO!","utf-8", &fileName, &(App::DocumentObjectPy::Type), &pcObj)) - //if (!PyArg_ParseTuple(args.ptr(), "etet","utf-8", &Name, "utf-8", &objName)) + char* fileName = NULL; + PyObject *pcObj = NULL; + + if (!PyArg_ParseTuple(args.ptr(), "et|O!","utf-8", &fileName, &(App::DocumentObjectPy::Type), &pcObj)) throw Py::Exception(); std::string EncodedName = std::string(fileName); PyMem_Free(fileName); - //std::string resName = std::string(objName); - //PyMem_Free(objName); - - //if (resName.length()) + if (!pcObj) { - // this function needs the second parameter: App::DocumentObjectPy, since it is created in python App::DocumentObjectPy* objpy= static_cast(pcObj); App::DocumentObject* obj = objpy->getDocumentObjectPtr(); if (!obj) diff --git a/src/Mod/Fem/App/FemVTKTools.cpp b/src/Mod/Fem/App/FemVTKTools.cpp index be2553f58..8c9f62280 100644 --- a/src/Mod/Fem/App/FemVTKTools.cpp +++ b/src/Mod/Fem/App/FemVTKTools.cpp @@ -107,7 +107,6 @@ template void writeVTKFile(const char* filename, vtkSmartPointer< writer->SetFileName(filename); writer->SetInputData(dataset); writer->Write(); - //writer->Update(); } void FemVTKTools::importVTKMesh(vtkSmartPointer dataset, FemMesh* mesh) @@ -444,7 +443,6 @@ App::DocumentObject* getObjectByType(const Base::Type type) if(obj->getTypeId() == type) { - Base::Console().Message("active documentObject type: %s \n", obj->getTypeId()); return obj; } if(obj->getTypeId() == FemAnalysis::getClassTypeId()) @@ -491,7 +489,6 @@ App::DocumentObject* FemVTKTools::readFluidicResult(const char* filename, App::D Base::FileInfo f(filename); vtkSmartPointer ds; - //vtkDataSet* ds; // if(f.hasExtension("vtu")) { ds = readVTKFile(filename); @@ -531,10 +528,10 @@ App::DocumentObject* FemVTKTools::readFluidicResult(const char* filename, App::D App::DocumentObject* mesh = pcDoc->addObject("Fem::FemMeshObject", "ResultMesh"); FemMesh* fmesh = new FemMesh(); // PropertyFemMesh instance is responsible to relase FemMesh ?? - importVTKMesh(dataset, fmesh); // in doc, mesh is empty, why? + importVTKMesh(dataset, fmesh); static_cast(mesh->getPropertyByName("FemMesh"))->setValue(*fmesh); static_cast(result->getPropertyByName("Mesh"))->setValue(mesh); - //PropertyLink is the property type to store DocumentObject pointer + // PropertyLink is the property type to store DocumentObject pointer importFluidicResult(dataset, result); pcDoc->recompute(); @@ -544,25 +541,6 @@ App::DocumentObject* FemVTKTools::readFluidicResult(const char* filename, App::D return result; } -/* -App::DocumentObject* readFluidicResult(const char* filename, const std::string objName) { - App::Document* pcDoc = App::GetApplication().getActiveDocument(); - if(!pcDoc) - { - Base::Console().Message("No active document is found thus created\n"); - pcDoc = App::GetApplication().newDocument(); - } - - App::DocumentObject* res = pcDoc->getObject(objName.c_str()); - if (!res) { - return FemVTKTools::readFluidicResult(filename, res); - } - else{ - Base::Console().Message("Can not find ResultObject by name %s in activeDocument", objName); - return FemVTKTools::readFluidicResult(filename, NULL); - } -} - * */ void FemVTKTools::writeResult(const char* filename, const App::DocumentObject* res) { if (!res) @@ -613,25 +591,7 @@ void FemVTKTools::writeResult(const char* filename, const App::DocumentObject* r Base::Console().Log(" %f: Done \n",Base::TimeInfo::diffTimeF(Start, Base::TimeInfo())); } -/* -void FemVTKTools::writeResult(const char* filename, const std::string objName) { - App::Document* pcDoc = App::GetApplication().getActiveDocument(); - if(!pcDoc) - { - Base::Console().Message("No active document is found thus writing is ignored\n"); - return; - } - - App::DocumentObject* res = pcDoc->getObject(objName.c_str()); - if (!res) { - return FemVTKTools::writeResult(filename, res); - } - else{ - Base::Console().Message("Can not find ResultObject by name %s in activeDocument", objName); - return FemVTKTools::writeResult(filename, NULL); - } -} -*/ + void FemVTKTools::importFluidicResult(vtkSmartPointer dataset, App::DocumentObject* res) { // velocity and pressure are essential, Temperature is optional, so are turbulence related variables @@ -690,7 +650,6 @@ void FemVTKTools::importFluidicResult(vtkSmartPointer dataset, App:: stats[index*3] = vmin; stats[index*3 + 2] = vmax; stats[index*3 + 1] = vmean/nPoints; - Base::Console().Message("debug info: vel ptr: %p \n", res->getPropertyByName("Velocity")); App::PropertyVectorList* velocity = static_cast(res->getPropertyByName("Velocity")); if(velocity) { //PropertyVectorList will not show up in PropertyEditor @@ -717,7 +676,6 @@ void FemVTKTools::importFluidicResult(vtkSmartPointer dataset, App:: continue; } - Base::Console().Message("debug info: npoints = %d, NumberOfTuples = %d", nPoints, vec->GetNumberOfTuples()); double vmin=1.0e100, vmean=0.0, vmax=0.0; std::vector values(nPoints, 0.0); for(vtkIdType i = 0; i < vec->GetNumberOfTuples(); i++)