Source code for Finding Bilateral Symmetry Planes

May 2016

We are interested in creating computer-based tools to help design engineers during the first stage of the design process, known as conceptual design. Hence, we develop Sketch-Based Modelling (SBM) systems. Our approach for SBM relies on finding cues or regularities, which are those sketch properties which reveal properties of the three-dimensional object depicted in the sketch. In this context, symmetry planes are cues. In particular, the finding-symmetry algorithm we consider here (SYM) is aimed at finding circuits of lines that represent contours of symmetry planes of the polyhedral shapes depicted by wireframe models of polyhedral objects.

Attached is a C++ implementation of the code of the new SYM algorithm.

You can download the SYM code from here.

Although most of the cues are mutually related, we intend to detect every cue using minimal information. For SYM to work, the input sketch must have been previously vectorised, and strokes of the sketch must have been converted into lines of the line drawing. In addition, faces must have been detected. Hence, the input to the code is a 2D drawing, which includes a list of vertices, edges and faces in the following format:

·        Coordinates of every vertex are stored in an instance of the POINT2D class. The set of all vertices is stored in a standard vector (std::vector <POINT2D>Vertex)

o   VertexCount= number of vertex in the line drawing

o   VertexX[i]= X coordinate of the i-th vertex

o   VertexY[i]= Y coordinate of the i-th vertex

·        Edges are defined by way of their head and tail vertices. The set of all edge heads is stored in a standard vector (std::vector <long> EdgeU) and the set of all edge tails is stored in another standard vector (std::vector <long> EdgeV):

o   EdgeCount= number of edges in the line drawing

o   EdgeU[i]= Head vertex defining the i-th edge

o   EdgeVl[i]= Tail vertex defining the i-th edge

·        Faces are defined by a closed sequence of edges. The information is stored in instances of a FACE class, (std::vector <FACE> Face), where every FACE instance includes:

o   int C= Number of edges/vertices that define the face

o   std::vector <int> E= List of edges that define the face

o   std::vector <int> V= List of vertices that define the face

Reader must note that the vectorisation of the sketch required by this approach includes previous merging of endpoints of all the edges that share nodes or vertices of the polyhedral shape (merging into a single vertex all endpoints that should be perceived by humans as a common junction).

The output is the list of symmetry planes, together with their merits:

·        The symmetry planes are stored in nested vectors. Thus SymPlanes[i][j][k] contains the k-th corner of the j-th symmetry plane of the i-th subgraph. The information of symmetry planes is stored through the corners of the sides of the circuits. Corners may be vertices or midpoints. Vertices are stored by their numbers, while midpoints are stored by the number of the edge they belong to switched to negative and decreased by one unit (i.e. midpoint of edge 3 is stored as -4).

·        The merits of the symmetry planes are stored in nested vectors. Thus SymMerits[i][j] contains the merit of the j-th symmetry plane of the i-th subgraph.

The approach is encapsulated into a main class CCueSymmetry, which shares the same file with some auxiliary classes.

This approach for finding symmetry is extensively described in:

Plumed R., Company P. and Varley P.A.C. (2016).
Detecting mirror symmetry in single-view wireframe sketches of polyhedral shapes.
Computers & Graphics, Vol. 59. pp. 1-12, 2016.

To help understanding how the code works, and in order to offer a test environment too, the following main file is also provided:

·        Main.cpp, and its header Main.h.

Finally, we must highlight that the code was written to make it readable. Efficiency never was a goal.

 

*************************************************************************************

The SYM code is free software. But if you find it useful for your own research,
please cite our paper:

Plumed R., Company P. and Varley P.A.C. (2016).
Detecting mirror symmetry in single-view wireframe sketches of polyhedral shapes.
Computers & Graphics, Vol. 59. pp. 1-12, 2016.

**************************************************************************************