Reputation: 65
I am trying to simplify 3D mesh by merging adjacent and co-planar faces from an 3D OBJ file, OBJ files consists of triangulation for the mesh, I want to reduce the number of the edges without loosing quality of the mesh. Is there any algorithm which will help me in solving this??
Upvotes: 1
Views: 1611
Reputation: 6253
If you want to have something working out of the box and your points are exactly coplanar, then you can build a Nef_polyhedron and dump it back into a surface mesh. This example without the Boolean operation in the middle will work.
If you want something more efficient or if your points are not necessarily exactly coplanar, you have to iterate over edges of your mesh to identify redundant edges. Then you can define connected components of faces connected by those edges. For all the faces in the same connected component, you'll have to first determine if the component is simply connected (i.e. topologically a disk). If not then you'll need to add some extra edges to connect the holes to the outer boundary of that face (that's why iteratively calling join_face()
won't work in general). If the component is simply connected then you know that you can remove all the edges. You can walk on the boundary of that face by starting from a boundary edge of the component and cycling around the target so as to define the
cycle of boundary edges.
Upvotes: 2
Reputation: 1873
Each edges is defined by 2 points and because all the faces are trianges, each edges is common to 2 adjacent triangles. If you take into account those 2 triangles, you have 4 points in total : the two extremities of the edge (common to both triangles) and the two extremities of the 2 triangles.
What you can do is loop through all the edges and check whether the 4 points are co planar or not. If they are, the edge is useless and you can remove it.
To check if 4 points are coplanar :
take 3 points among the 4 and compute the equation of the plane defined by those 3 points (the equation of a plane is of the form ax + by + cz + d = 0).
check if the 4th point satisfies the plane equation.
Upvotes: 0