Antiprism 0.23
|
Geometry Interface. More...
#include <geom.h>
Public Member Functions | |
virtual | ~geom_if () |
Destructor. | |
operator bool () const | |
Check whether geometry is set. | |
virtual const vector< vec3d > & | verts () const =0 |
Read access to the vertices. | |
virtual vector< vec3d > & | raw_verts ()=0 |
Read/Write access to the vertices. | |
virtual const vec3d & | verts (int v_idx) const =0 |
Read access to a vertex. | |
virtual const vector< vector < int > > & | edges () const =0 |
Read access to the edges. | |
virtual vector< vector< int > > & | raw_edges ()=0 |
Read/Write access to the edges. | |
virtual const vector< int > & | edges (int e_idx) const =0 |
Read access to an edge. | |
virtual int | edges (int e_idx, int v_no) const =0 |
Get the index number of a vertex of an edge. | |
vec3d | edge_v (int e_idx, int v_no) const |
Get the coordinates of a vertex of an edge. | |
virtual const vector< vector < int > > & | faces () const =0 |
Read access to the faces. | |
virtual vector< vector< int > > & | raw_faces ()=0 |
Read/Write access to the faces. | |
virtual const vector< int > & | faces (int f_idx) const =0 |
Read access to a face. | |
virtual int | faces (int f_idx, int v_no) const =0 |
Get the index number of a vertex of a face. | |
virtual int | faces_mod (int f_idx, int v_no) const |
Get the index number of a vertex of a face mod the size of the face. | |
vec3d | face_v (int f_idx, int v_no) const |
Get the coordinates of a vertex of an face. | |
virtual int | add_vert (vec3d vert) |
Add a vertex. | |
virtual int | add_verts (const vector< vec3d > &vrts) |
Add several vertices. | |
virtual int | add_face (const vector< int > &face) |
Add a face. | |
virtual int | add_face (int v1,...) |
Add a face made from integer arguments. | |
virtual int | add_faces (const vector< vector< int > > &fces) |
Add several faces. | |
virtual int | add_edge (const vector< int > edge) |
Add an edge. | |
virtual int | add_edge (int v_idx1, int v_idx2) |
Add an edge from vertex index numbers. | |
virtual int | add_edges (const vector< vector< int > > &edgs) |
Add several edges. | |
virtual int | add_edge_raw (const vector< int > &edge) |
Add an edge without checking it is valid. | |
virtual int | add_edges_raw (const vector< vector< int > > &edgs) |
Add several edges without checking they are valid. | |
virtual void | delete_vert (int v_idx, map< int, int > *vert_map=0) |
Delete a vertex. | |
virtual void | delete_verts (const vector< int > &v_idxs, map< int, int > *vert_map=0) |
Delete several vertices. | |
virtual void | delete_edges (const vector< int > &e_idxs, map< int, int > *edge_map=0) |
Delete several edges. | |
virtual void | delete_faces (const vector< int > &f_idxs, map< int, int > *face_map=0) |
Delete several faces. | |
virtual void | clear_verts () |
Delete all the vertices. | |
virtual void | clear_edges () |
Delete all the edges. | |
virtual void | clear_faces () |
Delete all the faces. | |
virtual void | clear_all () |
Delete all the vertices, edges and faces. | |
virtual void | append (const geom_if &geom) |
Append a geometry. | |
void | verts_merge (map< int, int > &vmap) |
Merge some of the vertices. | |
virtual void | add_missing_impl_edges () |
Add missing implicit edges. | |
int | add_hull (string qh_args="", char *errmsg=0) |
Add the faces of the convex hull to the geometry. | |
int | set_hull (string qh_args="", char *errmsg=0) |
Set the geometry to its convex hull. | |
vector< vec3d > | get_star (char type='v', vec3d centre=vec3d(0, 0, 0)) |
Get a star of vectors to use for making a zonohedron. | |
bool | set_zono (const vector< vec3d > &star, char *errmsg=0) |
Set the geometry to a zonohedron made from a star. | |
bool | set_geodesic_planar (const geom_if &base, int m, int n=0) |
Set planar geodesic division. | |
bool | set_geodesic_sphere (const geom_if &base, int m, int n=0, vec3d cent=vec3d(0, 0, 0)) |
Set spherical geodesic division. | |
void | sphere_projection (vec3d centre=vec3d(0, 0, 0), double radius=1.0) |
Project the vertices onto a sphere. | |
int | orient (vector< vector< int > > *parts=0) |
Orient the geometry (if possible.) | |
bool | orient (int type, char *errmsg=0) |
Orient the geometry (if possible.) | |
void | orient_reverse () |
Reverse the orientation of all the faces. | |
void | transform (const mat3d &trans) |
Apply a transformation matrix. | |
void | sym_align () |
Align a polyhedron with the standard alignment for its symmetry type. | |
void | triangulate (col_val col=col_val(), unsigned int winding=TESS_WINDING_NONZERO, vector< int > *fmap=0) |
Triangulate (tesselate) the faces. | |
vec3d | centroid () const |
Get the centroid of all the vertices. | |
void | face_cents (vector< vec3d > &ctds) const |
Get all the face centroids. | |
void | face_norms (vector< vec3d > &norms, bool allow_zero=false) const |
Get all the face normals. | |
vec3d | face_cent (int f_idx) const |
Get a face centroid, for a face index. | |
vec3d | face_cent (const vector< int > &face) const |
Get a face centroid, for a face. | |
vec3d | face_norm (int f_idx, bool allow_zero=false) const |
Get a face normal, for a face index. | |
vec3d | face_norm (const vector< int > &face, bool allow_zero=false) const |
Get a face normal, for a face. | |
vec3d | face_nearpt (int f_idx, vec3d P) const |
Get the nearest point on a face to another point, for a face index. | |
vec3d | face_nearpt (const vector< int > &face, vec3d P) const |
Get the nearest point on a face to another point, for a face. | |
vec3d | edge_cent (int e_idx) const |
Get an edge centre (the centroid), for an edge index. | |
vec3d | edge_cent (const vector< int > &edge) const |
Get an edge centre (the centroid), for an edge. | |
vec3d | edge_vec (int e_idx) const |
Get the vector between the ends of an edge, for an edge index. | |
vec3d | edge_vec (const vector< int > &edge) const |
Get the vector between the ends of an edge, for an edge. | |
vec3d | edge_vec (int v_idx0, int v_idx1) const |
Get the vector between two vertices by vertex index. | |
vec3d | edge_nearpt (int e_idx, vec3d P) const |
Get the nearest point on an edge to another point, for a edge index. | |
vec3d | edge_nearpt (const vector< int > &edge, vec3d P) const |
Get the nearest point on an edge to another point, for an edge. | |
double | edge_len (int e_idx) const |
Get the length of an edge, for an edge index. | |
double | edge_len (const vector< int > &edge) const |
Get the length of an edge, for an edge. | |
virtual bool | read (string file_name="", char *errmsg=0) |
Read geometry from a file. | |
virtual bool | read (FILE *file, char *errmsg=0) |
Read geometry from a file stream. | |
virtual bool | read_resource (string res_name="", char *errmsg=0) |
Read resource geometry from resource model name. | |
virtual bool | write (string file_name="", char *errmsg=0, int sig_dgts=DEF_SIG_DGTS) const |
Write geometry to a file. | |
virtual void | write (FILE *file, int sig_dgts=DEF_SIG_DGTS) const |
Write geometry to a file stream. | |
virtual bool | write_crds (string file_name="", char *errmsg=0, const char *sep=" ", int sig_dgts=DEF_SIG_DGTS) const |
Write coordinates to a file. | |
virtual void | write_crds (FILE *file, const char *sep=" ", int sig_dgts=DEF_SIG_DGTS) const |
Write coordinates to a file stream. | |
bool | is_oriented () const |
Check if geomtery is consistently oriented. | |
geom_info | get_info () const |
Get geom_info object. | |
void | get_impl_edges (vector< vector< int > > &edgs) const |
Get implicit edges. |
Geometry Interface.
int geom_if::add_edge | ( | const vector< int > | edge | ) | [virtual] |
Add an edge.
The edge is added only if it is not already present in the edge list.
edge | edge to add. |
int geom_if::add_edge | ( | int | v_idx1, |
int | v_idx2 | ||
) | [virtual] |
Add an edge from vertex index numbers.
v_idx1 | index number of first vertex. |
v_idx2 | index number of second vertex. |
int geom_if::add_edge_raw | ( | const vector< int > & | edge | ) | [virtual] |
Add an edge without checking it is valid.
This function is much faster than add_edge()
. The edge should have the lowest vertex index first. The edge should not already be included in the edge list.
edge | edge to add. |
int geom_if::add_edges | ( | const vector< vector< int > > & | edgs | ) | [virtual] |
Add several edges.
Each edge is added only if it is not already present in the edge list.
edgs | edges to add. |
int geom_if::add_edges_raw | ( | const vector< vector< int > > & | edgs | ) | [virtual] |
Add several edges without checking they are valid.
This function is much faster than add_edges()
. The edges should have the lowest vertex index first. The edges should not already be included in the edge list.
edgs | edges to add. |
int geom_if::add_face | ( | int | v1, |
... | |||
) | [virtual] |
Add a face made from integer arguments.
The final argument must be a dummy value of -1
.
v1 | the first index |
... | further indexes in the face, and a final -1 to terminate. |
int geom_if::add_face | ( | const vector< int > & | face | ) | [virtual] |
Add a face.
face | face to add. |
int geom_if::add_faces | ( | const vector< vector< int > > & | fces | ) | [virtual] |
Add several faces.
fces | faces to add. |
int geom_if::add_hull | ( | string | qh_args = "" , |
char * | errmsg = 0 |
||
) |
Add the faces of the convex hull to the geometry.
qh_args | additional arguments to pass to qhull (unsupported, may not work, check output.) |
errmsg | an array at least MSG_SZ chars long to return any error message. |
void geom_if::add_missing_impl_edges | ( | ) | [virtual] |
Add missing implicit edges.
Add implicit edges (edges of faces) to the edge list if they are not already included
Reimplemented in col_geom_v.
int geom_if::add_vert | ( | vec3d | vert | ) | [virtual] |
Add a vertex.
vert | vertex to add. |
int geom_if::add_verts | ( | const vector< vec3d > & | vrts | ) | [virtual] |
Add several vertices.
vrts | vertices to add. |
void geom_if::append | ( | const geom_if & | geom | ) | [virtual] |
Append a geometry.
Include the elements of a geometry after the current set of elements
Reimplemented in col_geom_v.
vec3d geom_if::centroid | ( | ) | const [inline] |
Get the centroid of all the vertices.
void geom_if::delete_edges | ( | const vector< int > & | e_idxs, |
map< int, int > * | edge_map = 0 |
||
) | [virtual] |
Delete several edges.
e_idxs | edge index numbers to delete |
edge_map | a map of old index numbers to new index numbers, deleted edges map to index -1 . |
Reimplemented in col_geom_v.
void geom_if::delete_faces | ( | const vector< int > & | f_idxs, |
map< int, int > * | face_map = 0 |
||
) | [virtual] |
Delete several faces.
f_idxs | face index numbers to delete |
face_map | a map of old index numbers to new index numbers, deleted faces map to index -1 . |
Reimplemented in col_geom_v.
void geom_if::delete_vert | ( | int | v_idx, |
map< int, int > * | vert_map = 0 |
||
) | [virtual] |
Delete a vertex.
When deleting several vertices is is more efficient to use delete_verts()
.
v_idx | vertex index number to delete |
vert_map | a map of old index numbers to new index numbers, deleted vertices map to index -1 . |
void geom_if::delete_verts | ( | const vector< int > & | v_idxs, |
map< int, int > * | vert_map = 0 |
||
) | [virtual] |
Delete several vertices.
v_idxs | vertex index numbers to delete |
vert_map | a map of old index numbers to new index numbers, deleted vertices map to index -1 . |
Reimplemented in col_geom_v.
vec3d geom_if::edge_cent | ( | int | e_idx | ) | const [inline] |
Get an edge centre (the centroid), for an edge index.
e_idx | edge index number. |
vec3d geom_if::edge_cent | ( | const vector< int > & | edge | ) | const [inline] |
Get an edge centre (the centroid), for an edge.
edge | contains the two vertex index numbers. |
double geom_if::edge_len | ( | int | e_idx | ) | const [inline] |
Get the length of an edge, for an edge index.
e_idx | edge index number. |
double geom_if::edge_len | ( | const vector< int > & | edge | ) | const [inline] |
Get the length of an edge, for an edge.
edge | contains the two vertex index numbers. |
Get the nearest point on an edge to another point, for a edge index.
e_idx | edge index number. |
P | the point |
P
on the line of the edge. Get the nearest point on an edge to another point, for an edge.
edge | contains the two vertex index numbers. |
P | the point |
P
on the line of the edge. vec3d geom_if::edge_v | ( | int | e_idx, |
int | v_no | ||
) | const [inline] |
Get the coordinates of a vertex of an edge.
e_idx | edge index number. |
v_no | the position the vertex appears in the edge, 0 or 1 |
vec3d geom_if::edge_vec | ( | const vector< int > & | edge | ) | const [inline] |
Get the vector between the ends of an edge, for an edge.
edge | contains the two vertex index numbers. |
vec3d geom_if::edge_vec | ( | int | e_idx | ) | const [inline] |
Get the vector between the ends of an edge, for an edge index.
e_idx | edge index number. |
vec3d geom_if::edge_vec | ( | int | v_idx0, |
int | v_idx1 | ||
) | const [inline] |
Get the vector between two vertices by vertex index.
v_idx0 | start vertex index number. |
v_idx1 | end vertex index number. |
virtual const vector<int>& geom_if::edges | ( | int | e_idx | ) | const [pure virtual] |
Read access to an edge.
e_idx | index number of the edge. |
Implemented in geom_v.
virtual int geom_if::edges | ( | int | e_idx, |
int | v_no | ||
) | const [pure virtual] |
Get the index number of a vertex of an edge.
e_idx | edge index number. |
v_no | the position the vertex appears in the edge, 0 or 1 |
Implemented in geom_v.
virtual const vector<vector<int> >& geom_if::edges | ( | ) | const [pure virtual] |
vec3d geom_if::face_cent | ( | int | f_idx | ) | const [inline] |
Get a face centroid, for a face index.
f_idx | face index number. |
vec3d geom_if::face_cent | ( | const vector< int > & | face | ) | const [inline] |
Get a face centroid, for a face.
face | contains the vertex index numbers. |
void geom_if::face_cents | ( | vector< vec3d > & | ctds | ) | const [inline] |
Get all the face centroids.
ctds | vector used to return the coordinates of the centroids. |
Get the nearest point on a face to another point, for a face.
face | contains the vertex index numbers. |
P | the point |
P
on the face plane. Get the nearest point on a face to another point, for a face index.
f_idx | face index number. |
P | the point |
P
on the face plane. vec3d geom_if::face_norm | ( | const vector< int > & | face, |
bool | allow_zero = false |
||
) | const [inline] |
Get a face normal, for a face.
face | contains the vertex index numbers in the face. |
allow_zero | if true then the magnitude of the normal is the area of the face, if false then for faces with near-zero area a normal with a more accurate direction is calculated. |
vec3d geom_if::face_norm | ( | int | f_idx, |
bool | allow_zero = false |
||
) | const [inline] |
Get a face normal, for a face index.
f_idx | the face index number. |
allow_zero | if true then the magnitude of the normal is the area of the face, if false then for faces with near-zero area a normal with a more accurate direction is calculated. |
void geom_if::face_norms | ( | vector< vec3d > & | norms, |
bool | allow_zero = false |
||
) | const [inline] |
Get all the face normals.
norms | vector used to return the normals. |
allow_zero | if true then the magnitude of the normal is the area of the face, if false then for faces with near-zero area a normal with a more accurate direction is calculated. |
vec3d geom_if::face_v | ( | int | f_idx, |
int | v_no | ||
) | const [inline] |
Get the coordinates of a vertex of an face.
f_idx | face index number. |
v_no | the posisition the vertex appears in the face, 0 , 1 , 2 , ... |
virtual const vector<int>& geom_if::faces | ( | int | f_idx | ) | const [pure virtual] |
Read access to a face.
f_idx | index number of the face. |
Implemented in geom_v.
virtual int geom_if::faces | ( | int | f_idx, |
int | v_no | ||
) | const [pure virtual] |
Get the index number of a vertex of a face.
f_idx | face index number. |
v_no | the position the vertex appears in the face, 0 , 1 , 2 , ... |
Implemented in geom_v.
virtual const vector<vector<int> >& geom_if::faces | ( | ) | const [pure virtual] |
int geom_if::faces_mod | ( | int | f_idx, |
int | v_no | ||
) | const [inline, virtual] |
Get the index number of a vertex of a face mod the size of the face.
f_idx | face index number. |
v_no | the position the vertex appears in the face, 0 , 1 , 2 , ... |
void geom_if::get_impl_edges | ( | vector< vector< int > > & | edgs | ) | const |
Get implicit edges.
Returns the edges of the polygon faces
edgs | the edges are returned here |
geom_info geom_if::get_info | ( | ) | const |
Get geom_info object.
Get a star of vectors to use for making a zonohedron.
type | the type of star to make can be
|
centre | the centre to use when the type is v. |
bool geom_if::is_oriented | ( | ) | const |
Check if geomtery is consistently oriented.
true
if consistently oriented, otherwise false
. geom_if::operator bool | ( | ) | const [inline] |
Check whether geometry is set.
true
if the geometry is set, otherwise false
. int geom_if::orient | ( | vector< vector< int > > * | parts = 0 | ) |
Orient the geometry (if possible.)
parts | used to return the index numbers of the faces in each of the disconnected parts (if parts is not 0 .) |
bool geom_if::orient | ( | int | type, |
char * | errmsg = 0 |
||
) |
Orient the geometry (if possible.)
type | type of orientation, 1 - positive volume, 2 negative volume, 3 - reverse first face and orient, 4 - reverse faces without orienting. |
errmsg | to return any error messages |
true
if the orientation was succesful, otherwise false
. virtual vector<vector<int> >& geom_if::raw_edges | ( | ) | [pure virtual] |
virtual vector<vector<int> >& geom_if::raw_faces | ( | ) | [pure virtual] |
virtual vector<vec3d>& geom_if::raw_verts | ( | ) | [pure virtual] |
Read/Write access to the vertices.
Implemented in geom_v.
bool geom_if::read | ( | FILE * | file, |
char * | errmsg = 0 |
||
) | [virtual] |
Read geometry from a file stream.
The file is first read as a normal OFF file, if that fails it will be read as a Qhull formatted OFF file, and if that fails the file will be read for any coordinates (lines that contains three numbers separated by commas and/or spaces will be taken as a set of coordinates.)
file | the file stream. |
errmsg | an array at least MSG_SZ chars long to return any error message. |
bool geom_if::read | ( | string | file_name = "" , |
char * | errmsg = 0 |
||
) | [virtual] |
Read geometry from a file.
The file is first read as a normal OFF file, if that fails it will be read as a Qhull formatted OFF file, and if that fails the file will be read for any coordinates (lines that contains three numbers separated by commas and/or spaces will be taken as a set of coordinates.)
file_name | the file name ("" or "-" for standard input). |
errmsg | an array at least MSG_SZ chars long to return any error message. |
bool geom_if::read_resource | ( | string | res_name = "" , |
char * | errmsg = 0 |
||
) | [virtual] |
Read resource geometry from resource model name.
res_name | the resource model name. |
errmsg | an array at least MSG_SZ chars long to return any error message. |
bool geom_if::set_geodesic_planar | ( | const geom_if & | base, |
int | m, | ||
int | n = 0 |
||
) |
Set planar geodesic division.
A Class I pattern is made with m=0,n=1. A Class II pattern is made with m=1,n=1. A Class III pattern is made with n>=1,m>1.
base | the base polyhedron |
m | the first pattern specifier. |
n | the second pattern specifier. |
bool geom_if::set_geodesic_sphere | ( | const geom_if & | base, |
int | m, | ||
int | n = 0 , |
||
vec3d | cent = vec3d(0,0,0) |
||
) |
Set spherical geodesic division.
A Class I pattern is made with m=0,n=1. A Class II pattern is made with m=1,n=1. A Class III pattern is made with n>=1,m>1.
base | the base polyhedron |
m | the first pattern specifier. |
n | the second pattern specifier. |
cent | the centre of projection. |
int geom_if::set_hull | ( | string | qh_args = "" , |
char * | errmsg = 0 |
||
) |
Set the geometry to its convex hull.
If the convex hull could not be calculated the the geometry will be left empty.
qh_args | additional arguments to pass to qhull (unsupported, may not work, check output.) |
errmsg | an array at least MSG_SZ chars long to return any error message. |
bool geom_if::set_zono | ( | const vector< vec3d > & | star, |
char * | errmsg = 0 |
||
) |
Set the geometry to a zonohedron made from a star.
star | the star of vectors. |
errmsg | an array at least MSG_SZ chars long to return any error message. |
Project the vertices onto a sphere.
centre | the centre of the sphere. |
radius | the radius of the sphere. |
void geom_if::transform | ( | const mat3d & | trans | ) | [inline] |
Apply a transformation matrix.
trans | the transformation matrix. |
void geom_if::triangulate | ( | col_val | col = col_val() , |
unsigned int | winding = TESS_WINDING_NONZERO , |
||
vector< int > * | fmap = 0 |
||
) |
Triangulate (tesselate) the faces.
Divide the faces into triangles, adding new vertices as necessary, and coloured edges if a colour is set for new elements.
col | the colour for any new edges or vertices that were added. The default leaves them with default colours. If it is set to col_val::invisible then the new elements are given a colour that indicates that they should not be displayed. |
winding | selects resulting faces acording to winding number TESS_WINDING_ODD TESS_WINDING_NONZERO (default) TESS_WINDING_POSITIVE TESS_WINDING_NEGATIVE TESS_WINDING_ABS_GEQ_TWO |
fmap | a vector to return the face mapping. Each old face index maps to the first index of faces it was converted to. A final index holds the total number of new faces |
virtual const vector<vec3d>& geom_if::verts | ( | ) | const [pure virtual] |
virtual const vec3d& geom_if::verts | ( | int | v_idx | ) | const [pure virtual] |
Read access to a vertex.
v_idx | index number of the vertex. |
Implemented in geom_v.
void geom_if::verts_merge | ( | map< int, int > & | vmap | ) |
Merge some of the vertices.
vmap | a map from each vertex index number to the index number of the vertex it will be replaced with |
void geom_if::write | ( | FILE * | file, |
int | sig_dgts = DEF_SIG_DGTS |
||
) | const [virtual] |
Write geometry to a file stream.
file | the file stream. |
sig_dgts | the number of significant digits to write, or if negative then the number of digits after the decimal point. |
bool geom_if::write | ( | string | file_name = "" , |
char * | errmsg = 0 , |
||
int | sig_dgts = DEF_SIG_DGTS |
||
) | const [virtual] |
Write geometry to a file.
file_name | the file name ("" for standard output.) |
errmsg | an array at least MSG_SZ chars long to return any error message. |
sig_dgts | the number of significant digits to write, or if negative then the number of digits after the decimal point. |
void geom_if::write_crds | ( | FILE * | file, |
const char * | sep = " " , |
||
int | sig_dgts = DEF_SIG_DGTS |
||
) | const [virtual] |
Write coordinates to a file stream.
file | the file stream. |
sep | a string to use as the seperator between coordinates. |
sig_dgts | the number of significant digits to write, or if negative then the number of digits after the decimal point. |
bool geom_if::write_crds | ( | string | file_name = "" , |
char * | errmsg = 0 , |
||
const char * | sep = " " , |
||
int | sig_dgts = DEF_SIG_DGTS |
||
) | const [virtual] |
Write coordinates to a file.
file_name | the file name ("" for standard output.) |
errmsg | an array at least MSG_SZ chars long to return any error message. |
sep | a string to use as the seperator between coordinates. |
sig_dgts | the number of significant digits to write, or if negative then the number of digits after the decimal point. |