Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
22bde48
Move map of parametrics into the CSGDatabase instance
madhephaestus Oct 4, 2025
e1e0544
fix the unit test
madhephaestus Oct 4, 2025
74bbf58
move operation code into the dataabase
madhephaestus Oct 4, 2025
3491011
remove the static API for cleaning
madhephaestus Oct 4, 2025
8259e60
exclude fields not explicatly serializable
madhephaestus Oct 5, 2025
c5e0b67
set which fields to expose, no recoursive inclusing with the instance
madhephaestus Oct 5, 2025
b8741d6
add save tothe test
madhephaestus Oct 5, 2025
c17329b
sync properties needs the dataabase to work
madhephaestus Oct 5, 2025
7bd4d7c
make the static and objects transparent foe serialization
madhephaestus Oct 5, 2025
a5e12b5
add prints
madhephaestus Oct 5, 2025
e454dcf
Use a unique ID as the comparitor for identity
madhephaestus Oct 5, 2025
0efc551
store the affine in a static structure as well as the rest of the
madhephaestus Oct 5, 2025
be36eba
store the affine in a static structure as well as the rest of the
madhephaestus Oct 5, 2025
2aaf159
syncing the parameters for cadoodle state
madhephaestus Oct 6, 2025
67f0b86
udate the cadoodle fetures
madhephaestus Oct 6, 2025
4a7e829
ensure all of the text extrude is set to not be a hole
madhephaestus Oct 7, 2025
4d94fcf
be careful how and when to save
madhephaestus Oct 7, 2025
bf5d7c5
make properties concurency safe
madhephaestus Oct 8, 2025
e79d98b
move the color set and add a print to motion lock set
madhephaestus Oct 8, 2025
50d87c1
Use a temp file for the CSGDatabase when in default mode
madhephaestus Oct 8, 2025
b491054
remove save database when it it empty
madhephaestus Oct 8, 2025
c49e178
just print exception and return early
madhephaestus Oct 8, 2025
da55c5d
refactor touching to use bounds, faster
madhephaestus Oct 9, 2025
7d28ab2
remove the exception from lock
madhephaestus Oct 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
322 changes: 193 additions & 129 deletions src/main/java/eu/mihosoft/vrl/v3d/CSG.java

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/main/java/eu/mihosoft/vrl/v3d/Cube.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,15 @@ public Cube(Vector3d center, Vector3d dimensions) {
public Cube(double w, double h, double d) {
this(Vector3d.ZERO, new Vector3d(w, h, d));
}
public Cube(LengthParameter w, LengthParameter h, LengthParameter d) {
this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
parametrics.add(w);
parametrics.add(h);
parametrics.add(d);
}
public Cube(LengthParameter size) {
this(size,size,size);
}
// public Cube(LengthParameter w, LengthParameter h, LengthParameter d) {
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
//// parametrics.add(w);
//// parametrics.add(h);
//// parametrics.add(d);
// }
// public Cube(LengthParameter size) {
// this(size,size,size);
// }
/* (non-Javadoc)
* @see eu.mihosoft.vrl.v3d.Primitive#toPolygons()
*/
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/eu/mihosoft/vrl/v3d/Cylinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,24 @@ public Cylinder(double startRadius, double endRadius, double height) {
this.startRadius = startRadius<MINIMUM_RADIUS?MINIMUM_RADIUS:startRadius;
this.endRadius = endRadius<MINIMUM_RADIUS?MINIMUM_RADIUS:endRadius;
}
public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height, int numSlices) {
this(startRadius.getMM(),endRadius.getMM(),height.getMM(),numSlices);
parametrics.add(startRadius);
parametrics.add(endRadius);
parametrics.add(height);
}
public Cylinder(LengthParameter startRadius, LengthParameter height, int numSlices) {
this(startRadius,startRadius,height,numSlices);
}
public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height) {
this(startRadius.getMM(),endRadius.getMM(),height.getMM());
parametrics.add(startRadius);
parametrics.add(endRadius);
parametrics.add(height);
}
public Cylinder(LengthParameter startRadius, LengthParameter height) {
this(startRadius,startRadius,height);
}
// public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height, int numSlices) {
// this(startRadius.getMM(),endRadius.getMM(),height.getMM(),numSlices);
//// parametrics.add(startRadius);
//// parametrics.add(endRadius);
//// parametrics.add(height);
// }
// public Cylinder(LengthParameter startRadius, LengthParameter height, int numSlices) {
// this(startRadius,startRadius,height,numSlices);
// }
// public Cylinder(LengthParameter startRadius, LengthParameter endRadius, LengthParameter height) {
// this(startRadius.getMM(),endRadius.getMM(),height.getMM());
//// parametrics.add(startRadius);
//// parametrics.add(endRadius);
//// parametrics.add(height);
// }
// public Cylinder(LengthParameter startRadius, LengthParameter height) {
// this(startRadius,startRadius,height);
// }
/* (non-Javadoc)
* @see eu.mihosoft.vrl.v3d.Primitive#toPolygons()
*/
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/eu/mihosoft/vrl/v3d/Primitive.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
* @author Michael Hoffer &lt;info@michaelhoffer.de&gt;
*/
public abstract class Primitive implements ItoCSG{
ArrayList<Parameter> parametrics=new ArrayList<>();
// ArrayList<Parameter> parametrics=new ArrayList<>();


/**
Expand All @@ -62,9 +62,9 @@ public abstract class Primitive implements ItoCSG{
*/
public CSG toCSG() {
CSG tmp = CSG.fromPolygons(getProperties(),new ArrayList<>(toPolygons()));
if(parametrics!=null)
for(Parameter p:parametrics)
tmp.setParameter(p);
// if(parametrics!=null)
// for(Parameter p:parametrics)
// tmp.setParameter(p);
//tmp.triangulate();
return tmp;
}
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/eu/mihosoft/vrl/v3d/PropertyStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import javafx.scene.paint.Color;

Expand All @@ -50,8 +51,10 @@
*/
public class PropertyStorage implements Serializable{

/** The map. */
private final Map<String, Object> map = new HashMap<>();
private static final long serialVersionUID = 1460815261025940141L;

/** The map. */
private final ConcurrentHashMap<String, Object> map = new ConcurrentHashMap<>();

/** The Constant colors. */
private static final Color[] colors = {
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/eu/mihosoft/vrl/v3d/RoundedCube.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ public RoundedCube(double size) {
}


public RoundedCube(LengthParameter w, LengthParameter h, LengthParameter d) {
this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
parametrics.add(w);
parametrics.add(h);
parametrics.add(d);
}
public RoundedCube(LengthParameter size) {
this(size,size,size);
}
// public RoundedCube(LengthParameter w, LengthParameter h, LengthParameter d) {
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
// parametrics.add(w);
// parametrics.add(h);
// parametrics.add(d);
// }
// public RoundedCube(LengthParameter size) {
// this(size,size,size);
// }

/**
* Constructor. Creates a new rounded cuboid with the specified center and
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/eu/mihosoft/vrl/v3d/Sphere.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ public Sphere(double radius) {
// this(Vector3d.ZERO, new Vector3d(w.getMM(), h.getMM(), d.getMM()));
//
// }
public Sphere(LengthParameter size) {
this(size.getMM());
parametrics.add(size);
}
public Sphere(LengthParameter size, int numSlices, int numStacks) {
this(size.getMM(), numSlices, numStacks);
parametrics.add(size);
}
// public Sphere(LengthParameter size) {
// this(size.getMM());
// parametrics.add(size);
// }
// public Sphere(LengthParameter size, int numSlices, int numStacks) {
// this(size.getMM(), numSlices, numStacks);
// parametrics.add(size);
// }
/**
* Constructor. Creates a sphere with the specified radius, number of slices
* and stacks.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/eu/mihosoft/vrl/v3d/TextExtrude.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ private TextExtrude(String text, Font font, double dir) {
// subtract.getElements().forEach(this::getPoints);

for (int i = 0; i < sections.size(); i++) {
sections.get(i).setIsHole(false);
for (CSG h : holes) {
try {
if (sections.get(i).isBoundsTouching(h)) {
// println "Hole found "
CSG nl = sections.get(i).difference(h);

CSG nl = sections.get(i).difference(h).setIsHole(false);
sections.set(i, nl);
}
} catch (Exception e) {
Expand Down
121 changes: 67 additions & 54 deletions src/main/java/eu/mihosoft/vrl/v3d/parametrics/CSGDatabase.java
Original file line number Diff line number Diff line change
@@ -1,68 +1,81 @@
package eu.mihosoft.vrl.v3d.parametrics;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.util.HashMap;
import java.util.concurrent.CopyOnWriteArrayList;

public class CSGDatabase {
private static CSGDatabaseInstance instance = new CSGDatabaseInstance(new File("CSGdatabase.json"));

public static void set(String key, Parameter value) {
getInstance().set(key, value);
}

public static Parameter get(String key) {
return getInstance().get(key);
}

public static void clear() {
getInstance().clear();
}

public static void addParameterListener(String key, IParameterChanged l) {
getInstance().addParameterListener(key, l);
}

public static void clearParameterListeners(String key) {
getInstance().clearParameterListeners(key);
}

public static void removeParameterListener(String key, IParameterChanged l) {
getInstance().removeParameterListener(key, l);
}

public static CopyOnWriteArrayList<IParameterChanged> getParamListeners(String key) {
return getInstance().getParamListeners(key);
}

public static void delete(String key) {
getInstance().delete(key);
}

public static void loadDatabaseFromFile(File f) {
getInstance().loadDatabaseFromFile(f);
}

public static String getDataBaseString() {
return getInstance().getDataBaseString();
}

public static void saveDatabase() {
getInstance().saveDatabase();
}


public static File getDbFile() {
return getInstance().getDbFile();
}
import eu.mihosoft.vrl.v3d.CSG;

public static void reLoadDbFile() {
getInstance().reLoadDbFile();
}
public class CSGDatabase {
private static CSGDatabaseInstance instance ;
// public static void set(String key, Parameter value) {
// getInstance().set(key, value);
// }
//
// public static Parameter get(String key) {
// return getInstance().get(key);
// }
//
// public static void clear() {
// getInstance().clear();
// }
//
// public static void addParameterListener(String key, IParameterChanged l) {
// getInstance().addParameterListener(key, l);
// }
//
// public static void clearParameterListeners(String key) {
// getInstance().clearParameterListeners(key);
// }
//
// public static void removeParameterListener(String key, IParameterChanged l) {
// getInstance().removeParameterListener(key, l);
// }
//
// public static CopyOnWriteArrayList<IParameterChanged> getParamListeners(String key) {
// return getInstance().getParamListeners(key);
// }
//
// public static void delete(String key) {
// getInstance().delete(key);
// }
//
// public static void loadDatabaseFromFile(File f) {
// getInstance().loadDatabaseFromFile(f);
// }
//
// public static String getDataBaseString() {
// return getInstance().getDataBaseString();
// }
//
// public static void saveDatabase() {
// getInstance().saveDatabase();
// }
//
//
// public static File getDbFile() {
// return getInstance().getDbFile();
// }
//
// public static void reLoadDbFile() {
// getInstance().reLoadDbFile();
// }

public static CSGDatabaseInstance getInstance() {
new Exception("Depricated database access!").printStackTrace();
if(instance==null) {
try {
instance = new CSGDatabaseInstance( Files.createTempFile("CSGDatabase", ".json").toFile());
} catch (IOException e) {
throw new RuntimeException(e);
}

}
return instance;
}

public static void setInstance(CSGDatabaseInstance instance) {
System.out.println("\n\nCSG Instance Set here to "+instance.getDbFile().getAbsolutePath()+"\n\n");
CSGDatabase.instance = instance;
Expand Down
Loading