CS488 PA7
Functions
meshUtilities.h File Reference
#include "../pa6/Color.h"
#include "../pa6/Geometry.hpp"
#include <list>
#include "../pa5/Matrix.hpp"
#include <stdio.h>
#include "Triangle.h"

Go to the source code of this file.

Functions

Matrix< 4, 2 > findBounds (list< Triangle *> triangles)
 
void read (const char *fileName, list< Triangle *> *triangles)
 
void scaleAndTranslate (list< Triangle *> triangles, double width, double height, double depth)
 

Detailed Description

Functions for working with triangular meshes.

A triangular mesh is stored as a list<Triangle*> (i.e., a list of pointers to Triangle objects).

Notes:

  1. We are using a list rather than a vector to avoid confusion between vector and Vector.
  2. We are using a list of pointers so that we can change the contents of the list (e.g., so we don't have to create a copy of the entire list when the Triangle objects are scaled)

Function Documentation

◆ findBounds()

Matrix<4, 2> findBounds ( list< Triangle *>  triangles)

Find the bounds of a triangular mesh.

The bounds are returned as a Matrix of 2 points in 4-D. One point contains the minimum value for all dimensions and the other contains the maximum value for all dimensions.

Parameters
trianglesThe "triangular mesh" (i.e., the list of Triangle*)
Returns
The bounds

◆ read()

void read ( const char *  fileName,
list< Triangle *> *  triangles 
)

Read a triangular mesh.

Parameters
fileNameThe name of the file to read from
trianglesThe "triangular mesh" to populat

◆ scaleAndTranslate()

void scaleAndTranslate ( list< Triangle *>  triangles,
double  width,
double  height,
double  depth 
)

Scales and translates the given Triangle objects so that they fit within a rectangular solid and are centered at 0,0. The aspect ratio of the Triangle objects will remain unchanged.

Parameters
trianglesThe Triangle objects to scale and translate
widthThe width of the rectangle
heightThe height of the rectangle
depthThe depth of the rectangle