xc
LineMap.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // XC program; finite element analysis code
4 // for structural analysis and design.
5 //
6 // Copyright (C) Luis C. Pérez Tato
7 //
8 // This program derives from OpenSees <http://opensees.berkeley.edu>
9 // developed by the «Pacific earthquake engineering research center».
10 //
11 // Except for the restrictions that may arise from the copyright
12 // of the original program (see copyright_opensees.txt)
13 // XC is free software: you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation, either version 3 of the License, or
16 // (at your option) any later version.
17 //
18 // This software is distributed in the hope that it will be useful, but
19 // WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program.
26 // If not, see <http://www.gnu.org/licenses/>.
27 //----------------------------------------------------------------------------
28 //LineMap.h
29 
30 #ifndef LINEMAP_H
31 #define LINEMAP_H
32 
33 #include "EntityMap.h"
34 #include "preprocessor/multi_block_topology/entities/1d/Edge.h"
35 
36 class Line3d;
37 class Plane;
38 
39 namespace XC {
40 
41 class Line;
42 class DividedLine;
43 class CmbEdge;
44 class CircularArc;
45 
47 //
49 class LineMap: public EntityMap<Edge>
50  {
51  private:
52  void updateSets(Edge *) const;
53  protected:
54  template <class E>
55  Edge *Crea(void);
56 
57  public:
58  LineMap(MultiBlockTopology *mbt= nullptr);
59 
60  Vector3d getVector(const Indice &i,const Indice &j) const;
61  Line3d getRecta(const Indice &i,const Indice &j) const;
62  Plane getPlane(const Indice &i,const Indice &j,const Indice &k) const;
63 
64  template <class E>
65  Edge *New(void);
66  template <class E>
67  Edge *New(const size_t &);
68  Edge *New(const size_t &, const std::string &);
69  Edge *createLine(Pnt *,Pnt *);
71  Edge *createArc(Pnt *,Pnt *,Pnt *);
72  Edge *createLineSequence(void);
73  Edge *createCopy(const Edge *l);
74 
75  Line *newLine(const size_t &, const size_t &);
76  DividedLine *newDividedLine(const size_t &, const size_t &);
77  CircularArc *newCircleArc(const size_t &, const size_t &, const size_t &);
78  CmbEdge *newLineSequence(void);
79 
80  double getAverageLength(void) const;
81 
82  boost::python::dict getPyDict(void) const;
83  void setPyDict(const boost::python::dict &);
84  };
85 
87 template <class E>
89  {
90  Preprocessor *preprocessor= getPreprocessor();
91  assert(preprocessor);
92  Edge *retval= new E(preprocessor);
93  const size_t tg= this->getTag();
94  retval->Name()= "l"+boost::lexical_cast<std::string>(tg);
95  (*this)[tg]= retval;
96  updateSets(retval);
97  tag++;
98  return retval;
99  }
100 
102 template <class E>
104  {
105  Edge *retval= busca(getTag());
106  if(!retval) // the edge is new.
107  retval= Crea<E>();
108  return retval;
109  }
110 
112 template <class E>
113 Edge *LineMap::New(const size_t &tag)
114  {
115  size_t old_tag= getTag();
116  Edge *retval= nullptr;
117  setTag(tag); // Edge identifier.
118  retval= busca(getTag());
119  if(retval)
120  {
121  std::cerr << getClassName() << "::" << __FUNCTION__
122  << "; edge with identifier: " << tag
123  << " already exists. Command ignored." << std::endl;
124  }
125  else
126  { retval= Crea<E>(); }
127  setTag(old_tag);
128  return retval;
129  }
130 
131 } //end of XC namespace
132 #endif
Edge * createDividedLine(Pnt *, Pnt *)
Creates a new line between the points being passed as parameters and inserts it on the container...
Definition: LineMap.cc:170
Edge * New(void)
Creates a new Edge.
Definition: LineMap.h:103
Base class for one-dimensional geometry objects.
Definition: Edge.h:48
Edge * createLine(Pnt *, Pnt *)
Find a line between the points or creates a new one.
Definition: LineMap.cc:133
CmbEdge * newLineSequence(void)
Line sequence.
Definition: LineMap.cc:107
LineMap(MultiBlockTopology *mbt=nullptr)
Constructor.
Definition: LineMap.cc:44
Geometric entities container (points, lines, surfaces,...).
Definition: EntityMap.h:43
Finite element model generation tools.
Definition: Preprocessor.h:59
CircularArc * newCircleArc(const size_t &, const size_t &, const size_t &)
Circle arc.
Definition: LineMap.cc:92
Model geometry manager.
Definition: MultiBlockTopology.h:68
Line divided in segments of specified lengths.
Definition: DividedLine.h:40
boost::python::dict getPyDict(void) const
Return a Python dictionary with the object members values.
Definition: LineMap.cc:281
Edge * createArc(Pnt *, Pnt *, Pnt *)
Creates a new arc of circle between the points being passed as parameters and inserts it in the edge ...
Definition: LineMap.cc:205
Edge * createLineSequence(void)
Creates a line sequence (polyline) with those being passed as parameters and inserts it in the edge s...
Definition: LineMap.cc:236
Plane in a three-dimensional space.
Definition: Plane.h:49
std::string & Name(void)
Return a reference to the object name.
Definition: NamedEntity.h:52
DividedLine * newDividedLine(const size_t &, const size_t &)
Divided line.
Definition: LineMap.cc:79
Line * newLine(const size_t &, const size_t &)
Line segment.
Definition: LineMap.cc:66
Circumference arc.
Definition: CircularArc.h:44
Edge * createCopy(const Edge *l)
Return a copy of the argument edge.
Definition: LineMap.cc:244
virtual std::string getClassName(void) const
Returns demangled class name.
Definition: EntityWithOwner.cc:90
Line container.
Definition: LineMap.h:49
Line: base class for 1D objects.
Definition: Line.h:42
Compound line.
Definition: CmbEdge.h:46
Point (KPoint).
Definition: Pnt.h:50
const Preprocessor * getPreprocessor(void) const
Return a pointer to preprocessor.
Definition: ModelComponentContainerBase.cc:54
Line in a three-dimensional space.
Definition: Line3d.h:62
Open source finite element program for structural analysis.
Definition: ContinuaReprComponent.h:35
Edge * Crea(void)
Creates a new line.
Definition: LineMap.h:88
Vector en tres dimensiones.
Definition: Vector3d.h:39
void setPyDict(const boost::python::dict &)
Set the values of the object members from a Python dictionary.
Definition: LineMap.cc:297
Edge * busca(const Indice &)
Return a pointer to the geometry entity whose identifier is passed as parameter.
Definition: ModelComponentContainer.h:78
double getAverageLength(void) const
Return the average length of the surfaces.
Definition: LineMap.cc:271