BREP and first approach to Boolean algorithm

A project log for jsketcher

Parametric 2D and 3D modeler written in pure javascript

Val ErastovVal Erastov 10/12/2017 at 06:130 Comments

After the implementation of the 2d sketcher I decided to come up with a proof of concept of designing things in 3d where one can:

  1. pick a face and then draw a sketch on a that face
  2. Convert the 2d sketch to 3d by either extruding or revolving it
  3. Perform a Boolean operation: either union or subtract

My first implementation of 3D sub-system was based on csg.js library It’s a great library and allowed me to put 2d and 3d sub-systems together and come up with the first prof of concept. This library gave me the most important piece I didn't have is to perform the 3d operations on 3d objects(union,  intersect and subtract).

CSG.js uses the mesh representation which means I had to tessellate the faces to triangles in order to perform a boolean operation loosing the information about  a face boundary such as kind of line(circle, arc, line…) and its parameters. This fact means that it's not really possible to draw a sketch applying constraints to the face boundary.

The second big limitation of the csg approach was unable to perform any operations on edges like facets or fillet. Neither on vertices. Because all this information gets lost after the tessellation.

Recovering the boundaries  information wasn't really possible and I hade few failed attempts to solve this problem.

So taking into account that such implementation of 3d was a just proof of concept it was a time to move on and coming up with a better engine for the 3d part.

The industrial standard for 3d  CADs is BREP - boundary representation. Unlike mesh-based data structures which is just a big set of triangles(or maybe convex polygons) the BREP is a collection of connected surfaces where each surface can be for example a plane or a conical surface or a NURBS. A surface is trimmed by a set of edges. A trimmed surface  is connected to other trimmed surfaces through those edges. 

Another big advantage of BREP is that after applying boolean operation the boundary information(edges and vertices etc.) doesn't get lost. No tessellation is required for the boolean operations. Tessellation is only needed for visualizing the BREP.

My plan was to define the BREP data-structures and try to implement the boolean algorithm on them. I started only with supporting planes as a surface. And then after awhile I was able to perform see first real results of my BREP boolean algorithm: