kopia lustrzana https://github.com/jameshball/osci-render
Add RELEASE markdown to store message on release pages and clean up CPP solver
rodzic
34d1e9116d
commit
bf0439ec47
|
@ -0,0 +1,3 @@
|
||||||
|
See the [changelog](https://github.com/jameshball/osci-render/blob/master/CHANGELOG.md) for changes to this version.
|
||||||
|
|
||||||
|
GPU VERSION - This is potentially unstable on Mac/Linux!! Please report any issues. If you hear nothing, but you see the program interface, then please let me know.
|
|
@ -22,17 +22,18 @@ jobs:
|
||||||
mvn -B jpackage:jpackage@win
|
mvn -B jpackage:jpackage@win
|
||||||
$version= mvn help:evaluate -Dexpression="project.version" -q -DforceStdout
|
$version= mvn help:evaluate -Dexpression="project.version" -q -DforceStdout
|
||||||
echo "VERSION=$version" >> $env:GITHUB_ENV
|
echo "VERSION=$version" >> $env:GITHUB_ENV
|
||||||
echo "See [/CHANGELOG.md](https://github.com/jameshball/osci-render/blob/master/CHANGELOG.md) for changes to this version.\nGPU VERSION - This is potentially unstable on Mac/Linux!! Please report any issues. If you hear nothing, but you see the program interface, then please let me know." > CHANGELOG
|
|
||||||
mv "target/lib/osci-render-$version.jar" "target/lib/osci-render-win-$version.jar"
|
mv "target/lib/osci-render-$version.jar" "target/lib/osci-render-win-$version.jar"
|
||||||
|
Compress-Archive -Path "blender/osci_render" -DestinationPath "target/lib/osci-render-blender-addon.zip"
|
||||||
ls target/lib/
|
ls target/lib/
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
with:
|
with:
|
||||||
body_path: CHANGELOG
|
body_path: .github/workflows/RELEASE.md
|
||||||
tag_name: v${{ env.VERSION }}
|
tag_name: v${{ env.VERSION }}
|
||||||
files: |
|
files: |
|
||||||
target/lib/osci-render-${{ env.VERSION }}.exe
|
target/lib/osci-render-${{ env.VERSION }}.exe
|
||||||
target/lib/osci-render-win-${{ env.VERSION }}.jar
|
target/lib/osci-render-win-${{ env.VERSION }}.jar
|
||||||
|
target/lib/osci-render-blender-addon.zip
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
GITHUB_REPOSITORY: jameshball/osci-render
|
GITHUB_REPOSITORY: jameshball/osci-render
|
||||||
|
|
|
@ -5,13 +5,14 @@ import com.mokiat.data.front.parser.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.jgrapht.Graph;
|
import org.jgrapht.Graph;
|
||||||
import org.jgrapht.alg.connectivity.ConnectivityInspector;
|
import org.jgrapht.alg.connectivity.ConnectivityInspector;
|
||||||
import org.jgrapht.alg.cycle.ChinesePostman;
|
import org.jgrapht.alg.cycle.ChinesePostman;
|
||||||
import org.jgrapht.graph.AsSubgraph;
|
import org.jgrapht.alg.shortestpath.DijkstraShortestPath;
|
||||||
import org.jgrapht.graph.DefaultUndirectedWeightedGraph;
|
import org.jgrapht.graph.*;
|
||||||
import org.jgrapht.graph.DefaultWeightedEdge;
|
|
||||||
|
|
||||||
public class WorldObject {
|
public class WorldObject {
|
||||||
|
|
||||||
|
@ -60,33 +61,89 @@ public class WorldObject {
|
||||||
return triangles;
|
return triangles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getDrawPath(Set<Line3D> edges) {
|
private Vector3 addEdgeToPath(Vector3 realSource, Graph<Vector3, DefaultEdge> graph, DefaultEdge edge, Set<DefaultEdge> visited, Set<DefaultEdge> notVisited, List<Vector3> path) {
|
||||||
Graph<Vector3, DefaultWeightedEdge> graph = new DefaultUndirectedWeightedGraph<>(
|
visited.add(edge);
|
||||||
DefaultWeightedEdge.class);
|
notVisited.remove(edge);
|
||||||
|
|
||||||
// Add all lines in frame to graph as vertices and edges. Edge weight is determined by the
|
Vector3 supposedSource = graph.getEdgeSource(edge);
|
||||||
// length of the line as this is directly proportional to draw time.
|
Vector3 supposedSink = graph.getEdgeTarget(edge);
|
||||||
for (Line3D edge : edges) {
|
// no guarantee on order since the graph is undirected
|
||||||
graph.addVertex(edge.getStart());
|
Vector3 source = supposedSource == realSource ? supposedSource : supposedSink;
|
||||||
graph.addVertex(edge.getEnd());
|
Vector3 sink = supposedSink == realSource ? supposedSource : supposedSink;
|
||||||
|
|
||||||
DefaultWeightedEdge weightedEdge = new DefaultWeightedEdge();
|
path.add(source);
|
||||||
graph.addEdge(edge.getStart(), edge.getEnd(), weightedEdge);
|
path.add(sink);
|
||||||
graph.addEdge(edge.getStart(), edge.getEnd());
|
|
||||||
graph.setEdgeWeight(weightedEdge, edge.getStart().distance(edge.getEnd()));
|
return sink;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unused but faster than chinese postman - not good at handling with lots of vertices
|
||||||
|
private void fasterPath(Graph<Vector3, DefaultEdge> graph, Set<Vector3> vertices) {
|
||||||
|
Set<DefaultEdge> visited = new HashSet<>();
|
||||||
|
List<Vector3> path = new ArrayList<>();
|
||||||
|
AsSubgraph<Vector3, DefaultEdge> subgraph = new AsSubgraph<>(graph, vertices);
|
||||||
|
Set<DefaultEdge> notVisited = new HashSet<>(subgraph.edgeSet());
|
||||||
|
|
||||||
|
DefaultEdge outgoingEdge = notVisited.stream().findFirst().orElseThrow();
|
||||||
|
Vector3 currentVertex = subgraph.getEdgeSource(outgoingEdge);
|
||||||
|
Vector3 startVertex = currentVertex;
|
||||||
|
visited.add(outgoingEdge);
|
||||||
|
notVisited.remove(outgoingEdge);
|
||||||
|
path.add(currentVertex);
|
||||||
|
path.add(subgraph.getEdgeTarget(outgoingEdge));
|
||||||
|
|
||||||
|
while (!notVisited.isEmpty()) {
|
||||||
|
Set<DefaultEdge> outgoing = subgraph.outgoingEdgesOf(currentVertex);
|
||||||
|
DefaultEdge newEdge = null;
|
||||||
|
for (DefaultEdge edge : outgoing) {
|
||||||
|
if (!visited.contains(edge)) {
|
||||||
|
newEdge = edge;
|
||||||
|
currentVertex = addEdgeToPath(currentVertex, subgraph, edge, visited, notVisited, path);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newEdge == null) {
|
||||||
|
newEdge = notVisited.stream().findFirst().orElseThrow();
|
||||||
|
Vector3 dest = subgraph.getEdgeSource(newEdge);
|
||||||
|
|
||||||
|
List<DefaultEdge> shortestPath = DijkstraShortestPath.findPathBetween(subgraph, currentVertex, dest).getEdgeList();
|
||||||
|
for (DefaultEdge edge : shortestPath) {
|
||||||
|
addEdgeToPath(currentVertex, subgraph, edge, visited, notVisited, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
currentVertex = dest;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectivityInspector<Vector3, DefaultWeightedEdge> inspector = new ConnectivityInspector<>(
|
// return back to start vertex
|
||||||
|
path.addAll(DijkstraShortestPath.findPathBetween(subgraph, currentVertex, startVertex).getVertexList());
|
||||||
|
vertexPath.add(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void getDrawPath(Set<Line3D> edges) {
|
||||||
|
Graph<Vector3, DefaultEdge> graph = new DefaultUndirectedGraph<>(DefaultEdge.class);
|
||||||
|
|
||||||
|
// Add all lines in frame to graph as vertices and edges.
|
||||||
|
Stream.concat(
|
||||||
|
edges.stream().map(Line3D::getStart),
|
||||||
|
edges.stream().map(Line3D::getEnd)
|
||||||
|
).distinct().forEach(graph::addVertex);
|
||||||
|
|
||||||
|
for (Line3D edge : edges) {
|
||||||
|
graph.addEdge(edge.getStart(), edge.getEnd());
|
||||||
|
}
|
||||||
|
|
||||||
|
ConnectivityInspector<Vector3, DefaultEdge> inspector = new ConnectivityInspector<>(
|
||||||
graph);
|
graph);
|
||||||
|
|
||||||
// Chinese Postman can only be performed on connected graphs, so iterate over all connected
|
// Chinese Postman can only be performed on connected graphs, so iterate over all connected
|
||||||
// sub-graphs.
|
// sub-graphs.
|
||||||
// TODO: parallelize?
|
vertexPath = inspector.connectedSets().parallelStream().map(vertices -> {
|
||||||
for (Set<Vector3> vertices : inspector.connectedSets()) {
|
ChinesePostman<Vector3, DefaultEdge> cp = new ChinesePostman<>();
|
||||||
AsSubgraph<Vector3, DefaultWeightedEdge> subgraph = new AsSubgraph<>(graph, vertices);
|
AsSubgraph<Vector3, DefaultEdge> subgraph = new AsSubgraph<>(graph, vertices);
|
||||||
ChinesePostman<Vector3, DefaultWeightedEdge> cp = new ChinesePostman<>();
|
return cp.getCPPSolution(subgraph).getVertexList();
|
||||||
vertexPath.add(cp.getCPPSolution(subgraph).getVertexList());
|
}).toList();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 getRotation() {
|
public Vector3 getRotation() {
|
||||||
|
|
Ładowanie…
Reference in New Issue