diff --git a/main/main.pde b/main/main.pde index 0a6478f..68a3072 100644 --- a/main/main.pde +++ b/main/main.pde @@ -9,6 +9,7 @@ Point removeEdgePoint; boolean colorEdge = false; Point colorEdgePoint; int colorFaceColor = 1; +HalfEdge colorFaceHalfEdge; public void setup() { size(800, 500); @@ -166,6 +167,11 @@ public void mousePressed() { } } } + if(mode == 4) { + float x = mouseX; + float y = mouseY; + colorFaceHalfEdge = list.getHalfEdgeBySinglePoint(x,y,10); + } } void mouseReleased() { float x = mouseX; @@ -188,41 +194,51 @@ void mouseReleased() { public void colorFace(float x, float y) { - HalfEdge h = list.getHalfEdgeBySinglePoint(x,y,20); - if(h != null) { - Face f = new Face(h, list); - f.printFace(); - switch (colorFaceColor) { - case 0: - f.daColoring(255,255,255,list, width, height); - break; - case 1: - f.daColoring(0,0,0,list, width, height); - break; - case 2: - f.daColoring(244, 67, 54,list, width, height); - break; - case 3: - f.daColoring(76, 175, 80,list, width, height); - break; - case 4: - f.daColoring(33, 150, 243,list,width,height); - break; - case 5: - f.daColoring(156, 39, 176,list,width,height); - break; - case 6: - f.daColoring(255, 235, 59,list,width,height); - break; - case 7: - f.daColoring(103, 58, 183,list,width,height); - break; - case 8: - f.daColoring(233, 30, 99,list,width,height); - break; - case 9: - f.daColoring(63, 81, 181,list,width,height); - break; + if(colorFaceHalfEdge != null) { + HalfEdge h = CompGeo.findCWR(colorFaceHalfEdge); + h.printFace(); + boolean b = CompGeo.inside(h, new Point(x,y), list.getFar()); + if(b) { + h = h.gettwin(); + //h = colorFaceHalfEdge; + } else { + //h = h.gettwin(); + //h = colorFaceHalfEdge.gettwin(); + } + if(h != null) { + Face f = new Face(h, list); + switch (colorFaceColor) { + case 0: + f.daColoring(255,255,255,list, width, height); + break; + case 1: + f.daColoring(0,0,0,list, width, height); + break; + case 2: + f.daColoring(244, 67, 54,list, width, height); + break; + case 3: + f.daColoring(76, 175, 80,list, width, height); + break; + case 4: + f.daColoring(33, 150, 243,list,width,height); + break; + case 5: + f.daColoring(156, 39, 176,list,width,height); + break; + case 6: + f.daColoring(255, 235, 59,list,width,height); + break; + case 7: + f.daColoring(103, 58, 183,list,width,height); + break; + case 8: + f.daColoring(233, 30, 99,list,width,height); + break; + case 9: + f.daColoring(63, 81, 181,list,width,height); + break; + } } } noFill(); @@ -340,10 +356,8 @@ public void removePointMode(float x, float y) { public void removeEdgeMode(float x, float y) { - System.out.println("entered remove edge"); - HalfEdge h = list.getHalfEdgeBySinglePoint(x,y,20); + HalfEdge h = list.getHalfEdgeBySinglePoint(x,y,10); if(h != null) { - System.out.println("h is not null"); h.Remove(); } }