xc
SolidExtru3d.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 //SolidExtru3d.h
22 
23 #ifndef SOLIDEXTRU3D_H
24 #define SOLIDEXTRU3D_H
25 
26 #include "Solid3d.h"
27 #include "BND3d.h"
28 #include "../FT_matrix.h"
29 #include "../pos_vec/Pos3d.h"
30 
31 
33 //
37 template<class S>
38 class SolidExtru3d : public Solid3d
39  {
40  protected:
41  S scc;
42  GEOM_FT l;
43  public:
44  SolidExtru3d(void): Solid3d(), scc(),l(1.0) {}
45  SolidExtru3d(const S &secc,const GEOM_FT &lng): scc(secc), l(lng) {}
46  explicit SolidExtru3d(const SolidExtru3d<S> &se)
47  : Solid3d(se), scc(se.scc), l(se.l) {}
48  SolidExtru3d<S> &operator=(const SolidExtru3d<S> &se)
49  {
51  scc=se.scc;
52  l= se.l;
53  return *this;
54  }
55  virtual GeomObj *getCopy(void) const
56  { return new SolidExtru3d<S>(*this); }
58  void self_offset(const GEOM_FT &offset)
59  {
60  scc= scc.offset(offset);
61  l+=2.0*offset;
62  }
64  SolidExtru3d<S> offset(const GEOM_FT &offset) const
65  {
66  SolidExtru3d<S> retval(this);
67  retval.self_offset(offset);
68  return retval;
69  }
71  const S &Section(void) const
72  { return scc; }
74  S &Section(void)
75  { return scc; }
77  inline GEOM_FT getArea(void) const
78  {
79  GEOM_FT area= 2*scc.getArea();
80  area+= scc.getLength()*l;
81  return area;
82  }
84  inline GEOM_FT getLength(void) const
85  { return l; }
87  inline GEOM_FT getVolume(void) const
88  { return scc.getArea() * l; }
89  inline virtual GEOM_FT Ix(void) const
90  { return scc.Ix()*l + scc.getArea()*l*l*l/12; }
91  inline virtual GEOM_FT Iy(void) const
92  { return scc.Iy()*l + scc.getArea()*l*l*l/12; }
93  inline virtual GEOM_FT Iz(void) const
94  { return (scc.Ix()+scc.Iy())*l; }
95 /* inline Pos3d getCenterOfMassOfBase(unsigned short int i) const */
96 /* //Return the center of mass of one of the bases. */
97 /* //0 bottom base (z=-l/2) and 1 top */
98 /* //base (z=+l/2). */
99 /* { */
100 /* if(i) */
101 /* return scc.getGlobalPosition(Pos3d(0,0,l/2.0)); */
102 /* else */
103 /* return scc.getGlobalPosition(Pos3d(0,0,-l/2.0)); */
104 /* } */
105 /* inline Pos3d getCenterOfMassOfTop(void) const */
106 /* { return getCenterOfMassOfBase(1); } */
107 /* inline Pos3d getCenterOfMassOfBottom(void) const */
108 /* { return getCenterOfMassOfBase(0); } */
109 /* inline S GetBase(unsigned short int i) const */
110 /* //0 la base inferior (z=-l/2) y 1 la */
111 /* //base superior (z=+l/2). */
112 /* { */
113 /* Pos3d p= getCenterOfMassOfBase(i); */
114 /* S secc= scc; */
115 /* secc.setOrg(p); */
116 /* return secc; */
117 /* } */
119  inline virtual GEOM_FT GetMax(unsigned short int i) const
120  {
121  //return max(GetBase(0).GetMax(i),GetBase(1).GetMax(i));
122  std::cerr << "SolidExtru3d::" << __FUNCTION__
123  << "not implemented." << std::endl;
124  return 0.0;
125  }
127  inline virtual GEOM_FT GetMin(unsigned short int i) const
128  {
129  //return min(GetBase(0).GetMin(i),GetBase(1).GetMin(i));
130  std::cerr << "SolidExtru3d::" << __FUNCTION__
131  << "not implemented." << std::endl;
132  return 0.0;
133  }
134  BND3d Bnd(void) const
135  //Return la extension of the object.
136  { return GeomObj3d::Bnd(); }
137  FT_matrix I(void) const
138  { return GeomObj3d::I(); }
139  Pos3d getCenterOfMass(void) const
140  { return scc.getCenterOfMass(); }
141  };
142 
143 #endif
144 
145 
146 
147 
148 
149 
void self_offset(const GEOM_FT &offset)
offset this object.
Definition: SolidExtru3d.h:58
SolidExtru3d, sólidos de extrusión.
Definition: SolidExtru3d.h:38
virtual GEOM_FT GetMax(unsigned short int i) const
Return the maximum value of the i-th coordinate.
Definition: SolidExtru3d.h:119
EntityWithOwner & operator=(const EntityWithOwner &)
Assignment operator.
Definition: EntityWithOwner.cc:53
Clase base para los sólidos en tres dimensiones.
Definition: Solid3d.h:31
virtual GEOM_FT GetMin(unsigned short int i) const
Return the minimum value of the i-th coordinate.
Definition: SolidExtru3d.h:127
SolidExtru3d< S > offset(const GEOM_FT &offset) const
get an object parallel to this one, at a fixed distance.
Definition: SolidExtru3d.h:64
GEOM_FT getLength(void) const
Return object length.
Definition: SolidExtru3d.h:84
const S & Section(void) const
Return the extruded section.
Definition: SolidExtru3d.h:71
"boundary" en tres dimensiones.
Definition: BND3d.h:34
S & Section(void)
Return the extruded section.
Definition: SolidExtru3d.h:74
S scc
Surface that create the solid.
Definition: SolidExtru3d.h:41
GEOM_FT getArea(void) const
Return the object area.
Definition: SolidExtru3d.h:77
Posición en tres dimensiones.
Definition: Pos3d.h:44
Solid3d(void)
Constructor.
Definition: Solid3d.cc:27
FT_matrix I(void) const
Return the inertia tensor with respect to the center of mass of the object.
Definition: GeomObj3d.cc:157
BND3d Bnd(void) const
Return the boundary of the object.
Definition: GeomObj3d.cc:82
GEOM_FT getVolume(void) const
Return the object volume.
Definition: SolidExtru3d.h:87
GEOM_FT l
Lentgh of the extruded solid (negative if undefined).
Definition: SolidExtru3d.h:42
Clase base para las entidades geométricas.
Definition: GeomObj.h:40
Matrix which components are GEOM_FT numbers.
Definition: FT_matrix.h:40