diff --git a/src/Mod/JtReader/App/AppJtReader.cpp b/src/Mod/JtReader/App/AppJtReader.cpp index 156634e40e..c771106799 100644 --- a/src/Mod/JtReader/App/AppJtReader.cpp +++ b/src/Mod/JtReader/App/AppJtReader.cpp @@ -30,32 +30,30 @@ extern struct PyMethodDef JtReader_methods[]; extern "C" { -void AppJtReaderExport initJtReader() { +void AppJtReaderExport initJtReader() +{ - static struct PyModuleDef JtReaderAPIDef = { - PyModuleDef_HEAD_INIT, - "JtReader", 0, -1, JtReader_methods, - NULL, NULL, NULL, NULL - }; - PyModule_Create(&JtReaderAPIDef); + static struct PyModuleDef JtReaderAPIDef = + {PyModuleDef_HEAD_INIT, "JtReader", 0, -1, JtReader_methods, NULL, NULL, NULL, NULL}; + PyModule_Create(&JtReaderAPIDef); - // load dependent module - Base::Interpreter().loadModule("Mesh"); + // load dependent module + Base::Interpreter().loadModule("Mesh"); // Initialize JtTk - //JtkEntityFactory::init(); + // JtkEntityFactory::init(); - // Note, non-evaluation JT Open Toolkit licensees must uncomment the - // following line, inserting their "Sold_To_ID". Each licensee has a - // unique Sold_To_ID issued by UGS Corp. - // - //JtkEntityFactory::registerCustomer( 1103193 ); - //JtkEntityFactory::registerCustomer(1103103); + // Note, non-evaluation JT Open Toolkit licensees must uncomment the + // following line, inserting their "Sold_To_ID". Each licensee has a + // unique Sold_To_ID issued by UGS Corp. + // + // JtkEntityFactory::registerCustomer( 1103193 ); + // JtkEntityFactory::registerCustomer(1103103); - Base::Console().Log("Loading JtReader module... done\n"); + Base::Console().Log("Loading JtReader module... done\n"); - return; + return; } -} // extern "C" { +}// extern "C" { diff --git a/src/Mod/JtReader/App/AppJtReaderPy.cpp b/src/Mod/JtReader/App/AppJtReaderPy.cpp index 53ac9056a5..bedcda48b3 100644 --- a/src/Mod/JtReader/App/AppJtReaderPy.cpp +++ b/src/Mod/JtReader/App/AppJtReaderPy.cpp @@ -36,198 +36,199 @@ using std::vector; using namespace MeshCore; -//using namespace JtReader; +// using namespace JtReader; /* module functions */ -static PyObject * read(PyObject * /*self*/, PyObject *args) +static PyObject* read(PyObject* /*self*/, PyObject* args) { - char* Name; - if (!PyArg_ParseTuple(args, "et","utf-8",&Name)) + char* Name; + if (!PyArg_ParseTuple(args, "et", "utf-8", &Name)) { return NULL; - std::string EncodedName = std::string(Name); - PyMem_Free(Name); + } + std::string EncodedName = std::string(Name); + PyMem_Free(Name); - PY_TRY { - //std::auto_ptr apcKernel(new MeshCore::MeshKernel()); + PY_TRY + { + // std::auto_ptr apcKernel(new MeshCore::MeshKernel()); - //vector facets; - //facets.resize(0 /* some size*/); + // vector facets; + // facets.resize(0 /* some size*/); - //const SimpleMeshFacet* It=iterStart(); - //int i=0; - //while(It=iterGetNext()) - //{ - // facets[i]._aclPoints[0].x = It->p1[0]; - // facets[i]._aclPoints[0].y = It->p1[1]; - // facets[i]._aclPoints[0].z = It->p1[2]; - // facets[i]._aclPoints[1].x = It->p2[0]; - // facets[i]._aclPoints[1].y = It->p2[1]; - // facets[i]._aclPoints[1].z = It->p2[2]; - // facets[i]._aclPoints[2].x = It->p3[0]; - // facets[i]._aclPoints[2].y = It->p3[1]; - // facets[i]._aclPoints[2].z = It->p3[2]; - //} - - //(*apcKernel) = facets; + // const SimpleMeshFacet* It=iterStart(); + // int i=0; + // while(It=iterGetNext()) + //{ + // facets[i]._aclPoints[0].x = It->p1[0]; + // facets[i]._aclPoints[0].y = It->p1[1]; + // facets[i]._aclPoints[0].z = It->p1[2]; + // facets[i]._aclPoints[1].x = It->p2[0]; + // facets[i]._aclPoints[1].y = It->p2[1]; + // facets[i]._aclPoints[1].z = It->p2[2]; + // facets[i]._aclPoints[2].x = It->p3[0]; + // facets[i]._aclPoints[2].y = It->p3[1]; + // facets[i]._aclPoints[2].z = It->p3[2]; + // } - //return new Mesh::MeshPy(new Mesh::MeshObject(*(apcKernel.release()))); + //(*apcKernel) = facets; - } PY_CATCH; + // return new Mesh::MeshPy(new Mesh::MeshObject(*(apcKernel.release()))); + } + PY_CATCH; - Py_Return; + Py_Return; } -static PyObject * -open(PyObject * /*self*/, PyObject *args) +static PyObject* open(PyObject* /*self*/, PyObject* args) { - char* Name; - if (!PyArg_ParseTuple(args, "et","utf-8",&Name)) + char* Name; + if (!PyArg_ParseTuple(args, "et", "utf-8", &Name)) { return NULL; - std::string EncodedName = std::string(Name); - PyMem_Free(Name); - - PY_TRY { - - //Base::Console().Log("Open in Mesh with %s",Name); - Base::FileInfo file(EncodedName.c_str()); - - // extract ending - if(file.extension() == "") - Py_Error(Base::PyExc_FC_GeneralError, "no file ending"); - - if(file.hasExtension("jt")) - { - TestJtReader reader; - reader.setFile(EncodedName.c_str()); - reader.read(); - - // create new document and add Import feature - // App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); - // Mesh::Feature *pcFeature = (Mesh::Feature*)pcDoc->addObject("Mesh::Feature",file.fileNamePure().c_str()); - // - // std::auto_ptr apcKernel(new MeshCore::MeshKernel()); - - // readFile(EncodedName.c_str(),0); - - // vector facets; - // facets.resize(iterSize()); - - // const SimpleMeshFacet* It=iterStart(); - // int i=0; - // while(It=iterGetNext()) - // { - // facets[i]._aclPoints[0].x = It->p1[0]; - // facets[i]._aclPoints[0].y = It->p1[1]; - // facets[i]._aclPoints[0].z = It->p1[2]; - // facets[i]._aclPoints[1].x = It->p2[0]; - // facets[i]._aclPoints[1].y = It->p2[1]; - // facets[i]._aclPoints[1].z = It->p2[2]; - // facets[i]._aclPoints[2].x = It->p3[0]; - // facets[i]._aclPoints[2].y = It->p3[1]; - // facets[i]._aclPoints[2].z = It->p3[2]; - // i++; - // } - // clearData(); - // (*apcKernel) = facets; - // pcFeature->Mesh.setValue(*(apcKernel.get())); - - ////pcFeature->FileName.setValue( Name ); - // pcDoc->recompute(); } - else + std::string EncodedName = std::string(Name); + PyMem_Free(Name); + + PY_TRY { - Py_Error(Base::PyExc_FC_GeneralError, "unknown file ending"); - } + // Base::Console().Log("Open in Mesh with %s",Name); + Base::FileInfo file(EncodedName.c_str()); - } PY_CATCH; - - Py_Return; -} - - -/* module functions */ -static PyObject * -insert(PyObject * /*self*/, PyObject *args) -{ - char* Name; - const char* DocName; - if (!PyArg_ParseTuple(args, "ets","utf-8",&Name,&DocName)) - return NULL; - std::string EncodedName = std::string(Name); - PyMem_Free(Name); - - PY_TRY { - - Base::FileInfo file(EncodedName.c_str()); - - // extract ending - if(file.extension() == "") - Py_Error(Base::PyExc_FC_GeneralError, "no file ending"); - - if(file.hasExtension("jt") ) - { - // add Import feature - App::Document *pcDoc = App::GetApplication().getDocument(DocName); - if (!pcDoc) - { - char szBuf[200]; - snprintf(szBuf, 200, "Import called to the non-existing document '%s'", DocName); - Py_Error(Base::PyExc_FC_GeneralError, szBuf); + // extract ending + if (file.extension() == "") { + Py_Error(Base::PyExc_FC_GeneralError, "no file ending"); } - //readFile(EncodedName.c_str(),0); + if (file.hasExtension("jt")) { + TestJtReader reader; + reader.setFile(EncodedName.c_str()); + reader.read(); - //vector facets; + // create new document and add Import feature + // App::Document *pcDoc = App::GetApplication().newDocument("Unnamed"); + // Mesh::Feature *pcFeature = + // (Mesh::Feature*)pcDoc->addObject("Mesh::Feature",file.fileNamePure().c_str()); + // + // std::auto_ptr apcKernel(new MeshCore::MeshKernel()); - //if(iterSize()>0){ - // facets.resize(iterSize()); + // readFile(EncodedName.c_str(),0); - // const SimpleMeshFacet* It=iterStart(); - // int i=0; - // while(It=iterGetNext()) - // { - // facets[i]._aclPoints[0].x = It->p1[0]; - // facets[i]._aclPoints[0].y = It->p1[1]; - // facets[i]._aclPoints[0].z = It->p1[2]; - // facets[i]._aclPoints[1].x = It->p2[0]; - // facets[i]._aclPoints[1].y = It->p2[1]; - // facets[i]._aclPoints[1].z = It->p2[2]; - // facets[i]._aclPoints[2].x = It->p3[0]; - // facets[i]._aclPoints[2].y = It->p3[1]; - // facets[i]._aclPoints[2].z = It->p3[2]; - // i++; - // } - // clearData(); - // Mesh::Feature *pcFeature = (Mesh::Feature*)pcDoc->addObject("Mesh::Feature",file.fileNamePure().c_str()); - // - // std::auto_ptr apcKernel(new MeshCore::MeshKernel()); - // (*apcKernel) = facets; - // pcFeature->Mesh.setValue(*(apcKernel.get())); + // vector facets; + // facets.resize(iterSize()); - // //pcDoc->recompute(); + // const SimpleMeshFacet* It=iterStart(); + // int i=0; + // while(It=iterGetNext()) + // { + // facets[i]._aclPoints[0].x = It->p1[0]; + // facets[i]._aclPoints[0].y = It->p1[1]; + // facets[i]._aclPoints[0].z = It->p1[2]; + // facets[i]._aclPoints[1].x = It->p2[0]; + // facets[i]._aclPoints[1].y = It->p2[1]; + // facets[i]._aclPoints[1].z = It->p2[2]; + // facets[i]._aclPoints[2].x = It->p3[0]; + // facets[i]._aclPoints[2].y = It->p3[1]; + // facets[i]._aclPoints[2].z = It->p3[2]; + // i++; + // } + // clearData(); + // (*apcKernel) = facets; + // pcFeature->Mesh.setValue(*(apcKernel.get())); - //}else{ - // clearData(); - // //Py_Error(Base::BaseExceptionFreeCADError,"No Mesh in file"); - // Base::Console().Warning("No Mesh in file: %s\n",EncodedName.c_str()); - //} - } - else - { - Py_Error(Base::PyExc_FC_GeneralError, "unknown file ending"); + ////pcFeature->FileName.setValue( Name ); + // pcDoc->recompute(); + } + else { + Py_Error(Base::PyExc_FC_GeneralError, "unknown file ending"); + } } + PY_CATCH; - } PY_CATCH; + Py_Return; +} - Py_Return; + +/* module functions */ +static PyObject* insert(PyObject* /*self*/, PyObject* args) +{ + char* Name; + const char* DocName; + if (!PyArg_ParseTuple(args, "ets", "utf-8", &Name, &DocName)) { + return NULL; + } + std::string EncodedName = std::string(Name); + PyMem_Free(Name); + + PY_TRY + { + + Base::FileInfo file(EncodedName.c_str()); + + // extract ending + if (file.extension() == "") { + Py_Error(Base::PyExc_FC_GeneralError, "no file ending"); + } + + if (file.hasExtension("jt")) { + // add Import feature + App::Document* pcDoc = App::GetApplication().getDocument(DocName); + if (!pcDoc) { + char szBuf[200]; + snprintf(szBuf, 200, "Import called to the non-existing document '%s'", DocName); + Py_Error(Base::PyExc_FC_GeneralError, szBuf); + } + + // readFile(EncodedName.c_str(),0); + + // vector facets; + + // if(iterSize()>0){ + // facets.resize(iterSize()); + + // const SimpleMeshFacet* It=iterStart(); + // int i=0; + // while(It=iterGetNext()) + // { + // facets[i]._aclPoints[0].x = It->p1[0]; + // facets[i]._aclPoints[0].y = It->p1[1]; + // facets[i]._aclPoints[0].z = It->p1[2]; + // facets[i]._aclPoints[1].x = It->p2[0]; + // facets[i]._aclPoints[1].y = It->p2[1]; + // facets[i]._aclPoints[1].z = It->p2[2]; + // facets[i]._aclPoints[2].x = It->p3[0]; + // facets[i]._aclPoints[2].y = It->p3[1]; + // facets[i]._aclPoints[2].z = It->p3[2]; + // i++; + // } + // clearData(); + // Mesh::Feature *pcFeature = + // (Mesh::Feature*)pcDoc->addObject("Mesh::Feature",file.fileNamePure().c_str()); + // + // std::auto_ptr apcKernel(new MeshCore::MeshKernel()); + // (*apcKernel) = facets; + // pcFeature->Mesh.setValue(*(apcKernel.get())); + + // //pcDoc->recompute(); + + //}else{ + // clearData(); + // //Py_Error(Base::BaseExceptionFreeCADError,"No Mesh in file"); + // Base::Console().Warning("No Mesh in file: %s\n",EncodedName.c_str()); + //} + } + else { + Py_Error(Base::PyExc_FC_GeneralError, "unknown file ending"); + } + } + PY_CATCH; + + Py_Return; } /* registration table */ struct PyMethodDef JtReader_methods[] = { - {"open" ,open , Py_NEWARGS, "open a jt file in a new Document"}, - {"insert" ,insert, Py_NEWARGS, "isert a jt file in a existing document"}, - {"read" ,read, Py_NEWARGS, "Read a Mesh from a jt file and returns a Mesh object."}, - {NULL, NULL, 0, NULL} -}; + {"open", open, Py_NEWARGS, "open a jt file in a new Document"}, + {"insert", insert, Py_NEWARGS, "isert a jt file in a existing document"}, + {"read", read, Py_NEWARGS, "Read a Mesh from a jt file and returns a Mesh object."}, + {NULL, NULL, 0, NULL}}; diff --git a/src/Mod/JtReader/App/FcLodHandler.cpp b/src/Mod/JtReader/App/FcLodHandler.cpp index 1f6315b850..003924bbc9 100644 --- a/src/Mod/JtReader/App/FcLodHandler.cpp +++ b/src/Mod/JtReader/App/FcLodHandler.cpp @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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" @@ -29,5 +29,5 @@ void FcLodHandler::startLod() { - Base::Console().Log("FcLodHandler::startLod()"); + Base::Console().Log("FcLodHandler::startLod()"); } diff --git a/src/Mod/JtReader/App/FcLodHandler.h b/src/Mod/JtReader/App/FcLodHandler.h index f564743d57..370ff90ead 100644 --- a/src/Mod/JtReader/App/FcLodHandler.h +++ b/src/Mod/JtReader/App/FcLodHandler.h @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef FcLodHandler_HEADER #define FcLodHandler_HEADER @@ -29,16 +29,7 @@ class FcLodHandler: public LodHandler { public: virtual void startLod(); - - - }; - #endif - - - - - diff --git a/src/Mod/JtReader/App/JrJt/Context.h b/src/Mod/JtReader/App/JrJt/Context.h index 5151f0f259..7673e9e5cf 100644 --- a/src/Mod/JtReader/App/JrJt/Context.h +++ b/src/Mod/JtReader/App/JrJt/Context.h @@ -1,46 +1,44 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef Context_HEADER #define Context_HEADER +#include "Context.h" #include #include -#include "Context.h" using namespace std; class Context { public: - Context(istream &s) :Strm(s){}; + Context(istream& s) + : Strm(s) {}; uint8_t VersionMinor; uint8_t VersionMajor; - istream & Strm; - + istream& Strm; }; - #endif - diff --git a/src/Mod/JtReader/App/JrJt/Element_Header.h b/src/Mod/JtReader/App/JrJt/Element_Header.h index 832a92451b..258d4712ef 100644 --- a/src/Mod/JtReader/App/JrJt/Element_Header.h +++ b/src/Mod/JtReader/App/JrJt/Element_Header.h @@ -1,37 +1,36 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef Element_Header_HEADER #define Element_Header_HEADER +#include #include #include -#include #include "Context.h" #include "GUID.h" -#include "UChar.h" #include "I32.h" - +#include "UChar.h" using namespace std; @@ -39,14 +38,14 @@ using namespace std; struct Element_Header { - Element_Header(){}; + Element_Header() {}; - Element_Header(Context& cont, bool zLib=false) + Element_Header(Context& cont, bool zLib = false) { read(cont, zLib); }; - inline void read(Context& cont ,bool zLib=false) + inline void read(Context& cont, bool zLib = false) { // only zip less implemented so far... assert(zLib == false); @@ -56,20 +55,10 @@ struct Element_Header Object_Base_Type.read(cont); }; - I32 Element_Length; + I32 Element_Length; GUID Object_Type_ID; UChar Object_Base_Type; - - }; - #endif - - - - - - - diff --git a/src/Mod/JtReader/App/JrJt/GUID.h b/src/Mod/JtReader/App/JrJt/GUID.h index 2d75da3e60..6daf53587e 100644 --- a/src/Mod/JtReader/App/JrJt/GUID.h +++ b/src/Mod/JtReader/App/JrJt/GUID.h @@ -1,24 +1,24 @@ /*************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef GUID_HEADER #define GUID_HEADER @@ -27,10 +27,9 @@ #include #include -#include "U8.h" #include "U16.h" #include "U32.h" - +#include "U8.h" using namespace std; @@ -39,10 +38,30 @@ using namespace std; struct GUID { - GUID(){}; + GUID() {}; - GUID(uint32_t a1, uint16_t b1, uint16_t b2, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, uint8_t c6, uint8_t c7, uint8_t c8) - :_A1(a1), _B1(b1), _B2(b2), _C1(c1), _C2(c2), _C3(c3), _C4(c4), _C5(c5), _C6(c6), _C7(c7), _C8(c8) + GUID(uint32_t a1, + uint16_t b1, + uint16_t b2, + uint8_t c1, + uint8_t c2, + uint8_t c3, + uint8_t c4, + uint8_t c5, + uint8_t c6, + uint8_t c7, + uint8_t c8) + : _A1(a1) + , _B1(b1) + , _B2(b2) + , _C1(c1) + , _C2(c2) + , _C3(c3) + , _C4(c4) + , _C5(c5) + , _C6(c6) + , _C7(c7) + , _C8(c8) {} GUID(Context& cont) @@ -50,23 +69,16 @@ struct GUID read(cont); } - bool operator!=(const GUID& other) const { - return !operator == (other); + bool operator!=(const GUID& other) const + { + return !operator==(other); } - bool operator==(const GUID& other) const { - return - _A1 == other._A1 - && _B1 == other._B1 - && _B2 == other._B2 - && _C1 == other._C1 - && _C2 == other._C2 - && _C3 == other._C3 - && _C4 == other._C4 - && _C5 == other._C5 - && _C6 == other._C6 - && _C7 == other._C7 - && _C8 == other._C8; + bool operator==(const GUID& other) const + { + return _A1 == other._A1 && _B1 == other._B1 && _B2 == other._B2 && _C1 == other._C1 + && _C2 == other._C2 && _C3 == other._C3 && _C4 == other._C4 && _C5 == other._C5 + && _C6 == other._C6 && _C7 == other._C7 && _C8 == other._C8; } inline void read(Context& cont) @@ -86,9 +98,11 @@ struct GUID _C8.read(cont); } - std::string toString()const{ + std::string toString() const + { std::stringstream strm; - strm << "{" << std::hex << _A1 << "-" << _B1 << _B2 << "-" << _C1 << _C2 << _C3 << _C4 << _C5 << _C6 << _C7 << _C8 << "}"; + strm << "{" << std::hex << _A1 << "-" << _B1 << _B2 << "-" << _C1 << _C2 << _C3 << _C4 + << _C5 << _C6 << _C7 << _C8 << "}"; return strm.str(); } @@ -97,17 +111,15 @@ struct GUID U16 _B1; U16 _B2; - U8 _C1; - U8 _C2; - U8 _C3; - U8 _C4; - U8 _C5; - U8 _C6; - U8 _C7; - U8 _C8; - + U8 _C1; + U8 _C2; + U8 _C3; + U8 _C4; + U8 _C5; + U8 _C6; + U8 _C7; + U8 _C8; }; - -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JrJt/I32.h b/src/Mod/JtReader/App/JrJt/I32.h index fbac085c2d..3d90020cf0 100644 --- a/src/Mod/JtReader/App/JrJt/I32.h +++ b/src/Mod/JtReader/App/JrJt/I32.h @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef I32_HEADER #define I32_HEADER @@ -30,7 +30,7 @@ using namespace std; struct I32 { - I32(){}; + I32() {}; I32(Context& cont) { @@ -51,5 +51,4 @@ struct I32 }; - -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JrJt/JtReader.cpp b/src/Mod/JtReader/App/JrJt/JtReader.cpp index 0161924646..c44a49f8a6 100644 --- a/src/Mod/JtReader/App/JrJt/JtReader.cpp +++ b/src/Mod/JtReader/App/JrJt/JtReader.cpp @@ -5,10 +5,10 @@ #include #include +#include "Element_Header.h" #include "GUID.h" #include "I32.h" #include "LodHandler.h" -#include "Element_Header.h" #include "Segment_Header.h" #include "TOC_Entry.h" #include "UChar.h" @@ -17,81 +17,90 @@ using namespace std; -const GUID JtReader::TriStripSetShapeLODElement_ID(0x10dd10ab, 0x2ac8, 0x11d1, 0x9b, 0x6b, 0x0, 0x80, 0xc7, 0xbb, 0x59, 0x97); +const GUID JtReader::TriStripSetShapeLODElement_ID(0x10dd10ab, + 0x2ac8, + 0x11d1, + 0x9b, + 0x6b, + 0x0, + 0x80, + 0xc7, + 0xbb, + 0x59, + 0x97); JtReader::JtReader() -{ -} +{} JtReader::~JtReader() -{ -} +{} void JtReader::setFile(const std::string fileName) { - this->_fileName = fileName; + this->_fileName = fileName; } const std::vector& JtReader::readToc() { - ifstream strm; + ifstream strm; - strm.open(_fileName, ios::binary); + strm.open(_fileName, ios::binary); - if (!strm) - throw "cannot open file"; + if (!strm) { + throw "cannot open file"; + } - Context cont(strm); + Context cont(strm); - char headerString[80]; - strm.read(headerString, 80); + char headerString[80]; + strm.read(headerString, 80); - UChar Byte_Order(cont); - I32 Empty_Field(cont); - I32 TOC_Offset(cont); + UChar Byte_Order(cont); + I32 Empty_Field(cont); + I32 TOC_Offset(cont); - GUID LSG_Segment_ID(cont); + GUID LSG_Segment_ID(cont); - cont.Strm.seekg((int32_t)TOC_Offset); - - I32 Entry_Count(cont); - + cont.Strm.seekg((int32_t)TOC_Offset); + + I32 Entry_Count(cont); + TocEntries.resize(Entry_Count); - for (std::vector::iterator i = TocEntries.begin(); i != TocEntries.end(); ++i) - i->read(cont); - - return TocEntries; - + for (std::vector::iterator i = TocEntries.begin(); i != TocEntries.end(); ++i) { + i->read(cont); + } + return TocEntries; } void JtReader::readLodSegment(const TOC_Entry& toc, LodHandler& /*handler*/) { - std::ifstream strm; - strm.open(_fileName, ios::binary); + std::ifstream strm; + strm.open(_fileName, ios::binary); - if (!strm) throw "cannot open file"; + if (!strm) { + throw "cannot open file"; + } - strm.seekg((int32_t)toc.Segment_Offset); + strm.seekg((int32_t)toc.Segment_Offset); - Context cont(strm); + Context cont(strm); - - // check if called with the right Toc - assert(toc.getSegmentType() == 7); - // read the segment header - Segment_Header header(cont); + // check if called with the right Toc + assert(toc.getSegmentType() == 7); - // read the non zip Element header - Element_Header eHeader(cont, false); + // read the segment header + Segment_Header header(cont); - if ( eHeader.Object_Type_ID != TriStripSetShapeLODElement_ID) - return; + // read the non zip Element header + Element_Header eHeader(cont, false); - + if (eHeader.Object_Type_ID != TriStripSetShapeLODElement_ID) { + return; + } } diff --git a/src/Mod/JtReader/App/JrJt/JtReader.h b/src/Mod/JtReader/App/JrJt/JtReader.h index 04b8893a56..bae66c8301 100644 --- a/src/Mod/JtReader/App/JrJt/JtReader.h +++ b/src/Mod/JtReader/App/JrJt/JtReader.h @@ -1,33 +1,30 @@ #pragma once +#include "TOC_Entry.h" #include #include -#include "TOC_Entry.h" class LodHandler; - class JtReader { public: - JtReader(); - ~JtReader(); + JtReader(); + ~JtReader(); - void setFile(const std::string fileName); + void setFile(const std::string fileName); - const std::vector& readToc(); + const std::vector& readToc(); - void readSegment(int tocIndex); + void readSegment(int tocIndex); - void readLodSegment(const TOC_Entry&, LodHandler&); + void readLodSegment(const TOC_Entry&, LodHandler&); - static const GUID TriStripSetShapeLODElement_ID; + static const GUID TriStripSetShapeLODElement_ID; protected: - std::string _fileName; - vector TocEntries; - + std::string _fileName; + vector TocEntries; }; - diff --git a/src/Mod/JtReader/App/JrJt/LodHandler.h b/src/Mod/JtReader/App/JrJt/LodHandler.h index c61c2d5d3c..fcdd9942ca 100644 --- a/src/Mod/JtReader/App/JrJt/LodHandler.h +++ b/src/Mod/JtReader/App/JrJt/LodHandler.h @@ -1,41 +1,34 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef LodHandler_HEADER #define LodHandler_HEADER - class LodHandler { public: - virtual void startLod(){}; - - - + virtual void startLod() {}; }; - #endif - - diff --git a/src/Mod/JtReader/App/JrJt/Segment_Header.h b/src/Mod/JtReader/App/JrJt/Segment_Header.h index bde3d139df..e996a4b2d1 100644 --- a/src/Mod/JtReader/App/JrJt/Segment_Header.h +++ b/src/Mod/JtReader/App/JrJt/Segment_Header.h @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef Segment_Header_HEADER #define Segment_Header_HEADER @@ -28,10 +28,9 @@ #include "Context.h" #include "GUID.h" +#include "I32.h" #include "U16.h" #include "U32.h" -#include "I32.h" - using namespace std; @@ -39,7 +38,7 @@ using namespace std; struct Segment_Header { - Segment_Header(){}; + Segment_Header() {}; Segment_Header(Context& cont) { @@ -54,15 +53,9 @@ struct Segment_Header }; GUID Segment_ID; - I32 Segment_Type; - I32 Segment_Length; - - + I32 Segment_Type; + I32 Segment_Length; }; - #endif - - - diff --git a/src/Mod/JtReader/App/JrJt/TOC_Entry.h b/src/Mod/JtReader/App/JrJt/TOC_Entry.h index 73f9f0e985..9ce22f126f 100644 --- a/src/Mod/JtReader/App/JrJt/TOC_Entry.h +++ b/src/Mod/JtReader/App/JrJt/TOC_Entry.h @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef TOC_Entry_HEADER #define TOC_Entry_HEADER @@ -28,10 +28,9 @@ #include "Context.h" #include "GUID.h" +#include "I32.h" #include "U16.h" #include "U32.h" -#include "I32.h" - using namespace std; @@ -39,7 +38,7 @@ using namespace std; struct TOC_Entry { - TOC_Entry(){}; + TOC_Entry() {}; TOC_Entry(Context& cont) { @@ -54,26 +53,25 @@ struct TOC_Entry Segment_Attributes.read(cont); }; - uint8_t getSegmentType()const + uint8_t getSegmentType() const { return Segment_Attributes >> 24; } - std::string toString()const{ + std::string toString() const + { stringstream strm; - strm << getSegmentType() << ":" << Segment_Offset << ":" << Segment_Length << ":" << Segment_ID.toString(); + strm << getSegmentType() << ":" << Segment_Offset << ":" << Segment_Length << ":" + << Segment_ID.toString(); return strm.str(); } GUID Segment_ID; - I32 Segment_Offset; - I32 Segment_Length; - U32 Segment_Attributes; - - + I32 Segment_Offset; + I32 Segment_Length; + U32 Segment_Attributes; }; - -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JrJt/U16.h b/src/Mod/JtReader/App/JrJt/U16.h index 3bb5488e1c..433ca8fde5 100644 --- a/src/Mod/JtReader/App/JrJt/U16.h +++ b/src/Mod/JtReader/App/JrJt/U16.h @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef U16_HEADER #define U16_HEADER @@ -30,9 +30,11 @@ using namespace std; struct U16 { - U16(){}; + U16() {}; - U16(uint16_t ui) :_U16(ui){} + U16(uint16_t ui) + : _U16(ui) + {} U16(Context& cont) { @@ -53,5 +55,4 @@ struct U16 }; - -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JrJt/U32.h b/src/Mod/JtReader/App/JrJt/U32.h index ccf258d724..908f928367 100644 --- a/src/Mod/JtReader/App/JrJt/U32.h +++ b/src/Mod/JtReader/App/JrJt/U32.h @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef U32_HEADER #define U32_HEADER @@ -30,9 +30,11 @@ using namespace std; struct U32 { - U32(){}; + U32() {}; - U32(uint32_t ui) :_U32(ui){} + U32(uint32_t ui) + : _U32(ui) + {} U32(Context& cont) { @@ -53,6 +55,4 @@ struct U32 }; - - -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JrJt/U8.h b/src/Mod/JtReader/App/JrJt/U8.h index a6131565c0..8bd41428aa 100644 --- a/src/Mod/JtReader/App/JrJt/U8.h +++ b/src/Mod/JtReader/App/JrJt/U8.h @@ -1,39 +1,41 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef U8_HEADER #define U8_HEADER +#include "Context.h" #include #include -#include "Context.h" using namespace std; struct U8 { - U8(){}; + U8() {}; - U8(uint8_t ui) :_U8(ui){} + U8(uint8_t ui) + : _U8(ui) + {} U8(Context& cont) { @@ -51,9 +53,8 @@ struct U8 } - uint8_t _U8; }; -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JrJt/UChar.h b/src/Mod/JtReader/App/JrJt/UChar.h index 32831bf1a9..4e82475113 100644 --- a/src/Mod/JtReader/App/JrJt/UChar.h +++ b/src/Mod/JtReader/App/JrJt/UChar.h @@ -1,37 +1,37 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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 * + * * + ***************************************************************************/ #ifndef UChar_HEADER #define UChar_HEADER +#include "Context.h" #include #include -#include "Context.h" using namespace std; struct UChar { - UChar(){}; + UChar() {}; UChar(Context& cont) { @@ -52,5 +52,4 @@ struct UChar }; - -#endif \ No newline at end of file +#endif diff --git a/src/Mod/JtReader/App/JtReader.cpp b/src/Mod/JtReader/App/JtReader.cpp index 70e2df2c9f..72d2930ad3 100644 --- a/src/Mod/JtReader/App/JtReader.cpp +++ b/src/Mod/JtReader/App/JtReader.cpp @@ -7,19 +7,19 @@ #ifndef _PreComp_ #include #include -#include #include +#include #endif -#include #include +#include #include #include using std::string; -using std::vector; using std::strstream; +using std::vector; #include "JtReader.h" @@ -32,697 +32,647 @@ vector result; vector::const_iterator resultIt; -#define indent(i) {for(int l=0; l < i; l++) InfoOut << " ";} +#define indent(i) \ + { \ + for (int l = 0; l < i; l++) \ + InfoOut << " "; \ + } -void printXform(JtkTransform *partXform, int level) +void printXform(JtkTransform* partXform, int level) { - float *elements= NULL; + float* elements = NULL; - indent(level); - InfoOut << "JtkTRANSFORM\n"; + indent(level); + InfoOut << "JtkTRANSFORM\n"; - partXform->getTElements(elements); - if( elements ) - { - indent(level+1); - InfoOut << elements[0] << ", " << elements[1] << ", " - << elements[2] << ", " << elements[3] << "\n"; - indent(level+1); - InfoOut << elements[4] << ", " << elements[5] << ", " - << elements[6] << ", " << elements[7] << "\n"; - indent(level+1); - InfoOut << elements[8] << ", " << elements[9] << ", " - << elements[10] << ", " << elements[11] << "\n"; - indent(level+1); - InfoOut << elements[12] << ", " << elements[13] << ", " - << elements[14] << ", " << elements[15] << "\n"; + partXform->getTElements(elements); + if (elements) { + indent(level + 1); + InfoOut << elements[0] << ", " << elements[1] << ", " << elements[2] << ", " << elements[3] + << "\n"; + indent(level + 1); + InfoOut << elements[4] << ", " << elements[5] << ", " << elements[6] << ", " << elements[7] + << "\n"; + indent(level + 1); + InfoOut << elements[8] << ", " << elements[9] << ", " << elements[10] << ", " + << elements[11] << "\n"; + indent(level + 1); + InfoOut << elements[12] << ", " << elements[13] << ", " << elements[14] << ", " + << elements[15] << "\n"; #ifdef _DEBUG - JtkEntityFactory::deleteMemory( elements ); + JtkEntityFactory::deleteMemory(elements); #else - delete [] elements; + delete[] elements; #endif - } + } } -void printMaterial(JtkMaterial *partMaterial, int level) +void printMaterial(JtkMaterial* partMaterial, int level) { - float *ambient= NULL, - *diffuse= NULL, - *specular= NULL, - *emission= NULL, - shininess= -999.0; + float *ambient = NULL, *diffuse = NULL, *specular = NULL, *emission = NULL, shininess = -999.0; - indent(level); - InfoOut << "JtkMATERIAL\n"; + indent(level); + InfoOut << "JtkMATERIAL\n"; - partMaterial->getAmbientColor(ambient); - if( ambient ) - { - indent(level+1); - InfoOut << "ambient = ( " << ambient[0] << ", " << ambient[1] << ", " - << ambient[2] << ", " << ambient[3] << " )\n"; + partMaterial->getAmbientColor(ambient); + if (ambient) { + indent(level + 1); + InfoOut << "ambient = ( " << ambient[0] << ", " << ambient[1] << ", " << ambient[2] << ", " + << ambient[3] << " )\n"; #ifdef _DEBUG - JtkEntityFactory::deleteMemory( ambient ); + JtkEntityFactory::deleteMemory(ambient); #else - delete [] ambient; + delete[] ambient; #endif - } + } - partMaterial->getDiffuseColor(diffuse); - if( diffuse ) - { - indent(level+1); - InfoOut << "diffuse = ( " << diffuse[0] << ", " << diffuse[1] << ", " - << diffuse[2] << ", " << diffuse[3] << " )\n"; + partMaterial->getDiffuseColor(diffuse); + if (diffuse) { + indent(level + 1); + InfoOut << "diffuse = ( " << diffuse[0] << ", " << diffuse[1] << ", " << diffuse[2] << ", " + << diffuse[3] << " )\n"; #ifdef _DEBUG - JtkEntityFactory::deleteMemory( diffuse ); + JtkEntityFactory::deleteMemory(diffuse); #else - delete [] diffuse; + delete[] diffuse; #endif - } + } - partMaterial->getSpecularColor(specular); - if( specular ) - { - indent(level+1); - InfoOut << "specular = ( " << specular[0] << ", " << specular[1] << ", " - << specular[2] << ", " << specular[3] << " )\n"; + partMaterial->getSpecularColor(specular); + if (specular) { + indent(level + 1); + InfoOut << "specular = ( " << specular[0] << ", " << specular[1] << ", " << specular[2] + << ", " << specular[3] << " )\n"; #ifdef _DEBUG - JtkEntityFactory::deleteMemory( specular ); + JtkEntityFactory::deleteMemory(specular); #else - delete [] specular; + delete[] specular; #endif - } + } - partMaterial->getEmissionColor(emission); - if( emission ) - { - indent(level+1); - InfoOut << "emission = ( " << emission[0] << ", " << emission[1] << ", " - << emission[2] << ", " << emission[3] << " )\n"; + partMaterial->getEmissionColor(emission); + if (emission) { + indent(level + 1); + InfoOut << "emission = ( " << emission[0] << ", " << emission[1] << ", " << emission[2] + << ", " << emission[3] << " )\n"; #ifdef _DEBUG - JtkEntityFactory::deleteMemory( emission ); + JtkEntityFactory::deleteMemory(emission); #else - delete [] emission; + delete[] emission; #endif - } + } - partMaterial->getShininess(shininess); - if( shininess != -999.0 ) - { - indent(level+1); - InfoOut << "shininess = " << shininess << "\n"; - } + partMaterial->getShininess(shininess); + if (shininess != -999.0) { + indent(level + 1); + InfoOut << "shininess = " << shininess << "\n"; + } } -void printBrep(JtkBrep *partBrep, int level) +void printBrep(JtkBrep* partBrep, int level) { - indent(level); - InfoOut << "JtkBREP\n"; + indent(level); + InfoOut << "JtkBREP\n"; } -void printWrep(JtkWrep *partWrep, int level) +void printWrep(JtkWrep* partWrep, int level) { - indent(level); - InfoOut << "JtkWREP\n"; + indent(level); + InfoOut << "JtkWREP\n"; } -void printShape(JtkShape *partShape, int level) +void printShape(JtkShape* partShape, int level) { - indent(level); - InfoOut << "JtkSHAPE\n"; + indent(level); + InfoOut << "JtkSHAPE\n"; - for(int set=0; set < partShape->numOfSets(); set++) - { - indent(level+1); - InfoOut << "geom set #" << set << ":\n"; + for (int set = 0; set < partShape->numOfSets(); set++) { + indent(level + 1); + InfoOut << "geom set #" << set << ":\n"; - float *vertex= NULL, - *normal= NULL, - *color= NULL, - *texture= NULL; - int vertexCount= -1, - normCount= -1, - colorCount= -1, - textCount= -1; + float *vertex = NULL, *normal = NULL, *color = NULL, *texture = NULL; + int vertexCount = -1, normCount = -1, colorCount = -1, textCount = -1; - partShape->getInternal(vertex, vertexCount, normal, normCount, - color, colorCount, texture, textCount, set); + partShape->getInternal(vertex, + vertexCount, + normal, + normCount, + color, + colorCount, + texture, + textCount, + set); - if( vertex && (vertexCount > 0) ) - { - indent(level+2); - InfoOut << "vertices = ( "; + if (vertex && (vertexCount > 0)) { + indent(level + 2); + InfoOut << "vertices = ( "; - for(int elems=0; elems < vertexCount*3; elems++) - { - InfoOut << ((elems != 0) ? ", " : "") << vertex[elems]; - } + for (int elems = 0; elems < vertexCount * 3; elems++) { + InfoOut << ((elems != 0) ? ", " : "") << vertex[elems]; + } - InfoOut << " )\n"; + InfoOut << " )\n"; #ifdef _DEBUG - JtkEntityFactory::deleteMemory( vertex ); + JtkEntityFactory::deleteMemory(vertex); #else - delete [] vertex; + delete[] vertex; #endif - } - - if( normal && (normCount > 0) ) - { - indent(level+2); - InfoOut << "normals = ( "; - - for(int elems=0; elems < normCount*3; elems++) - { - InfoOut << ((elems != 0) ? ", " : "") << normal[elems]; - } - - InfoOut << " )\n"; - -#ifdef _DEBUG - JtkEntityFactory::deleteMemory( normal ); -#else - delete [] normal; -#endif - } - - if( color && (colorCount > 0) ) - { - indent(level+2); - InfoOut << "color = ( "; - - for(int elems=0; elems < colorCount*3; elems++) - { - InfoOut << ((elems != 0) ? ", " : "") << color[elems]; - } - - InfoOut << " )\n"; - -#ifdef _DEBUG - JtkEntityFactory::deleteMemory( color ); -#else - delete [] color; -#endif - } - - if( texture && (textCount > 0) ) - { - indent(level+2); - InfoOut << "texture = ( "; - - for(int elems=0; elems < textCount; elems++) - { - InfoOut << ((elems != 0) ? ", " : "") << texture[elems]; - } - - InfoOut << " )\n"; - -#ifdef _DEBUG - JtkEntityFactory::deleteMemory( texture ); -#else - delete [] texture; -#endif - } - } -} - -int myPreactionCB_PrintName(JtkHierarchy *CurrNode, int level, JtkClientData*) -{ - indent(level); - - my_level++; - - switch (CurrNode->typeID()) - { - case JtkEntity::JtkNONE: - InfoOut << "JtkNONE\n"; - break; - - case JtkEntity::JtkBREP: - InfoOut << "JtkBREP\n"; - break; - - case JtkEntity::JtkREGION: - InfoOut << "JtkREGION\n"; - break; - - case JtkEntity::JtkSHELL: - InfoOut << "JtkSHELL\n"; - break; - - case JtkEntity::JtkLOOP: - InfoOut << "JtkLOOP\n"; - break; - - case JtkEntity::JtkCOEDGE: - InfoOut << "JtkCOEDGE\n"; - break; - - case JtkEntity::JtkEDGE: - InfoOut << "JtkEDGE\n"; - break; - - case JtkEntity::JtkVERTEX: - InfoOut << "JtkVERTEX\n"; - break; - - case JtkEntity::JtkNURBSSURFACE: - InfoOut << "JtkNURBSSURFACE\n"; - break; - - case JtkEntity::JtkUVCURVE: - InfoOut << "JtkUVCURVE\n"; - break; - - case JtkEntity::JtkXYZCURVE: - InfoOut << "JtkXYZCURVE\n"; - break; - - case JtkEntity::JtkTRISTRIPSET: - InfoOut << "JtkTRISTRIPSET\n"; - break; - - case JtkEntity::JtkPOINTSET: - InfoOut << "JtkPOINTSET\n"; - break; - - case JtkEntity::JtkLINESTRIPSET: - InfoOut << "JtkLINESTRIPSET\n"; - break; - - case JtkEntity::JtkPOLYGONSET: - InfoOut << "JtkPOLYGONSET\n"; - break; - - case JtkEntity::JtkPOINT: - InfoOut << "JtkPOINT\n"; - break; - - case JtkEntity::JtkMATERIAL: - InfoOut << "JtkMATERIAL\n"; - break; - - case JtkEntity::JtkTRANSFORM: - InfoOut << "JtkTRANSFORM\n"; - break; - - case JtkEntity::JtkPROPERTY: - InfoOut << "JtkPROPERTY\n"; - break; - - case JtkEntity::JtkPART: - { - InfoOut << "JtkPART: "; - InfoOut << CurrNode->name() << "\n"; - - if( want_details ) - { - JtkTransform *partXform= NULL; - ((JtkPart*) CurrNode)->getTransform(partXform); - if( partXform ) - { - printXform(partXform, level+1); - } - - JtkMaterial *partMaterial= NULL; - ((JtkPart*) CurrNode)->getMaterial(partMaterial); - if( partMaterial ) - { - printMaterial(partMaterial, level+1); - } - - JtkBrep *partBrep= NULL; - ((JtkPart*) CurrNode)->getBrep(partBrep); - if( partBrep ) - { - printBrep(partBrep, level+1); - } - - JtkWrep *partWrep= NULL; - ((JtkPart*) CurrNode)->getWrep(partWrep); - if( partWrep ) - { - printWrep(partWrep, level+1); - } - - int partNumShapeLODs= -1; - partNumShapeLODs= ((JtkPart*) CurrNode)->numPolyLODs(); - for(int lod=0; lod < partNumShapeLODs; lod++) - { - indent(level+1); - InfoOut << "LOD#" << lod << ":\n"; - - int partNumShapes= -1; - partNumShapes= ((JtkPart*) CurrNode)->numPolyShapes(lod); - for(int shNum=0; shNum < partNumShapes; shNum++) - { - indent(level+2); - InfoOut << "Shape#" << shNum << ":\n"; - - JtkShape *partShape= NULL; - ((JtkPart*) CurrNode)->getPolyShape(partShape, lod, shNum); - if( partShape ) - { - printShape(partShape, level+3); - } - } - } - } - } - break; - - case JtkEntity::JtkASSEMBLY: - { - InfoOut << "JtkASSEMBLY: "; - InfoOut << CurrNode->name() << "(" - << ((JtkAssembly*) CurrNode)->numChildren() - << " children)\n"; - - if( want_details ) - { - JtkTransform *partXform= NULL; - ((JtkPart*) CurrNode)->getTransform(partXform); - if( partXform ) - { - printXform(partXform, level+1); - } - - JtkMaterial *partMaterial= NULL; - ((JtkPart*) CurrNode)->getMaterial(partMaterial); - if( partMaterial ) - { - printMaterial(partMaterial, level+1); - } - } - } - break; - - case JtkEntity::JtkINSTANCE: - { - InfoOut << "JtkINSTANCE: "; - InfoOut << CurrNode->name() << "\n"; - - if( want_details ) - { - JtkTransform *partXform= NULL; - ((JtkPart*) CurrNode)->getTransform(partXform); - if( partXform ) - { - printXform(partXform, level+1); - } - - JtkMaterial *partMaterial= NULL; - ((JtkPart*) CurrNode)->getMaterial(partMaterial); - if( partMaterial ) - { - printMaterial(partMaterial, level+1); - } - } - } - break; - - - case JtkEntity::JtkCLIENTDATA: - InfoOut << "JtkCLIENTDATA\n"; - break; - - case JtkEntity::JtkWIRE: - InfoOut << "JtkWIRE\n"; - break; - } - - return( Jtk_OK ); -} - -void insertShapeFaces(JtkShape *partShape) -{ - for(int set=0; set < partShape->numOfSets(); set++) - { - float *vertex= NULL, - *normal= NULL, - *color= NULL, - *texture= NULL; - int vertexCount= -1, - normCount= -1, - colorCount= -1, - textCount= -1; - - partShape->getInternal(vertex, vertexCount, normal, normCount, color, colorCount, texture, textCount, set); - - if(normCount < 3) - return; - - - if( vertex && (vertexCount > 0) && normal && (normCount > 0) ) - { - for(int i = 0 ; i< vertexCount-2; i++) - { - SimpleMeshFacet temp; - temp.n[0] = normal[i*3+0]; - temp.n[1] = normal[i*3+1]; - temp.n[2] = normal[i*3+2]; - temp.p1[0]= vertex[i*3+0]; - temp.p1[1]= vertex[i*3+1]; - temp.p1[2]= vertex[i*3+2]; - temp.p2[0]= vertex[i*3+3]; - temp.p2[1]= vertex[i*3+4]; - temp.p2[2]= vertex[i*3+5]; - temp.p3[0]= vertex[i*3+6]; - temp.p3[1]= vertex[i*3+7]; - temp.p3[2]= vertex[i*3+8]; - - result.push_back(temp); -/* - file << " facet normal "<< normal[i*3+0] << " " << normal[i*3+1] << " " << normal[i*3+2] << " " << endl; - file << " outer loop" << endl; - file << " vertex " << vertex[i*3+0] << " " << vertex[i*3+1] << " " << vertex[i*3+2] << " " << endl; - file << " vertex " << vertex[i*3+3] << " " << vertex[i*3+4] << " " << vertex[i*3+5] << " " << endl; - file << " vertex " << vertex[i*3+6] << " " << vertex[i*3+7] << " " << vertex[i*3+8] << " " << endl; - file << " endloop" << endl; - file << " endfacet" << endl; -*/ - } - } -#ifdef _DEBUG - if (vertex) JtkEntityFactory::deleteMemory( vertex ); - if (vertex) JtkEntityFactory::deleteMemory( normal ); - if (color) JtkEntityFactory::deleteMemory( color ); - if (texture) JtkEntityFactory::deleteMemory( texture ); -#else - if (vertex) delete [] vertex; - if (vertex) delete [] normal; - if (color) delete [] color; - if (texture)delete [] texture; -#endif - - } + if (normal && (normCount > 0)) { + indent(level + 2); + InfoOut << "normals = ( "; + for (int elems = 0; elems < normCount * 3; elems++) { + InfoOut << ((elems != 0) ? ", " : "") << normal[elems]; + } + + InfoOut << " )\n"; + +#ifdef _DEBUG + JtkEntityFactory::deleteMemory(normal); +#else + delete[] normal; +#endif + } + + if (color && (colorCount > 0)) { + indent(level + 2); + InfoOut << "color = ( "; + + for (int elems = 0; elems < colorCount * 3; elems++) { + InfoOut << ((elems != 0) ? ", " : "") << color[elems]; + } + + InfoOut << " )\n"; + +#ifdef _DEBUG + JtkEntityFactory::deleteMemory(color); +#else + delete[] color; +#endif + } + + if (texture && (textCount > 0)) { + indent(level + 2); + InfoOut << "texture = ( "; + + for (int elems = 0; elems < textCount; elems++) { + InfoOut << ((elems != 0) ? ", " : "") << texture[elems]; + } + + InfoOut << " )\n"; + +#ifdef _DEBUG + JtkEntityFactory::deleteMemory(texture); +#else + delete[] texture; +#endif + } + } +} + +int myPreactionCB_PrintName(JtkHierarchy* CurrNode, int level, JtkClientData*) +{ + indent(level); + + my_level++; + + switch (CurrNode->typeID()) { + case JtkEntity::JtkNONE: + InfoOut << "JtkNONE\n"; + break; + + case JtkEntity::JtkBREP: + InfoOut << "JtkBREP\n"; + break; + + case JtkEntity::JtkREGION: + InfoOut << "JtkREGION\n"; + break; + + case JtkEntity::JtkSHELL: + InfoOut << "JtkSHELL\n"; + break; + + case JtkEntity::JtkLOOP: + InfoOut << "JtkLOOP\n"; + break; + + case JtkEntity::JtkCOEDGE: + InfoOut << "JtkCOEDGE\n"; + break; + + case JtkEntity::JtkEDGE: + InfoOut << "JtkEDGE\n"; + break; + + case JtkEntity::JtkVERTEX: + InfoOut << "JtkVERTEX\n"; + break; + + case JtkEntity::JtkNURBSSURFACE: + InfoOut << "JtkNURBSSURFACE\n"; + break; + + case JtkEntity::JtkUVCURVE: + InfoOut << "JtkUVCURVE\n"; + break; + + case JtkEntity::JtkXYZCURVE: + InfoOut << "JtkXYZCURVE\n"; + break; + + case JtkEntity::JtkTRISTRIPSET: + InfoOut << "JtkTRISTRIPSET\n"; + break; + + case JtkEntity::JtkPOINTSET: + InfoOut << "JtkPOINTSET\n"; + break; + + case JtkEntity::JtkLINESTRIPSET: + InfoOut << "JtkLINESTRIPSET\n"; + break; + + case JtkEntity::JtkPOLYGONSET: + InfoOut << "JtkPOLYGONSET\n"; + break; + + case JtkEntity::JtkPOINT: + InfoOut << "JtkPOINT\n"; + break; + + case JtkEntity::JtkMATERIAL: + InfoOut << "JtkMATERIAL\n"; + break; + + case JtkEntity::JtkTRANSFORM: + InfoOut << "JtkTRANSFORM\n"; + break; + + case JtkEntity::JtkPROPERTY: + InfoOut << "JtkPROPERTY\n"; + break; + + case JtkEntity::JtkPART: { + InfoOut << "JtkPART: "; + InfoOut << CurrNode->name() << "\n"; + + if (want_details) { + JtkTransform* partXform = NULL; + ((JtkPart*)CurrNode)->getTransform(partXform); + if (partXform) { + printXform(partXform, level + 1); + } + + JtkMaterial* partMaterial = NULL; + ((JtkPart*)CurrNode)->getMaterial(partMaterial); + if (partMaterial) { + printMaterial(partMaterial, level + 1); + } + + JtkBrep* partBrep = NULL; + ((JtkPart*)CurrNode)->getBrep(partBrep); + if (partBrep) { + printBrep(partBrep, level + 1); + } + + JtkWrep* partWrep = NULL; + ((JtkPart*)CurrNode)->getWrep(partWrep); + if (partWrep) { + printWrep(partWrep, level + 1); + } + + int partNumShapeLODs = -1; + partNumShapeLODs = ((JtkPart*)CurrNode)->numPolyLODs(); + for (int lod = 0; lod < partNumShapeLODs; lod++) { + indent(level + 1); + InfoOut << "LOD#" << lod << ":\n"; + + int partNumShapes = -1; + partNumShapes = ((JtkPart*)CurrNode)->numPolyShapes(lod); + for (int shNum = 0; shNum < partNumShapes; shNum++) { + indent(level + 2); + InfoOut << "Shape#" << shNum << ":\n"; + + JtkShape* partShape = NULL; + ((JtkPart*)CurrNode)->getPolyShape(partShape, lod, shNum); + if (partShape) { + printShape(partShape, level + 3); + } + } + } + } + } break; + + case JtkEntity::JtkASSEMBLY: { + InfoOut << "JtkASSEMBLY: "; + InfoOut << CurrNode->name() << "(" << ((JtkAssembly*)CurrNode)->numChildren() + << " children)\n"; + + if (want_details) { + JtkTransform* partXform = NULL; + ((JtkPart*)CurrNode)->getTransform(partXform); + if (partXform) { + printXform(partXform, level + 1); + } + + JtkMaterial* partMaterial = NULL; + ((JtkPart*)CurrNode)->getMaterial(partMaterial); + if (partMaterial) { + printMaterial(partMaterial, level + 1); + } + } + } break; + + case JtkEntity::JtkINSTANCE: { + InfoOut << "JtkINSTANCE: "; + InfoOut << CurrNode->name() << "\n"; + + if (want_details) { + JtkTransform* partXform = NULL; + ((JtkPart*)CurrNode)->getTransform(partXform); + if (partXform) { + printXform(partXform, level + 1); + } + + JtkMaterial* partMaterial = NULL; + ((JtkPart*)CurrNode)->getMaterial(partMaterial); + if (partMaterial) { + printMaterial(partMaterial, level + 1); + } + } + } break; + + + case JtkEntity::JtkCLIENTDATA: + InfoOut << "JtkCLIENTDATA\n"; + break; + + case JtkEntity::JtkWIRE: + InfoOut << "JtkWIRE\n"; + break; + } + + return (Jtk_OK); +} + +void insertShapeFaces(JtkShape* partShape) +{ + for (int set = 0; set < partShape->numOfSets(); set++) { + float *vertex = NULL, *normal = NULL, *color = NULL, *texture = NULL; + int vertexCount = -1, normCount = -1, colorCount = -1, textCount = -1; + + partShape->getInternal(vertex, + vertexCount, + normal, + normCount, + color, + colorCount, + texture, + textCount, + set); + + if (normCount < 3) { + return; + } + + + if (vertex && (vertexCount > 0) && normal && (normCount > 0)) { + for (int i = 0; i < vertexCount - 2; i++) { + SimpleMeshFacet temp; + temp.n[0] = normal[i * 3 + 0]; + temp.n[1] = normal[i * 3 + 1]; + temp.n[2] = normal[i * 3 + 2]; + temp.p1[0] = vertex[i * 3 + 0]; + temp.p1[1] = vertex[i * 3 + 1]; + temp.p1[2] = vertex[i * 3 + 2]; + temp.p2[0] = vertex[i * 3 + 3]; + temp.p2[1] = vertex[i * 3 + 4]; + temp.p2[2] = vertex[i * 3 + 5]; + temp.p3[0] = vertex[i * 3 + 6]; + temp.p3[1] = vertex[i * 3 + 7]; + temp.p3[2] = vertex[i * 3 + 8]; + + result.push_back(temp); + /* + file << " facet normal "<< normal[i*3+0] << " " << normal[i*3+1] << " " + << normal[i*3+2] << " " << endl; file << " outer loop" << endl; file << " + vertex " << vertex[i*3+0] << " " << vertex[i*3+1] << " " << vertex[i*3+2] << " " + << endl; file << " vertex " << vertex[i*3+3] << " " << vertex[i*3+4] << " " + << vertex[i*3+5] << " " << endl; file << " vertex " << vertex[i*3+6] << " " + << vertex[i*3+7] << " " << vertex[i*3+8] << " " << endl; file << " endloop" << + endl; file << " endfacet" << endl; + */ + } + } +#ifdef _DEBUG + if (vertex) { + JtkEntityFactory::deleteMemory(vertex); + } + if (vertex) { + JtkEntityFactory::deleteMemory(normal); + } + if (color) { + JtkEntityFactory::deleteMemory(color); + } + if (texture) { + JtkEntityFactory::deleteMemory(texture); + } +#else + if (vertex) { + delete[] vertex; + } + if (vertex) { + delete[] normal; + } + if (color) { + delete[] color; + } + if (texture) { + delete[] texture; + } +#endif + } } - -int myPreactionCB_CollectFacets(JtkHierarchy *CurrNode, int level, JtkClientData*) +int myPreactionCB_CollectFacets(JtkHierarchy* CurrNode, int level, JtkClientData*) { - switch (CurrNode->typeID()) - { + switch (CurrNode->typeID()) { + + case JtkEntity::JtkPART: { - case JtkEntity::JtkPART: - { - - { - JtkTransform *partXform= NULL; - ((JtkPart*) CurrNode)->getTransform(partXform); - if( partXform ) { - printXform(partXform, level+1); - } + JtkTransform* partXform = NULL; + ((JtkPart*)CurrNode)->getTransform(partXform); + if (partXform) { + printXform(partXform, level + 1); + } + + int partNumShapeLODs = -1; + partNumShapeLODs = ((JtkPart*)CurrNode)->numPolyLODs(); + for (int lod = 0; lod < partNumShapeLODs; lod++) { + indent(level + 1); + InfoOut << "LOD#" << lod << ":\n"; + + if (iLod != lod && iLod != -1) { + continue; + } + + int partNumShapes = -1; + partNumShapes = ((JtkPart*)CurrNode)->numPolyShapes(lod); + for (int shNum = 0; shNum < partNumShapes; shNum++) { + indent(level + 2); + InfoOut << "Shape#" << shNum << ":\n"; + + JtkShape* partShape = NULL; + ((JtkPart*)CurrNode)->getPolyShape(partShape, lod, shNum); + if (partShape) { + insertShapeFaces(partShape); + } + } + } + } + } break; + + case JtkEntity::JtkASSEMBLY: { + InfoOut << "JtkASSEMBLY: "; + InfoOut << CurrNode->name() << "(" << ((JtkAssembly*)CurrNode)->numChildren() + << " children)\n"; - int partNumShapeLODs= -1; - partNumShapeLODs= ((JtkPart*) CurrNode)->numPolyLODs(); - for(int lod=0; lod < partNumShapeLODs; lod++) { - indent(level+1); - InfoOut << "LOD#" << lod << ":\n"; - - if(iLod!=lod && iLod!=-1) - continue; - - int partNumShapes= -1; - partNumShapes= ((JtkPart*) CurrNode)->numPolyShapes(lod); - for(int shNum=0; shNum < partNumShapes; shNum++) - { - indent(level+2); - InfoOut << "Shape#" << shNum << ":\n"; - - JtkShape *partShape= NULL; - ((JtkPart*) CurrNode)->getPolyShape(partShape, lod, shNum); - if( partShape ) - { - insertShapeFaces(partShape); - } - } + JtkTransform* partXform = NULL; + ((JtkPart*)CurrNode)->getTransform(partXform); + if (partXform) {} } - } - } - break; + } break; - case JtkEntity::JtkASSEMBLY: - { - InfoOut << "JtkASSEMBLY: "; - InfoOut << CurrNode->name() << "(" - << ((JtkAssembly*) CurrNode)->numChildren() - << " children)\n"; - - { - JtkTransform *partXform= NULL; - ((JtkPart*) CurrNode)->getTransform(partXform); - if( partXform ) + case JtkEntity::JtkINSTANCE: { { - + JtkTransform* partXform = NULL; + ((JtkPart*)CurrNode)->getTransform(partXform); + if (partXform) {} } - - } - } - break; - - case JtkEntity::JtkINSTANCE: - { - { - JtkTransform *partXform= NULL; - ((JtkPart*) CurrNode)->getTransform(partXform); - if( partXform ) - { - - } - - } - } - break; - - } - return( Jtk_OK ); + } break; + } + return (Jtk_OK); } /* Interface functions */ void testLicence(void) { - // Try to create a JtkCADExporter to test for JT write/general licensing - JtkCADExporter *jtwriter = NULL; - jtwriter = JtkEntityFactory::createCADExporter(); - if( !jtwriter ) - { - cerr << "No export license found.\n"; - exit(1); - } - else - { - jtwriter->ref(); - jtwriter->unref(); - jtwriter = NULL; - } + // Try to create a JtkCADExporter to test for JT write/general licensing + JtkCADExporter* jtwriter = NULL; + jtwriter = JtkEntityFactory::createCADExporter(); + if (!jtwriter) { + cerr << "No export license found.\n"; + exit(1); + } + else { + jtwriter->ref(); + jtwriter->unref(); + jtwriter = NULL; + } - // Try to create a JtkCADImporter to test for JT read licensing - JtkCADImporter *jtreader = NULL; - jtreader = JtkEntityFactory::createCADImporter(); - if( !jtreader ) - { - cerr << "No import license found.\n"; - exit(1); - } - else - { - jtreader->ref(); - jtreader->unref(); - jtreader = NULL; - } + // Try to create a JtkCADImporter to test for JT read licensing + JtkCADImporter* jtreader = NULL; + jtreader = JtkEntityFactory::createCADImporter(); + if (!jtreader) { + cerr << "No import license found.\n"; + exit(1); + } + else { + jtreader->ref(); + jtreader->unref(); + jtreader = NULL; + } } void readFile(const char* FileName, int iLods) { - iLod = iLods; + iLod = iLods; - testLicence(); + testLicence(); - JtkCADImporter* importer= NULL; - importer= JtkEntityFactory::createCADImporter(); - if( importer ) - { - importer->ref(); - importer->setShapeLoadOption(JtkCADImporter::JtkALL_LODS); - importer->setBrepLoadOption(JtkCADImporter::JtkTESS_AND_BREP); - JtkHierarchy *root= NULL; + JtkCADImporter* importer = NULL; + importer = JtkEntityFactory::createCADImporter(); + if (importer) { + importer->ref(); + importer->setShapeLoadOption(JtkCADImporter::JtkALL_LODS); + importer->setBrepLoadOption(JtkCADImporter::JtkTESS_AND_BREP); + JtkHierarchy* root = NULL; - root= importer->import(FileName); + root = importer->import(FileName); - if( root ) { - root->ref(); - JtkTraverser* trav = JtkEntityFactory::createTraverser(); - trav->setupPreActionCallback(myPreactionCB_CollectFacets); - if( trav ) { - trav->ref(); - trav->traverseGraph(root); - trav->unref(); - trav = NULL; - } else { - throw "Unable to create JtkTraverser.\n"; + if (root) { + root->ref(); + JtkTraverser* trav = JtkEntityFactory::createTraverser(); + trav->setupPreActionCallback(myPreactionCB_CollectFacets); + if (trav) { + trav->ref(); + trav->traverseGraph(root); + trav->unref(); + trav = NULL; + } + else { + throw "Unable to create JtkTraverser.\n"; + } + + root->unref(); + root = NULL; + } + else { + throw "Unable in find root node. Check file...\n"; } - root->unref(); - root = NULL; - }else{ - throw "Unable in find root node. Check file...\n"; - } - - importer->unref(); - importer = NULL; + importer->unref(); + importer = NULL; } - else - { + else { throw "Unable to create JtkCADImporter. Check license...\n"; } - - // Uninitialize JtTk - //JtkEntityFactory::fini(); - + // Uninitialize JtTk + // JtkEntityFactory::fini(); } - - const SimpleMeshFacet* iterStart(void) { - resultIt = result.begin(); - if(resultIt != result.end()) - return &(*(resultIt)); - else - return 0; + resultIt = result.begin(); + if (resultIt != result.end()) { + return &(*(resultIt)); + } + else { + return 0; + } } const SimpleMeshFacet* iterGetNext(void) { - if(++resultIt != result.end()) - return &(*(resultIt)); - else - return 0; + if (++resultIt != result.end()) { + return &(*(resultIt)); + } + else { + return 0; + } } unsigned int iterSize(void) { - return (unsigned int) result.size(); + return (unsigned int)result.size(); } /** clears the internal structure */ void clearData(void) { - result.clear(); - resultIt = result.begin(); - InfoOut.clear(); - my_level = 0; + result.clear(); + resultIt = result.begin(); + InfoOut.clear(); + my_level = 0; } - diff --git a/src/Mod/JtReader/App/JtReader.h b/src/Mod/JtReader/App/JtReader.h index 65948ae3ce..9faba18c5c 100644 --- a/src/Mod/JtReader/App/JtReader.h +++ b/src/Mod/JtReader/App/JtReader.h @@ -9,13 +9,14 @@ /** simple facet structure */ -struct SimpleMeshFacet { - float p1[3],p2[3],p3[3],n[3]; +struct SimpleMeshFacet +{ + float p1[3], p2[3], p3[3], n[3]; }; /** Reads a JT File an build up the internal data structure - * imports all the meshes of all Parts, recursing the Assamblies. - */ + * imports all the meshes of all Parts, recursing the Assamblies. + */ void readFile(const char* FileName, int iLods = 0); /** Write the read Part to a file */ @@ -33,4 +34,4 @@ unsigned int iterSize(void); /** clears the internal structure */ void clearData(void); -#endif // __JtReader_h__ \ No newline at end of file +#endif// __JtReader_h__ diff --git a/src/Mod/JtReader/App/PreCompiled.cpp b/src/Mod/JtReader/App/PreCompiled.cpp index 0b915d1b1b..af15487840 100644 --- a/src/Mod/JtReader/App/PreCompiled.cpp +++ b/src/Mod/JtReader/App/PreCompiled.cpp @@ -4,4 +4,4 @@ ***************************************************************************/ -#include "PreCompiled.h" +#include "PreCompiled.h" diff --git a/src/Mod/JtReader/App/PreCompiled.h b/src/Mod/JtReader/App/PreCompiled.h index 69fd594b69..020b4464f8 100644 --- a/src/Mod/JtReader/App/PreCompiled.h +++ b/src/Mod/JtReader/App/PreCompiled.h @@ -11,11 +11,11 @@ // Importing of App classes #ifdef FC_OS_WIN32 -# define MeshExport __declspec(dllimport) -# define AppJtReaderExport __declspec(dllexport) -#else // for Linux -# define MeshExport -# define AppJtReaderExport +#define MeshExport __declspec(dllimport) +#define AppJtReaderExport __declspec(dllexport) +#else// for Linux +#define MeshExport +#define AppJtReaderExport #endif #ifdef _PreComp_ @@ -23,16 +23,16 @@ /// point at which warnings of overly long specifiers disabled (needed for VC6) #ifdef _MSC_VER -# pragma warning( disable : 4251 ) -# pragma warning( disable : 4503 ) -# pragma warning( disable : 4275 ) -# pragma warning( disable : 4786 ) // specifier longer then 255 chars +#pragma warning(disable : 4251) +#pragma warning(disable : 4503) +#pragma warning(disable : 4275) +#pragma warning(disable : 4786)// specifier longer then 255 chars #endif // standard -#include #include +#include // STL #include @@ -51,6 +51,6 @@ // sys #include -#endif //_PreComp_ +#endif//_PreComp_ #endif diff --git a/src/Mod/JtReader/App/TestJtReader.cpp b/src/Mod/JtReader/App/TestJtReader.cpp index a06205764c..4a66f04a21 100644 --- a/src/Mod/JtReader/App/TestJtReader.cpp +++ b/src/Mod/JtReader/App/TestJtReader.cpp @@ -1,24 +1,24 @@ /************************************************************************** -* Copyright (c) 2014 Juergen Riegel * -* * -* 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 * -* * -***************************************************************************/ + * Copyright (c) 2014 Juergen Riegel * + * * + * 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" #ifndef _PreComp_ @@ -28,39 +28,32 @@ #include #include -#include "TestJtReader.h" #include "FcLodHandler.h" +#include "TestJtReader.h" TestJtReader::TestJtReader() -{ -} +{} TestJtReader::~TestJtReader() -{ -} +{} void TestJtReader::read(void) { - //const std::vector& toc = readToc(); + // const std::vector& toc = readToc(); - for (std::vector::const_iterator i = TocEntries.begin(); i != TocEntries.end(); ++i){ + for (std::vector::const_iterator i = TocEntries.begin(); i != TocEntries.end(); + ++i) { int segType = i->getSegmentType(); - if (segType == 7){ + if (segType == 7) { FcLodHandler handler; readLodSegment(*i, handler); - - } Base::Console().Log(i->toString().c_str()); } - - - - } diff --git a/src/Mod/JtReader/App/TestJtReader.h b/src/Mod/JtReader/App/TestJtReader.h index 15addb7dd1..341776a8d0 100644 --- a/src/Mod/JtReader/App/TestJtReader.h +++ b/src/Mod/JtReader/App/TestJtReader.h @@ -9,11 +9,8 @@ class TestJtReader: public JtReader { public: - TestJtReader(); - ~TestJtReader(); - - void read(void); - + TestJtReader(); + ~TestJtReader(); + void read(void); }; - diff --git a/src/Mod/JtReader/Init.py b/src/Mod/JtReader/Init.py index 2d985feb40..cb44eff0af 100644 --- a/src/Mod/JtReader/Init.py +++ b/src/Mod/JtReader/Init.py @@ -2,4 +2,4 @@ # (c) 2007 Juergen Riegel LGPL # Append the open handler -FreeCAD.addImportType("JtOpen (*.jt)","JtReader") +FreeCAD.addImportType("JtOpen (*.jt)", "JtReader") diff --git a/src/Mod/JtReader/InitGui.py b/src/Mod/JtReader/InitGui.py index 826f9602a1..18f23f31b9 100644 --- a/src/Mod/JtReader/InitGui.py +++ b/src/Mod/JtReader/InitGui.py @@ -1,29 +1,28 @@ -#*************************************************************************** -#* Copyright (c) 2002,2003 Juergen Riegel * -#* * -#* This file is part of the FreeCAD CAx development system. * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* FreeCAD 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 Lesser General Public License for more details. * -#* * -#* You should have received a copy of the GNU Library General Public * -#* License along with FreeCAD; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#*************************************************************************** +# *************************************************************************** +# * Copyright (c) 2002,2003 Juergen Riegel * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * FreeCAD 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 Lesser General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with FreeCAD; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** # JtReader gui init module # # Gathering all the information to start FreeCAD # This is the second one of three init scripts, the third one # runs when the gui is up -