Loading Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/CrossSection.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,9 @@ public class CrossSection extends MeshVisitor { private Set<MeshTriangle> visited; /** * Constructor * @param plane the cutting plane * Constructor for CrossSection visitor * * @param plane cutting plane */ public CrossSection(Plane plane) { this.plane = plane; Loading Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/CrossSectionZigZag.java +11 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,11 @@ public class CrossSectionZigZag extends MeshVisitor { private Plane plane; /** * Constructor for CrossSectionZigZag visitor * * @param plane cutting plane */ public CrossSectionZigZag(Plane plane) { this.plane = plane; this.points = new ArrayList<>(); Loading Loading @@ -118,24 +123,30 @@ public class CrossSectionZigZag extends MeshVisitor { if (intersection1 != null) { //Intersection 1 addPoint(intersection1, true); visitMeshFacetRec(facet, first.index1, first.index2, first, true); if (intersection2 != null) { //Intersection 1 and 2 addPoint(intersection2, false); visitMeshFacetRec(facet, first.index2, first.index3, first, false); } else if (intersection3 != null) { //Intersection 1 and 3 addPoint(intersection3, false); visitMeshFacetRec(facet, first.index3, first.index1, first, false); } } else if (intersection2 != null) { //Intersection 2 addPoint(intersection2, true); visitMeshFacetRec(facet, first.index2, first.index3, first, true); if (intersection3 != null) { //Intersection 2 and 3 addPoint(intersection3, false); visitMeshFacetRec(facet, first.index3, first.index1, first, false); } } else if (intersection3 != null) { //Intersection 3 only addPoint(intersection3, true); visitMeshFacetRec(facet, first.index3, first.index1, first, true); } //No intersection Loading Comparison/src/test/java/cz/fidentis/analyst/visitors/mesh/CrossSectionTest.java 0 → 100644 +116 −0 Original line number Diff line number Diff line package cz.fidentis.analyst.visitors.mesh; import java.util.List; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import cz.fidentis.analyst.mesh.core.CornerTableRow; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshFacetImpl; import cz.fidentis.analyst.mesh.core.MeshModel; import cz.fidentis.analyst.mesh.core.MeshPointImpl; import cz.fidentis.analyst.symmetry.Plane; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * @author Dominik Racek */ public class CrossSectionTest { private MeshModel createModel() { MeshModel model = new MeshModel(); MeshFacet facet = new MeshFacetImpl(); facet.addVertex(new MeshPointImpl(new Point3d(0, 0, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 0, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 1, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(0, 1, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 2, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(0, 2, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 3, 0), null, null)); facet.getCornerTable().addRow(new CornerTableRow(0, -1)); facet.getCornerTable().addRow(new CornerTableRow(1, 5)); facet.getCornerTable().addRow(new CornerTableRow(2, -1)); facet.getCornerTable().addRow(new CornerTableRow(0, 8)); facet.getCornerTable().addRow(new CornerTableRow(2, -1)); facet.getCornerTable().addRow(new CornerTableRow(3, 1)); facet.getCornerTable().addRow(new CornerTableRow(3, -1)); facet.getCornerTable().addRow(new CornerTableRow(2, 11)); facet.getCornerTable().addRow(new CornerTableRow(4, 3)); facet.getCornerTable().addRow(new CornerTableRow(3, 13)); facet.getCornerTable().addRow(new CornerTableRow(4, -1)); facet.getCornerTable().addRow(new CornerTableRow(5, 7)); facet.getCornerTable().addRow(new CornerTableRow(4, -1)); facet.getCornerTable().addRow(new CornerTableRow(6, 9)); facet.getCornerTable().addRow(new CornerTableRow(5, -1)); model.addFacet(facet); return model; } /** * Unit test for CrossSectionZigZag visitor */ @Test public void CrossSectionZigZag() { Plane cuttingPlane = new Plane(new Vector3d(1, 0, 0), -0.5); MeshModel model = createModel(); CrossSectionZigZag cs = new CrossSectionZigZag(cuttingPlane); model.compute(cs); List<Point3d> points = cs.getPoints(); //They can be ordered two ways, check both Assertions.assertEquals(points.size(), 6); if (points.get(0).equals(new Point3d(0.5, 0, 0))) { Assertions.assertEquals(points.get(0), new Point3d(0.5, 0, 0)); Assertions.assertEquals(points.get(1), new Point3d(0.5, 0.5, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(4), new Point3d(0.5, 2, 0)); Assertions.assertEquals(points.get(5), new Point3d(0.5, 2.5, 0)); } else if (points.get(0).equals(new Point3d(0.5, 2.5, 0))) { Assertions.assertEquals(points.get(0), new Point3d(0.5, 2.5, 0)); Assertions.assertEquals(points.get(1), new Point3d(0.5, 2, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(4), new Point3d(0.5, 0.5, 0)); Assertions.assertEquals(points.get(5), new Point3d(0.5, 0, 0)); } else { Assertions.fail(); } } /** * Unit test for CrossSection visitor */ @Test public void CrossSection() { Plane cuttingPlane = new Plane(new Vector3d(1, 0, 0), -0.5); MeshModel model = createModel(); CrossSection cs = new CrossSection(cuttingPlane); model.compute(cs); List<Point3d> points = cs.getPoints(); //They can be ordered two ways, check both //Flaw of the non-zigzag design: it can't detect first and last intersection, //since it only controls edges between two triangles. Assertions.assertEquals(points.size(), 4); if (points.get(0).equals(new Point3d(0.5, 0.5, 0))) { Assertions.assertEquals(points.get(0), new Point3d(0.5, 0.5, 0)); Assertions.assertEquals(points.get(1), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 2, 0)); } else if (points.get(0).equals(new Point3d(0.5, 2, 0))) { Assertions.assertEquals(points.get(1), new Point3d(0.5, 2, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(4), new Point3d(0.5, 0.5, 0)); } else { Assertions.fail(); } } } GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java +0 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package cz.fidentis.analyst.symmetry; import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.ControlPanelAction; import cz.fidentis.analyst.visitors.mesh.CrossSection; import cz.fidentis.analyst.visitors.mesh.CrossSectionZigZag; import org.openide.filesystems.FileChooserBuilder; Loading MeshModel/src/main/java/cz/fidentis/analyst/mesh/core/MeshTriangle.java +5 −4 Original line number Diff line number Diff line Loading @@ -73,13 +73,14 @@ public class MeshTriangle implements Iterable<MeshPoint> { } @Override public boolean equals(Object obj) { if(this == obj) public boolean equals(Object obj) { if(this == obj) { return true; } if(obj == null || obj.getClass()!= this.getClass()) if(obj == null || obj.getClass()!= this.getClass()) { return false; } MeshTriangle mt = (MeshTriangle) obj; Loading Loading
Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/CrossSection.java +3 −2 Original line number Diff line number Diff line Loading @@ -28,8 +28,9 @@ public class CrossSection extends MeshVisitor { private Set<MeshTriangle> visited; /** * Constructor * @param plane the cutting plane * Constructor for CrossSection visitor * * @param plane cutting plane */ public CrossSection(Plane plane) { this.plane = plane; Loading
Comparison/src/main/java/cz/fidentis/analyst/visitors/mesh/CrossSectionZigZag.java +11 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,11 @@ public class CrossSectionZigZag extends MeshVisitor { private Plane plane; /** * Constructor for CrossSectionZigZag visitor * * @param plane cutting plane */ public CrossSectionZigZag(Plane plane) { this.plane = plane; this.points = new ArrayList<>(); Loading Loading @@ -118,24 +123,30 @@ public class CrossSectionZigZag extends MeshVisitor { if (intersection1 != null) { //Intersection 1 addPoint(intersection1, true); visitMeshFacetRec(facet, first.index1, first.index2, first, true); if (intersection2 != null) { //Intersection 1 and 2 addPoint(intersection2, false); visitMeshFacetRec(facet, first.index2, first.index3, first, false); } else if (intersection3 != null) { //Intersection 1 and 3 addPoint(intersection3, false); visitMeshFacetRec(facet, first.index3, first.index1, first, false); } } else if (intersection2 != null) { //Intersection 2 addPoint(intersection2, true); visitMeshFacetRec(facet, first.index2, first.index3, first, true); if (intersection3 != null) { //Intersection 2 and 3 addPoint(intersection3, false); visitMeshFacetRec(facet, first.index3, first.index1, first, false); } } else if (intersection3 != null) { //Intersection 3 only addPoint(intersection3, true); visitMeshFacetRec(facet, first.index3, first.index1, first, true); } //No intersection Loading
Comparison/src/test/java/cz/fidentis/analyst/visitors/mesh/CrossSectionTest.java 0 → 100644 +116 −0 Original line number Diff line number Diff line package cz.fidentis.analyst.visitors.mesh; import java.util.List; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import cz.fidentis.analyst.mesh.core.CornerTableRow; import cz.fidentis.analyst.mesh.core.MeshFacet; import cz.fidentis.analyst.mesh.core.MeshFacetImpl; import cz.fidentis.analyst.mesh.core.MeshModel; import cz.fidentis.analyst.mesh.core.MeshPointImpl; import cz.fidentis.analyst.symmetry.Plane; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; /** * @author Dominik Racek */ public class CrossSectionTest { private MeshModel createModel() { MeshModel model = new MeshModel(); MeshFacet facet = new MeshFacetImpl(); facet.addVertex(new MeshPointImpl(new Point3d(0, 0, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 0, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 1, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(0, 1, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 2, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(0, 2, 0), null, null)); facet.addVertex(new MeshPointImpl(new Point3d(1, 3, 0), null, null)); facet.getCornerTable().addRow(new CornerTableRow(0, -1)); facet.getCornerTable().addRow(new CornerTableRow(1, 5)); facet.getCornerTable().addRow(new CornerTableRow(2, -1)); facet.getCornerTable().addRow(new CornerTableRow(0, 8)); facet.getCornerTable().addRow(new CornerTableRow(2, -1)); facet.getCornerTable().addRow(new CornerTableRow(3, 1)); facet.getCornerTable().addRow(new CornerTableRow(3, -1)); facet.getCornerTable().addRow(new CornerTableRow(2, 11)); facet.getCornerTable().addRow(new CornerTableRow(4, 3)); facet.getCornerTable().addRow(new CornerTableRow(3, 13)); facet.getCornerTable().addRow(new CornerTableRow(4, -1)); facet.getCornerTable().addRow(new CornerTableRow(5, 7)); facet.getCornerTable().addRow(new CornerTableRow(4, -1)); facet.getCornerTable().addRow(new CornerTableRow(6, 9)); facet.getCornerTable().addRow(new CornerTableRow(5, -1)); model.addFacet(facet); return model; } /** * Unit test for CrossSectionZigZag visitor */ @Test public void CrossSectionZigZag() { Plane cuttingPlane = new Plane(new Vector3d(1, 0, 0), -0.5); MeshModel model = createModel(); CrossSectionZigZag cs = new CrossSectionZigZag(cuttingPlane); model.compute(cs); List<Point3d> points = cs.getPoints(); //They can be ordered two ways, check both Assertions.assertEquals(points.size(), 6); if (points.get(0).equals(new Point3d(0.5, 0, 0))) { Assertions.assertEquals(points.get(0), new Point3d(0.5, 0, 0)); Assertions.assertEquals(points.get(1), new Point3d(0.5, 0.5, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(4), new Point3d(0.5, 2, 0)); Assertions.assertEquals(points.get(5), new Point3d(0.5, 2.5, 0)); } else if (points.get(0).equals(new Point3d(0.5, 2.5, 0))) { Assertions.assertEquals(points.get(0), new Point3d(0.5, 2.5, 0)); Assertions.assertEquals(points.get(1), new Point3d(0.5, 2, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(4), new Point3d(0.5, 0.5, 0)); Assertions.assertEquals(points.get(5), new Point3d(0.5, 0, 0)); } else { Assertions.fail(); } } /** * Unit test for CrossSection visitor */ @Test public void CrossSection() { Plane cuttingPlane = new Plane(new Vector3d(1, 0, 0), -0.5); MeshModel model = createModel(); CrossSection cs = new CrossSection(cuttingPlane); model.compute(cs); List<Point3d> points = cs.getPoints(); //They can be ordered two ways, check both //Flaw of the non-zigzag design: it can't detect first and last intersection, //since it only controls edges between two triangles. Assertions.assertEquals(points.size(), 4); if (points.get(0).equals(new Point3d(0.5, 0.5, 0))) { Assertions.assertEquals(points.get(0), new Point3d(0.5, 0.5, 0)); Assertions.assertEquals(points.get(1), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 2, 0)); } else if (points.get(0).equals(new Point3d(0.5, 2, 0))) { Assertions.assertEquals(points.get(1), new Point3d(0.5, 2, 0)); Assertions.assertEquals(points.get(2), new Point3d(0.5, 1.5, 0)); Assertions.assertEquals(points.get(3), new Point3d(0.5, 1, 0)); Assertions.assertEquals(points.get(4), new Point3d(0.5, 0.5, 0)); } else { Assertions.fail(); } } }
GUI/src/main/java/cz/fidentis/analyst/symmetry/ProfilesAction.java +0 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,6 @@ package cz.fidentis.analyst.symmetry; import cz.fidentis.analyst.canvas.Canvas; import cz.fidentis.analyst.core.ControlPanelAction; import cz.fidentis.analyst.visitors.mesh.CrossSection; import cz.fidentis.analyst.visitors.mesh.CrossSectionZigZag; import org.openide.filesystems.FileChooserBuilder; Loading
MeshModel/src/main/java/cz/fidentis/analyst/mesh/core/MeshTriangle.java +5 −4 Original line number Diff line number Diff line Loading @@ -73,13 +73,14 @@ public class MeshTriangle implements Iterable<MeshPoint> { } @Override public boolean equals(Object obj) { if(this == obj) public boolean equals(Object obj) { if(this == obj) { return true; } if(obj == null || obj.getClass()!= this.getClass()) if(obj == null || obj.getClass()!= this.getClass()) { return false; } MeshTriangle mt = (MeshTriangle) obj; Loading