Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
GeometryKernelSurfaceInternalUtils.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7#include "GeometryKernelSurfaceInternalUtils.h"
8/* Author : havep at Wed Apr 1 14:31:35 2009
9 * Generated by createNew
10 */
11
12#include <arcane/utils/NotImplementedException.h>
13#include <GeometryKernel/tools/surface/triangulation-topo-tools.h>
14
15ARCANE_BEGIN_NAMESPACE
16NUMERICS_BEGIN_NAMESPACE
17using namespace Arcane;
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
23 GeometryKernel::TriangulationDataStructurePtr surface,
27 Real3 & normal)
28{
29 surface->clear();
30 face_array.clear();
31 face_array.reserve(group.size()); // au moins un par face
32 node_array.clear();
33 normal = Real3(0.,0.,0.);
34
35 NodeMapping nodeMapping(group.mesh(),node_array,*surface);
36
37 ENUMERATE_FACE(iface,group) {
38 const Face & face = *iface;
39 const Real face_factor = ((face.isBoundaryOutside())?1:-1);
40 switch (face.type()) {
41 case IT_Triangle3:
42 surface->newFace(nodeMapping.getNodeId(face.node(0)),
43 nodeMapping.getNodeId(face.node(1)),
44 nodeMapping.getNodeId(face.node(2)));
45 face_array.add(face);
46 if (face.isOwn())
47 normal += face_factor*nodeMapping.computeNormal(face.node(0), face.node(1), face.node(2));
48 break;
49 case IT_Quad4:
50 surface->newFace(nodeMapping.getNodeId(face.node(0)),
51 nodeMapping.getNodeId(face.node(1)),
52 nodeMapping.getNodeId(face.node(2)));
53 face_array.add(face);
54 if (face.isOwn())
55 normal += face_factor*nodeMapping.computeNormal(face.node(0), face.node(1), face.node(2));
56 surface->newFace(nodeMapping.getNodeId(face.node(2)),
57 nodeMapping.getNodeId(face.node(3)),
58 nodeMapping.getNodeId(face.node(0)));
59 face_array.add(face);
60 if (face.isOwn())
61 normal += face_factor*nodeMapping.computeNormal(face.node(2), face.node(3), face.node(0));
62 break;
63 default:
64 throw NotImplementedException(A_FUNCINFO,"Non Tri3 or Quad4 face type");
65 }
66 }
67
68 // Orientation de la surface et sauvegarde des changements d'orientation
69 GeometryKernel::TriangulationTopoTools topology(*surface);
70 face_reorient.resize(face_array.size());
71 topology.computeMicroTopology(face_reorient.begin(),face_reorient.end());
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77void saveSurface(const char * filename, GeometryKernel::TriangulationDataStructure & tr)
78{
79 typedef GeometryKernel::Vector Vector;
80 typedef GeometryKernel::TriangulationFace Face;
81 typedef GeometryKernel::TObjectId TObjectId;
82
83 std::ofstream file;
84 file.open(filename,std::ios::out | std::ios::binary);
85 const int nVertices = tr.numberOfVertices();
86 file.write((const char*)&nVertices,sizeof(int));
87 for(Integer i=0;i<nVertices;++i)
88 {
89 const Vector & point = tr.vertex(i).point();
90 file.write((const char*)&point,sizeof(Vector));
91 }
92 const int nFaces = tr.numberOfFaces();
93 file.write((const char*)&nFaces,sizeof(int));
94 for(Integer i=0;i<nFaces;++i)
95 {
96 const Face & face = tr.face(i);
97 for(int j=0;j<3;++j) {
98 const TObjectId k = face.vertex(j);
99 file.write((const char*)&k,sizeof(TObjectId));
100 }
101 }
102 file.close();
103}
104
105/*---------------------------------------------------------------------------*/
106
107void loadSurface(const char * filename, GeometryKernel::TriangulationDataStructure & tr)
108{
109 typedef GeometryKernel::Vector Vector;
110 typedef GeometryKernel::TriangulationFace Face;
111 typedef GeometryKernel::TObjectId TObjectId;
112
113 tr.clear();
114
115 std::ifstream file;
116 file.open(filename,std::ios::in | std::ios::binary);
117 int nVertices;
118 file.read((char*)&nVertices,sizeof(int));
119 for(Integer i=0;i<nVertices;++i)
120 {
122 file.read((char*)&point,sizeof(Vector));
123 tr.newVertex(point);
124 }
125 int nFaces;
126 file.read((char*)&nFaces,sizeof(int));
127 for(Integer i=0;i<nFaces;++i)
128 {
129 TObjectId k[3];
130 for(int j=0;j<3;++j) {
131 file.read((char*)&k[j],sizeof(TObjectId));
132 }
133 tr.newFace(k[0],k[1],k[2]);
134 }
135 file.close();
136}
137
138/*---------------------------------------------------------------------------*/
139/*---------------------------------------------------------------------------*/
140
141NUMERICS_END_NAMESPACE
142ARCANE_END_NAMESPACE
143
144/*---------------------------------------------------------------------------*/
145/*---------------------------------------------------------------------------*/
146
#define ENUMERATE_FACE(name, group)
Enumérateur générique d'un groupe de faces.
Face d'une maille.
Definition Item.h:932
ARCANE_DEPRECATED_118 bool isBoundaryOutside() const
Indique si la face est au bord t orientée vers l'extérieur.
Definition Item.h:1044
Integer size() const
Nombre d'éléments du groupe.
Definition ItemGroup.h:88
IMesh * mesh() const
Maillage auquel appartient ce groupe (0 pour le group nul)
Definition ItemGroup.h:126
Node node(Int32 i) const
i-ème noeud de l'entité
Definition Item.h:768
bool isOwn() const
true si l'entité est appartient au sous-domaine
Definition Item.h:244
Int16 type() const
Type de l'entité
Definition Item.h:232
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Classe gérant un vecteur de réel de dimension 3.
Definition Real3.h:132
Vector class, to be used by user.
Exception lorsqu'une fonction n'est pas implémentée.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
void loadSurface(const char *filename, GeometryKernel::TriangulationDataStructure &tr)
Load surface utility for debugging purpose (binary format)
void saveSurface(const char *filename, GeometryKernel::TriangulationDataStructure &tr)
Save surface utility for debugging purpose (binary format)
void buildFaceGroupSurface(FaceGroup group, GeometryKernel::TriangulationDataStructurePtr surface, Array< Node > &node_array, Array< Face > &face_array, Array< bool > &face_reorient, Real3 &normal)
Build GK triangulation and additional data from a face group.