Public Member Functions | Static Package Functions | Private Member Functions | Private Attributes | Static Private Attributes
edu.tum.cs.vis.model.Model Class Reference

List of all members.

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< LinegetLines ()
float getScale ()
double getSizeX ()
double getSizeY ()
double getSizeZ ()
String getTextureBasePath ()
List< TrianglegetTriangles ()
float getUnscaled (float scaled)
Tuple3f[] getUnscaled (Point3f[] corner)
Tuple3f getUnscaled (Tuple3f t)
Vector3f getUnscaled (Vector3f t)
List< VertexgetVertices ()
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< Linelines = new ArrayList<Line>()
boolean normalsInitialized = false
float scale = 1
String textureBasePath = null
final List< Triangletriangles = new ArrayList<Triangle>()
final List< Vertexvertices = new ArrayList<Vertex>()

Static Private Attributes

static Logger logger = Logger.getLogger(Model.class)

Detailed Description

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.

Author:
Stefan Profanter

Definition at line 50 of file Model.java.


Member Function Documentation

Calculates the bounding sphere for the model. Calculated by Miniball class.

See also:
edu.tum.cs.vis.model.util.algorithm.Miniball

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.

Parameters:
tTriangle

Definition at line 606 of file Model.java.

void edu.tum.cs.vis.model.Model.draw ( PGraphics  g,
DrawSettings  drawSettings 
) [inline]
Parameters:
gGraphics context to draw on
drawSettingsSettings 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.

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.

Returns:
the file containing the exported model or null on error

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.

Parameters:
paththe path to the file where to store the data
overwriteoverwrite existing file
Returns:
true on success

Definition at line 692 of file Model.java.

A characteristic "feature size" for the mesh. Computed as the median edge length.

Ported (and modified) from trimesh2 library (version: 2.12)

Returns:
median edge length

Definition at line 783 of file Model.java.

Gets the bounding sphere set by Miniball class.

See also:
edu.tum.cs.vis.model.util.algorithm.Miniball
Returns:
the boundingSphere

Definition at line 119 of file Model.java.

Get main group of model

Returns:
the group

Definition at line 130 of file Model.java.

Get all lines of model

Returns:
the lines

Definition at line 139 of file Model.java.

Gets scale factor of model. Model is scaled (normalized) for reasoning. This value indicates this scale factor.

Returns:
model scale

Definition at line 149 of file Model.java.

Get the model size on x axis.

Returns:
model size on x axis calculated by the maximum x value minus minimum x value

Definition at line 730 of file Model.java.

Get the model size on y axis.

Returns:
model size on y axis calculated by the maximum y value minus minimum y value

Definition at line 739 of file Model.java.

Get the model size on z axis.

Returns:
model size on z axis calculated by the maximum z value minus minimum z value

Definition at line 748 of file Model.java.

Get texture base path which is the base for all relative texture paths for this model.

Returns:
the textureBasePath

Definition at line 158 of file Model.java.

Get all triangles of model

Returns:
the triangles

Definition at line 167 of file Model.java.

float edu.tum.cs.vis.model.Model.getUnscaled ( float  scaled) [inline]

Unscale the specified float value by dividing scaled by getScale

Parameters:
scaledscaled value
Returns:
unscaled 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

Parameters:
cornerscaled value
Returns:
unscaled 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

Parameters:
tscaled value
Returns:
unscaled 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

Parameters:
tscaled value
Returns:
unscaled value

Definition at line 218 of file Model.java.

Get all vertices of model

Returns:
the vertices

Definition at line 229 of file Model.java.

Mirror model on x axis my multiplying each x value of all vertices with -1

Definition at line 236 of file Model.java.

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.

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.

Returns:
Number of removed triangles

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.

Parameters:
factorFactor 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.

Parameters:
groupthe 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.

Parameters:
textureBasePaththe textureBasePath to set

Definition at line 296 of file Model.java.

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.

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.

Parameters:
tthe main triangle
none of the neighboring triangles of t
checkedTrianglesSet of already checked triangles. If one is already checked, it is ignored in this call.
toRemoveSet 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.

Parameters:
tTriangle to check
checkedTrianglesalready checked triangles
toRemoveSet 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.


Member Data Documentation

Minimum bounding sphere of this model. Only set if previously calculated (by Miniball class).

See also:
edu.tum.cs.vis.model.util.algorithm.Miniball

Definition at line 87 of file Model.java.

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.

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.

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.


The documentation for this class was generated from the following file:


knowrob_cad_parser
Author(s): Stefan Profanter
autogenerated on Sat Dec 28 2013 17:09:45