2016年6月26日 星期日

stl loader using j3d package


STLA Files
ASCII stereolithography files


STLA is a data directory which contains examples of "ASCII STL" files. "STL" stands for "stereolithography", and indicates that the primary purpose of this file format is to describe the shape of a 3D stationary object. Stereolithography is a means of creating physical 3D models of such objects, using resin or carefully cut and joined pieces of paper.


ref : http://people.sc.fsu.edu/~jburkardt/data/stla/stla.html

Class GeometryInfo


he GeometryInfo object holds data for processing by the Java3D geometry utility tools.

The NormalGenerator adds normals to geometry without normals.The Stripifier combines adjacent triangles into triangle strips for more efficent rendering.



example:

GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY); // initialize the geometry info here // generate normals NormalGenerator ng = new NormalGenerator(); ng.generateNormals(gi); // stripify Stripifier st = new Stripifier(); st.stripify(gi); GeometryArray result = gi.getGeometryArray();


Class Shape3D



The Shape3D leaf node specifies all geometric objects. It contains a list of one or more Geometry component objects and a single Appearance component object. The geometry objects define the shape node's geometric data. The appearance object specifies that object's appearance attributes, including color, material, texture, and so on.
The list of geometry objects must all be of the same equivalence class, that is, the same basic type of primitive. For subclasses of GeometryArray, all point objects are equivalent, all line objects are equivalent, and all polygon objects are equivalent. For other subclasses of Geometry, only objects of the same subclass are equivalent. The equivalence classes are as follows:
  • GeometryArray (point): [Indexed]PointArray
  • GeometryArray (line): [Indexed]{LineArray, LineStripArray}
  • GeometryArray (polygon): [Indexed]{TriangleArray, TriangleStripArray, TriangleFanArray, QuadArray}
  • CompressedGeometry
  • Raster
  • Text3D

2016年3月28日 星期一

java.util.prefs.WindowsPreferences WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5

Dennis answer is correct. However I would like to explain the solution in a bit more detailled way (for Windows User):
  1. Go into your Start Menu and type regedit into the search field.
  2. Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft
  3. Right click on the JavaSoft folder and click on New -> Key
  4. Name the new Key Prefs and everything should work.

java.lang.outofmemoryerror java heap space eclipse


Solution :

 

1. Solution – VM arguments

On Eclipse menu, clicks Run -> Run Configurations.., select the Java application you want to run, clicks on theArguments tab, update the VM arguments with the following options
Bash
-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size
For example, -Xms512M -Xmx1024M
eclipse-out-of-memory

2. Mistake – eclipse.ini

The memory settings in eclipse.ini is allocated to Eclipse IDE only, not the program you want to run. A very common mistake is updated the heap size in eclipse.ini, and expects it to solve above out of memory problem.
Note
The Java application, Ant / Maven build scripts, or unit test cases, are run as an external tool from Eclipse, and it does not inherit the VM settings in eclipse.ini.
But, if your Eclipse IDE is always crashed by no reason, you can try to increase the heap size and perm gen ineclipse.ini.
/Users/mkyong/Downloads/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
Bash
 
 -startu
 openFile
 -showsplash
        //...
 -XX:MaxPermSize=512m
 -Xms512m
 -Xmx1024m
        //...
 -Xdock:icon=../Resources/Eclipse.icns
 -XstartOnFirstThread
P.S eclipse.ini is located in the Eclipse installation folder.

Ref : http://www.mkyong.com/eclipse/eclipse-java-lang-outofmemoryerror-java-heap-space/

2016年3月27日 星期日

2016年3月24日 星期四

sla 3d printer 研究筆記 : printObject


 private void printObject() throws Exception {
        System.out.println("Printing Object layers");

        CommandBase cmd;
        SVGElement element;

        // Object layers
        // loop layers
        int total = Consts.sFLAG_DEBUG_MODE ? Math.min(6, root.getNumChildren()) : root.getNumChildren();
        int layerSteps = printingInfo.getStepsPerLayer();
        int layerExpoTime = printingInfo.getLayerExpoTimeInMillis();

        int upSteps = printingInfo.getUpLiftSteps();
        int downSteps = upSteps - layerSteps;
        System.out.println(String.format("Object layers upSteps: %d, layerSteps: %d, downSteps: %d",
                upSteps, layerSteps, downSteps));

        for (int i = 1; i < total; i++) {
            layerIndex = i;

            // Go up
           
            cmd = PrinterScriptFactory.generatePlatformMovement(PlatformMovement.UP, upSteps);
            processCommand(cmd);

            // Wait a little bit
            cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
            processCommand(cmd);

            // Go down
            cmd = PrinterScriptFactory.generatePlatformMovement(PlatformMovement.DOWN, downSteps);
            processCommand(cmd);
           
            // Exposure layer
            element = children.get(i);
            publish(element);
           
           
            for (int restExpoTime = layerExpoTime; restExpoTime > 0; restExpoTime -= Consts.MAX_EXPOSURE_MILLIS) {
                int expoTime = restExpoTime >= Consts.MAX_EXPOSURE_MILLIS ? Consts.MAX_EXPOSURE_MILLIS : restExpoTime;
                cmd = PrinterScriptFactory.generatePauseCommand(expoTime);
                processCommand(cmd, expoTime);
            }
           

            publish(layerCircle);
            cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
            processCommand(cmd);
        }
    }