Skip to content
Snippets Groups Projects
Commit f6eca2e3 authored by Powers, Peter M.'s avatar Powers, Peter M.
Browse files

added path to source tree

parent 7cbd9726
No related branches found
No related tags found
1 merge request!277mfd-tree and text updates
...@@ -363,6 +363,7 @@ abstract class ModelLoader { ...@@ -363,6 +363,7 @@ abstract class ModelLoader {
System.out.println(" tree: [" + feature.id + "] " + root.relativize(geojson)); System.out.println(" tree: [" + feature.id + "] " + root.relativize(geojson));
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(geojson)
.name(feature.name) .name(feature.name)
.id(feature.id) .id(feature.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -532,6 +533,7 @@ abstract class ModelLoader { ...@@ -532,6 +533,7 @@ abstract class ModelLoader {
} }
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(dir)
.name(name) .name(name)
.id(info.id) .id(info.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -751,6 +753,7 @@ abstract class ModelLoader { ...@@ -751,6 +753,7 @@ abstract class ModelLoader {
data.interfaceFeatureMap(readInterfaceFeatures(dir).orElseThrow()); data.interfaceFeatureMap(readInterfaceFeatures(dir).orElseThrow());
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(dir)
.name(name) .name(name)
.id(info.id) .id(info.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -853,6 +856,7 @@ abstract class ModelLoader { ...@@ -853,6 +856,7 @@ abstract class ModelLoader {
data.interfaceFeatureMap(readInterfaceFeatures(dir).orElseThrow()); data.interfaceFeatureMap(readInterfaceFeatures(dir).orElseThrow());
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(dir)
.name(name) .name(name)
.id(info.id) .id(info.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -958,6 +962,7 @@ abstract class ModelLoader { ...@@ -958,6 +962,7 @@ abstract class ModelLoader {
System.out.println(" tree: [" + info.id + "] " + name); System.out.println(" tree: [" + info.id + "] " + name);
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(dir)
.name(name) .name(name)
.id(info.id) .id(info.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -1084,6 +1089,7 @@ abstract class ModelLoader { ...@@ -1084,6 +1089,7 @@ abstract class ModelLoader {
System.out.println(" tree: [" + info.id + "] " + root.relativize(dir)); System.out.println(" tree: [" + info.id + "] " + root.relativize(dir));
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(dir)
.name(name) .name(name)
.id(info.id) .id(info.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -1206,6 +1212,7 @@ abstract class ModelLoader { ...@@ -1206,6 +1212,7 @@ abstract class ModelLoader {
Path.of(feature.name)); Path.of(feature.name));
SourceTree tree = SourceTree.builder() SourceTree tree = SourceTree.builder()
.path(geojson.getParent())
.name(feature.name) .name(feature.name)
.id(feature.id) .id(feature.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
...@@ -1230,6 +1237,7 @@ abstract class ModelLoader { ...@@ -1230,6 +1237,7 @@ abstract class ModelLoader {
System.out.println(" tree: [" + info.id + "] " + root.relativize(dir)); System.out.println(" tree: [" + info.id + "] " + root.relativize(dir));
SourceTree.Builder treeBuilder = SourceTree.builder() SourceTree.Builder treeBuilder = SourceTree.builder()
.path(dir)
.name(name) .name(name)
.id(info.id) .id(info.id)
.setting(data.tectonicSetting()) .setting(data.tectonicSetting())
......
...@@ -23,9 +23,7 @@ import com.google.common.base.Strings; ...@@ -23,9 +23,7 @@ import com.google.common.base.Strings;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.graph.EndpointPair; import com.google.common.graph.EndpointPair;
import com.google.common.graph.Graphs; import com.google.common.graph.Graphs;
import com.google.common.graph.ImmutableNetwork;
import com.google.common.graph.MutableNetwork; import com.google.common.graph.MutableNetwork;
import com.google.common.graph.Network;
import com.google.common.graph.NetworkBuilder; import com.google.common.graph.NetworkBuilder;
import com.google.common.graph.Traverser; import com.google.common.graph.Traverser;
...@@ -56,6 +54,7 @@ public class SourceTree extends ...@@ -56,6 +54,7 @@ public class SourceTree extends
* only one incident edge. Leaf weights are rounded to 8 decimal places. * only one incident edge. Leaf weights are rounded to 8 decimal places.
*/ */
private final Path path;
private final String name; private final String name;
private final int id; private final int id;
private final TectonicSetting setting; private final TectonicSetting setting;
...@@ -65,12 +64,10 @@ public class SourceTree extends ...@@ -65,12 +64,10 @@ public class SourceTree extends
private final Map<Leaf, List<Branch<Path>>> branches; private final Map<Leaf, List<Branch<Path>>> branches;
private final Map<Leaf, Double> weights; private final Map<Leaf, Double> weights;
private final List<Leaf> leaves; private final List<Leaf> leaves;
// private final Map<String, Leaf> leafIds; // private final Network<Node, Branch<Path>> tree;
// not currently used directly
private final Network<Node, Branch<Path>> tree;
SourceTree(Builder builder) { SourceTree(Builder builder) {
this.path = builder.path;
this.name = builder.name; this.name = builder.name;
this.id = builder.id; this.id = builder.id;
this.setting = builder.setting; this.setting = builder.setting;
...@@ -80,17 +77,14 @@ public class SourceTree extends ...@@ -80,17 +77,14 @@ public class SourceTree extends
this.branches = builder.branches; this.branches = builder.branches;
this.weights = builder.leafWeights; this.weights = builder.leafWeights;
this.leaves = builder.leaves; this.leaves = builder.leaves;
// this.leafIds = builder.leafIds; // this.tree = ImmutableNetwork.copyOf(builder.tree);
this.tree = ImmutableNetwork.copyOf(builder.tree); }
// List<String> branchStrs = branches.keySet().stream() /** The model path to this tree. */
// .map(this::branchString) public Path path() {
// .sorted() return path;
// .collect(toList());
// branchStrs.forEach(System.out::println);
} }
/** The name of this tree. */
@Override @Override
public String name() { public String name() {
return name; return name;
...@@ -174,7 +168,6 @@ public class SourceTree extends ...@@ -174,7 +168,6 @@ public class SourceTree extends
@Override @Override
public String toString() { public String toString() {
// nodes().toString() + NEWLINE +
return this.stream() return this.stream()
.sorted((b1, b2) -> b1.value().name().compareTo(b2.value().name())) .sorted((b1, b2) -> b1.value().name().compareTo(b2.value().name()))
.map(branch -> " ↳ " + .map(branch -> " ↳ " +
...@@ -197,6 +190,7 @@ public class SourceTree extends ...@@ -197,6 +190,7 @@ public class SourceTree extends
private int index = 1; private int index = 1;
/* Required fields. */ /* Required fields. */
private Path path;
private String name; private String name;
private Integer id; private Integer id;
private TectonicSetting setting; private TectonicSetting setting;
...@@ -211,10 +205,16 @@ public class SourceTree extends ...@@ -211,10 +205,16 @@ public class SourceTree extends
private Map<Leaf, List<Branch<Path>>> branches; private Map<Leaf, List<Branch<Path>>> branches;
private Map<Leaf, Double> leafWeights; private Map<Leaf, Double> leafWeights;
private List<Leaf> leaves; private List<Leaf> leaves;
// private Map<String, Leaf> leafIds;
private Builder() {} private Builder() {}
/* Set the model path to the root of the tree. */
Builder path(Path path) {
checkState(this.path == null, "Tree path already set");
this.path = checkNotNull(path);
return this;
}
/* Set the name of the tree. */ /* Set the name of the tree. */
Builder name(String name) { Builder name(String name) {
checkState(this.name == null, "Tree name already set"); checkState(this.name == null, "Tree name already set");
...@@ -295,6 +295,7 @@ public class SourceTree extends ...@@ -295,6 +295,7 @@ public class SourceTree extends
/* Create a new source tree from this builder. */ /* Create a new source tree from this builder. */
SourceTree build() { SourceTree build() {
checkNotNull(path);
checkNotNull(name); checkNotNull(name);
checkNotNull(id); checkNotNull(id);
checkNotNull(setting); checkNotNull(setting);
...@@ -348,10 +349,6 @@ public class SourceTree extends ...@@ -348,10 +349,6 @@ public class SourceTree extends
Entry::getKey, Entry::getKey,
e -> leafWeight(e.getValue()))); e -> leafWeight(e.getValue())));
leaves = List.copyOf(branches.keySet()); leaves = List.copyOf(branches.keySet());
// leafIds = leaves.stream().collect(
// toUnmodifiableMap(
// Leaf::toString,
// leaf -> leaf));
/* /*
* Assign weights to RuptureSets. It would be nice if a RuptureSet didn't * Assign weights to RuptureSets. It would be nice if a RuptureSet didn't
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment