示例#1
0
 private static Map<Geometry, SceneGraphComponent> getGeometries_R(
     SceneGraphComponent root, SceneGraphPath p) {
   p.push(root);
   Map<Geometry, SceneGraphComponent> r = new HashMap<Geometry, SceneGraphComponent>();
   if (root.getGeometry() != null) {
     Geometry g = root.getGeometry();
     if (g instanceof PointSet) { // remove vertex normals if flat shading
       PointSet pSet = (PointSet) g;
       if (pSet.getVertexAttributes().containsAttribute(Attribute.NORMALS)) {
         EffectiveAppearance ea = EffectiveAppearance.create(p);
         DefaultGeometryShader dgs = ShaderUtility.createDefaultGeometryShader(ea);
         DefaultPolygonShader ps = (DefaultPolygonShader) dgs.getPolygonShader();
         if (!ps.getSmoothShading()) {
           pSet.setVertexAttributes(Attribute.NORMALS, null);
         }
       }
     }
     r.put(root.getGeometry(), root);
   }
   for (int i = 0; i < root.getChildComponentCount(); i++) {
     Map<Geometry, SceneGraphComponent> subList = getGeometries_R(root.getChildComponent(i), p);
     if (subList.size() != 0) {
       r.putAll(subList);
     }
   }
   p.pop();
   return r;
 }
 public void visit(PointSet p) {
   // Following code should only be activated if we have listeners installed to update
   // the bounding box when it goes out of date.
   if (checkForBoundingBox(p)) return;
   Object domain = p.getGeometryAttributes(GeometryUtility.HEIGHT_FIELD_SHAPE);
   if (domain != null && domain instanceof Rectangle2D) {
     Rectangle2D box = (Rectangle2D) domain;
     double[][] data = p.getVertexAttributes(Attribute.COORDINATES).toDoubleArrayArray(null);
     double[][] zbnds = new double[2][1];
     Rn.calculateBounds(zbnds, data);
     double[][] xyzbnds = new double[2][3];
     xyzbnds[0][0] = box.getMinX();
     xyzbnds[1][0] = box.getMaxX();
     xyzbnds[0][1] = box.getMinY();
     xyzbnds[1][1] = box.getMaxY();
     xyzbnds[0][2] = zbnds[0][0];
     xyzbnds[1][2] = zbnds[1][0];
     if (Double.isNaN(xyzbnds[0][0])) throw new IllegalStateException("Nan");
     Rectangle3D box3 = new Rectangle3D(xyzbnds);
     unionBox(box3);
     return;
   }
   DataList vv = p.getVertexAttributes(Attribute.COORDINATES);
   if (vv == null) {
     // signal error
     return;
   }
   unionVectors(vv);
 }