Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remesh example? #20

Open
danhambleton opened this issue May 5, 2015 · 14 comments
Open

remesh example? #20

danhambleton opened this issue May 5, 2015 · 14 comments

Comments

@danhambleton
Copy link

Hi there,

I was wondering how to use the remesh functions (or in general, how to interact with mesh.h) - is there some example code I could take a look at? Ideally, I would like to input a .off file and have it remesh based min/max edge length.

Do I need to implement my own VertData and TriData stucts? It looks like there are some conditions that need these need to satisfy, but I'm not sure what exactly they are.

Any help is most appreciated!

@gilbo
Copy link
Owner

gilbo commented May 5, 2015

You need to provide some member functions in the vert and tri data structs, but I don't remember which off the top of my head. The compiler will yell at you until they're all there. You can also look at my toptop code, which uses the same underlying data structures.

-- Gilbert

On May 5, 2015, at 11:33 AM, danhambleton [email protected] wrote:

Hi there,

I was wondering how to use the remesh functions (or in general, how to interact with mesh.h) - is there some example code I could take a look at? Ideally, I would like to input a .off file and have it remesh based min/max edge length.

Do I need to implement my own VertData and TriData stucts? It looks like there are some conditions that need these need to satisfy, but I'm not sure what exactly they are.

Any help is most appreciated!


Reply to this email directly or view it on GitHub.

@danhambleton
Copy link
Author

Thanks! So, something like:

struct ModelerVertex : public MinimalVertexData, public RemeshVertexData
{


};

struct ModelerTriangle : public MinimalTriangleData, public RemeshTriangleData
{
    //void merge(const ModelerTriangle &, const ModelerTriangle &) {}
    //static void split(ModelerTriangle &, ModelerTriangle &,
    //                  const ModelerTriangle &) {}
    //void move(const ModelerTriangle &) {}
    //void subdivide(SubdivideTriInput<ModelerVertex,ModelerTriangle>) {}
};

When I add this to my (vs2012) project I get a bunch of LNK2005 errors,,,

image

Have you run in to this before? Might just be a windows thing...

@danhambleton
Copy link
Author

To clarify, just defining these structs generates the error - the code compiled fine before.

@gilbo
Copy link
Owner

gilbo commented May 6, 2015

Since a lot of the code is template code, that’s unsurprising that adding the structs could cause an error. I’m not sure what’s going wrong from the errors you posted. It looks like it’s complaining about having the << operator not be defined.

However, I’d guess that this is more likely an issue with how you’re using the template system. Unfortunately C++ is quite finicky about how templates interact with object files. You might have defined something twice and then are getting name conflicts at link time. But again, it’s hard to say.

— Gilbert

On May 5, 2015, at 3:27 PM, danhambleton [email protected] wrote:

To clarify, just defining these structs generates the error - the code compiled fine before.


Reply to this email directly or view it on GitHub.

@danhambleton
Copy link
Author

I actually get this error simply by including mesh.h in the wincork main...

Full error here:

Error   7   error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct TopoEdge const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUTopoEdge@@@Z) already defined in cork.obj  D:\ThirdParty\cork\win\wincork\main.obj

I don't have much experience with templates so I'm at a bit of a loss! I'll read through the toptop code a bit more carefully...

@gilbo
Copy link
Owner

gilbo commented May 6, 2015

Look at this part of the error:
"already defined in cork.obj"
The problem is that you're trying to link files with redundant (possibly conflicting!) definitions of the mesh.

On May 6, 2015, at 9:20 AM, danhambleton [email protected] wrote:

I actually get this error simply by including mesh.h in the wincork main...

Full error here:

Error 7 error LNK2005: "class std::basic_ostream<char,struct std::char_traits > & __cdecl operator<<(class std::basic_ostream<char,struct std::char_traits > &,struct TopoEdge const &)" (??6@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUTopoEdge@@@z) already defined in cork.obj D:\ThirdParty\cork\win\wincork\main.obj
I don't have much experience with templates so I'm at a bit of a loss! I'll read through the toptop code a bit more carefully...


Reply to this email directly or view it on GitHub.

@danhambleton
Copy link
Author

I understand the gist of the error and am totally fine with working away on my own on this (i.e. this is open source code and you probably don't want to be answering these questions!).

However, I'm literally just including your mesh.h in the wincork main and getting that linker error - is this expected behaviour?

Anyway, thanks for your time so far!

@gilbo
Copy link
Owner

gilbo commented May 6, 2015

Ok, here’s the quick simple answer from scanning the library (haven’t looked at the code in a while)

Notice the following include structure:

cork.cpp
includes mesh.h
includes cork.h

main.cpp
includes cork.h

This is because I was trying to create a C-friendly interface for the library. Effectively cork.h/cork.cpp implement that wrapper and main.cpp just implements a simple command-line tool interface to the library.

The problem you’re having if you include mesh.h in main.cpp is that you’ve now included mesh.h (which is really an enormous chunk of the library thanks to templates having to be entirely in headers) in two different .cpp files. Each of those .cpp files is getting compiled into a .o file and then those are getting linked together. To reiterate, the problem is that you’re compiling two separate versions of the Mesh type.

FIX: you can fix this by working with mesh.h from cork.cpp, or if you have your own project, you can use cork.h/cork.cpp as an example for how you should implement your own wrapper around the CPP cork library interface. Make sure mesh.h is only included in this one .cpp file for the wrapper.

Ok, here’s the more precision fix after looking in a bit more detail.

The TopoTri, TopoEdge etc. operator<< functions are defined in a header (mesh.topocache.tpp) and so the problem is that you’re getting two copies of those symbols. You might be able to fix that by just changing those functions to have the ‘static inline’ keywords, which is a standard workaround to the problem of having functions defined in header files… (I could be wrong about that)

I can’t promise that the precision fix will fix everything.

— Gilbert

On May 6, 2015, at 2:38 PM, danhambleton [email protected] wrote:

I understand the gist of the error and am totally fine with working away on my own on this (i.e. this is open source code and you probably don't want to be answering these questions!).

However, I'm literally just including your mesh.h in the wincork main and getting that linker error - is this expected behaviour?

Anyway, thanks for time so far!


Reply to this email directly or view it on GitHub.

@danhambleton
Copy link
Author

Thanks! This is exactly what I needed.

@danhambleton
Copy link
Author

Works great:

image

@fangq
Copy link

fangq commented Aug 8, 2016

@danhambleton, do you mind sharing your lines for the remeshing work? just want to get some ideas how to apply the remesh feature after a boolean operation. thanks!

@mortmaire
Copy link

@danhambleton , your example is something I really need right now. Shame you didn't include it.

@mortmaire
Copy link

Funny thing - I actually spend last 2 weeks trying to recreate mesh library JUST TO GET THIS REMESH OPTION YOU DID NOT GIVE US, @danhambleton .

@fangq
Copy link

fangq commented Jul 29, 2020

FYI, the remesh function is now exposed in my fork as -remesh in out, also double-dash commands, like --command, apply a remesh to the boolean output, see

fangq@33bea81

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants