20#include <Polygon_geom_tools.h>
25template <
typename _SIZE_>
35template <
typename _SIZE_>
38 s<< FacesIndex_ <<finl;
39 s<< PolygonIndex_ <<finl;
40 s<< nb_som_elem_max_ <<finl;
41 s<< nb_face_elem_max_ <<finl;
46template <
typename _SIZE_>
57template <
typename _SIZE_>
60 const IntTab_t& les_elems = mon_dom->les_elems();
64 for (
int_t ele=0; ele<nb_elem; ele++)
67 while (les_elems(ele,nbf-1)<0)
69 PolygonIndex_OK[ele+1]= PolygonIndex_OK[ele]+nbf;
71 ArrOfInt_t FacesIndex_OK(PolygonIndex_OK[nb_elem]);
73 for (
int_t ele=0; ele<nb_elem; ele++)
74 for (
int ss=0; ss<(int)(PolygonIndex_OK[ele+1]-PolygonIndex_OK[ele]); ss++)
75 FacesIndex_OK[f++]= les_elems(ele,ss);
77 assert(f==PolygonIndex_OK[nb_elem]);
86template <
typename _SIZE_>
89 type_elem.typer(
"Polygone");
94 const IntTab_t& les_elems = mon_dom->les_elems();
100 int_t e = elems_sous_part[i];
106 Fi.append_array(les_elems(e, nf) > 0 ? 1 : -1);
113template <
typename _SIZE_>
120template <
typename _SIZE_>
126template <
typename _SIZE_>
132 return mon_dom->les_elems().dimension_int(1);
139template <
typename _SIZE_>
153template <
typename _SIZE_>
154int contient_triangle(
const ArrOfDouble& pos, _SIZE_ som0, _SIZE_ som1, _SIZE_ som2,
const TRUSTTab<double, _SIZE_>& coord)
156 double prod,p0,p1,p2;
162 prod = (coord(som1,0)-coord(som0,0))*(coord(som2,1)-coord(som0,1))
163 - (coord(som1,1)-coord(som0,1))*(coord(som2,0)-coord(som0,0));
170 p0 = (pos[0]-coord(som0,0))*(pos[1]-coord(som1,1))
171 - (pos[1]-coord(som0,1))*(pos[0]-coord(som1,0));
174 p1 = (pos[0]-coord(som1,0))*(pos[1]-coord(som2,1))
175 - (pos[1]-coord(som1,1))*(pos[0]-coord(som2,0));
178 p2 = (pos[0]-coord(som2,0))*(pos[1]-coord(som0,1))
179 - (pos[1]-coord(som2,1))*(pos[0]-coord(som0,0));
182 if ((p0>-epsilon) && (p1>-epsilon) && (p2>-epsilon))
196template <
typename _SIZE_>
199 const Domaine_t& domaine=mon_dom.valeur();
200 const IntTab_t& elem=domaine.les_elems();
205 int_t s0=elem(num_poly,0);
208 int_t s1=elem(num_poly,s);
209 int_t s2=elem(num_poly,s+1);
213 if (contient_triangle(pos_r,s0,s1,s2,coord))
227template <
typename _SIZE_>
239template <
typename _SIZE_>
242 const Domaine_t& domaine = mon_dom.valeur();
243 const IntTab_t& elem = domaine.les_elems();
244 const DoubleTab_t& coord = domaine.coord_sommets();
245 int_t size = domaine.nb_elem();
247 assert(volumes.
size_totale()==domaine.nb_elem_tot());
249 for (
int_t num_poly = 0; num_poly < size; num_poly++)
254 while (nbsom < nbsom_max && elem(num_poly, nbsom) >= 0) nbsom++;
257 volumes(num_poly) = 0.;
261 const auto index_of = [&](
int i) ->
int_t {
return elem(num_poly, i); };
265 volumes(num_poly) = geom.
area_;
267 volumes(num_poly) = 2.0 * M_PI * std::fabs(geom.
moment_r_);
284template <
typename _SIZE_>
290template <
typename _SIZE_>
300 for (
int fl=0; fl<nb_face-1; fl++)
302 faces_som_local(fl,0)=fl;
303 faces_som_local(fl,1)=fl+1;
308 faces_som_local(fl,0)=fl;
309 faces_som_local(fl,1)=0;
316template <
typename _SIZE_>
324 for (
int_t ele=0; ele<nelem; ele++)
327 int_t nbf=PolygonIndex[ele+1]-PolygonIndex[ele];
329 for (
int_t f=PolygonIndex[ele]; f<PolygonIndex[ele+1]; f++)
331 int nbsom=prov.
size();
340 for (
int_t ele=0; ele<nelem; ele++)
343 for (
int_t f=PolygonIndex[ele]; f<PolygonIndex[ele+1]; f++)
345 int nbsom=prov.
size();
346 for (
int s=0; s<nbsom; s++)
347 les_elems(ele,s)=prov[s];
355template <
typename _SIZE_>
358 const Domaine_t& domaine=mon_dom.valeur();
359 const IntTab_t& elem=domaine.les_elems();
364 nb_elem = mon_dom->nb_elem_tot();
373 for (
int_t num_poly=0; num_poly<nb_elem; num_poly++)
377 int_t s0=elem(num_poly,0);
379 pos(0,d)=coord(s0,d);
382 int_t s1=elem(num_poly,s);
383 int_t s2=elem(num_poly,s+1);
388 pos(1,d)=coord(s1,d);
389 pos(2,d)=coord(s2,d);
391 double airel = aire_triangle(pos);
393 xpl[d]+=airel*(pos(0,d)+pos(1,d)+pos(2,d));
398 xp(num_poly,d)=xpl[d]/(aire);
402template <
typename _SIZE_>
405 const Domaine_t& domaine=mon_dom.valeur();
406 const IntTab_t& elem=domaine.les_elems();
416 int_t s0=elem(num_poly,0);
418 pos(0,d)=coord(s0,d);
421 int_t s1=elem(num_poly,s);
422 int_t s2=elem(num_poly,s+1);
427 pos(1,d)=coord(s1,d);
428 pos(2,d)=coord(s2,d);
430 double airel = aire_triangle(pos);
432 xpl[d]+=airel*(pos(0,d)+pos(1,d)+pos(2,d));
Class Elem_geom_base This class is the base class for the definition of elements.
Class defining operators and methods for all reading operation in an input flow (file,...
class Nom: a character string for naming TRUST objects.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
static double precision_geom
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Base class for polyedrons and polygons. Connectivity is stored in descending mode:
Class Polygone represents the geometric element Polygone.
int get_tab_faces_sommets_locaux(IntTab &faces_som_local) const override
Fills faces_som_local(i,j) giving for 0 <= i < nb_faces() and 0 <= j < nb_som_face(i) the local verte...
_SIZE_ get_somme_nb_faces_elem() const override
void build_reduced(OWN_PTR(Elem_geom_base_32_64< int >)&type_elem, const ArrOfInt_t &elems_sous_part) const override
friend class Polygone_32_64
Domaine_32_64< _SIZE_ > Domaine_t
void calculer_un_centre_gravite(const int_t elem, DoubleVect &xp) const override
ArrOfInt_T< _SIZE_ > ArrOfInt_t
void calculer_centres_gravite(DoubleTab_t &xp) const override
Compute all centers of mass of all elements in the domain.
void calculer_volumes(DoubleVect_t &vols) const override
Computes the volumes (areas) of the elements of the associated domain.
int get_nb_som_elem_max() const
int nb_som_face(int=0) const override
Returns the maximum number of vertices of the faces of the specified type.
SmallArrOfTID_T< _SIZE_ > SmallArrOfTID_t
DoubleTab_T< _SIZE_ > DoubleTab_t
void affecte_connectivite_numero_global(const ArrOfInt_t &FacesIndex, const ArrOfInt_t &PolygonIndex, IntTab_t &les_elems)
void compute_virtual_index() override
IntTab_T< _SIZE_ > IntTab_t
int contient(const ArrOfDouble &pos, int_t elem) const override
Returns 1 if element "num_poly" of the domain associated with this geometric element contains the poi...
DoubleVect_T< _SIZE_ > DoubleVect_t
const Nom & nom_lml() const override
Returns the LML name of a polygon = "POLYEDRE_" + 2*nb_som_max (or "POLYGONE_" + nb_som_max in 3D).
static double mp_max(double)
Base class for output streams.
void append_array(_TYPE_ valeur)
_SIZE_ size_array() const
void resize(_SIZE_ new_size, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
: Class used to represent a list of int/double precision reals.
TRUSTList & add_if_not(_TYPE_)
Ajout d'un element a la liste ssi il n'existe pas deja.
void vide()
Vide la liste.
N-dimensional array for N <= 4.
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension_tot(int) const override
_SIZE_ dimension(int d) const
_SIZE_ size_totale() const
void resize(_SIZE_, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
virtual void echange_espace_virtuel(IsExchangeBlocking exchange_type=IsExchangeBlocking::DefaultBlocking, const std::string kernel_name="noname")