surface flattening

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
wmayer
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Sun Nov 05, 2017 2:52 pm

Which Eigen3 version do you use? Mine is 3.2.5 and this lacks of Eigen::LeastSquaresConjugateGradient.
Inside std::function<double(double)> get_basis(int degree, int i, Eigen::VectorXd knots) you use the keyword and. Not sure if the C++ standard defines it, at least MSVC doesn't support it, use && instead. The same is with not, use ! instead. And the same with or, use || instead.

The Cmake file should be changed to:

Code: Select all


################################ flat mesh ###############################
SET(FLATMESH_SRCS
    MeshFlattening.cpp
    MeshFlattening.h
    MeshFlatteningNurbs.h
    MeshFlatteningNurbs.cpp
    MeshFlatteningLscmRelax.h
    MeshFlatteningLscmRelax.cpp
)

if (PYBIND11_FOUND)
SET(FLATMESH_SRCS
    ${FLATMESH_SRCS}
    MeshFlatteningPy.cpp
)
endif()


add_library(flatmesh SHARED ${FLATMESH_SRCS})
SET_PYTHON_PREFIX_SUFFIX(flatmesh)
target_link_libraries(flatmesh ${PYTHON_LIBRARIES} ${MeshPart_LIBS})

SET_BIN_DIR(flatmesh flatmesh /Mod/MeshPart)
install(TARGETS flatmesh DESTINATION ${CMAKE_INSTALL_LIBDIR})
############################################################################
looo
Posts: 2665
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Sun Nov 05, 2017 8:43 pm

wmayer wrote:Which Eigen3 version do you use? Mine is 3.2.5 and this lacks of Eigen::LeastSquaresConjugateGradient.
thanks for havin a look at this. eigen is version 3.3.3 from conda-forge. Conda is quite fast with adding new versions...
wmayer wrote:Inside std::function<double(double)> get_basis(int degree, int i, Eigen::VectorXd knots) you use the keyword and. Not sure if the C++ standard defines it, at least MSVC doesn't support it, use && instead. The same is with not, use ! instead. And the same with or, use || instead.
This should be corrected. With your suggestion for cmake the library should be build also without pybind11. But there are still these occ-errors...
wmayer
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Sun Nov 05, 2017 9:37 pm

But there are still these occ-errors...
I don't get them.
looo
Posts: 2665
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Mon Nov 06, 2017 5:32 pm

wmayer wrote:I don't get them.
which occ-version are you using?
wmayer
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Mon Nov 06, 2017 6:52 pm

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.12559 (Git)
Build type: Release
Branch: master
Hash: 41deaf82dd52c9f5aa48302f2c4d30a481ba7292
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
Locale: German/Germany (de_DE)
wmayer
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Mon Nov 06, 2017 9:05 pm

These are all the changes I made to build the sources:

Code: Select all

diff --git a/src/Mod/MeshPart/App/MeshFlattening.cpp b/src/Mod/MeshPart/App/MeshFlattening.cpp
index a4fcb6f..ba057b7 100644
--- a/src/Mod/MeshPart/App/MeshFlattening.cpp
+++ b/src/Mod/MeshPart/App/MeshFlattening.cpp
@@ -21,6 +21,7 @@
  ***************************************************************************/


+#include "PreCompiled.h"
 #include "MeshFlattening.h"
 #include "MeshFlatteningLscmRelax.h"
 #include <Poly_Triangulation.hxx>
diff --git a/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp b/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp
index 42b8cd7..f46d563 100644
--- a/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp
+++ b/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.cpp
@@ -20,10 +20,10 @@
  *                                                                         *
  ***************************************************************************/

-
+#include "PreCompiled.h"
 #include "MeshFlatteningLscmRelax.h"
 #include <Eigen/IterativeLinearSolvers>
-#include<Eigen/SparseCholesky>
+#include <Eigen/SparseCholesky>
 #include <Eigen/SVD>
 #include <iostream>
 #include <algorithm>
diff --git a/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.h b/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.h
index c6bcccf..8147b39 100644
--- a/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.h
+++ b/src/Mod/MeshPart/App/MeshFlatteningLscmRelax.h
@@ -43,6 +43,7 @@
 #include <Eigen/IterativeLinearSolvers>

 #include "MeshFlatteningLscmRelax.h"
+#include "MeshFlattening.h"

 typedef Eigen::SparseMatrix<double> spMat;

@@ -50,12 +51,6 @@ typedef Eigen::SparseMatrix<double> spMat;
 typedef Eigen::Vector3d Vector3;
 typedef Eigen::Vector2d Vector2;

-template <typename type, unsigned int size>
-using ColMat = Eigen::Matrix<type, Eigen::Dynamic, size>;
-
-template <typename type, unsigned int size>
-using RowMat = Eigen::Matrix<type, size, Eigen::Dynamic>;
-
 class LscmRelax{
 private:
     ColMat<double, 3> q_l_g;  // the position of the 3d triangles at there locale coord sys
diff --git a/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp b/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp
index 63eb540..bc7fa28 100644
--- a/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp
+++ b/src/Mod/MeshPart/App/MeshFlatteningNurbs.cpp
@@ -21,6 +21,7 @@
  ***************************************************************************/


+#include "PreCompiled.h"
 #include "MeshFlatteningNurbs.h"
 #include <iostream>
 #include "math.h"
diff --git a/src/Mod/MeshPart/App/PreCompiled.h b/src/Mod/MeshPart/App/PreCompiled.h
index e7463d3..9d02c81 100644
--- a/src/Mod/MeshPart/App/PreCompiled.h
+++ b/src/Mod/MeshPart/App/PreCompiled.h
@@ -38,6 +38,7 @@
 #endif

 #ifdef _MSC_VER
+# pragma warning(disable : 4244)
 # pragma warning(disable : 4275)
 # pragma warning(disable : 4290)
 #endif
looo
Posts: 2665
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Mon Nov 06, 2017 9:44 pm

thanks, now this looks better. I guess the missing PreCompiled.h where the source of the occ error?
but with pybind11 there is still a problem, but I think this is related to something else...

Code: Select all

MeshFlatteningPy.cpp.obj : error LNK2019: unresolved external symbol __imp_strdup referenced in function "protected: void __cdecl pybind11::cpp_function::initialize_generic(struct pybind11::detail::function_record *,char const *,class type_info const * const *,unsigned __int64)" (?initialize_generic@cpp_function@pybind11@@IEAAXPEAUfunction_record@detail@2@PEBDPEBQEBVtype_info@@_K@Z)
wmayer
Site Admin
Posts: 14479
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Wed Nov 08, 2017 9:19 am

looo wrote:
Mon Nov 06, 2017 9:44 pm
thanks, now this looks better. I guess the missing PreCompiled.h where the source of the occ error?
but with pybind11 there is still a problem, but I think this is related to something else...

Code: Select all

MeshFlatteningPy.cpp.obj : error LNK2019: unresolved external symbol __imp_strdup referenced in function "protected: void __cdecl pybind11::cpp_function::initialize_generic(struct pybind11::detail::function_record *,char const *,class type_info const * const *,unsigned __int64)" (?initialize_generic@cpp_function@pybind11@@IEAAXPEAUfunction_record@detail@2@PEBDPEBQEBVtype_info@@_K@Z)
IIRC to use pybind11 on Windows you must use VS 2015 but this is currently not an option at all as I think you also need at least Windows 8.
looo
Posts: 2665
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Wed Nov 08, 2017 9:33 am

I am using vs2015 with conda, and I think this should also be possible with win7, at least the packages I use are compiled with vs15 on windows 7... But I also think this is somehow related to pybind11.