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 @@
<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: 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" />
</component>
</module>
\ No newline at end of file
......@@ -4,79 +4,111 @@ import java.util.ArrayList;
import java.util.List;
/**
* Representation of mesh in memory
* Representation of mesh in memory using corner table
*
* @author Matej Lukes
*/
public class CornerTable {
private List<CornerTableRow> rows = new ArrayList<>();
/**
* returns index of face that contains corner
* @param c index of corner
* returns index of face that contains 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
*/
public int getIndexOfFace(int c) {
return c / 3;
public int getIndexOfFace(int index) {
if (index < 0 || index > rows.size())
return -2;
return index / 3;
}
/**
* returns index of opposite corner
* @param c index of corner
* returns index of opposite 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
*/
public int getIndexOfOppositeCorner(int c) {
return rows.get(c).getOppositeCornerIndex();
public int getIndexOfOppositeCorner(int index) {
if (index < 0 || index > rows.size())
return -2;
return rows.get(index).getOppositeCornerIndex();
} // opposite
/**
* returns index of next corner in Face
* @param c index of corner
* @return 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 next corner
*/
public int getIndexOfNextCornerInFace(int c) {
if ((c % 3) == 2)
return c - 1;
return c + 1;
}// next in t(c)
public int getIndexOfNextCornerInFace(int index) {
if (index < 0 || index > rows.size())
return -2;
if ((index % 3) == 2)
return index - 1;
return index + 1;
}
/**
* returns index of previous corner in Face
* @param c index of corner
* @return 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 previous corner
*/
public int getIndexOfPreviousCornerInFace(int c) {
return getIndexOfNextCornerInFace(getIndexOfNextCornerInFace(c));
} // previous corner
public int getIndexOfPreviousCornerInFace(int index) {
if (index < 0 || index > rows.size())
return -2;
return getIndexOfNextCornerInFace(getIndexOfNextCornerInFace(index));
}
/**
* 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
*/
public int getIndexOfTipCornerOnLeft(int c) {
return getIndexOfOppositeCorner(getIndexOfPreviousCornerInFace(c));
} // tip on left
public int getIndexOfTipCornerOnLeft(int index) {
if (index < 0 || index > rows.size())
return -2;
return getIndexOfOppositeCorner(getIndexOfPreviousCornerInFace(index));
}
/**
* 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
*/
public int getIndexOfTipCornerOnRight(int c) {
return getIndexOfOppositeCorner(getIndexOfNextCornerInFace(c));
} // tip on right
public int getIndexOfTipCornerOnRight(int index) {
if (index < 0 || index > rows.size())
return -2;
return getIndexOfOppositeCorner(getIndexOfNextCornerInFace(index));
}
/**
* 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
*/
public int getNextAroundCorner(int c) {
return getIndexOfNextCornerInFace(getIndexOfTipCornerOnLeft(c));
} // next around v(c)
public int getNextAroundCorner(int index) {
if (index < 0 || index > rows.size())
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
*/
public void addRow(CornerTableRow row) {
......@@ -85,6 +117,7 @@ public class CornerTable {
/**
* replaces row of corner table at specified index
*
* @param index index of replaced row
* @param row new row
*/
......
......@@ -2,11 +2,18 @@ package cz.fidentis.analyst.mesh.core;
/**
* single row in corner table
*
* @author Matej Lukes
*/
public class CornerTableRow {
private int oppositeCornerIndex;
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) {
this.vertexIndex = vertexIndex;
this.oppositeCornerIndex = oppositeCornerIndex;
......@@ -27,7 +34,11 @@ public class CornerTableRow {
public int getOppositeCornerIndex() {
return oppositeCornerIndex;
}
/**
* sets index of the opposite corner
* @param index index of the opposite corner in corner table
*/
public void setOppositeCornerIndex(int index) {
this.oppositeCornerIndex = index;
}
......
......@@ -12,18 +12,35 @@ public class MeshFacet {
private List<MeshPoint> vertexes = new ArrayList<>();
private CornerTable cornerTable = new CornerTable();
public MeshPoint GetVertex(int c) {
return vertexes.get(c);
} // vertex of c
/**
* returns vertex of specified index
* @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){
vertexes.add(point);
}
/**
* returns number of vertexes in MeshFacet
* @return number of vertexes
*/
public int getNumberOfVertexes() {
return vertexes.size();
}
/**
* returns Corner Table representing MeshFacet
* @return corner table
*/
public CornerTable getCornerTable() {
return cornerTable;
}
......
......@@ -5,14 +5,24 @@ import java.util.List;
/**
* MeshModel is a root node of the hierarchy
*
* @author Matej Lukes
*/
public class MeshModel {
private List<MeshFacet> facets = new ArrayList<>();
/**
* returns list of MeshFacets
* @return list of MeshFacets
*/
public List<MeshFacet> getFacets() {
return facets;
}
/**
* adds new MeshFacet to the model
* @param facet new MeshFacet
*/
public void addFacet(MeshFacet facet) {
facets.add(facet);
}
......
......@@ -10,6 +10,12 @@ import javax.vecmath.Vector3d;
public class MeshPoint {
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) {
if (position == null || normal == null || texCoord == null)
throw new NullPointerException("position, normal and texCoord cannot be null");
......@@ -55,6 +61,10 @@ public class MeshPoint {
&& this.texCoord.equals(meshPointObj.texCoord);
}
/**
* returns hash of MeshPoint
* @return hash
*/
@Override
public int 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