From 055ea38ad03ed56fc00a64458a9e59007e40c130 Mon Sep 17 00:00:00 2001
From: Radek Oslejsek <oslejsek@fi.muni.cz>
Date: Tue, 23 Jun 2020 11:58:53 +0200
Subject: [PATCH] The weird usage MeshPoints replaced with using Vector3d

---
 .../cz/fidentis/analyst/symmetry/Plane.java   | 53 ++++++++++---------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java b/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java
index 3237797a..a6d95e42 100644
--- a/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java
+++ b/Comparison/src/main/java/cz/fidentis/analyst/symmetry/Plane.java
@@ -4,12 +4,15 @@ import cz.fidentis.analyst.mesh.core.MeshFacet;
 import cz.fidentis.analyst.mesh.core.MeshFacetImpl;
 import cz.fidentis.analyst.mesh.core.MeshPoint;
 import cz.fidentis.analyst.mesh.core.MeshPointImpl;
+import cz.fidentis.analyst.mesh.core.MeshTriangle;
+import java.util.List;
+import javax.vecmath.Vector3d;
 
 /**
  *
  * @author Natália Bebjaková
  * 
- * Representation of the plane 
+ * Representation of the symmetry plane 
  */
 public class Plane {
     public double a;
@@ -54,36 +57,38 @@ public class Plane {
      * @param scale distance of points given by bounding box
      * @return plane represented as mesh 
      */
-    public static SymmetryEstimator createPlaneMesh(MeshPoint centroid, MeshPoint a, MeshPoint b, double scale) {
-        facet = new MeshFacetImpl();
-        SymmetryEstimator planeMesh = new SymmetryEstimator(facet, Config.getDefault());
-        
-        MeshPoint[] points = new MeshPoint[4];
+    public static SymmetryEstimator createPlaneMesh(Vector3d centroid, Vector3d a, Vector3d b, double scale) {
+        Vector3d[] points = new Vector3d[4];
         
-        points[0] = centroid.subtractPosition(a.multiplyPosition(scale)).subtractPosition(b.multiplyPosition(scale));
-        points[1] = centroid.subtractPosition(a.multiplyPosition(scale)).addPosition(b.multiplyPosition(scale));
-        points[2] = centroid.addPosition(a.multiplyPosition(scale)).addPosition(b.multiplyPosition(scale));
-        points[3] = centroid.addPosition(a.multiplyPosition(scale)).subtractPosition(b.multiplyPosition(scale));
+        Vector3d aScaled = new Vector3d(a);
+        Vector3d bScaled = new Vector3d(b);
+        aScaled.scale(scale);
+        bScaled.scale(scale);
         
-        for (MeshPoint point : points) {
-            facet.addVertex(point);
-        }
-
-        Triangle[] triangles = new Triangle[4];
+        points[0] = new Vector3d(centroid);
+        points[0].sub(aScaled);
+        points[0].sub(bScaled);
         
-        triangles[0] = new Triangle(0, 1, 2);
-        triangles[1] = new Triangle(0, 2, 3);
-        triangles[2] = new Triangle(0, 2, 1);
-        triangles[3] = new Triangle(0, 3, 2);
-        planeMesh.setTriangles(triangles);
+        points[1] = new Vector3d(centroid);
+        points[1].sub(aScaled);
+        points[1].add(bScaled);
         
-        MeshPoint[] normals = planeMesh.calculateNormals();
+        points[2] = new Vector3d(centroid);
+        points[2].add(aScaled);
+        points[2].add(bScaled);
         
-        facet.getVertices().clear();
+        points[3] = new Vector3d(centroid);
+        points[3].add(aScaled);
+        points[3].sub(bScaled);
         
-        for (int i = 0; i < points.length; i++) {
-            facet.addVertex(new MeshPointImpl(points[i].getPosition(),normals[i].getPosition(),null));
+        facet = new MeshFacetImpl();
+        for (Vector3d point : points) {
+            facet.addVertex(new MeshPointImpl(point, null, null));
         }
+        facet.calculateVertexNormals();
+
+        SymmetryEstimator planeMesh = new SymmetryEstimator(facet, Config.getDefault());
+        
         return planeMesh;
     }
     
-- 
GitLab