Package org.jwildfire.create.tina.meshgen.marchingcubes

Examples of org.jwildfire.create.tina.meshgen.marchingcubes.GenerateFacesThread


    }

    int zmin = -1;
    int zPerThread = zsize / threadCount;
    for (int i = 0; i < threadCount; i++) {
      GenerateFacesThread thread = new GenerateFacesThread(pSampler, pSeekValue);
      threads.add(thread);
      thread.setZmin(zmin);
      thread.setWithNormals(withNormals);
      thread.setProgressUpdater(progressUpdater, totalProgress);
      int zmax = zmin + zPerThread - 1;
      if (zmax >= pSampler.getStackZSize()) {
        zmax = pSampler.getStackZSize() - 1;
      }
      thread.setZmin(zmin);
      thread.setZmax(zmax);
      zmin += zPerThread;
      new Thread(thread).start();
    }

    while (true) {
      boolean finished = true;
      for (int i = threads.size() - 1; i >= 0; i--) {
        GenerateFacesThread thread = threads.get(i);
        if (!thread.isDone()) {
          finished = false;
          break;
        }
      }
      try {
        Thread.sleep(1);
      }
      catch (InterruptedException e) {
        e.printStackTrace();
      }
      if (finished) {
        break;
      }
    }

    // Merge result
    List<Point> faces = new ArrayList<Point>();
    List<Point> normals;
    if (withNormals) {
      normals = new ArrayList<Point>();
      for (GenerateFacesThread thread : threads) {
        faces.addAll(thread.getFaces());
        normals.addAll(thread.getNormals());
      }
    }
    else {
      normals = null;
      for (GenerateFacesThread thread : threads) {
        faces.addAll(thread.getFaces());
      }
    }
    return new RawFaces(faces, normals);
  }
View Full Code Here

TOP

Related Classes of org.jwildfire.create.tina.meshgen.marchingcubes.GenerateFacesThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.