Public Member Functions | |
void | draw (PGraphics g, DrawSettings drawSettings) |
File | exportVerticesAsTxt () |
boolean | exportVerticesAsTxt (File path, boolean overwrite) |
float | feature_size () |
BSphere | getBoundingSphere () |
Group | getGroup () |
List< Line > | getLines () |
float | getScale () |
double | getSizeX () |
double | getSizeY () |
double | getSizeZ () |
String | getTextureBasePath () |
List< Triangle > | getTriangles () |
float | getUnscaled (float scaled) |
Tuple3f[] | getUnscaled (Point3f[] corner) |
Tuple3f | getUnscaled (Tuple3f t) |
Vector3f | getUnscaled (Vector3f t) |
List< Vertex > | getVertices () |
void | mirrorX () |
void | normalize () |
int | removeDoubleSidedTriangles () |
void | scale (float factor) |
void | setGroup (Group group) |
void | setTextureBasePath (String textureBasePath) |
void | updateVertexNormals () |
void | updateVertexSharing () |
Static Package Functions | |
static void | calculateVertexNormalsForTriangle (final Triangle t) |
Private Member Functions | |
void | calculateBoundingsphere () |
void | reloadVertexList () |
void | updateVertexSharingForNeighbors (final Triangle t, final Triangle n, final Set< Triangle > checkedTriangles, Set< Vertex > toRemove) |
void | updateVertexSharingForTriangle (final Triangle t, final Set< Triangle > checkedTriangles, final Set< Vertex > toRemove) |
Private Attributes | |
BSphere | boundingSphere = null |
Group | group |
final List< Line > | lines = new ArrayList<Line>() |
boolean | normalsInitialized = false |
float | scale = 1 |
String | textureBasePath = null |
final List< Triangle > | triangles = new ArrayList<Triangle>() |
final List< Vertex > | vertices = new ArrayList<Vertex>() |
Static Private Attributes | |
static Logger | logger = Logger.getLogger(Model.class) |
Class which represents a CAD model loaded from file. A CAD model consists of triangles and lines which have vertices. These can be grouped hierarchically into subgroups.
Definition at line 50 of file Model.java.
void edu.tum.cs.vis.model.Model.calculateBoundingsphere | ( | ) | [inline, private] |
Calculates the bounding sphere for the model. Calculated by Miniball class.
Definition at line 758 of file Model.java.
static void edu.tum.cs.vis.model.Model.calculateVertexNormalsForTriangle | ( | final Triangle | t | ) | [inline, static, package] |
Calculate vertex normals for each vertex of triangle.
t | Triangle |
Definition at line 606 of file Model.java.
void edu.tum.cs.vis.model.Model.draw | ( | PGraphics | g, |
DrawSettings | drawSettings | ||
) | [inline] |
g | Graphics context to draw on |
drawSettings | Settings for drawing the model, e.g. to override face color of model. Useful if you want to ignore color of model and draw whole model in a specific color. |
Definition at line 107 of file Model.java.
File edu.tum.cs.vis.model.Model.exportVerticesAsTxt | ( | ) | [inline] |
Export the vertices of the model into a temporary txt file with the format:
NUMBER_OF_POINTS x1 y1 z1 nx1 nx2 nx3 x2 y2 z2 nx2 nx2 nx2
where the first 3 values are the coordinates of the point, the next 3 values represent the normal vector.
The file name is generated in the temporary directory and will be unique.
Definition at line 661 of file Model.java.
boolean edu.tum.cs.vis.model.Model.exportVerticesAsTxt | ( | File | path, |
boolean | overwrite | ||
) | [inline] |
Export the vertices of the model into a txt file with the format:
NUMBER_OF_POINTS x1 y1 z1 nx1 nx2 nx3 x2 y2 z2 nx2 nx2 nx2
where the first 3 values are the coordinates of the point, the next 3 values represent the normal vector.
path | the path to the file where to store the data |
overwrite | overwrite existing file |
Definition at line 692 of file Model.java.
float edu.tum.cs.vis.model.Model.feature_size | ( | ) | [inline] |
A characteristic "feature size" for the mesh. Computed as the median edge length.
Ported (and modified) from trimesh2 library (version: 2.12)
Definition at line 783 of file Model.java.
BSphere edu.tum.cs.vis.model.Model.getBoundingSphere | ( | ) | [inline] |
Gets the bounding sphere set by Miniball class.
Definition at line 119 of file Model.java.
Group edu.tum.cs.vis.model.Model.getGroup | ( | ) | [inline] |
List<Line> edu.tum.cs.vis.model.Model.getLines | ( | ) | [inline] |
float edu.tum.cs.vis.model.Model.getScale | ( | ) | [inline] |
Gets scale factor of model. Model is scaled (normalized) for reasoning. This value indicates this scale factor.
Definition at line 149 of file Model.java.
double edu.tum.cs.vis.model.Model.getSizeX | ( | ) | [inline] |
Get the model size on x axis.
Definition at line 730 of file Model.java.
double edu.tum.cs.vis.model.Model.getSizeY | ( | ) | [inline] |
Get the model size on y axis.
Definition at line 739 of file Model.java.
double edu.tum.cs.vis.model.Model.getSizeZ | ( | ) | [inline] |
Get the model size on z axis.
Definition at line 748 of file Model.java.
String edu.tum.cs.vis.model.Model.getTextureBasePath | ( | ) | [inline] |
Get texture base path which is the base for all relative texture paths for this model.
Definition at line 158 of file Model.java.
List<Triangle> edu.tum.cs.vis.model.Model.getTriangles | ( | ) | [inline] |
float edu.tum.cs.vis.model.Model.getUnscaled | ( | float | scaled | ) | [inline] |
Unscale the specified float value by dividing scaled
by getScale
scaled | scaled value |
Definition at line 178 of file Model.java.
Tuple3f [] edu.tum.cs.vis.model.Model.getUnscaled | ( | Point3f[] | corner | ) | [inline] |
Unscale the specified point coordinates by dividing each coordinate of corner
by getScale
corner | scaled value |
Definition at line 190 of file Model.java.
Tuple3f edu.tum.cs.vis.model.Model.getUnscaled | ( | Tuple3f | t | ) | [inline] |
Unscale the specified float value by dividing t
by getScale
t | scaled value |
Definition at line 205 of file Model.java.
Vector3f edu.tum.cs.vis.model.Model.getUnscaled | ( | Vector3f | t | ) | [inline] |
Unscale the specified float value by dividing t
by getScale
t | scaled value |
Definition at line 218 of file Model.java.
List<Vertex> edu.tum.cs.vis.model.Model.getVertices | ( | ) | [inline] |
void edu.tum.cs.vis.model.Model.mirrorX | ( | ) | [inline] |
Mirror model on x axis my multiplying each x value of all vertices with -1
Definition at line 236 of file Model.java.
void edu.tum.cs.vis.model.Model.normalize | ( | ) | [inline] |
Normalizes the model. Makes sure that the model fits into a cube with side length of 1. So each vertex is scaled.
Definition at line 248 of file Model.java.
void edu.tum.cs.vis.model.Model.reloadVertexList | ( | ) | [inline, private] |
Rebuilds the main triangles and vertices list by iterating over all child groups and collecting all triangles and vertices found.
Definition at line 368 of file Model.java.
int edu.tum.cs.vis.model.Model.removeDoubleSidedTriangles | ( | ) | [inline] |
Searches for triangles which have exactly the same coordinate points and removes one of them to avoid two triangles drawn on exactly the same position. Used for mesh reasoning.
Definition at line 306 of file Model.java.
void edu.tum.cs.vis.model.Model.scale | ( | float | factor | ) | [inline] |
Scale model by given factor by multiplying all vertices with factor
. Call setScale afterwards if you want to set scale factor also for parameters.
factor | Factor to scale |
Definition at line 268 of file Model.java.
void edu.tum.cs.vis.model.Model.setGroup | ( | Group | group | ) | [inline] |
Set main group of model.
group | the group to set |
Definition at line 286 of file Model.java.
void edu.tum.cs.vis.model.Model.setTextureBasePath | ( | String | textureBasePath | ) | [inline] |
Set texture base path for all texture elements of this model.
textureBasePath | the textureBasePath to set |
Definition at line 296 of file Model.java.
void edu.tum.cs.vis.model.Model.updateVertexNormals | ( | ) | [inline] |
Ported from trimesh2 (2.12) (Szymon Rusinkiewicz Princeton University)
uses average of per-face normals, weighted according to: Max, N. "Weights for Computing Vertex Normals from Facet Normals," Journal of Graphics Tools, Vol. 4, No. 2, 1999.
Definition at line 514 of file Model.java.
void edu.tum.cs.vis.model.Model.updateVertexSharing | ( | ) | [inline] |
Check for each vertex if it should be shared with neighbor triangles or not. This decision is made according to the dihedral angle between the two triangles
Definition at line 389 of file Model.java.
void edu.tum.cs.vis.model.Model.updateVertexSharingForNeighbors | ( | final Triangle | t, |
final Triangle | n, | ||
final Set< Triangle > | checkedTriangles, | ||
Set< Vertex > | toRemove | ||
) | [inline, private] |
Check for the given two triangles if their vertices should be shared or not. The decision is made according to the dihedral angle between the two triangles.
t | the main triangle |
n | one of the neighboring triangles of t |
checkedTriangles | Set of already checked triangles. If one is already checked, it is ignored in this call. |
toRemove | Set of vertices which should be removed from the main vertices list. Combined vertices which aren't anymore in the model will be added to this set. |
Definition at line 418 of file Model.java.
void edu.tum.cs.vis.model.Model.updateVertexSharingForTriangle | ( | final Triangle | t, |
final Set< Triangle > | checkedTriangles, | ||
final Set< Vertex > | toRemove | ||
) | [inline, private] |
Check for all vertices between given triangle and its neighbors if the vertex should be shared or not according to the dihedral angle.
t | Triangle to check |
checkedTriangles | already checked triangles |
toRemove | Set of vertices which should be removed from the main vertices list. Combined vertices which aren't anymore in the model will be added to this set. |
Definition at line 488 of file Model.java.
BSphere edu.tum.cs.vis.model.Model.boundingSphere = null [private] |
Minimum bounding sphere of this model. Only set if previously calculated (by Miniball class).
Definition at line 87 of file Model.java.
Group edu.tum.cs.vis.model.Model.group [private] |
Main group of the model. Each model should have at least one group.
Definition at line 65 of file Model.java.
final List<Line> edu.tum.cs.vis.model.Model.lines = new ArrayList<Line>() [private] |
List of all lines in this model
Definition at line 80 of file Model.java.
Logger edu.tum.cs.vis.model.Model.logger = Logger.getLogger(Model.class) [static, private] |
Log4J Logger
Definition at line 55 of file Model.java.
boolean edu.tum.cs.vis.model.Model.normalsInitialized = false [private] |
Indicates if the vertex normals of each vertex have already been initialized.
Definition at line 98 of file Model.java.
float edu.tum.cs.vis.model.Model.scale = 1 [private] |
Current model scale. Is used to normalize model for further reasoning. getUnscaled methods use this value to undo scaling for parameters such as height, width, radius, ...
Definition at line 93 of file Model.java.
String edu.tum.cs.vis.model.Model.textureBasePath = null [private] |
Absolute file path where the relative paths within the model are based.
Definition at line 60 of file Model.java.
final List<Triangle> edu.tum.cs.vis.model.Model.triangles = new ArrayList<Triangle>() [private] |
List of all triangles in this model
Definition at line 75 of file Model.java.
final List<Vertex> edu.tum.cs.vis.model.Model.vertices = new ArrayList<Vertex>() [private] |
List of all vertices in this model
Definition at line 70 of file Model.java.