Thread: [Bprocessor-commit] model/src/net/sourceforge/bprocessor/model Edge.java, 1.78, 1.79 Geometry.java,
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-03-28 09:00:48
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv14493/src/net/sourceforge/bprocessor/model Modified Files: Edge.java Geometry.java Log Message: made som changes to find the right space assignment when extruding a contour, seems to work fabulous Index: Edge.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Edge.java,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** Edge.java 27 Mar 2007 17:18:11 -0000 1.78 --- Edge.java 28 Mar 2007 09:00:47 -0000 1.79 *************** *** 1001,1052 **** surfaceedges.add(e); Surface side = new Surface(surfaceedges); ! List<Surface> surfs = Geometry.neighbourAroundEdge(side, e); if (surfs != null) { - CoordinateSystem cs = side.coordinateSystem(); - log.info("Side coord " + cs); //for front domain Surface inside = surfs.get(0); ! int dir1 = inside.direction(cs); ! int dir2 = side.direction(cs); ! if (dir1 == Surface.PARALLEL) { ! if (cs.translate(e.getFrom().add(inside.normal())).getY() < 0) { ! if (dir2 == Surface.LEFT) { ! side.setFrontDomain(inside.getBackDomain()); ! } else { ! side.setBackDomain(inside.getBackDomain()); ! } } else { ! if (dir2 == Surface.LEFT) { ! side.setFrontDomain(inside.getFrontDomain()); ! } else { ! side.setBackDomain(inside.getFrontDomain()); ! } } - } else if (dir1 == dir2) { - side.setFrontDomain(inside.getFrontDomain()); } else { ! side.setFrontDomain(inside.getBackDomain()); } //for back domain Surface outside = surfs.get(surfs.size() - 1); ! dir1 = outside.direction(cs); ! if (dir1 == Surface.PARALLEL) { ! /*if (cs.translate(e.getFrom().add(outside.normal())).getY() < 0) { ! if (dir2 == Surface.RIGHT) { ! side.setBackDomain(outside.getBackDomain()); ! } else { ! side.setFrontDomain(outside.getBackDomain()); ! } } else { ! if (dir2 == Surface.RIGHT) { ! side.setBackDomain(outside.getFrontDomain()); ! } else { ! side.setFrontDomain(outside.getFrontDomain()); ! } ! }*/ ! } else if (dir1 == dir2) { ! side.setBackDomain(outside.getBackDomain()); } else { ! side.setBackDomain(outside.getFrontDomain()); } } --- 1001,1040 ---- surfaceedges.add(e); Surface side = new Surface(surfaceedges); ! Map<Surface, Double> surToAngle = new HashMap<Surface, Double>(); ! List<Surface> surfs = Geometry.neighbourAroundEdge(side, e, surToAngle); if (surfs != null) { //for front domain Surface inside = surfs.get(0); ! double angleToInside = surToAngle.get(inside); ! if (inside.normal().dot(direction) >= 0) { ! if (angleToInside <= Math.PI) { ! side.setFrontDomain(inside.getFrontDomain()); } else { ! side.setFrontDomain(inside.getBackDomain()); } } else { ! if (angleToInside <= Math.PI) { ! side.setFrontDomain(inside.getBackDomain()); ! } else { ! side.setFrontDomain(inside.getFrontDomain()); ! } } //for back domain Surface outside = surfs.get(surfs.size() - 1); ! double angleToOutside = surToAngle.get(outside); ! double dotout = outside.normal().dot(direction); ! if (dotout >= 0) { ! //the surface to get backdomain from have front to us if angle are greater that PI ! if (angleToOutside > Math.PI) { ! side.setBackDomain(outside.getFrontDomain()); } else { ! side.setBackDomain(outside.getBackDomain()); ! } } else { ! if (angleToOutside > Math.PI) { ! side.setBackDomain(outside.getBackDomain()); ! } else { ! side.setBackDomain(outside.getFrontDomain()); ! } } } Index: Geometry.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/Geometry.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** Geometry.java 27 Mar 2007 17:18:11 -0000 1.47 --- Geometry.java 28 Mar 2007 09:00:47 -0000 1.48 *************** *** 509,515 **** * @param from the surface to find neighbours for. * @param edge the shared edge * @return the neighbour surface ordered after angle to from. */ ! public static List<Surface> neighbourAroundEdge(Surface from, Edge edge) { //Building a coordinate system: Vertex n = edge.getDirection(); --- 509,519 ---- * @param from the surface to find neighbours for. * @param edge the shared edge + * @param surToAngle a map from surface to angle + * (null can be given as argument if info in not needed) * @return the neighbour surface ordered after angle to from. */ ! public static List<Surface> neighbourAroundEdge(Surface from, ! Edge edge, ! Map<Surface, Double> surToAngle) { //Building a coordinate system: Vertex n = edge.getDirection(); *************** *** 527,532 **** Plane p = new Plane(n.getX(), n.getY(), n.getZ(), sharedVertex); ! Vertex projVertex = p.project(adjacentVertex); ! Vertex i = projVertex.minus(sharedVertex); i.normalize(); CoordinateSystem cs = new CoordinateSystem(i, j , n, sharedVertex); --- 531,536 ---- Plane p = new Plane(n.getX(), n.getY(), n.getZ(), sharedVertex); ! Vertex projVertex = p.project(adjacentVertex.minus(sharedVertex)); ! Vertex i = projVertex; i.normalize(); CoordinateSystem cs = new CoordinateSystem(i, j , n, sharedVertex); *************** *** 534,540 **** //Project.getInstance().getActiveSpace().add(cs); List<Surface> neighbours = new LinkedList<Surface>(edge.getSurfaces()); ! Map<Surface, Double> surToAngle = new HashMap<Surface, Double>(); //make pre calculations finding all angles to surfaces and filling map ! for (Surface s : edge.getSurfaces()) { if (s != from) { Vertex notShared = findNonparallelVertex(s, edge); --- 538,547 ---- //Project.getInstance().getActiveSpace().add(cs); List<Surface> neighbours = new LinkedList<Surface>(edge.getSurfaces()); ! if (surToAngle == null) { ! surToAngle = new HashMap<Surface, Double>(); ! } //make pre calculations finding all angles to surfaces and filling map ! Set<Surface> surs = edge.getSurfaces(); ! for (Surface s : surs) { if (s != from) { Vertex notShared = findNonparallelVertex(s, edge); *************** *** 542,545 **** --- 549,556 ---- double angle = Geometry.findAngle(notShared, cs); surToAngle.put(s, angle); + if (s.getExterior() != null) { + surToAngle.put(s.getExterior(), (Math.PI + angle) % (2 * Math.PI)); + neighbours.add(s.getExterior()); + } } } |