Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Simplified project structure. Added loading information frame for que…
Browse files Browse the repository at this point in the history
…ry executions. Fixed a few bugs.
  • Loading branch information
Vlad-Adrian Moglan committed Feb 4, 2019
1 parent 9d10ff2 commit 24a235f
Show file tree
Hide file tree
Showing 25 changed files with 832 additions and 749 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Semviz

![Tag](https://img.shields.io/badge/tag-v1.0.0-blue.svg) [![Build Status](https://travis-ci.com/vmoglan/semviz.svg?branch=master)](https://travis-ci.org/vmoglan/semviz)
![Tag](https://img.shields.io/badge/tag-v1.0.1-blue.svg) [![Build Status](https://travis-ci.com/vmoglan/semviz.svg?branch=master)](https://travis-ci.org/vmoglan/semviz)

## Main objective

Expand All @@ -24,7 +24,7 @@ The display of 3D objects must be done in three ways:

### Setup

You can download the Semviz all-in-one `.jar` at this [link](https://github.com/vmoglan/semviz/releases/download/v1.0.0/semviz-1.0.0.jar). There is no installation process, just make sure you have Java 8 installed on your marchine and then you should be able to run the file.
You can download the Semviz all-in-one `.jar` at this [link](https://github.com/vmoglan/semviz/releases/download/v1.0.1/semviz-1.0.1.jar). There is no installation process, just make sure you have Java 8 installed on your marchine and then you should be able to run the file.

### Initialization

Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.movlad</groupId>
<artifactId>semviz</artifactId>
<name>Semviz</name>
<version>1.0.0</version>
<version>1.0.1</version>
<description>A viewer for semantically annotated three-dimensional point clouds.</description>
<build>
<plugins>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.movlad</groupId>
<artifactId>semviz</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<name>Semviz</name>
<description>A viewer for semantically annotated three-dimensional point clouds.</description>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@
public final class CommandNavigationController extends Controller {

private final List<String> commands;
private int selectedIndex;
private int selectedCommandIndex;

public CommandNavigationController() {
commands = new ArrayList<>();

commands.add("");

selectedIndex = commands.size() - 1;
}

public String getSelection() {
return commands.get(selectedIndex);
selectedCommandIndex = commands.size() - 1;
}

/**
Expand All @@ -30,31 +26,35 @@ public String getSelection() {
*/
public void enter(String command) {
commands.add(commands.size() - 1, command);

changeSupport.firePropertyChange("CommandLaunch", null, command);
}

/**
* Selects previous command.
*/
public void up() {
if (selectedIndex - 1 >= 0) {
String prev = getSelection();
if (selectedCommandIndex - 1 >= 0) {
String prev = commands.get(selectedCommandIndex);

selectedIndex--;
selectedCommandIndex--;

changeSupport.firePropertyChange("CommandNavigationUp", prev, getSelection());
changeSupport.firePropertyChange("CommandNavigationUp", prev,
commands.get(selectedCommandIndex));
}
}

/**
* Selects a more recent command.
*/
public void down() {
if (selectedIndex + 1 < commands.size()) {
String prev = getSelection();
if (selectedCommandIndex + 1 < commands.size()) {
String prev = commands.get(selectedCommandIndex);

selectedIndex++;
selectedCommandIndex++;

changeSupport.firePropertyChange("CommandNavigationDown", prev, getSelection());
changeSupport.firePropertyChange("CommandNavigationDown", prev,
commands.get(selectedCommandIndex));
}
}

Expand Down

This file was deleted.

99 changes: 99 additions & 0 deletions src/main/java/com/movlad/semviz/application/SQMController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package com.movlad.semviz.application;

import com.movlad.semviz.core.io.InvalidDirectoryException;
import com.movlad.semviz.core.sqm.SQM;
import com.movlad.semviz.core.sqm.SemanticCloudDescription;
import java.io.FileNotFoundException;
import java.nio.file.NotDirectoryException;
import java.util.List;

/**
* Controller for the Semviz Query Manager.
*/
public final class SQMController extends Controller {

private static SQMController instance = null;
private final SQM sqm; // the unique instance of the Semviz Query Manager
private List<SemanticCloudDescription> descriptions; // the list of current query results
private int selectedDescriptionIndex; // the currently selected Description

private SQMController() {
sqm = SQM.getInstance();
selectedDescriptionIndex = -1;
}

public static SQMController getInstance() {
if (instance == null) {
instance = new SQMController();
}

return instance;
}

/**
* @return the currently selected description
*/
public SemanticCloudDescription getSelectedDescription() {
if (selectedDescriptionIndex > -1
&& selectedDescriptionIndex < descriptions.size()) {
return descriptions.get(selectedDescriptionIndex);
}

return null;
}

/**
* Given a Semviz directory, this method loads a Semviz directory into the
* Semviz query manager singleton.
*
* @param path is the path to the Semviz directory
*/
public void load(String path) {
if (descriptions != null) {
descriptions.clear();
}

try {
sqm.load(path);

changeSupport.firePropertyChange("SQMLoadSuccess", null, sqm);
} catch (InvalidDirectoryException | NotDirectoryException | FileNotFoundException e) {
changeSupport.firePropertyChange("SQMLoadError", null, e.getMessage());
}
}

/**
* Executes a query on the currently loaded Semviz directory.
*
* @param queryString is the string of the query to be executed
*/
public void exec(String queryString) {
List<SemanticCloudDescription> prevDescriptions = descriptions;

try {
changeSupport.firePropertyChange("SQMExecutionStarted", null, sqm);

descriptions = sqm.exec(queryString);

changeSupport.firePropertyChange("SQMFailCountChanged", null, sqm.getFailCount());
changeSupport.firePropertyChange("SQMExecutionSuccess", prevDescriptions, descriptions);
} catch (Exception e) {
changeSupport.firePropertyChange("SQMExecutionError", null, e.getMessage());
}
}

/**
* Sets the selected semantic cloud description index.
*
* @param i is the index of the selected description
*/
public void setSelectedDescriptionIndex(int i) {
int prev = selectedDescriptionIndex;

selectedDescriptionIndex = i;

changeSupport.firePropertyChange("SQMDescriptionIndexChanged", prev,
selectedDescriptionIndex);
}

}
74 changes: 63 additions & 11 deletions src/main/java/com/movlad/semviz/application/SceneController.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package com.movlad.semviz.application;

import com.github.quickhull3d.Point3d;
import com.github.quickhull3d.Vector3d;
import com.movlad.semviz.core.graphics.Geometry;
import com.movlad.semviz.core.graphics.GeometryFactory;
import com.movlad.semviz.core.graphics.Scene;
import com.movlad.semviz.core.graphics.SceneObject;
import com.movlad.semviz.core.math.geometry.BoundingBox;
import com.movlad.semviz.core.math.geometry.PointCloud;
import com.movlad.semviz.core.semantic.SemanticCloud;
import com.movlad.semviz.core.sqm.SemanticCloudDescription;
import java.util.ArrayList;
import java.util.List;
import org.joml.Vector3f;

/**
* Controller for the modification of a {@code Scene} and view in general.
Expand Down Expand Up @@ -38,16 +41,18 @@ public Scene getScene() {
/**
* Loads the base geometry for each cloud in a semantic cloud
*
* @param cloud is the cloud containing the clusters
* @param descriptions
*/
public void loadDisplayInformation(SemanticCloud cloud) {
public void load(List<SemanticCloudDescription> descriptions) {
resetDisplayInformation();
center(descriptions);
rotate(descriptions);

views = new SceneObject[cloud.size()][3];
selectedViewIndices = new int[cloud.size()];
views = new SceneObject[descriptions.size()][3];
selectedViewIndices = new int[descriptions.size()];

for (int i = 0; i < cloud.size(); i++) {
clusters.add(cloud.get(i));
for (int i = 0; i < descriptions.size(); i++) {
clusters.add(descriptions.get(i).getCloud());

SceneObject object = new SceneObject(GeometryFactory.getInstance()
.createHighResolutionCloudGeometry(clusters.get(i)));
Expand Down Expand Up @@ -87,8 +92,6 @@ public int getSelectedViewIndex(int i) {
* @param view is the view selection for the cluster at index {@code i}
*/
public void setSelectedViewIndex(int i, int view) {
int prev = selectedViewIndices[i];

selectedViewIndices[i] = view;

if (views[i][view] == null) {
Expand Down Expand Up @@ -117,7 +120,7 @@ public void setSelectedViewIndex(int i, int view) {

scene.replace(i, object);

changeSupport.firePropertyChange("SelectedViewIndexUpdate", prev, selectedViewIndices[i]);
changeSupport.firePropertyChange("SceneViewIndexUpdate", null, scene);
}

/**
Expand All @@ -135,7 +138,56 @@ public void setDisplaySelection(int i) {
scene.add(new SceneObject("selection", geometry));
}

changeSupport.firePropertyChange("SceneSelectionUpdate", null, i);
changeSupport.firePropertyChange("SceneSelectionUpdate", null, scene);
}

/**
* Centers the cluster contained within each semantic description according
* to a common centroid.
*
* @param descriptions is a list of semantic cloud descriptions, each
* containing a cluster.
*/
private void center(List<SemanticCloudDescription> descriptions) {
Point3d centroid = new Point3d(0, 0, 0);
int size = 0;

for (SemanticCloudDescription description : descriptions) {
PointCloud cluster = description.getCloud();

size += cluster.size();

cluster.forEach(point -> {
centroid.add(new Vector3d(point.x, point.y, point.z));
});
}

centroid.set(centroid.x / size, centroid.y / size, centroid.z / size);

descriptions.stream().map((description) -> description.getCloud()).forEachOrdered((cluster) -> {
cluster.forEach(point -> {
point.sub(centroid);
});
});
}

/**
* Rotates the cluster of each semantic description so that the up vector of
* the whole corresponds to the world Z-axis.
*
* @param descriptions is a list of semantic cloud descriptions, each
* containing a cluster.
*/
private void rotate(List<SemanticCloudDescription> descriptions) {
descriptions.stream().map((description) -> description.getCloud()).forEachOrdered((cluster) -> {
cluster.forEach(point -> {
Vector3f v = new Vector3f((float) point.x, (float) point.y, (float) point.z);

v.rotateAxis((float) (Math.PI / 2), 0.0f, 1.0f, 0.0f);

point.set(v.x, v.y, v.z);
});
});
}

}
Loading

0 comments on commit 24a235f

Please sign in to comment.