30 #ifndef TRITRIZPTRBASE_H 31 #define TRITRIZPTRBASE_H 33 #include "xc_utils/src/nucleo/EntCmd.h" 34 #include "xc_utils/src/geom/pos_vec/ConstRefCajaTritriz.h" 35 #include "xc_utils/src/geom/pos_vec/ConstRefCapaICte.h" 36 #include "xc_utils/src/geom/pos_vec/ConstRefCapaJCte.h" 37 #include "xc_utils/src/geom/pos_vec/ConstRefCapaKCte.h" 38 #include "xc_utils/src/geom/pos_vec/ConstRefFilaI.h" 39 #include "xc_utils/src/geom/pos_vec/ConstRefFilaJ.h" 40 #include "xc_utils/src/geom/pos_vec/ConstRefFilaK.h" 41 #include "xc_utils/src/geom/pos_vec/VarRefCajaTritriz.h" 42 #include "xc_utils/src/geom/pos_vec/VarRefCapaICte.h" 43 #include "xc_utils/src/geom/pos_vec/VarRefCapaJCte.h" 44 #include "xc_utils/src/geom/pos_vec/VarRefCapaKCte.h" 45 #include "xc_utils/src/geom/pos_vec/VarRefFilaI.h" 46 #include "xc_utils/src/geom/pos_vec/VarRefFilaJ.h" 47 #include "xc_utils/src/geom/pos_vec/VarRefFilaK.h" 54 template <
class MatrizPtr>
58 typedef typename MatrizPtr::value_type value_type;
59 typedef typename MatrizPtr::reference reference;
60 typedef typename MatrizPtr::const_reference const_reference;
61 typedef typename std::vector<MatrizPtr>::iterator iterator;
62 typedef typename std::vector<MatrizPtr>::const_iterator const_iterator;
64 typedef ConstRefCajaTritriz<TritrizPtrBase<MatrizPtr> > const_ref_caja;
65 typedef ConstRefCapaICte<TritrizPtrBase<MatrizPtr> > const_ref_capa_i_cte;
66 typedef ConstRefCapaJCte<TritrizPtrBase<MatrizPtr> > const_ref_capa_j_cte;
67 typedef ConstRefCapaKCte<TritrizPtrBase<MatrizPtr> > const_ref_capa_k_cte;
68 typedef ConstRefFilaI<TritrizPtrBase<MatrizPtr> > const_ref_fila_i;
69 typedef ConstRefFilaJ<TritrizPtrBase<MatrizPtr> > const_ref_fila_j;
70 typedef ConstRefFilaK<TritrizPtrBase<MatrizPtr> > const_ref_fila_k;
72 typedef VarRefCajaTritriz<TritrizPtrBase<MatrizPtr> > var_ref_caja;
73 typedef VarRefCapaICte<TritrizPtrBase<MatrizPtr> > var_ref_capa_i_cte;
74 typedef VarRefCapaJCte<TritrizPtrBase<MatrizPtr> > var_ref_capa_j_cte;
75 typedef VarRefCapaKCte<TritrizPtrBase<MatrizPtr> > var_ref_capa_k_cte;
76 typedef VarRefFilaI<TritrizPtrBase<MatrizPtr> > var_ref_fila_i;
77 typedef VarRefFilaJ<TritrizPtrBase<MatrizPtr> > var_ref_fila_j;
78 typedef VarRefFilaK<TritrizPtrBase<MatrizPtr> > var_ref_fila_k;
87 bool check_range(
const size_t &,
const size_t &,
const size_t &)
const;
88 void resize(
const size_t &);
89 void resize(
const size_t &,
const size_t &,
const size_t &,
const value_type &v= value_type());
90 size_t GetCapas(
void)
const;
91 size_t getNumFilas(
void)
const;
92 size_t getNumCols(
void)
const;
93 size_t GetDim(
void)
const;
101 bool Null(
void)
const;
105 void dim(
const size_t &,
const size_t &,
const size_t &);
107 const MatrizPtr &
operator()(
const size_t &capa)
const;
109 inline const_reference
operator()(
const size_t &i,
const size_t &j,
const size_t &k)
const 110 {
return ((*
this)(i))(j,k); }
111 inline reference
operator()(
const size_t &i,
const size_t &j,
const size_t &k)
112 {
return ((*
this)(i))(j,k); }
113 reference getAtI(
const size_t &i);
114 const_reference getAtI(
const size_t &)
const;
115 reference getAtIJ(
const size_t &,
const size_t &);
116 const_reference getAtIJ(
const size_t &,
const size_t &)
const;
117 value_type getAtIJK(
const size_t &,
const size_t &,
const size_t &);
119 const_ref_caja GetConstRefCaja(
size_t capa=1,
size_t f=1,
size_t c=1)
const;
120 const_ref_caja GetConstRefCaja(
const RangoTritriz &rango)
const;
122 const_ref_capa_i_cte GetConstRefCapaICte(
size_t capa=1,
size_t f=1,
size_t c=1)
const;
123 const_ref_capa_i_cte GetConstRefCapaICte(
size_t capa,
const RangoIndice &,
const RangoIndice &)
const;
124 const_ref_capa_j_cte GetConstRefCapaJCte(
size_t f=1,
size_t capa=1,
size_t c=1)
const;
125 const_ref_capa_j_cte GetConstRefCapaJCte(
const RangoIndice &,
const size_t &f,
const RangoIndice &)
const;
126 const_ref_capa_k_cte GetConstRefCapaKCte(
size_t c=1,
size_t capa=1,
size_t f=1)
const;
127 const_ref_capa_k_cte GetConstRefCapaKCte(
const RangoIndice &,
const RangoIndice &,
const size_t &)
const;
129 const_ref_fila_i GetConstRefFilaI(
size_t f=1,
size_t c=1)
const;
130 const_ref_fila_i GetConstRefFilaI(
const RangoIndice &,
const size_t &f,
const size_t &c)
const;
131 const_ref_fila_j GetConstRefFilaJ(
size_t capa=1,
size_t c=1)
const;
132 const_ref_fila_j GetConstRefFilaJ(
const size_t &capa,
const RangoIndice &,
const size_t &c)
const;
133 const_ref_fila_k GetConstRefFilaK(
size_t capa=1,
size_t f=1)
const;
134 const_ref_fila_k GetConstRefFilaK(
const size_t &capa,
const size_t &f,
const RangoIndice &)
const;
136 var_ref_caja GetVarRefCaja(
size_t capa=1,
size_t f=1,
size_t c=1);
137 var_ref_caja GetVarRefCaja(
const RangoTritriz &);
139 var_ref_capa_i_cte GetVarRefCapaICte(
size_t capa=1,
size_t f=1,
size_t c=1);
140 var_ref_capa_i_cte GetVarRefCapaICte(
const size_t &capa,
const RangoIndice &,
const RangoIndice &);
141 var_ref_capa_j_cte GetVarRefCapaJCte(
size_t f=1,
size_t capa=1,
size_t c=1);
142 var_ref_capa_j_cte GetVarRefCapaJCte(
const RangoIndice &,
const size_t &f,
const RangoIndice &);
143 var_ref_capa_k_cte GetVarRefCapaKCte(
size_t c=1,
size_t capa=1,
size_t f=1);
144 var_ref_capa_k_cte GetVarRefCapaKCte(
const RangoIndice &,
const RangoIndice &,
const size_t &c);
146 var_ref_fila_i GetVarRefFilaI(
size_t f=1,
size_t c=1);
147 var_ref_fila_i GetVarRefFilaI(
const RangoIndice &,
const size_t &f,
const size_t &c);
148 var_ref_fila_j GetVarRefFilaJ(
size_t capa=1,
size_t c=1);
149 var_ref_fila_j GetVarRefFilaJ(
const size_t &capa,
const RangoIndice &,
const size_t &c);
150 var_ref_fila_k GetVarRefFilaK(
size_t capa=1,
size_t f=1);
151 var_ref_fila_k GetVarRefFilaK(
const size_t &capa,
const size_t &f,
const RangoIndice &);
169 template <
class MatrizPtr>
171 :
std::vector<MatrizPtr>(capas), EntCmd()
175 template <
class MatrizPtr>
177 :
std::vector<MatrizPtr>(capas,m), EntCmd()
181 template <
class MatrizPtr>
183 :
std::vector<MatrizPtr>(capas), EntCmd()
185 for(
size_t i=0;i<capas;i++)
186 (*
this)[i]= MatrizPtr(filas,cols);
191 template <
class MatrizPtr>
194 for(iterator i=this->begin();i!=this->end();i++)
201 { this->
resize(nLayers,nRows,nCols,
nullptr); }
204 template <
class MatrizPtr>
207 std::vector<MatrizPtr>::resize(capas);
212 template <
class MatrizPtr>
215 std::vector<MatrizPtr>::resize(capas);
216 for(
size_t i= 0;i<capas;i++)
217 (*
this)[i].resize(filas,cols,v);
221 template <
class MatrizPtr>
231 template <
class MatrizPtr>
233 {
return this->size(); }
235 template <
class MatrizPtr>
240 retval= (*this)[0].getNumFilas();
243 template <
class MatrizPtr>
248 retval= (*this)[0].getNumCols();
251 template <
class MatrizPtr>
255 if(this->size()>1) retval++;
256 if(this->getNumFilas()>1) retval++;
257 if(this->getNumCols()>1) retval++;
262 template <
class MatrizPtr>
265 const size_t sz= this->size();
270 const MatrizPtr &capa= (*this)(1);
271 return sz*capa.getNumFilas()*capa.getNumCols();
276 template <
class MatrizPtr>
282 return (*
this)[0].Null();
286 template <
class MatrizPtr>
294 const size_t ncapas= this->GetCapas();
295 for(
size_t i=0;i<ncapas;i++)
296 if((*
this)[i].
Null())
306 template <
class MatrizPtr>
309 std::vector<MatrizPtr>::clear();
310 EntCmd::clearPyProps();
315 template <
class MatrizPtr>
318 if((this->getNumFilas()>1) || (this->getNumCols()>1))
return false;
323 template <
class MatrizPtr>
326 if((this->GetCapas()>1) || (this->getNumCols()>1))
return false;
331 template <
class MatrizPtr>
334 if((this->GetCapas()>1) || (this->getNumFilas()>1))
return false;
339 template <
class MatrizPtr>
341 {
return (this->GetCapas()==1); }
344 template <
class MatrizPtr>
346 {
return (this->getNumFilas()==1); }
349 template <
class MatrizPtr>
351 {
return (this->getNumCols()==1); }
354 template <
class MatrizPtr>
356 {
return (*
this)[capa-1]; }
359 template <
class MatrizPtr>
361 {
return (*
this)[capa-1]; }
364 template <
class MatrizPtr>
368 template <
class MatrizPtr>
379 std::cerr <<
"TritrizPtrBase::getAtI; the set is not one-dimensional." << std::endl;
384 template <
class MatrizPtr>
387 typename TritrizPtrBase<MatrizPtr>::value_type retval=
nullptr;
388 if(this->check_range(i,j,k))
389 retval= (*this)(i,j,k);
393 template <
class MatrizPtr>
397 template <
class MatrizPtr>
410 std::cerr << nombre_clase() <<
"::" << __FUNCTION__
411 <<
"; the node set is not bidimensional." << std::endl;
416 template <
class MatrizPtr>
418 {
return const_ref_caja(*
this,capa,f,c); }
419 template <
class MatrizPtr>
421 {
return const_ref_caja(*
this,rango); }
423 template <
class MatrizPtr>
425 {
return const_ref_capa_i_cte(*
this,capa,f,c); }
426 template <
class MatrizPtr>
428 {
return const_ref_capa_i_cte(*
this,capa,rango_filas,rango_cols); }
429 template <
class MatrizPtr>
431 {
return const_ref_capa_j_cte(*
this,capa,f,c); }
432 template <
class MatrizPtr>
434 {
return const_ref_capa_j_cte(*
this,rango_capas,f,rango_cols); }
435 template <
class MatrizPtr>
437 {
return const_ref_capa_k_cte(*
this,c,capa,f); }
438 template <
class MatrizPtr>
440 {
return const_ref_capa_k_cte(*
this,rango_capas,rango_filas,c); }
442 template <
class MatrizPtr>
444 {
return const_ref_fila_i(*
this,f,c); }
445 template <
class MatrizPtr>
447 {
return const_ref_fila_i(*
this,rango_capas,f,c); }
448 template <
class MatrizPtr>
450 {
return const_ref_fila_j(*
this,capa,c); }
451 template <
class MatrizPtr>
453 {
return const_ref_fila_j(*
this,capa,rango_filas,c); }
454 template <
class MatrizPtr>
456 {
return const_ref_fila_k(*
this,capa,f); }
457 template <
class MatrizPtr>
459 {
return const_ref_fila_k(*
this,capa,f,rango_cols); }
461 template <
class MatrizPtr>
463 {
return var_ref_caja(*
this,capa,f,c); }
464 template <
class MatrizPtr>
466 {
return var_ref_caja(*
this,rango); }
468 template <
class MatrizPtr>
470 {
return var_ref_capa_i_cte(*
this,capa,f,c); }
471 template <
class MatrizPtr>
473 {
return var_ref_capa_i_cte(*
this,capa,rfilas,rcols); }
474 template <
class MatrizPtr>
476 {
return var_ref_capa_j_cte(*
this,capa,f,c); }
477 template <
class MatrizPtr>
479 {
return var_ref_capa_j_cte(*
this,rcapas,f,rcols); }
480 template <
class MatrizPtr>
482 {
return var_ref_capa_k_cte(*
this,c,capa,f); }
483 template <
class MatrizPtr>
485 {
return var_ref_capa_k_cte(*
this,rcapas,rfilas,c); }
487 template <
class MatrizPtr>
489 {
return var_ref_fila_i(*
this,f,c); }
490 template <
class MatrizPtr>
492 {
return var_ref_fila_i(*
this,rcapas,f,c); }
493 template <
class MatrizPtr>
495 {
return var_ref_fila_j(*
this,capa,c); }
496 template <
class MatrizPtr>
498 {
return var_ref_fila_j(*
this,capa,rfilas,c); }
499 template <
class MatrizPtr>
501 {
return var_ref_fila_k(*
this,capa,f); }
502 template <
class MatrizPtr>
504 {
return var_ref_fila_k(*
this,capa,f,rcols); }
507 template <
class MatrizPtr>
510 const size_t ncapas= otra.GetCapas();
511 const size_t nfilas= otra.getNumFilas();
512 const size_t ncols= otra.getNumCols();
513 if((ncapas+offset_capa)>GetCapas())
515 std::cerr <<
"TritrizPtrNod::PutCaja; layer index out of range." << std::endl;
518 if((nfilas+offset_fila)>this->getNumFilas())
520 std::cerr <<
"TritrizPtrNod::PutCaja; row index out of range." << std::endl;
523 if((ncols+offset_col)>this->getNumCols())
525 std::cerr <<
"TritrizPtrNod::PutCaja; column index out of range." << std::endl;
528 for(
size_t i=1;i<=ncapas;i++)
529 for(
size_t j=1;j<=nfilas;j++)
530 for(
size_t k=1;k<=ncols;k++)
531 (*
this)(offset_capa+i,offset_fila+j,offset_col+k)= otra(i,j,k);
536 template <
class MatrizPtr>
538 {
return (*
this)(c).getTagsObjs(); }
541 template <
class MatrizPtr>
544 const size_t numCols= this->getNumCols();
545 std::vector<int> retval;
546 for(
size_t k= 1;k<=numCols;k++)
547 retval[k-1]= (*
this)(c,f,k)->getTag();
552 template <
class MatrizPtr>
555 const size_t numCapas= this->GetCapas();
556 const size_t numCols= this->getNumCols();
557 m_int retval(numCapas,numCols);
558 for(
size_t i= 1;i<=numCapas;i++)
559 for(
size_t k= 1;k<=numCols;k++)
560 retval(i,k)= (*this)(i,f,k)->getTag();
561 return retval.getVector();
565 template <
class MatrizPtr>
568 const size_t numFilas= this->getNumFilas();
569 std::vector<int> retval(numFilas);
570 for(
size_t j= 1;j<=numFilas;j++)
571 retval[j-1]= (*
this)(capa,j,c)->getTag();
576 template <
class MatrizPtr>
579 const size_t numCapas= this->GetCapas();
580 const size_t numFilas= this->getNumFilas();
581 m_int retval(numCapas,numFilas);
582 for(
size_t i= 1;i<=numCapas;i++)
583 for(
size_t j= 1;j<=numFilas;j++)
584 retval(i,j)= (*this)(i,j,c)->getTag();
585 return retval.getVector();
589 template <
class MatrizPtr>
591 {
return (*
this)(c).getObjsInteriores(); }
594 template <
class MatrizPtr>
597 const size_t numCols= this->getNumCols();
598 std::vector<int> retval(numCols);
599 for(
size_t k= 1;k<=numCols;k++)
600 retval[k-1]= (*
this)(c,f,k)->getTag();
605 template <
class MatrizPtr>
608 const size_t numCapas= this->GetCapas();
609 const size_t numCols= getNumCols();
610 m_int retval(numCapas-2,numCols-2);
611 for(
size_t i= 2;i<numCapas;i++)
612 for(
size_t k= 2;k<numCols;k++)
613 retval(i-1,k-1)= (*this)(i,f,k)->getTag();
614 return retval.getVector();
618 template <
class MatrizPtr>
621 const size_t numFilas= this->getNumFilas();
622 std::vector<int> retval(numFilas-2);
623 for(
size_t j= 2;j<numFilas;j++)
624 retval[j-2]= (*
this)(capa,j,c)->getTag();
629 template <
class MatrizPtr>
632 const size_t numCapas= this->GetCapas();
633 const size_t numFilas= this->getNumFilas();
634 m_int retval(numCapas-2,numFilas-2);
635 for(
size_t i= 2;i<numCapas;i++)
636 for(
size_t j= 2;j<numFilas;j++)
637 retval(i-1,j-1)= (*this)(i,j,c)->getTag();
638 return retval.getVector();
642 template <
class MatrizPtr>
645 std::cerr <<
"deprecated; use python" << std::endl;
646 std::vector<int> retval;
647 const size_t numCapas= this->GetCapas();
652 const size_t numFilas= this->getNumFilas();
657 const size_t numCols= this->getNumCols();
661 for(
size_t i= 2;i<numCapas;i++)
664 retval.insert(retval.end(),tmp.begin(),tmp.end());
std::vector< int > getTagsObjsInterioresColumna(const size_t &, const size_t &)
Returns the identifiers of the objects in the c-th column interior.
Definition: TritrizPtrBase.h:619
bool EsFilaJ(void) const
Returns true if only index J varies.
Definition: TritrizPtrBase.h:324
std::vector< int > getTagsObjsColumnas(const size_t &)
Returns the identifiers of the objects in the c-th columns.
Definition: TritrizPtrBase.h:577
std::vector< int > getTagsInteriorObjs(void)
Returns the tabs of the inerior elements.
Definition: TritrizPtrBase.h:643
std::vector< int > getTagsObjsFila(const size_t &, const size_t &)
Returns the identifiers of the objects in the row.
Definition: TritrizPtrBase.h:542
std::vector< int > getTagsObjsInterioresCapa(const size_t &)
Returns the identifiers of the objects in the layer interior.
Definition: TritrizPtrBase.h:590
std::vector< int > getTagsObjsInterioresFila(const size_t &, const size_t &)
Returns the identifiers of the objects in the row interior.
Definition: TritrizPtrBase.h:595
void set_owner_matrices(void)
Asigna el propietario a las matrices del contenedor.
Definition: TritrizPtrBase.h:192
std::vector< int > getTagsObjsInterioresColumnas(const size_t &)
Returns the identifiers of the objects in the c-th columns interior.
Definition: TritrizPtrBase.h:630
void PutCaja(size_t offset_capa, size_t offset_fila, size_t offset_col, const TritrizPtrBase< MatrizPtr > &otra)
Coloca en la tritriz la being passed as parameter.
Definition: TritrizPtrBase.h:508
std::vector< int > getTagsObjsFilas(const size_t &)
Returns the identifiers of the objects in the f-th rows.
Definition: TritrizPtrBase.h:553
bool EsCapaICte(void) const
Returns true if the indexes that vary are los J y K.
Definition: TritrizPtrBase.h:340
std::vector< int > getTagsObjsInterioresFilas(const size_t &)
Returns the identifiers of the objects in the c-th rows interior.
Definition: TritrizPtrBase.h:606
bool EsCapaJCte(void) const
Returns true if the indexes that vary are los I y K.
Definition: TritrizPtrBase.h:345
bool EsFilaK(void) const
Returns true if only index K varies.
Definition: TritrizPtrBase.h:332
TritrizPtrBase(const size_t &capas=0)
Default constructor.
Definition: TritrizPtrBase.h:170
bool EsFilaI(void) const
Returns true if only index I varies.
Definition: TritrizPtrBase.h:316
std::vector< int > getTagsObjsCapa(const size_t &)
Returns the identifiers of the objects in the layer.
Definition: TritrizPtrBase.h:537
std::vector< int > getTagsObjsColumna(const size_t &, const size_t &)
Returns the identifiers of the objects in the column.
Definition: TritrizPtrBase.h:566
void clearAll(void)
Clears all.
Definition: TritrizPtrBase.h:307
void resize(const size_t &)
Cambia el size of tritriz.
Definition: TritrizPtrBase.h:205
size_t NumPtrs(void) const
Returns the number of elements de la tritriz.
Definition: TritrizPtrBase.h:263
bool Null(void) const
Returns true if it's empty or the pointers are null.
Definition: TritrizPtrBase.h:277
bool EsCapaKCte(void) const
Returns true if the indexes that vary are los I y J.
Definition: TritrizPtrBase.h:350
================================================================================
Definition: ContinuaReprComponent.h:34
void dim(const size_t &, const size_t &, const size_t &)
Matrix dimensions.
Definition: TritrizPtrBase.h:200
"Tritriz" de pointers to objetos.
Definition: TritrizPtrBase.h:55
const MatrizPtr & operator()(const size_t &capa) const
Return the capa which index is being passed as parameter.
Definition: TritrizPtrBase.h:355
bool HasNull(void) const
Returns true if it's empty or some of the pointers are null.
Definition: TritrizPtrBase.h:287