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!
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Wed Nov 08, 2017 9:25 pm

I already thought about changing to pycxx, but I don't think it's easy to connect numpy arrays to eigen arrays and the other way round. In my eyes this is a missing feature of freecad. Using some established vector-libraries (on both sides) does simplify quite a bit...
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Thu Nov 23, 2017 7:11 pm

I can't reproduce my own reported problem... Now there are only these occ-problems reported. The first looks like this:

Code: Select all

C:\Users\fc_builder\Miniconda3\envs\fc_debug\_b_env\Library\include\opencascade\Standard_DimensionError.hxx(26): error C2550: 'Handle_Standard_DimensionError': constructor initializer lists are only allowed on constructor definitions
Does this mean this is an error with occ? I have no clue what it means.
wmayer
Site Admin
Posts: 14448
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Thu Nov 23, 2017 7:14 pm

Can you post the content of Standard_DimensionError.hxx?
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Thu Nov 23, 2017 7:59 pm

Code: Select all

// Created on: 1991-09-05
// Created by: J.P. TIRAUlt
// Copyright (c) 1991-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _Standard_DimensionError_HeaderFile
#define _Standard_DimensionError_HeaderFile

#include <Standard_Type.hxx>
#include <Standard_DefineException.hxx>
#include <Standard_SStream.hxx>
#include <Standard_DomainError.hxx>

class Standard_DimensionError;
DEFINE_STANDARD_HANDLE(Standard_DimensionError, Standard_DomainError)

#if !defined No_Exception && !defined No_Standard_DimensionError
  #define Standard_DimensionError_Raise_if(CONDITION, MESSAGE) \
  if (CONDITION) throw Standard_DimensionError(MESSAGE);
#else
  #define Standard_DimensionError_Raise_if(CONDITION, MESSAGE)
#endif

DEFINE_STANDARD_EXCEPTION(Standard_DimensionError, Standard_DomainError)

#endif // _Standard_DimensionError_HeaderFile
wmayer
Site Admin
Posts: 14448
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Fri Nov 24, 2017 8:22 am

OK, and now can you figure out how the macro DEFINE_STANDARD_HANDLE is defined.
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Fri Nov 24, 2017 8:53 am

Code: Select all

//! For compatibility with previous versions of OCCT, define Handle_Class alias for opencascade::handle<Class>.
#if (defined(_MSC_VER) && _MSC_VER >= 1800) 
//! For Visual Studio 2013+, define Handle_Class as non-template class to allow exporting this type in C++/CLI.
#define DEFINE_STANDARD_HANDLECLASS(C1,C2,BC) class C1; class Handle_##C1 : public Handle(C1) \
{ \
public: \
  Handle_##C1() {} \
  Handle_##C1(Handle(C1)&& theHandle) : Handle(C1)(theHandle) {} \
  template <class T2, typename = typename std::enable_if <std::is_base_of <C1,T2>::value>::type> \
  inline Handle_##C1(const opencascade::handle<T2>& theOther) : Handle(C1)(theOther) {} \
  template <class T2, typename = typename std::enable_if <std::is_base_of <C1,T2>::value>::type> \
  inline Handle_##C1(const T2* theOther) : Handle(C1)(theOther) {} \
  template<typename T> inline Handle_##C1& operator=(T theOther) { Handle(C1)::operator=(theOther); return *this; } \
};
#else
//! For other compilers, use simple typedef
#define DEFINE_STANDARD_HANDLECLASS(C1,C2,BC) class C1; typedef Handle(C1) Handle_##C1;
#endif

#define DEFINE_STANDARD_HANDLE(C1,C2) DEFINE_STANDARD_HANDLECLASS(C1,C2,Standard_Transient)
#define DEFINE_STANDARD_PHANDLE(C1,C2) DEFINE_STANDARD_HANDLECLASS(C1,C2,Standard_Persistent)
I use Handle in 3 places:

Code: Select all

const Handle(Poly_Triangulation) &triangulation = BRep_Tool::Triangulation(face, location);
const Handle(Geom_Surface) &_surface = BRep_Tool::Surface(face);
const Handle(Geom_BSplineSurface) &_bspline = Handle(Geom_BSplineSurface)::DownCast(_surface);
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Fri Nov 24, 2017 9:52 am

stupid me. It was related to the double declaration of ColMat and RowMat which you allready mentioned some posts ago.

Somehow I haven't saved stuff the last time I worked on this. Now I am getting the allready reported problem:

Code: Select all

   Creating library src\Mod\MeshPart\App\flatmesh.lib and object src\Mod\MeshPart\App\flatmesh.exp
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)
Mod\MeshPart\flatmesh.pyd : fatal error LNK1120: 1 unresolved externals
LINK failed. with 1120
wmayer
Site Admin
Posts: 14448
Joined: Thu Feb 19, 2009 10:32 am

Re: surface flattening

Postby wmayer » Fri Nov 24, 2017 11:14 am

In several places you write opencascade::handle<...>. Don't do this and instead write Handle(...) because otherwise your code doesn't work with older occ versions. Not sure if this is why the build also fails.
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Sun Nov 26, 2017 2:57 pm

still the same problem.

Maybe this is related to my windows. No idea how to update my visualstudio libraries.
looo
Posts: 2656
Joined: Mon Nov 11, 2013 5:29 pm

Re: surface flattening

Postby looo » Mon Dec 04, 2017 5:49 pm

When I tried to compile the current master branch of FreeCAD with pybind11 on windows I get the same error. So this problem is related to the combination freecad-win-pybind11. But as I have too many other tasks right now, I simple wait for next pybind11 release on conda...