Arcane  4.1.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
VtkCellTypes.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/*---------------------------------------------------------------------------*/
8/* VtkCellTypes.cc (C) 2000-2026 */
9/* */
10/* Définitions des types de maille de VTK. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/internal/VtkCellTypes.h"
15
16#include "ItemTypeInfo.h"
17#include "arcane/utils/IOException.h"
18#include "arcane/utils/FatalErrorException.h"
19
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28namespace VtkUtils
29{
30 unsigned char arcaneToVtkCellTypeNoThrow(Int16 arcane_type);
31}
32
33/*---------------------------------------------------------------------------*/
34/*---------------------------------------------------------------------------*/
35
36Int16 VtkUtils::
37vtkToArcaneCellType(int vtk_type, Int32 nb_node)
38{
39 switch (vtk_type) {
40 case VTK_EMPTY_CELL:
41 return IT_NullType;
42 case VTK_VERTEX:
43 return IT_Vertex;
44 case VTK_LINE:
45 return IT_Line2;
46 case VTK_QUADRATIC_EDGE:
47 return IT_Line3;
48 case VTK_TRIANGLE:
49 return IT_Triangle3;
50 case VTK_QUAD:
51 return IT_Quad4;
52 case VTK_QUADRATIC_QUAD:
53 return IT_Quad8;
54 case VTK_BIQUADRATIC_QUAD:
55 return IT_Quad9;
56 case VTK_POLYGON: // VTK_POLYGON (a tester...)
57 if (nb_node == 5)
58 return IT_Pentagon5;
59 if (nb_node == 6)
60 return IT_Hexagon6;
61 if (nb_node == 7)
62 return IT_Heptagon7;
63 if (nb_node == 8)
64 return IT_Octogon8;
65 ARCANE_THROW(IOException, "Unsupported VtkCellType VTK_POLYGON with nb_node={0}", nb_node);
66 case VTK_TETRA:
67 return IT_Tetraedron4;
68 case VTK_QUADRATIC_TETRA:
69 return IT_Tetraedron10;
70 case VTK_PYRAMID:
71 return IT_Pyramid5;
72 case VTK_WEDGE:
73 return IT_Pentaedron6;
74 case VTK_HEXAHEDRON:
75 return IT_Hexaedron8;
76 case VTK_QUADRATIC_HEXAHEDRON:
77 return IT_Hexaedron20;
78 case VTK_PENTAGONAL_PRISM:
79 return IT_Heptaedron10;
80 case VTK_HEXAGONAL_PRISM:
81 return IT_Octaedron12;
82 case VTK_TRIQUADRATIC_HEXAHEDRON:
83 return IT_Hexaedron27;
84 // NOTE GG: les types suivants ne sont pas bon pour VTK.
85 //case 27: it = IT_Enneedron14; break; //
86 //case 28: it = IT_Decaedron16; break; // VTK_HEXAGONAL_PRISM
87 //case 29: it = IT_Heptagon7; break; // VTK_HEPTAGON
88 //case 30: it = IT_Octogon8; break; // VTK_OCTAGON
89 default:
90 ARCANE_THROW(IOException, "Unsupported VtkCellType '{0}'", vtk_type);
91 }
92}
93
94/*---------------------------------------------------------------------------*/
95/*---------------------------------------------------------------------------*/
96
97unsigned char VtkUtils::
98arcaneToVtkCellTypeNoThrow(Int16 arcane_type)
99{
100 switch (arcane_type) {
101 case IT_NullType:
102 return VTK_EMPTY_CELL;
103 case IT_Vertex:
104 case IT_FaceVertex:
105 return VTK_VERTEX;
106 case IT_Line2:
107 case IT_CellLine2:
108 case IT_Cell3D_Line2:
109 return VTK_LINE;
110 case IT_Line3:
111 case IT_CellLine3:
112 case IT_Cell3D_Line3:
113 return VTK_QUADRATIC_EDGE;
114 case IT_Triangle3:
115 case IT_Cell3D_Triangle3:
116 return VTK_TRIANGLE;
117 case IT_Triangle6:
118 case IT_Cell3D_Triangle6:
119 return VTK_QUADRATIC_TRIANGLE;
120 case IT_Quad4:
121 case IT_Cell3D_Quad4:
122 return VTK_QUAD;
123 case IT_Quad8:
124 case IT_Cell3D_Quad8:
125 return VTK_QUADRATIC_QUAD;
126 case IT_Quad9:
127 case IT_Cell3D_Quad9:
128 return VTK_BIQUADRATIC_QUAD;
129 case IT_Pentagon5:
130 case IT_Hexagon6:
131 case IT_Heptagon7:
132 case IT_Octogon8:
133 return VTK_POLYGON;
134 case IT_Tetraedron4:
135 return VTK_TETRA;
136 case IT_Tetraedron10:
137 return VTK_QUADRATIC_TETRA;
138 case IT_Pyramid5:
139 return VTK_PYRAMID;
140 case IT_Pyramid13:
141 return VTK_QUADRATIC_PYRAMID;
142 case IT_Pentaedron6:
143 return VTK_WEDGE;
144 case IT_Pentaedron15:
145 return VTK_QUADRATIC_WEDGE;
146 case IT_Hexaedron8:
147 return VTK_HEXAHEDRON;
148 case IT_Hexaedron20:
149 return VTK_QUADRATIC_HEXAHEDRON;
150 case IT_Hexaedron27:
151 return VTK_TRIQUADRATIC_HEXAHEDRON;
152 case IT_Heptaedron10:
153 return VTK_PENTAGONAL_PRISM;
154 case IT_Octaedron12:
155 return VTK_HEXAGONAL_PRISM;
156 default:
157 return VTK_BAD_ARCANE_TYPE;
158 }
159}
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164unsigned char VtkUtils::
165arcaneToVtkCellType(Int16 arcane_type)
166{
167 unsigned char t = arcaneToVtkCellTypeNoThrow(arcane_type);
168 if (t == VTK_BAD_ARCANE_TYPE)
169 ARCANE_FATAL("Unsupported item type for VtkWriter arcane_type={0}", arcane_type);
170 return t;
171}
172
173/*---------------------------------------------------------------------------*/
174/*---------------------------------------------------------------------------*/
175
176unsigned char VtkUtils::
177arcaneToVtkCellType(const ItemTypeInfo* arcane_type)
178{
179 unsigned char t = arcaneToVtkCellTypeNoThrow(arcane_type->typeId());
180 if (t == VTK_BAD_ARCANE_TYPE)
181 ARCANE_FATAL("Unsupported item type for VtkWriter arcane_type={0}", arcane_type->typeName());
182 return t;
183}
184
185/*---------------------------------------------------------------------------*/
186/*---------------------------------------------------------------------------*/
187
188} // namespace Arcane::VtkUtils
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro pour envoyer une exception avec formattage.
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Déclarations des types généraux de Arcane.
Exception lorsqu'une erreur d'entrée/sortie est détectée.
Definition IOException.h:32
Infos sur un type d'entité du maillage.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
std::int16_t Int16
Type entier signé sur 16 bits.
std::int32_t Int32
Type entier signé sur 32 bits.