ofxCarveCSG

https://github.com/paulobala/ofxCarveCSG

ofxCarveCSG allows boolean operations (intersection, union, difference and symetric difference) between two ofMesh meshes.

http://vimeo.com/47096148

Any comments are welcome :slight_smile:

wow! really nice

Really nice addon!
I have trouble compiling it on Osx Lion XCode 4.4.

  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/polyhedron_impl.hpp:91:33: 'edges' is a protected member of 'carve::poly::Face<3>'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/polyhedron_impl.hpp:92:103: 'edges' is a protected member of 'carve::poly::Face<3>'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/polyhedron_impl.hpp:93:48: 'edges' is a protected member of 'carve::poly::Face<3>'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/polyhedron_impl.hpp:119:17: Cannot initialize a variable of type 'face_t *' (aka 'Face<3> *') with an lvalue of type 'const carve::poly::Face<3> *const'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/polyhedron_impl.hpp:134:17: Cannot initialize a variable of type 'face_t *' (aka 'Face<3> *') with an lvalue of type 'const carve::poly::Face<3> *const'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/polyhedron_impl.hpp:145:36: 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  

If I correct (hack) those error I have more troubles in kd_node.hpp

  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/kd_node.hpp:241:59: No type named 'data_t' in 'kd_node<ndim, data_t, inserter_t, aabb_calc_t>'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/kd_node.hpp:269:33: No type named 'data_t' in 'kd_node<ndim, data_t, inserter_t, aabb_calc_t>'  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/kd_node.hpp:246:23: Member reference base type 'const q_t' (aka 'const int') is not a structure or union  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/kd_node.hpp:273:38: Member reference base type 'q_t' (aka 'int') is not a structure or union  
/Users/bpetit/BeamArt/dev/addonsOF/ofxCarveCSG/src/include/carve/kd_node.hpp:275:26: Member reference base type 'q_t' (aka 'int') is not a structure or union  

What version of XCode and OSX are you compiling on?

Thanks for this addon! I can’t wait to evaluate the speed on bigger meshes.

Ben

EDIT: After writing those lines I tested using LLVM GCC 4.2 instead of Apple LLVM Compiler 4.0 and it worked!

Ok I did some further testing using the ply ofMesh loader.

I tested some basic pyramids/pyramids, torus/box, fish/dolphin tests but non of them worked! SOme generated segfaults (“CSG failed, exception degenerate edge”) the other bad results?

Is there some conditions on the data loaded?

Ben

EDIT: After further further testing it appears to work with the same ply files directly using “intersect” from Carve CSG. I’ll try to investigate!

Thanks for pointing this framework, I worked on a similar project last year but this one seems really neat!

Hi Ben

First of all, thanks for reminding that I compiled with LLVM GCC 4.2 instead of Apple LLVM Compiler.

I made ofCarveCSG because I’m making tCAD (thesis work), a tabletop 3D Modeling Application using tangible objects (with fiducial markers) and in-air gestures. Basically, 3D content was linked to physical objects, and the manipulation of the physical object object (rotating, translating, etc.) was replicated in the linked 3D Content. I use ofMesh from basic shapes (from STLs), textured depth maps from a Kinect above the tabletop and freehand contours (that were tessellated into 3D Shapes ). I don’t have a current version but in the following video (2 months ago), you can see the boolean operation between a texture depth map (which is a little complex) and a STL Sphere

https://vimeo.com/42399921

As you can see I tried it with some complex shapes and its normally pretty robust.

Maybe the problem you’re encountering is due to

vector getTriangles(ofMesh mesh)

where the ofMesh is separated in a series of triangles. I assume the points of the ofMesh are ordered in such a way that it would result in a series of triangles (OF_PRIMITIVE_TRIANGLES). Maybe the problem is that you’re using ofMesh that are not OF_PRIMITIVE_TRIANGLES.

Sorry I can’t help you more… I’m kinda of a newbie to openframeworks :slight_smile: