From 2e2873362bbc43ca92c413bbc2bce31ee3ed642d Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 4 Oct 2012 12:47:38 +0200 Subject: [PATCH 01/10] Fix STEP AP203/214 flaws --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 10 ++++++++++ src/Mod/Part/App/AppPart.cpp | 8 ++++---- src/Mod/Part/Gui/Command.cpp | 14 ++++++++------ src/Mod/Part/Init.py | 8 ++++---- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index be5a707012..bad749c9fd 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -55,6 +55,7 @@ # include # include # include +# include #if OCC_VERSION_HEX >= 0x060500 # include # else @@ -664,8 +665,17 @@ static PyObject * exporter(PyObject *self, PyObject *args) Base::FileInfo file(filename); if (file.hasExtension("stp") || file.hasExtension("step")) { + //Interface_Static::SetCVal("write.step.schema", "AP214IS"); STEPCAFControl_Writer writer; writer.Transfer(hDoc, STEPControl_AsIs); + + // edit STEP header + APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model()); + makeHeader.SetName(new TCollection_HAsciiString((const Standard_CString)filename)); + makeHeader.SetAuthorValue (1, new TCollection_HAsciiString("FreeCAD")); + makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString("FreeCAD")); + makeHeader.SetOriginatingSystem(new TCollection_HAsciiString("FreeCAD")); + makeHeader.SetDescriptionValue(1, new TCollection_HAsciiString("FreeCAD Model")); writer.Write(filename); } else if (file.hasExtension("igs") || file.hasExtension("iges")) { diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 6bcc488602..aee9f90b1c 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -95,11 +95,11 @@ void PartExport initPart() // see Init.py #if defined (_OCC64) #if OCC_VERSION_HEX < 0x060503 - App::GetApplication().addImportType("STEP AP203 format (*.step *.stp)","Part"); - App::GetApplication().addExportType("STEP AP203 format (*.step *.stp)","Part"); + App::GetApplication().addImportType("STEP (*.step *.stp)","Part"); + App::GetApplication().addExportType("STEP (*.step *.stp)","Part"); #else - App::GetApplication().addImportType("STEP AP214 format (*.step *.stp)","ImportGui"); - App::GetApplication().addExportType("STEP AP214 format (*.step *.stp)","ImportGui"); + App::GetApplication().addImportType("STEP with colors (*.step *.stp)","ImportGui"); + App::GetApplication().addExportType("STEP with colors (*.step *.stp)","ImportGui"); #endif #endif diff --git a/src/Mod/Part/Gui/Command.cpp b/src/Mod/Part/Gui/Command.cpp index a7e9b8154b..51f84675c6 100644 --- a/src/Mod/Part/Gui/Command.cpp +++ b/src/Mod/Part/Gui/Command.cpp @@ -446,9 +446,10 @@ CmdPartImport::CmdPartImport() void CmdPartImport::activated(int iMsg) { QStringList filter; - filter << QString::fromAscii("STEP AP203 (*.stp *.step)"); - filter << QString::fromAscii("STEP AP214 (*.stp *.step)"); + filter << QString::fromAscii("STEP (*.stp *.step)"); + filter << QString::fromAscii("STEP with colors (*.stp *.step)"); filter << QString::fromAscii("IGES (*.igs *.iges)"); + filter << QString::fromAscii("IGES with colors (*.igs *.iges)"); filter << QString::fromAscii("BREP (*.brp *.brep)"); QString select; @@ -459,7 +460,7 @@ void CmdPartImport::activated(int iMsg) if (!pDoc) return; // no document openCommand("Import Part"); if (select == filter[1] || - select == filter[2]) { + select == filter[3]) { doCommand(Doc, "import ImportGui"); doCommand(Doc, "ImportGui.insert(\"%s\",\"%s\")", (const char*)fn.toUtf8(), pDoc->getName()); } @@ -504,9 +505,10 @@ CmdPartExport::CmdPartExport() void CmdPartExport::activated(int iMsg) { QStringList filter; - filter << QString::fromAscii("STEP AP203 (*.stp *.step)"); - filter << QString::fromAscii("STEP AP214 (*.stp *.step)"); + filter << QString::fromAscii("STEP (*.stp *.step)"); + filter << QString::fromAscii("STEP with colors (*.stp *.step)"); filter << QString::fromAscii("IGES (*.igs *.iges)"); + filter << QString::fromAscii("IGES with colors (*.igs *.iges)"); filter << QString::fromAscii("BREP (*.brp *.brep)"); QString select; @@ -515,7 +517,7 @@ void CmdPartExport::activated(int iMsg) App::Document* pDoc = getDocument(); if (!pDoc) return; // no document if (select == filter[1] || - select == filter[2]) { + select == filter[3]) { Gui::Application::Instance->exportTo((const char*)fn.toUtf8(),pDoc->getName(),"ImportGui"); } else { diff --git a/src/Mod/Part/Init.py b/src/Mod/Part/Init.py index 33a81998e3..6da3a0373e 100644 --- a/src/Mod/Part/Init.py +++ b/src/Mod/Part/Init.py @@ -54,9 +54,9 @@ FreeCAD.addExportType("IGES format (*.iges *.igs)","Part") # The registration of the STEP filetype for 64-bit is handled in initPart() import platform if platform.architecture()[0]=='32bit': - FreeCAD.addImportType("STEP AP214 format (*.step *.stp)","ImportGui") - FreeCAD.addExportType("STEP AP214 format (*.step *.stp)","ImportGui") + FreeCAD.addImportType("STEP with colors (*.step *.stp)","ImportGui") + FreeCAD.addExportType("STEP with colors (*.step *.stp)","ImportGui") #else: -# FreeCAD.addImportType("STEP AP203 format (*.step *.stp)","Part") -# FreeCAD.addExportType("STEP AP203 format (*.step *.stp)","Part") +# FreeCAD.addImportType("STEP (*.step *.stp)","Part") +# FreeCAD.addExportType("STEP (*.step *.stp)","Part") From e41ec791b573a0c92df2982b75511f847e2afd30 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 5 Oct 2012 00:12:57 +0200 Subject: [PATCH 02/10] Add missing header file --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index bad749c9fd..5cb63a410e 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -45,6 +45,7 @@ # include # include # include +# include # include # include # include From 1933093e71e66c76190a6e39fa5b8134ea8945fa Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 5 Oct 2012 12:19:07 +0200 Subject: [PATCH 03/10] Fix build problems with ImportGui module, fix bug in Draft when using texture image --- CMakeLists.txt | 1 + cMake/FindOpenCasCade.cmake | 19 +++++++++++++------ src/Mod/Draft/Draft.py | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc7240bc43..6513b17737 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,7 @@ MARK_AS_ADVANCED(FORCE FREECAD_LIBPACK_CHECKFILE6X FREECAD_LIBPACK_CHECKFILE7X) message("-- OpenCASCADE Community Edition has been found.") add_definitions ( -DHAVE_CONFIG_H ) set( OCC_LIBRARIES "TKFeat;TKFillet;TKMesh;TKernel;TKG2d;TKG3d;TKMath;TKIGES;TKSTL;TKShHealing;TKXSBase;TKBool;TKBO;TKBRep;TKTopAlgo;TKGeomAlgo;TKGeomBase;TKOffset;TKPrim;TKSTEP;TKSTEPBase;TKSTEPAttr;TKHLR" ) #lib list copied from FreeCAD's FindOpenCasCade.cmake + set( OCC_OCAF_LIBRARIES "TKCAF;TKXCAF;TKLCAF;TKXDESTEP;TKXDEIGES" ) #lib list copied from FreeCAD's FindOpenCasCade.cmake set( OCC_INCLUDE_DIR ${OCE_INCLUDE_DIRS} ) set( OCC_FOUND ${OCE_FOUND} ) else() #look for OpenCASCADE diff --git a/cMake/FindOpenCasCade.cmake b/cMake/FindOpenCasCade.cmake index 1b04f709da..df0aa010b6 100644 --- a/cMake/FindOpenCasCade.cmake +++ b/cMake/FindOpenCasCade.cmake @@ -1,12 +1,12 @@ # Try to find OCC # Once done this will define # -# OCC_FOUND - system has OCC - OpenCASCADE -# OCC_INCLUDE_DIR - where the OCC include directory can be found -# OCC_LIBRARY_DIR - where the OCC library directory can be found -# OCC_LIBRARIES - Link this to use OCC -# - +# OCC_FOUND - system has OCC - OpenCASCADE +# OCC_INCLUDE_DIR - where the OCC include directory can be found +# OCC_LIBRARY_DIR - where the OCC library directory can be found +# OCC_LIBRARIES - Link this to use OCC +# OCC_OCAF_LIBRARIES - Link this to use OCC OCAF framework + IF (WIN32) IF (CYGWIN OR MINGW) @@ -80,5 +80,12 @@ IF(OCC_LIBRARY) TKHLR TKFeat ) + set(OCC_OCAF_LIBRARIES + TKCAF + TKXCAF + TKLCAF + TKXDESTEP + TKXDEIGES + ) ENDIF(OCC_LIBRARY) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 471cafad67..7939900df0 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -2402,6 +2402,7 @@ class _ViewProviderRectangle(_ViewProviderDraft): self.Object = vobj.Object def onChanged(self, vp, prop): + from pivy import coin if prop == "TextureImage": r = vp.RootNode if os.path.exists(vp.TextureImage): From 8a4c0ec2c0d0f2ac8d06415d841b8374bedd9f8e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 6 Oct 2012 12:17:08 +0200 Subject: [PATCH 04/10] Handle API change in OCC 6.5 --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 5cb63a410e..134fe15f7b 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -671,7 +671,11 @@ static PyObject * exporter(PyObject *self, PyObject *args) writer.Transfer(hDoc, STEPControl_AsIs); // edit STEP header +#if OCC_VERSION_HEX > 0x060500 + APIHeaderSection_MakeHeader makeHeader(writer.ChangeWriter().Model()); +#else APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model()); +#endif makeHeader.SetName(new TCollection_HAsciiString((const Standard_CString)filename)); makeHeader.SetAuthorValue (1, new TCollection_HAsciiString("FreeCAD")); makeHeader.SetOrganizationValue (1, new TCollection_HAsciiString("FreeCAD")); From a59b00e08e6e5020d5a848a5ab9f4050dcbc3d4a Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 6 Oct 2012 12:20:57 +0200 Subject: [PATCH 05/10] Handle API change in OCC 6.5 --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index 134fe15f7b..f9ce411892 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -671,7 +671,7 @@ static PyObject * exporter(PyObject *self, PyObject *args) writer.Transfer(hDoc, STEPControl_AsIs); // edit STEP header -#if OCC_VERSION_HEX > 0x060500 +#if OCC_VERSION_HEX >= 0x060500 APIHeaderSection_MakeHeader makeHeader(writer.ChangeWriter().Model()); #else APIHeaderSection_MakeHeader makeHeader(writer.Writer().Model()); From 1ddd1e22dc4a284f1f6d5002464b753b6bd94f30 Mon Sep 17 00:00:00 2001 From: Jose Luis Cercos Pita Date: Fri, 5 Oct 2012 12:42:12 +0200 Subject: [PATCH 06/10] Cleaned --- src/Mod/Ship/CMakeLists.txt | 1 - src/Mod/Ship/Makefile.am | 1 - src/Mod/Ship/OpenCL/simInit.cl | 99 ---------------------------------- 3 files changed, 101 deletions(-) delete mode 100644 src/Mod/Ship/OpenCL/simInit.cl diff --git a/src/Mod/Ship/CMakeLists.txt b/src/Mod/Ship/CMakeLists.txt index 9e7ed7347d..cb2a119ba9 100644 --- a/src/Mod/Ship/CMakeLists.txt +++ b/src/Mod/Ship/CMakeLists.txt @@ -58,7 +58,6 @@ SET(ShipExamples_SRCS Examples/s60_katamaran.fcstd Examples/wigley.fcstd Examples/wigley_katamaran.fcstd - OpenCL/simInit.cl ) SOURCE_GROUP("shipexamples" FILES ${ShipExamples_SRCS}) diff --git a/src/Mod/Ship/Makefile.am b/src/Mod/Ship/Makefile.am index 2c643646ce..87e1f22cbe 100644 --- a/src/Mod/Ship/Makefile.am +++ b/src/Mod/Ship/Makefile.am @@ -55,7 +55,6 @@ nobase_data_DATA = \ Examples/s60_katamaran.fcstd \ Examples/wigley.fcstd \ Examples/wigley_katamaran.fcstd \ - OpenCL/simInit.cl \ shipLoadExample/__init__.py \ shipLoadExample/TaskPanel.py \ shipLoadExample/TaskPanel.ui \ diff --git a/src/Mod/Ship/OpenCL/simInit.cl b/src/Mod/Ship/OpenCL/simInit.cl deleted file mode 100644 index 7bb8a3c2f2..0000000000 --- a/src/Mod/Ship/OpenCL/simInit.cl +++ /dev/null @@ -1,99 +0,0 @@ -/* - * ----------------------------------------------------------------------- - * - * This source file is part of AQUA-gpusph. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA - * - * - * Authors: - * - Cercos Pita, Jose Luis - * - Miguel Gonzalez, Leo - * - Saelices, Jaime - * - Souto Iglesias, Antonio - * - * ----------------------------------------------------------------------- - */ - -#ifndef M_PI - #define M_PI 3,14159265359 -#endif - -#ifdef _g - #error '_g' is already defined. -#endif -#define _g __global - -#ifdef _l - #error '_l' is already defined. -#endif -#define _l __local - -#ifdef _c - #error '_c' is already defined. -#endif -#define _c __constant - -#ifndef _grav - #define _grav 9.81 -#endif - -/** Setup velocity and acceleration potential for initial time step. - * @param pos Cell position. - * @param v Cell velocity. - * @param f Cell acceleration. - * @param waves Waves (A,T,phase,heading) - * @param phi Velocity potential. - * @param Phi Acceleration potential - * @param N Number of cell elements at each direction. - * @param n Number of waves. - */ -__kernel void FS(_g float4* pos, _g float4* v, _g float4* f, - _g float4* waves, _g float* phi, _g float* Phi, - uint2 N, uint n) -{ - // find position in global arrays - unsigned int i = get_global_id(0); - unsigned int j = get_global_id(1); - if( (i >= N.x) || (j >= N.y) ) - return; - unsigned int id = i*N.y + j; - - // ---- | ------------------------ | ---- - // ---- V ---- Your code here ---- V ---- - - unsigned int w; - for(w=0;w Date: Fri, 5 Oct 2012 12:51:09 +0200 Subject: [PATCH 07/10] Cleaned --- src/Mod/Ship/shipUtils/Paths.pyc | Bin 1379 -> 0 bytes src/Mod/Ship/shipUtils/__init__.pyc | Bin 159 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/Mod/Ship/shipUtils/Paths.pyc delete mode 100644 src/Mod/Ship/shipUtils/__init__.pyc diff --git a/src/Mod/Ship/shipUtils/Paths.pyc b/src/Mod/Ship/shipUtils/Paths.pyc deleted file mode 100644 index 260b7832cdaa250111a0b347bd1c94916d44c4fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1379 zcmcIjOKaOe5T2D3H+Bha66gyGTL{z?8quCZNwD+ip&{6$Ex8mStz)^ir0%XEhUAp~ z-yZq{+HXdFkXsLpY^`QzX6NzEx8d)N*00x(&r+H{0lxcqT?b2szoIeG#Zp#up%(gp zE&|E|`U!`SvQUJGvPgtAKHG1vAx{1W&#C0#`22Es*Tv$AMu@2B7HdFHZDcHh@xzwJ zvtJ+3pH_PR5LF#i)k!%qXYh0D*ux%k95J3dW8u(Ed~z!N`3G=0vc_}{y1ogyQx=2# z^4NIPO;kD`;loLN1A@8Aop)_Ed4`7#@0Qa0HdG{wJA@PuQAk{w3X3ggCiSKJHbAm8 z$zuM#Wx?4rUKANSRC@07v5TdF-D>7rh*USvsu$QfR#CXEw$+x30-272W;vZrY%rZ$ zApy^Y;g+i12~7V8b)J@(2e)_!@Q+KiV@P7zw>f{00jwnk=U&j@6jB(2v4f4{0a3W2 z(gg&ZTS(f6fX)FI^BEMqQ8d$Z^_;aMfDR$;vB^Y~r_gCx%7HMRJ@260 zy%TU(Y#1q;=QdFxkk5I)B4b`;=1S=DIT=sQp|z#0t?TgP44hGp=Jzt2M@VyNJWu8b z030FX8>rkC7FuhlNHtW5-%GUtxy|h9$yH)L&oANeH1F|5g-bm)^q9@7dPVw=*Nd^) StMAu`XOM-|J3+J6Z2SeBBtl;R diff --git a/src/Mod/Ship/shipUtils/__init__.pyc b/src/Mod/Ship/shipUtils/__init__.pyc deleted file mode 100644 index 711c3c8e986a40fc9e96644870d2ee3a44185970..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 159 zcmZSn%**v&T_7Nt0SXv_v;zR5ttd4$IWa{aMC*bW#YM^bzWFKo!5Nta`o%yZv?Md9SU)~KGcU6wK3=b& XvV;R@m`!eeN@-529mvXJAZ7pnse&aU From a6a5336bc55254edea6d883af495726e81dcbf43 Mon Sep 17 00:00:00 2001 From: Jose Luis Cercos Pita Date: Fri, 5 Oct 2012 13:04:50 +0200 Subject: [PATCH 08/10] Generated windows installer generator stuff --- src/WindowsInstaller/FreeCADModules.wxs | 1 + src/WindowsInstaller/ModShip.wxi | 172 ++++++++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 src/WindowsInstaller/ModShip.wxi diff --git a/src/WindowsInstaller/FreeCADModules.wxs b/src/WindowsInstaller/FreeCADModules.wxs index 019ae14f82..cc820ca325 100644 --- a/src/WindowsInstaller/FreeCADModules.wxs +++ b/src/WindowsInstaller/FreeCADModules.wxs @@ -53,6 +53,7 @@ + diff --git a/src/WindowsInstaller/ModShip.wxi b/src/WindowsInstaller/ModShip.wxi new file mode 100644 index 0000000000..274c0fc786 --- /dev/null +++ b/src/WindowsInstaller/ModShip.wxi @@ -0,0 +1,172 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From e11e4ba9ff7caaff018c27c1690926041ff94c5e Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 7 Oct 2012 17:07:23 +0200 Subject: [PATCH 09/10] Set tessellation tolerance in Drawing by user --- src/Mod/Drawing/App/AppDrawingPy.cpp | 14 ++++++++------ src/Mod/Drawing/App/FeatureViewPart.cpp | 6 +++++- src/Mod/Drawing/App/FeatureViewPart.h | 6 +++++- src/Mod/Drawing/App/ProjectionAlgos.cpp | 8 ++++---- src/Mod/Drawing/App/ProjectionAlgos.h | 4 ++-- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/Mod/Drawing/App/AppDrawingPy.cpp b/src/Mod/Drawing/App/AppDrawingPy.cpp index 345c629a12..892504a727 100644 --- a/src/Mod/Drawing/App/AppDrawingPy.cpp +++ b/src/Mod/Drawing/App/AppDrawingPy.cpp @@ -105,9 +105,10 @@ projectToSVG(PyObject *self, PyObject *args) PyObject *pcObjDir=0; const char *type=0; float scale=1.0f; + float tol=0.1f; - if (!PyArg_ParseTuple(args, "O!|O!sf", &(TopoShapePy::Type), &pcObjShape, - &(Base::VectorPy::Type), &pcObjDir, &type, &scale)) + if (!PyArg_ParseTuple(args, "O!|O!sff", &(TopoShapePy::Type), &pcObjShape, + &(Base::VectorPy::Type), &pcObjDir, &type, &scale, &tol)) return NULL; PY_TRY { @@ -121,7 +122,7 @@ projectToSVG(PyObject *self, PyObject *args) if (type && std::string(type) == "ShowHiddenLines") hidden = true; - Py::String result(Alg.getSVG(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale)); + Py::String result(Alg.getSVG(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale, tol)); return Py::new_reference_to(result); } PY_CATCH; @@ -134,9 +135,10 @@ projectToDXF(PyObject *self, PyObject *args) PyObject *pcObjDir=0; const char *type=0; float scale=1.0f; + float tol=0.1f; - if (!PyArg_ParseTuple(args, "O!|O!sf", &(TopoShapePy::Type), &pcObjShape, - &(Base::VectorPy::Type), &pcObjDir, &type, &scale)) + if (!PyArg_ParseTuple(args, "O!|O!sff", &(TopoShapePy::Type), &pcObjShape, + &(Base::VectorPy::Type), &pcObjDir, &type, &scale, &tol)) return NULL; PY_TRY { @@ -150,7 +152,7 @@ projectToDXF(PyObject *self, PyObject *args) if (type && std::string(type) == "ShowHiddenLines") hidden = true; - Py::String result(Alg.getDXF(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale)); + Py::String result(Alg.getDXF(hidden?ProjectionAlgos::WithHidden:ProjectionAlgos::Plain, scale, tol)); return Py::new_reference_to(result); } PY_CATCH; diff --git a/src/Mod/Drawing/App/FeatureViewPart.cpp b/src/Mod/Drawing/App/FeatureViewPart.cpp index 0eee19f3a2..93d201c625 100644 --- a/src/Mod/Drawing/App/FeatureViewPart.cpp +++ b/src/Mod/Drawing/App/FeatureViewPart.cpp @@ -70,6 +70,8 @@ using namespace std; // FeatureViewPart //=========================================================================== +App::PropertyFloatConstraint::Constraints FeatureViewPart::floatRange = {0.01f,5.0f,0.05f}; + PROPERTY_SOURCE(Drawing::FeatureViewPart, Drawing::FeatureView) @@ -83,6 +85,8 @@ FeatureViewPart::FeatureViewPart(void) ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines"); ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines"); ADD_PROPERTY_TYPE(LineWidth,(0.35f),vgroup,App::Prop_None,"The thickness of the resulting lines"); + ADD_PROPERTY_TYPE(Tolerance,(0.05f),vgroup,App::Prop_None,"The tessellation tolerance"); + Tolerance.setConstraints(&floatRange); } FeatureViewPart::~FeatureViewPart() @@ -198,7 +202,7 @@ App::DocumentObjectExecReturn *FeatureViewPart::execute(void) ProjectionAlgos::SvgExtractionType type = ProjectionAlgos::Plain; if (hidden) type = (ProjectionAlgos::SvgExtractionType)(type|ProjectionAlgos::WithHidden); if (smooth) type = (ProjectionAlgos::SvgExtractionType)(type|ProjectionAlgos::WithSmooth); - result << Alg.getSVG(type, this->LineWidth.getValue() / this->Scale.getValue()); + result << Alg.getSVG(type, this->LineWidth.getValue() / this->Scale.getValue(), this->Tolerance.getValue()); result << "" << endl; diff --git a/src/Mod/Drawing/App/FeatureViewPart.h b/src/Mod/Drawing/App/FeatureViewPart.h index 68ad3551f2..6a47fbcb4d 100644 --- a/src/Mod/Drawing/App/FeatureViewPart.h +++ b/src/Mod/Drawing/App/FeatureViewPart.h @@ -53,7 +53,8 @@ public: App::PropertyBool ShowHiddenLines; App::PropertyBool ShowSmoothLines; App::PropertyFloat LineWidth; - + App::PropertyFloatConstraint Tolerance; + /** @name methods overide Feature */ //@{ @@ -65,6 +66,9 @@ public: virtual const char* getViewProviderName(void) const { return "DrawingGui::ViewProviderDrawingView"; } + +private: + static App::PropertyFloatConstraint::Constraints floatRange; }; typedef App::FeaturePythonT FeatureViewPartPython; diff --git a/src/Mod/Drawing/App/ProjectionAlgos.cpp b/src/Mod/Drawing/App/ProjectionAlgos.cpp index b37c6cb482..0e99c76e65 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.cpp +++ b/src/Mod/Drawing/App/ProjectionAlgos.cpp @@ -149,7 +149,7 @@ void ProjectionAlgos::execute(void) } -std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale) +std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale, float tolerance) { std::stringstream result; SVGOutput output; @@ -187,7 +187,7 @@ std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale) } if (!VO.IsNull()) { float width = scale; - BRepMesh::Mesh(VO,0.1); + BRepMesh::Mesh(VO,tolerance); result << " Date: Mon, 8 Oct 2012 14:10:53 +0200 Subject: [PATCH 10/10] Use user-defined tolerance for tessellation --- src/Mod/Drawing/App/ProjectionAlgos.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Mod/Drawing/App/ProjectionAlgos.cpp b/src/Mod/Drawing/App/ProjectionAlgos.cpp index 0e99c76e65..d50706e687 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.cpp +++ b/src/Mod/Drawing/App/ProjectionAlgos.cpp @@ -157,7 +157,7 @@ std::string ProjectionAlgos::getSVG(SvgExtractionType type, float scale, float t if (!H.IsNull() && (type & WithHidden)) { float width = hfactor * scale; - BRepMesh::Mesh(H,0.1); + BRepMesh::Mesh(H,tolerance); result << "