Skip to content
Snippets Groups Projects
Commit 06fe847a authored by Matej Lukes's avatar Matej Lukes
Browse files

documentation and improvements

parent f255698d
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<orderEntry type="library" name="Maven: java3d:vecmath:1.3.1" level="project" /> <orderEntry type="library" name="Maven: java3d:vecmath:1.3.1" level="project" />
<orderEntry type="library" name="Maven: java3d:j3d-core:1.3.1" level="project" /> <orderEntry type="library" name="Maven: java3d:j3d-core:1.3.1" level="project" />
<orderEntry type="library" name="Maven: org.netbeans.api:org-netbeans-api-annotations-common:RELEASE82" level="project" /> <orderEntry type="library" name="Maven: org.netbeans.api:org-netbeans-api-annotations-common:RELEASE82" level="project" />
<orderEntry type="library" name="Maven: com.github.mokiat:java-data-front:v2.0.0" level="project" />
<orderEntry type="library" name="Maven: javax.vecmath:vecmath:1.5.2" level="project" /> <orderEntry type="library" name="Maven: javax.vecmath:vecmath:1.5.2" level="project" />
</component> </component>
</module> </module>
\ No newline at end of file
...@@ -4,79 +4,111 @@ import java.util.ArrayList; ...@@ -4,79 +4,111 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
* Representation of mesh in memory * Representation of mesh in memory using corner table
*
* @author Matej Lukes
*/ */
public class CornerTable { public class CornerTable {
private List<CornerTableRow> rows = new ArrayList<>(); private List<CornerTableRow> rows = new ArrayList<>();
/** /**
* returns index of face that contains corner * returns index of face that contains corner.
* @param c index of corner * returns -2 if index is less than 0 or more than number of rows in corner table
*
* @param index index of corner
* @return index of corner * @return index of corner
*/ */
public int getIndexOfFace(int c) { public int getIndexOfFace(int index) {
return c / 3; if (index < 0 || index > rows.size())
return -2;
return index / 3;
} }
/** /**
* returns index of opposite corner * returns index of opposite corner.
* @param c index of corner * returns -1 if corner does not have opposite
* returns -2 if index is less than 0 or more than number of rows in corner table
*
* @param index index of corner
* @return index of corner * @return index of corner
*/ */
public int getIndexOfOppositeCorner(int c) { public int getIndexOfOppositeCorner(int index) {
return rows.get(c).getOppositeCornerIndex(); if (index < 0 || index > rows.size())
return -2;
return rows.get(index).getOppositeCornerIndex();
} // opposite } // opposite
/** /**
* returns index of next corner in Face * returns index of next corner in Face
* @param c index of corner * returns -2 if index is less than 0 or more than number of rows in corner table
* @return index of corner *
* @param index index of corner
* @return index of next corner
*/ */
public int getIndexOfNextCornerInFace(int c) { public int getIndexOfNextCornerInFace(int index) {
if ((c % 3) == 2) if (index < 0 || index > rows.size())
return c - 1; return -2;
return c + 1; if ((index % 3) == 2)
}// next in t(c) return index - 1;
return index + 1;
}
/** /**
* returns index of previous corner in Face * returns index of previous corner in Face
* @param c index of corner * returns -2 if index is less than 0 or more than number of rows in corner table
* @return index of corner *
* @param index index of corner
* @return index of previous corner
*/ */
public int getIndexOfPreviousCornerInFace(int c) { public int getIndexOfPreviousCornerInFace(int index) {
return getIndexOfNextCornerInFace(getIndexOfNextCornerInFace(c)); if (index < 0 || index > rows.size())
} // previous corner return -2;
return getIndexOfNextCornerInFace(getIndexOfNextCornerInFace(index));
}
/** /**
* returns opposite corner of edge on the left side of corner * returns opposite corner of edge on the left side of corner
* @param c index of corner * returns -2 if index is less than 0 or more than number of rows in corner table
*
* @param index index of corner
* @return index of corner * @return index of corner
*/ */
public int getIndexOfTipCornerOnLeft(int c) { public int getIndexOfTipCornerOnLeft(int index) {
return getIndexOfOppositeCorner(getIndexOfPreviousCornerInFace(c)); if (index < 0 || index > rows.size())
} // tip on left return -2;
return getIndexOfOppositeCorner(getIndexOfPreviousCornerInFace(index));
}
/** /**
* returns opposite corner of edge on the right side of corner * returns opposite corner of edge on the right side of corner
* @param c index of corner * returns -2 if index is less than 0 ord more than number of rows in corner table
*
* @param index index of corner
* @return index of corner * @return index of corner
*/ */
public int getIndexOfTipCornerOnRight(int c) { public int getIndexOfTipCornerOnRight(int index) {
return getIndexOfOppositeCorner(getIndexOfNextCornerInFace(c)); if (index < 0 || index > rows.size())
} // tip on right return -2;
return getIndexOfOppositeCorner(getIndexOfNextCornerInFace(index));
}
/** /**
* returns corner next to the corner opposite the edge on the left side * returns corner next to the corner opposite the edge on the left side
* @param c index of corner * returns -2 if index is less than 0 ord more than number of rows in corner table
*
* @param index index of corner
* @return index of corner * @return index of corner
*/ */
public int getNextAroundCorner(int c) { public int getNextAroundCorner(int index) {
return getIndexOfNextCornerInFace(getIndexOfTipCornerOnLeft(c)); if (index < 0 || index > rows.size())
} // next around v(c) return -2;
return getIndexOfNextCornerInFace(getIndexOfTipCornerOnLeft(index));
}
/** /**
* adds row to the corner table * adds row at the end of corner table
*
* @param row that is going to be added to corner table * @param row that is going to be added to corner table
*/ */
public void addRow(CornerTableRow row) { public void addRow(CornerTableRow row) {
...@@ -85,6 +117,7 @@ public class CornerTable { ...@@ -85,6 +117,7 @@ public class CornerTable {
/** /**
* replaces row of corner table at specified index * replaces row of corner table at specified index
*
* @param index index of replaced row * @param index index of replaced row
* @param row new row * @param row new row
*/ */
......
...@@ -2,11 +2,18 @@ package cz.fidentis.analyst.mesh.core; ...@@ -2,11 +2,18 @@ package cz.fidentis.analyst.mesh.core;
/** /**
* single row in corner table * single row in corner table
*
* @author Matej Lukes
*/ */
public class CornerTableRow { public class CornerTableRow {
private int oppositeCornerIndex; private int oppositeCornerIndex;
private int vertexIndex; private int vertexIndex;
/**
* Constructor of a row in corner
* @param vertexIndex index of associated vertex in MashFacet
* @param oppositeCornerIndex index of the opposite corner, -1 if there is no opposite corner
*/
public CornerTableRow(int vertexIndex, int oppositeCornerIndex) { public CornerTableRow(int vertexIndex, int oppositeCornerIndex) {
this.vertexIndex = vertexIndex; this.vertexIndex = vertexIndex;
this.oppositeCornerIndex = oppositeCornerIndex; this.oppositeCornerIndex = oppositeCornerIndex;
...@@ -27,7 +34,11 @@ public class CornerTableRow { ...@@ -27,7 +34,11 @@ public class CornerTableRow {
public int getOppositeCornerIndex() { public int getOppositeCornerIndex() {
return oppositeCornerIndex; return oppositeCornerIndex;
} }
/**
* sets index of the opposite corner
* @param index index of the opposite corner in corner table
*/
public void setOppositeCornerIndex(int index) { public void setOppositeCornerIndex(int index) {
this.oppositeCornerIndex = index; this.oppositeCornerIndex = index;
} }
......
...@@ -12,18 +12,35 @@ public class MeshFacet { ...@@ -12,18 +12,35 @@ public class MeshFacet {
private List<MeshPoint> vertexes = new ArrayList<>(); private List<MeshPoint> vertexes = new ArrayList<>();
private CornerTable cornerTable = new CornerTable(); private CornerTable cornerTable = new CornerTable();
public MeshPoint GetVertex(int c) { /**
return vertexes.get(c); * returns vertex of specified index
} // vertex of c * @param index index of vertex
* @return vertex
*/
public MeshPoint GetVertex(int index) {
return vertexes.get(index);
}
/**
* adds vertex to MeshFacet
* @param point new vertex
*/
public void addVertex(MeshPoint point){ public void addVertex(MeshPoint point){
vertexes.add(point); vertexes.add(point);
} }
/**
* returns number of vertexes in MeshFacet
* @return number of vertexes
*/
public int getNumberOfVertexes() { public int getNumberOfVertexes() {
return vertexes.size(); return vertexes.size();
} }
/**
* returns Corner Table representing MeshFacet
* @return corner table
*/
public CornerTable getCornerTable() { public CornerTable getCornerTable() {
return cornerTable; return cornerTable;
} }
......
...@@ -5,14 +5,24 @@ import java.util.List; ...@@ -5,14 +5,24 @@ import java.util.List;
/** /**
* MeshModel is a root node of the hierarchy * MeshModel is a root node of the hierarchy
*
* @author Matej Lukes
*/ */
public class MeshModel { public class MeshModel {
private List<MeshFacet> facets = new ArrayList<>(); private List<MeshFacet> facets = new ArrayList<>();
/**
* returns list of MeshFacets
* @return list of MeshFacets
*/
public List<MeshFacet> getFacets() { public List<MeshFacet> getFacets() {
return facets; return facets;
} }
/**
* adds new MeshFacet to the model
* @param facet new MeshFacet
*/
public void addFacet(MeshFacet facet) { public void addFacet(MeshFacet facet) {
facets.add(facet); facets.add(facet);
} }
......
...@@ -10,6 +10,12 @@ import javax.vecmath.Vector3d; ...@@ -10,6 +10,12 @@ import javax.vecmath.Vector3d;
public class MeshPoint { public class MeshPoint {
private final Vector3d position, normal, texCoord; private final Vector3d position, normal, texCoord;
/**
* constructor of meshPoint
* @param position position of MeshPoint
* @param normal normal of MeshPoint
* @param texCoord coordinates in texture
*/
public MeshPoint(Vector3d position, Vector3d normal , Vector3d texCoord) { public MeshPoint(Vector3d position, Vector3d normal , Vector3d texCoord) {
if (position == null || normal == null || texCoord == null) if (position == null || normal == null || texCoord == null)
throw new NullPointerException("position, normal and texCoord cannot be null"); throw new NullPointerException("position, normal and texCoord cannot be null");
...@@ -55,6 +61,10 @@ public class MeshPoint { ...@@ -55,6 +61,10 @@ public class MeshPoint {
&& this.texCoord.equals(meshPointObj.texCoord); && this.texCoord.equals(meshPointObj.texCoord);
} }
/**
* returns hash of MeshPoint
* @return hash
*/
@Override @Override
public int hashCode() { public int hashCode() {
return position.hashCode() + normal.hashCode() + texCoord.hashCode(); return position.hashCode() + normal.hashCode() + texCoord.hashCode();
......
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