Skip to content
Snippets Groups Projects
Commit 055ea38a authored by Radek Ošlejšek's avatar Radek Ošlejšek
Browse files

The weird usage MeshPoints replaced with using Vector3d

parent aa63e251
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment