xc
SolidExtruPolygon3d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //SolidExtruPolygon3d.h
22 
23 #ifndef SOLIDEXTRUPLGNO3D_H
24 #define SOLIDEXTRUPLGNO3D_H
25 
26 #include "SolidExtru3d.h"
27 
29 //
31 template<class PG>
33  {
34  public:
36  inline unsigned int get_num_vertices_plgno(void) const
37  { return this->scc.getNumVertices(); }
38  public:
39  SolidExtruPolygon3d(void) {}
40  SolidExtruPolygon3d(const PG &secc,const GEOM_FT &lng): solid_extru_pg(secc,lng) {}
41 
42  virtual GeomObj *getCopy(void) const
43  { return new SolidExtruPolygon3d<PG>(*this); }
44  virtual unsigned int getNumVertices(void) const
45  { return 2*get_num_vertices_plgno(); }
46  virtual unsigned int getNumVerticesFaceta(unsigned int faceta) const;
47  inline virtual unsigned int getNumEdges(void) const
48  { return 3*this->scc.getNumEdges(); }
49  inline virtual unsigned int GetNumFacetas(void) const
50  { return 2+this->scc.getNumEdges(); }
51  Pos3d Vertice(unsigned int i) const;
52 /* virtual Polyhedron::v_ind_vertices IndVerticesArista(unsigned int arista) const; */
53 /* virtual Polyhedron::v_ind_vertices IndVerticesFaceta(unsigned int faceta) const; */
54  inline BND3d Bnd(void) const
55  //Return la extension del objeto.
56  { return solid_extru_pg::Bnd(); }
57  inline FT_matrix I(void) const
58  { return solid_extru_pg::I(); }
59  inline Pos3d getCenterOfMass(void) const
60  { return solid_extru_pg::getCenterOfMass(); }
61 
62  };
63 
64 template <class PG>
65 unsigned int SolidExtruPolygon3d<PG>::getNumVerticesFaceta(unsigned int faceta) const
66  {
67  unsigned int retval= 4;
68  unsigned int nf= GetNumFacetas();
69  unsigned int ifc= faceta%nf;
70  if((ifc==0)||(ifc==(nf-1))) retval= get_num_vertices_plgno();
71  return retval;
72  }
73 
74 template <class PG>
75 Pos3d SolidExtruPolygon3d<PG>::Vertice(unsigned int i) const
76  {
77  Pos3d p;
78  const unsigned int num_vert_plgno= get_num_vertices_plgno();
79  unsigned int j=i;
80  if(i>num_vert_plgno) j-=num_vert_plgno;
81  if(i<num_vert_plgno)
82  p= this->GetBase(0).Vertice(j);
83  else
84  p= this->GetBase(1).Vertice(j);
85  return p;
86  }
87 
88 /* template <class PG> */
89 /* Polyhedron::v_ind_vertices SolidExtruPolygon3d<PG>::IndVerticesArista(unsigned int arista) const */
90 /* { */
91 /* const unsigned int num_edges= getNumEdges(); */
92 /* Polyhedron::v_ind_vertices va(2); */
93 /* const unsigned int indice= arista%num_edges; */
94 /* const unsigned int num_vert_plgno= get_num_vertices_plgno(); */
95 /* if(indice<num_vert_plgno) //Si es una arista de la base */
96 /* { */
97 /* va[0]= indice; va[1]= indice + 1; */
98 /* if(va[1]>=num_vert_plgno) va[1]= 0; //Cierra con el primer vértice de la base. */
99 /* return va; */
100 /* } */
101 /* if(indice>=(2*num_vert_plgno)) //Si es una arista de la tapa. */
102 /* { */
103 /* va[0]= indice-num_vert_plgno; */
104 /* va[1]= va[0] + 1; */
105 /* if(va[1]>=2*num_vert_plgno) va[1]= num_vert_plgno; //Cierra con el primer vértice de la tapa. */
106 /* return va; */
107 /* } */
108 /* //En other caso, es una arista lateral. */
109 /* va[1]= indice; */
110 /* va[0]= indice - num_vert_plgno; */
111 /* return va; */
112 /* } */
113 /* template <class PG> */
114 /* Polyhedron::v_ind_vertices SolidExtruPolygon3d<PG>::IndVerticesFaceta(unsigned int faceta) const */
115 /* { */
116 /* const unsigned int num_facetas= GetNumFacetas(); */
117 /* const unsigned int num_vert_plgno= get_num_vertices_plgno(); */
118 /* const unsigned int nv= getNumVertices(); */
119 /* const unsigned int ifac= faceta%num_facetas; */
120 /* if(ifac == 0) //Es la base. */
121 /* { */
122 /* Polyhedron::v_ind_vertices iv(num_vert_plgno); */
123 /* for(size_t i= 0;i<num_vert_plgno;i++) */
124 /* iv[i]= i; */
125 /* return iv; */
126 /* } */
127 /* if(ifac == num_facetas-1) //Es la tapa. */
128 /* { */
129 /* Polyhedron::v_ind_vertices iv(num_vert_plgno); */
130 /* for(size_t i= nv-1,j=0;i>=num_vert_plgno;i--,j++) */
131 /* iv[j]= i; */
132 /* return iv; */
133 /* } */
134 /* //Es un lateral. */
135 /* Polyhedron::v_ind_vertices iv(4); */
136 /* iv[0]= ifac-1; //En la base. */
137 /* iv[1]= iv[0]+num_vert_plgno; //En la tapa. */
138 /* iv[2]= iv[1]+1; //En la tapa. */
139 /* if(iv[2]==nv) iv[2]= num_vert_plgno; */
140 /* iv[3]= iv[0]+1; //En la base. */
141 /* if(iv[3]==num_vert_plgno) iv[3]= 0; */
142 /* return iv; */
143 /* } */
144 
145 
146 #endif
SolidExtru3d, sólidos de extrusión.
Definition: SolidExtru3d.h:38
Sólido de extrusión generado por un polígono.
Definition: SolidExtruPolygon3d.h:32
"boundary" en tres dimensiones.
Definition: BND3d.h:34
PG scc
Surface that create the solid.
Definition: SolidExtru3d.h:41
Posición en tres dimensiones.
Definition: Pos3d.h:44
Clase base para las entidades geométricas.
Definition: GeomObj.h:40
Matrix which components are GEOM_FT numbers.
Definition: FT_matrix.h:40