forked from miho/JCSG
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ensure Bounds can be serialized and stored
- Loading branch information
1 parent
bf2b992
commit 5822986
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,14 +39,32 @@ | |
import static java.lang.Math.min; | ||
import java.util.Random; | ||
|
||
import com.google.gson.annotations.Expose; | ||
|
||
// TODO: Auto-generated Javadoc | ||
/** | ||
* 3D Vector3d. | ||
* | ||
* @author Michael Hoffer <[email protected]> | ||
*/ | ||
public class Vector3d extends javax.vecmath.Vector3d{ | ||
public class Vector3d { | ||
/** | ||
* The x coordinate. | ||
*/ | ||
@Expose (serialize = true, deserialize = true) | ||
public double x; | ||
|
||
/** | ||
* The y coordinate. | ||
*/ | ||
@Expose (serialize = true, deserialize = true) | ||
public double y; | ||
|
||
/** | ||
* The z coordinate. | ||
*/ | ||
@Expose (serialize = true, deserialize = true) | ||
public double z; | ||
|
||
/** | ||
* | ||
|
@@ -67,7 +85,14 @@ public class Vector3d extends javax.vecmath.Vector3d{ | |
|
||
/** The Constant Z_ONE. */ | ||
public static final Vector3d Z_ONE = new Vector3d(0, 0, 1); | ||
|
||
/** | ||
* Returns the length of this vector. | ||
* @return the length of this vector | ||
*/ | ||
public double length() | ||
{ | ||
return Math.sqrt(this.x*this.x + this.y*this.y + this.z*this.z); | ||
} | ||
/** | ||
* Creates a new vector. | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package eu.mihosoft.vrl.v3d; | ||
|
||
import java.lang.reflect.Type; | ||
|
||
import org.junit.Test; | ||
|
||
import com.google.gson.Gson; | ||
import com.google.gson.GsonBuilder; | ||
import com.google.gson.reflect.TypeToken; | ||
|
||
public class GsonTest { | ||
@Test | ||
public void runGson() { | ||
Type TT_CaDoodleFile = new TypeToken<Bounds>() { | ||
}.getType(); | ||
Gson gson = new GsonBuilder().disableHtmlEscaping().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation() | ||
.create(); | ||
Bounds b = new Cube(100).toCSG().getBounds(); | ||
String json = gson.toJson(b); | ||
System.out.println(json); | ||
} | ||
} |