polygon disappears when performing boolean > union


#5

Thanks for this zoharl, will have to give this a go…


#6

if you’re on OS X or Linux, there’s also Ticket01’s Boole plug-in, which also works really well.

Someone tried to compile that bool plug-in for OS X but it’s not a straightforward recompile.


#7

I thought all the code was cross platform. Do you have an idea what was the problem?


#8

sorry about this, I should have clarified, I haven’t added the plug-in yet…

I was asking a general question before reading through all the posts from the link you posted for the plug-in…didn’t realize booleans are an issue (to say the least) with Maya before asking the question.

just FYI running Maya 2010 on Windows 7 64bit


#9

I was asking @cgbeige about the OS X compilation.


#10

@zoharl…ok no worries.

I finally added the plug-in & it does show up in the plug-ins manager window.

I’m getting this error when performing a boolean:

# Error: NameError: name 'connect_boolPro' is not defined #

I shouldn’t have to mess with loadLibrary64.exe, right?


#11

Trey Harrell tried to compile the Mac version but the carve base package wouldn’t compile. I’m guessing it’s not set up for gcc in OS X and Linux. It does look like someone here got it to compile though:

http://code.google.com/p/carve/issues/detail?id=27

with clang, xcode and cmake. That’s a bit beyond me, though.


#12

@cgbeige, so if I’ll change the library code to compile with gcc (windows mingw), would it do the trick?

@scr33ner, you ran a python command connect_boolPro, instead of copying the script content to the script editor.


#13

it should. I don’t think the Maya plug-in would pose any problems if carve compiled with gcc.


#14

@zoharl: this is friggin brilliant & is such a time saver, can’t believe Autodesk couldn’t implement this on their VERY costly piece of software!

I got union to work. Excuse my ignorance but haven’t worked with python at all or melScript; so my next question is how can I get other boolean operations to work?

Can’t remember which thread I found this:


import maya.mel as mel
  import maya.cmds as mc
   if not mel.eval('exists boolop'):
 	 mc.loadPlugin('boolop')
  mel.eval('boolop 0 boolopRes')
  mc.unloadPlugin('boolop', force=1)
 
 enum OP {
 				UNION = 0,			/**< in a or b. */
 				INTERSECTION = 1,		/**< in a and b. */
 				A_MINUS_B = 2,			/**< in a, but not b. */
 				B_MINUS_A = 3,			/**< in b, but not a. */
 				SYMMETRIC_DIFFERENCE = 4,	   /**< in a or b, but not both. */
 				ALL = 5				/**< all split faces from a and b */
 			};

Anyway, next up is to make sure the output mesh are kosher with Unity.


#15

so far static mesh import to Unity with BoolPros is good!


#16

@cgbeige, okay, I’ll try to find the time to work on this.

@scr33ner, I think you are quoting something from my obsolete plugin boolop. BoolPro has a property (look at the channel box) for the boolean operation.
Regarding Autodesk, I just wrote a plugin that uses the open source carveLib. I’m not sure how much work the guy who wrote it did, but frankly besides shinny nonsense I don’t expect much from autodesk.


#17

@cgbeige,

The library supports cmake. cmake is a cross platform makefile generator. You need to install cmake on your os, and then point it to carve dir. You should config cmake to build the library alone without gui, opengl, glut, or boost. After the makefile is generated just use make. Every os might need some small source tweaking such as adding #include <algorithm>.

I think it’s quite straight forward. If you want to give it a try, I’m willing to walk you through this (I don’t have os x).


#18

ok - I’ve used cmake and have it installed so I’ll give it a try later. Which source version are you using? 1.4?


#19

so, with Boost and cmake setup, the make process gives me this error:

/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/polyhedron_impl.hpp:92:103: error: 'edges' is a protected member of 'carve::poly::Face<3>'
        const std::vector<const face_t *> &edge_faces = connectivity.edge_to_face[edgeToIndex_fast(f->edges[i])];
                                                                                                      ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/face_decl.hpp:72:35: note: declared protected here
      std::vector<const edge_t *> edges; // pointer into polyhedron.edges
                                  ^
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/lib/convex_hull.cpp:22:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/csg.hpp:28:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/poly.hpp:24:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/poly_impl.hpp:25:
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/polyhedron_impl.hpp:93:48: error: 'edges' is a protected member of 'carve::poly::Face<3>'
        const face_t *f2 = connectedFace(f, f->edges[i]);
                                               ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/face_decl.hpp:72:35: note: declared protected here
      std::vector<const edge_t *> edges; // pointer into polyhedron.edges
                                  ^
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/lib/convex_hull.cpp:22:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/csg.hpp:28:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/poly.hpp:24:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/poly_impl.hpp:25:
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/polyhedron_impl.hpp:119:17: error: cannot initialize a variable of type 'face_t *' (aka 'Face<3> *') with an
      lvalue of type 'const carve::poly::Face<3> *const'
        face_t *f = edge_faces[i];
                ^   ~
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/polyhedron_impl.hpp:134:17: error: cannot initialize a variable of type 'face_t *' (aka 'Face<3> *') with an
      lvalue of type 'const carve::poly::Face<3> *const'
        face_t *f = vertex_faces[i];
                ^   ~
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/polyhedron_impl.hpp:145:36: error: binding of reference to type 'std::vector<const edge_t *>' to a value of type
      'const std::vector<const carve::poly::Edge<3> *, std::allocator<const carve::poly::Edge<3> *>>' drops qualifiers
      std::vector<const edge_t *> &e = connectivity.vertex_to_edge[vertexToIndex_fast(v)];
                                   ^   ~
6 errors generated.
make[2]: *** [lib/CMakeFiles/carve.dir/convex_hull.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/carve.dir/all] Error 2
make: *** [all] Error 2

how do I configure it not to use Boost?


#20

In cmake you have a variable: CARVE_SYSTEM_BOOST. Actually I set all the boolean variables to false, except BUILD_SHARED_LIBRARY (you might even want to try and set it to false as well).
But your errors don’t seem to be boost related (so maybe you should leave it be for now). Let’s try and fix the first ones, and then please post an update errors list. If you can’t seem to find the line I’m talking about, then please let me know, since I’m might be looking on changed files.

1. The compiler seems to be right: The edges variable in class Face is protected. So let's make it public. In file face_decl.hpp move line 72 to line 69 (just cut and paste, don't delete empty lines, so the lines afterward would keep their line numbers).

2. polyhedron_impl.hpp lines 119 and 134 add const in the beginning of each line (f should be a const pointer in both places, since it is assigned to a const pointer).

3. In polyhedron_impl.hpp lines 145-147, the data type seems to be too complex for this compiler to make a reference of. So let's do it without an accessory variable; change these lines from
std::vector<const edge_t *> &e = connectivity.vertex_to_edge[vertexToIndex_fast(v)];
    std::copy(e.begin(), e.end(), result);
    return e.size();
to 
// std::vector<const edge_t *> &e = connectivity.vertex_to_edge[vertexToIndex_fast(v)];
    std::copy(connectivity.vertex_to_edge[vertexToIndex_fast(v)].begin(), connectivity.vertex_to_edge[vertexToIndex_fast(v)].end(), result);
    return connectivity.vertex_to_edge[vertexToIndex_fast(v)].size();

#21

ok - here’s the latest set of errors with polyhedron_impl.hpp having this as line 119:

const face_t *f = edge_faces[i];

and 134:

const face_t *f = vertex_faces[i];

and I’m still using boost

In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/lib/intersect.cpp:23:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/pointset.hpp:22:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/pointset_decl.hpp:27:
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:241:59: error: no type named 'data_t' in 'kd_node<ndim, data_t, inserter_t, aabb_calc_t>'
        typedef std::pair<double, const typename kd_node::data_t *> q_t;
                                        ~
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:269:33: error: no type named 'data_t' in 'kd_node<ndim, data_t, inserter_t, aabb_calc_t>'
        const typename kd_node::data_t *next() {
              ~
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:23: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                    ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:33: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                              ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:47: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                            ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:58: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                                       ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:71: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                                                    ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:82: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                                                               ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:273:38: error: member reference base type 'q_t' (aka 'int') is not a structure or union
              if (!node->parent || t.first < dist_to_parent_split) {
                                   ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:275:26: error: member reference base type 'q_t' (aka 'int') is not a structure or union
                return t.second;
                       ~ ^
10 errors generated.
make[2]: *** [lib/CMakeFiles/carve.dir/intersect.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/carve.dir/all] Error 2
make: *** [all] Error 2


#22

Now we stumble upon the most controversial subject between compilers, namely templates. In the lines of the first two error, please delete the keyword typename.

BTW, which compiler do you use, and are there other compilers out there?


#23

I’m using clang, which is the default compiler in OS X 10.8 but I can probably set it to fall back to gcc, if you can tell me how to change that

here are the latest errors:

[ 37%] Building CXX object lib/CMakeFiles/carve.dir/intersect.cpp.o
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/lib/intersect.cpp:23:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/pointset.hpp:22:
In file included from /Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/pointset_decl.hpp:27:
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:241:50: error: no type named 'data_t' in 'kd_node<ndim, data_t, inserter_t, aabb_calc_t>'
        typedef std::pair<double, const kd_node::data_t *> q_t;
                                        ~^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:269:24: error: no type named 'data_t' in 'kd_node<ndim, data_t, inserter_t, aabb_calc_t>'
        const kd_node::data_t *next() {
              ~^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:23: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                    ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:33: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                              ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:47: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                            ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:58: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                                       ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:71: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                                                    ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:246:82: error: member reference base type 'const q_t' (aka 'const int') is not a structure or union
            return (a.first > b.first) || ((a.first == b.first) && (a.second < b.second));
                                                                               ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:273:38: error: member reference base type 'q_t' (aka 'int') is not a structure or union
              if (!node->parent || t.first < dist_to_parent_split) {
                                   ~ ^
/Volumes/dullard/DOWNLOADS_dull/carve-1.4.0/include/carve/kd_node.hpp:275:26: error: member reference base type 'q_t' (aka 'int') is not a structure or union
                return t.second;
                       ~ ^
10 errors generated.
make[2]: *** [lib/CMakeFiles/carve.dir/intersect.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/carve.dir/all] Error 2
make: *** [all] Error 2


#24

The compiler is right, data_t isn’t not a member of the outside class, but a template parameter. Please change in lines 241, 269 the kd_node::data_t to data_t.
If it continues complaining about the same lines, then please change it instead to typename data_t (maybe now, without the kd_node, it would except the typename keyword, although it’s not that necessary to use it here).

I suggest that you try in parallel to compile with gcc as well in a different directory. In order to do so, copy only the original files, or more specifically the whole directory without the directory that cmake created. Actually I think if you specify for cmake a different “where to build the binaries” it should be enough. It would start the configuration from scratch and you could choose from a combo box the compiler you want to work with. But using a different directory for the source files as well would be wise, so the changes that we make to the source files won’t collide between the two compilers.