Bsoft  2.1.0
Bernard's software package
model_poly_spiral.cpp File Reference

Functions to generate polyhedra using the spiral algorithm. More...

#include "rwmodel.h"
#include "model_poly.h"
#include "model_poly_spiral.h"
#include "model_mechanics.h"
#include "model_links.h"
#include "model_transform.h"
#include "model_util.h"
#include "Matrix.h"
#include "math_util.h"
#include "linked_list.h"
#include "Vector3.h"
#include "utilities.h"
#include <sys/stat.h>
#include <fcntl.h>

Go to the source code of this file.

Functions

int polygon_add (int n, int valence, Bmodel *model)
 
int seq_count_adj_pentagons (Bstring &seq)
 
int model_vertex_types_in_first_polygons (Bmodel *model, int npoly)
 
int model_adjacent_pentagons (Bmodel *model)
 
int model_adjacent_pentagons_in_first_polygons (Bmodel *model, int npoly)
 
Bmodel * model_poly_spiral (Bstring &seq, int valence, int requirements)
 Generates a polyhedron using the spiral algorithm. More...
 
int model_poly_spiral_regularize (Bmodel *model)
 
int model_polyhedron_check (Bmodel *model, int valence)
 Checks a polyhedron for accuracy and completeness. More...
 
Bmodel * model_poly_gen_sequence (Bstring &seq, int valence, int enantiomorph, int requirements, int nm)
 Generates a polyhedron using a given sequence. More...
 
Bmodel * model_poly_gen_sequence (Bstring &seq, int valence, int enantiomorph, int requirements, int nm, double *table)
 Generates a polyhedron using a given sequence. More...
 
Bmodel * model_poly_gen_permutations (int vertices, int valence, int enantiomorph)
 All polyhedra are generated for a given number of vertices. More...
 
Bmodel * model_poly_gen_cone (int tip, int body, int base, int valence, int enantiomorph, int requirements)
 A cone tip with 5 pentagons and a base with 7 pentagons are use to generate polyhedra. More...
 
Bmodel * model_poly_gen_lozenge (int ttop, int tbody, int valence, int enantiomorph, int requirements)
 Two icosahedral tips are set up and polyhedra generated by rotating the 2 tips. More...
 
Bmodel * model_poly_gen_coffin (int ttop, int tbody, int tbase, int valence, int enantiomorph, int requirements)
 An icosahedral tip and a 6-fold base is set up and polyhedra generated by rotating the tip and base. More...
 
Bmodel * model_poly_gen_coffin_loose (int ttop, int tbody, int tbase, int valence, int enantiomorph, int requirements)
 An icosahedral tip and a 6-fold base is set up and polyhedra generated by permuting the tip and base. More...
 
Bmodel * model_poly_gen_coffin_jiggle (int ttop, int tbody, int tbase, int valence, int enantiomorph, int requirements)
 An icosahedral tip and a 6-fold base is set up and polyhedra generated by moving pentagons around. More...
 
Bmodel * model_poly_gen_3part (Bstring stip, Bstring sbody, Bstring sbase, int valence, int enantiomorph, int requirements)
 Generates several polyhedra by permuting the first and last parts of a three-part sequence. More...
 
Bmodel * move_pentagons (int len, int p[12], int n, int valence, int enantiomorph, int requirements, int *nm)
 
Bmodel * model_poly_gen_move_pentagons (Bstring &seq, int valence, int enantiomorph, int requirements)
 Generates many polyhedrons using a given sequence and moving pentagons around. More...
 

Variables

int verbose
 

Detailed Description

Functions to generate polyhedra using the spiral algorithm.

Author
Bernard Heymann
Date
Created: 20071127
Modified: 20110810

Definition in file model_poly_spiral.cpp.

Function Documentation

◆ model_adjacent_pentagons()

int model_adjacent_pentagons ( Bmodel *  model)

Definition at line 228 of file model_poly_spiral.cpp.

◆ model_adjacent_pentagons_in_first_polygons()

int model_adjacent_pentagons_in_first_polygons ( Bmodel *  model,
int  npoly 
)

Definition at line 243 of file model_poly_spiral.cpp.

◆ model_poly_gen_3part()

Bmodel* model_poly_gen_3part ( Bstring  stip,
Bstring  sbody,
Bstring  sbase,
int  valence,
int  enantiomorph,
int  requirements 
)

Generates several polyhedra by permuting the first and last parts of a three-part sequence.

A recursive algorithm is used to generate several models by shifting the 
positions of pentagons in a sequence. 
Parameters
stiptip sequence (permuted).
sbodybody sequence (all hexagons).
sbasebase/end sequence (permuted).
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 814 of file model_poly_spiral.cpp.

◆ model_poly_gen_coffin()

Bmodel* model_poly_gen_coffin ( int  ttop,
int  tbody,
int  tbase,
int  valence,
int  enantiomorph,
int  requirements 
)

An icosahedral tip and a 6-fold base is set up and polyhedra generated by rotating the tip and base.

Parameters
ttopnumber of polygons between pentagons in the tip.
tbodynumber of body rings.
tbasenumber of polygons between pentagons in the base
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 665 of file model_poly_spiral.cpp.

◆ model_poly_gen_coffin_jiggle()

Bmodel* model_poly_gen_coffin_jiggle ( int  ttop,
int  tbody,
int  tbase,
int  valence,
int  enantiomorph,
int  requirements 
)

An icosahedral tip and a 6-fold base is set up and polyhedra generated by moving pentagons around.

Parameters
ttopnumber of polygons between pentagons in the tip.
tbodynumber of body rings.
tbasenumber of polygons between pentagons in the base
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 770 of file model_poly_spiral.cpp.

◆ model_poly_gen_coffin_loose()

Bmodel* model_poly_gen_coffin_loose ( int  ttop,
int  tbody,
int  tbase,
int  valence,
int  enantiomorph,
int  requirements 
)

An icosahedral tip and a 6-fold base is set up and polyhedra generated by permuting the tip and base.

Parameters
ttopnumber of polygons between pentagons in the tip.
tbodynumber of body rings.
tbasenumber of polygons between pentagons in the base
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 732 of file model_poly_spiral.cpp.

◆ model_poly_gen_cone()

Bmodel* model_poly_gen_cone ( int  tip,
int  body,
int  base,
int  valence,
int  enantiomorph,
int  requirements 
)

A cone tip with 5 pentagons and a base with 7 pentagons are use to generate polyhedra.

Parameters
tipnumber of vertices in the tip.
bodynumber of vertices in the body.
basenumber of vertices in the base.
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 557 of file model_poly_spiral.cpp.

◆ model_poly_gen_lozenge()

Bmodel* model_poly_gen_lozenge ( int  ttop,
int  tbody,
int  valence,
int  enantiomorph,
int  requirements 
)

Two icosahedral tips are set up and polyhedra generated by rotating the 2 tips.

Parameters
ttopnumber of polygons between pentagons in the tip.
tbodynumber of body rings.
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 598 of file model_poly_spiral.cpp.

◆ model_poly_gen_move_pentagons()

Bmodel* model_poly_gen_move_pentagons ( Bstring &  seq,
int  valence,
int  enantiomorph,
int  requirements 
)

Generates many polyhedrons using a given sequence and moving pentagons around.

A recursive algorithm is used to generate several models by shifting the 
positions of pentagons in a sequence. 
Parameters
&seqpolygon sequence.
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 915 of file model_poly_spiral.cpp.

◆ model_poly_gen_permutations()

Bmodel* model_poly_gen_permutations ( int  vertices,
int  valence,
int  enantiomorph 
)

All polyhedra are generated for a given number of vertices.

Parameters
verticesnumber of vertices.
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 494 of file model_poly_spiral.cpp.

◆ model_poly_gen_sequence() [1/2]

Bmodel* model_poly_gen_sequence ( Bstring &  seq,
int  valence,
int  enantiomorph,
int  requirements,
int  nm 
)

Generates a polyhedron using a given sequence.

A single model is generated based on the sequence. 
Parameters
&seqpolygon sequence.
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
nmcurrent number of models (before creating this one).
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 399 of file model_poly_spiral.cpp.

◆ model_poly_gen_sequence() [2/2]

Bmodel* model_poly_gen_sequence ( Bstring &  seq,
int  valence,
int  enantiomorph,
int  requirements,
int  nm,
double *  table 
)

Generates a polyhedron using a given sequence.

A single model is generated based on the sequence. 
A table is used to keep track of sets of eigenvalues of previous models
to avoid generating redundant models. 
Parameters
&seqpolygon sequence.
valencevertex valence.
enantiomorphflag to generate enantiomorphs.
requirementspolyhedron requirements.
nmcurrent number of models (before creating this one).
*tabletable for sets of eigenvalues.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 419 of file model_poly_spiral.cpp.

◆ model_poly_spiral()

Bmodel* model_poly_spiral ( Bstring &  seq,
int  valence,
int  requirements 
)

Generates a polyhedron using the spiral algorithm.

Polygons are added based on the given sequence.
The success of the algorithm is checked using the indicated requirements:
    0       only a polyhedron consistency check is done
    1       the exact number of vertices must be obtained
    2       only a polyhedron with isolated pentagons is accepted
The generation fails when an incorrect number of vertices are added
or some of the vertices have incorrect valency. 
Parameters
&seqpolygon sequence.
valencevertex valence.
requirementspolyhedron requirements.
Returns
Bmodel* new model, NULL if generation failed.

Definition at line 274 of file model_poly_spiral.cpp.

◆ model_poly_spiral_regularize()

int model_poly_spiral_regularize ( Bmodel *  model)

Definition at line 317 of file model_poly_spiral.cpp.

◆ model_polyhedron_check()

int model_polyhedron_check ( Bmodel *  model,
int  valence 
)

Checks a polyhedron for accuracy and completeness.

Every component must have the required number of links = valence.
Every component must have the required number of polygons = valence.
The polyhedron must adhere to Euler's formula:
    components + polygons - links = 2
Parameters
*modelmodel structure.
valencevertex valence.
Returns
int number of failed conditions.

Definition at line 336 of file model_poly_spiral.cpp.

◆ model_vertex_types_in_first_polygons()

int model_vertex_types_in_first_polygons ( Bmodel *  model,
int  npoly 
)

Definition at line 206 of file model_poly_spiral.cpp.

◆ move_pentagons()

Bmodel* move_pentagons ( int  len,
int  p[12],
int  n,
int  valence,
int  enantiomorph,
int  requirements,
int *  nm 
)

Definition at line 864 of file model_poly_spiral.cpp.

◆ polygon_add()

int polygon_add ( int  n,
int  valence,
Bmodel *  model 
)

Definition at line 39 of file model_poly_spiral.cpp.

◆ seq_count_adj_pentagons()

int seq_count_adj_pentagons ( Bstring &  seq)

Definition at line 196 of file model_poly_spiral.cpp.

Variable Documentation

◆ verbose

int verbose
extern