diff --git a/pom.xml b/pom.xml
index d8282bb..0764711 100644
--- a/pom.xml
+++ b/pom.xml
@@ -182,7 +182,7 @@
- check
+ format
diff --git a/src/main/java/es/usc/citius/lab/joctomap/octree/JOctree.java b/src/main/java/es/usc/citius/lab/joctomap/octree/JOctree.java
index e2f5723..62bf4a4 100644
--- a/src/main/java/es/usc/citius/lab/joctomap/octree/JOctree.java
+++ b/src/main/java/es/usc/citius/lab/joctomap/octree/JOctree.java
@@ -43,8 +43,6 @@
* @author adrian.gonzalez
*/
public class JOctree extends NativeObject{
-
- private String path;
/**
* Initializes the JOctree with a pointer to the native OcTree object of
@@ -424,14 +422,5 @@ public JOctreeNode search(float x, float y, float z){
* @return octree with the given resolution
*/
public static native JOctree create(float res);
-
- /**
- * Retrieves the path from which the octree was loaded.
- *
- * @return
- */
- public String getPath() {
- return path;
- }
}
diff --git a/src/main/java/es/usc/citius/lab/joctomap/util/AdjacencyMap.java b/src/main/java/es/usc/citius/lab/joctomap/util/AdjacencyMap.java
index 25854e2..3404fb1 100644
--- a/src/main/java/es/usc/citius/lab/joctomap/util/AdjacencyMap.java
+++ b/src/main/java/es/usc/citius/lab/joctomap/util/AdjacencyMap.java
@@ -26,15 +26,12 @@
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* This class implements a builder for calculating the adjacency map of an Octomap.
@@ -49,7 +46,6 @@
public class AdjacencyMap implements Serializable{
private Map> adjacencies;
- private JOctree octree;
//contains the information of size and center of each leaf in the octree
private Map> nodesInfo;
private double EPSILON = 1e-3;
@@ -63,7 +59,6 @@ public class AdjacencyMap implements Serializable{
*/
private AdjacencyMap(JOctree octree){
this.adjacencies = new HashMap>();
- this.octree = octree;
this.nodesInfo = new HashMap>();
//create cache
Cache cacheOfKeys = new Cache();
@@ -116,10 +111,8 @@ private AdjacencyMap(){
public static AdjacencyMap create(JOctree octree){
//initialize structures
AdjacencyMap map = new AdjacencyMap();
- //assign octree
- map.octree = octree;
//fill with JNI method
- map.initializeJNI();
+ map.initializeJNI(octree);
//retrieve result
return map;
}
@@ -139,7 +132,7 @@ public static AdjacencyMap createJava(JOctree octree){
* This fills the structures of the adjacency map using full-native
* implementation method for efficiency.
*/
- private native void initializeJNI();
+ private native void initializeJNI(JOctree octree);
/**
* Retrieves the adjacencies for a current key.
@@ -159,10 +152,6 @@ public Map> getNodesInfo() {
return nodesInfo;
}
- public JOctree getOctree() {
- return octree;
- }
-
/**
* Retrieves the information of a node stored after exploring the adjacencies.
*
@@ -194,8 +183,6 @@ public boolean write(String filename){
//open output stream
try{
DataOutputStream outputStream = new DataOutputStream(new FileOutputStream(outputFile));
- //write name of octree
- outputStream.writeUTF(this.octree.getPath());
//write adjacencies & nodesInfo
outputStream.writeInt(adjacencies.size());
for(Map.Entry> current : adjacencies.entrySet()){
@@ -239,10 +226,6 @@ public static AdjacencyMap read(String filename){
//open input stream (will be closed after this statement)
try{
DataInputStream inputStream = new DataInputStream(new FileInputStream(inputFile));
- //read name of the octree
- String octreePath = inputStream.readUTF();
- //load octree
- map.octree = JOctree.read(octreePath);
//read map instance
int sizeMap = inputStream.readInt();
map.adjacencies = new HashMap>(sizeMap);
diff --git a/src/main/resources/joctomap-natives/include/adjacencymap.h b/src/main/resources/joctomap-natives/include/adjacencymap.h
index aba7a3c..c6a1aab 100644
--- a/src/main/resources/joctomap-natives/include/adjacencymap.h
+++ b/src/main/resources/joctomap-natives/include/adjacencymap.h
@@ -25,10 +25,10 @@ extern "C" {
/*
* Class: es_usc_citius_lab_joctomap_util_AdjacencyMap
* Method: initializeJNI
- * Signature: ()V
+ * Signature: (Les/usc/citius/lab/joctomap/octree/JOctree;)V
*/
JNIEXPORT void JNICALL Java_es_usc_citius_lab_joctomap_util_AdjacencyMap_initializeJNI
- (JNIEnv *, jobject);
+ (JNIEnv *, jobject, jobject);
#ifdef __cplusplus
}
diff --git a/src/main/resources/joctomap-natives/src/adjacencymap.cpp b/src/main/resources/joctomap-natives/src/adjacencymap.cpp
index 9ff7cae..66554cc 100644
--- a/src/main/resources/joctomap-natives/src/adjacencymap.cpp
+++ b/src/main/resources/joctomap-natives/src/adjacencymap.cpp
@@ -23,16 +23,14 @@
using namespace octomap;
JNIEXPORT void JNICALL Java_es_usc_citius_lab_joctomap_util_AdjacencyMap_initializeJNI
- (JNIEnv *env, jobject jadjacencymap){
+ (JNIEnv *env, jobject jadjacencymap, jobject joctree){
//error margin
float EPSILON = 0.001f;
//retrieve fields from adjacencymap
jclass cls_jadjacencymap = env->FindClass(CLS_JADJACENCYMAP);
- jfieldID field_joctomap = env->GetFieldID(cls_jadjacencymap, FIELD_ADJACENCYMAP_OCTREE, CLS_JOCTREE);
jfieldID field_nodes_info = env->GetFieldID(cls_jadjacencymap, FIELD_ADJACENCYMAP_NODESINFO, CLS_MAP);
jfieldID field_adjacencies = env->GetFieldID(cls_jadjacencymap, FIELD_ADJACENCYMAP_ADJACENCIES, CLS_MAP);
//retrieve objects from fields
- jobject joctree = env->GetObjectField(jadjacencymap, field_joctomap);
jobject jnodes_info = env->GetObjectField(jadjacencymap, field_nodes_info);
jobject jadjacencies = env->GetObjectField(jadjacencymap, field_adjacencies);
//retrieve HashMap, JOctreeKey, Pair, Point3D class
diff --git a/src/main/resources/joctomap-natives/src/joctree.cpp b/src/main/resources/joctomap-natives/src/joctree.cpp
index b78b37a..fd1c207 100644
--- a/src/main/resources/joctomap-natives/src/joctree.cpp
+++ b/src/main/resources/joctomap-natives/src/joctree.cpp
@@ -598,9 +598,6 @@ JNIEXPORT jboolean JNICALL Java_es_usc_citius_lab_joctomap_octree_JOctree_write
const char *nativeFilename = env->GetStringUTFChars(filename, &iscopy);
//write octree in filename
bool value = octree->write(nativeFilename);
- //set path to which the octree was read
- jfieldID pathField = env->GetFieldID(env->GetObjectClass(obj), FIELD_PATH, CLS_STRING);
- env->SetObjectField(obj, pathField, filename);
//release memory of native char*
env->ReleaseStringUTFChars(filename, nativeFilename);
//return obtained value
@@ -660,9 +657,6 @@ JNIEXPORT jobject JNICALL Java_es_usc_citius_lab_joctomap_octree_JOctree_read
stream.close();
//create joctree object
jobject jtree = env->NewObject(cls, constructor, ot);
- //set path from which the octree was read
- jfieldID pathField = env->GetFieldID(cls, FIELD_PATH, CLS_STRING);
- env->SetObjectField(jtree, pathField, filename);
return jtree;
}
diff --git a/src/test/java/es/usc/citius/lab/joctomap/JOctreeTest.java b/src/test/java/es/usc/citius/lab/joctomap/JOctreeTest.java
index f587360..25a6cbf 100644
--- a/src/test/java/es/usc/citius/lab/joctomap/JOctreeTest.java
+++ b/src/test/java/es/usc/citius/lab/joctomap/JOctreeTest.java
@@ -103,7 +103,6 @@ public void test02_readFileOt() throws IOException {
octree = JOctree.read(inputPath);
assertTrue("Octree direction of memory not assigned",
octree.getPointer() != 0);
- assertTrue("Octree input path not assigned", octree.getPath().equals(inputPath));
}
/**
@@ -117,8 +116,7 @@ public void test03_writeFileOtTest() throws IOException {
octree.write(fileWrite.getAbsolutePath());
// compare by content both files
assertTrue("Input and output files with the same content",
- FileUtils.contentEquals(fileRead, fileWrite));
- assertTrue("File path not set properly after write", octree.getPath().equals(fileWrite.getAbsolutePath()));
+ FileUtils.contentEquals(fileRead, fileWrite));
}
/**
diff --git a/src/test/java/es/usc/citius/lab/joctomap/util/AdjacencyMapTest.java b/src/test/java/es/usc/citius/lab/joctomap/util/AdjacencyMapTest.java
index 090166f..a35f4cc 100644
--- a/src/test/java/es/usc/citius/lab/joctomap/util/AdjacencyMapTest.java
+++ b/src/test/java/es/usc/citius/lab/joctomap/util/AdjacencyMapTest.java
@@ -55,8 +55,8 @@ public AdjacencyMapTest() throws URISyntaxException{
@Test
public void test01_calculateAdjacencyMap(){
- assertEquals("Nodes info size do not match with number of leaves.", adjacencyMap.getOctree().size(), adjacencyMap.getNodesInfo().size());
- assertEquals("Adjacencies info size do not match with number of leaves.", adjacencyMap.getOctree().size(), adjacencyMap.getAdjacencies().size());
+ assertEquals("Nodes info size do not match with number of leaves.", octree.size(), adjacencyMap.getNodesInfo().size());
+ assertEquals("Adjacencies info size do not match with number of leaves.", octree.size(), adjacencyMap.getAdjacencies().size());
//iterate over the entries of the adjacency map
for(Map.Entry> entry : adjacencyMap.getAdjacencies().entrySet()){
//center of first cell