Arcane  v3.16.9.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VtkCellTypes.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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-2025 */
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 ARCANE_THROW(IOException, "Unsupported VtkCellType VTK_POLYGON with nb_node={0}", nb_node);
62 case VTK_TETRA:
63 return IT_Tetraedron4;
64 case VTK_QUADRATIC_TETRA:
65 return IT_Tetraedron10;
66 case VTK_PYRAMID:
67 return IT_Pyramid5;
68 case VTK_WEDGE:
69 return IT_Pentaedron6;
70 case VTK_HEXAHEDRON:
71 return IT_Hexaedron8;
72 case VTK_QUADRATIC_HEXAHEDRON:
73 return IT_Hexaedron20;
74 case VTK_PENTAGONAL_PRISM:
75 return IT_Heptaedron10;
76 case VTK_HEXAGONAL_PRISM:
77 return IT_Octaedron12;
78 case VTK_TRIQUADRATIC_HEXAHEDRON:
79 return IT_Hexaedron27;
80 // NOTE GG: les types suivants ne sont pas bon pour VTK.
81 //case 27: it = IT_Enneedron14; break; //
82 //case 28: it = IT_Decaedron16; break; // VTK_HEXAGONAL_PRISM
83 //case 29: it = IT_Heptagon7; break; // VTK_HEPTAGON
84 //case 30: it = IT_Octogon8; break; // VTK_OCTAGON
85 default:
86 ARCANE_THROW(IOException, "Unsupported VtkCellType '{0}'", vtk_type);
87 }
88}
89
90/*---------------------------------------------------------------------------*/
91/*---------------------------------------------------------------------------*/
92
93unsigned char VtkUtils::
94arcaneToVtkCellTypeNoThrow(Int16 arcane_type)
95{
96 switch (arcane_type) {
97 case IT_NullType:
98 return VTK_EMPTY_CELL;
99 case IT_Vertex:
100 case IT_FaceVertex:
101 return VTK_VERTEX;
102 case IT_Line2:
103 case IT_CellLine2:
104 case IT_Cell3D_Line2:
105 return VTK_LINE;
106 case IT_Line3:
107 case IT_CellLine3:
108 case IT_Cell3D_Line3:
109 return VTK_QUADRATIC_EDGE;
110 case IT_Triangle3:
111 case IT_Cell3D_Triangle3:
112 return VTK_TRIANGLE;
113 case IT_Triangle6:
114 case IT_Cell3D_Triangle6:
115 return VTK_QUADRATIC_TRIANGLE;
116 case IT_Quad4:
117 case IT_Cell3D_Quad4:
118 return VTK_QUAD;
119 case IT_Quad8:
120 case IT_Cell3D_Quad8:
121 return VTK_QUADRATIC_QUAD;
122 case IT_Quad9:
123 case IT_Cell3D_Quad9:
124 return VTK_BIQUADRATIC_QUAD;
125 case IT_Pentagon5:
126 return VTK_POLYGON;
127 // VTK_POLYGON (a tester...)
128 case IT_Hexagon6:
129 return VTK_POLYGON;
130 // VTK_POLYGON (a tester ...)
131 case IT_Tetraedron4:
132 return VTK_TETRA;
133 case IT_Tetraedron10:
134 return VTK_QUADRATIC_TETRA;
135 case IT_Pyramid5:
136 return VTK_PYRAMID;
137 case IT_Pyramid13:
138 return VTK_QUADRATIC_PYRAMID;
139 case IT_Pentaedron6:
140 return VTK_WEDGE;
141 case IT_Pentaedron15:
142 return VTK_QUADRATIC_WEDGE;
143 case IT_Hexaedron8:
144 return VTK_HEXAHEDRON;
145 case IT_Hexaedron20:
146 return VTK_QUADRATIC_HEXAHEDRON;
147 case IT_Hexaedron27:
148 return VTK_TRIQUADRATIC_HEXAHEDRON;
149 case IT_Heptaedron10:
150 return VTK_PENTAGONAL_PRISM;
151 case IT_Octaedron12:
152 return VTK_HEXAGONAL_PRISM;
153 default:
154 return VTK_BAD_ARCANE_TYPE;
155 }
156}
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
161unsigned char VtkUtils::
162arcaneToVtkCellType(Int16 arcane_type)
163{
164 unsigned char t = arcaneToVtkCellTypeNoThrow(arcane_type);
165 if (t == VTK_BAD_ARCANE_TYPE)
166 ARCANE_FATAL("Unsupported item type for VtkWriter arcane_type={0}", arcane_type);
167 return t;
168}
169
170/*---------------------------------------------------------------------------*/
171/*---------------------------------------------------------------------------*/
172
173unsigned char VtkUtils::
174arcaneToVtkCellType(const ItemTypeInfo* arcane_type)
175{
176 unsigned char t = arcaneToVtkCellTypeNoThrow(arcane_type->typeId());
177 if (t == VTK_BAD_ARCANE_TYPE)
178 ARCANE_FATAL("Unsupported item type for VtkWriter arcane_type={0}", arcane_type->typeName());
179 return t;
180}
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
184
185} // namespace Arcane::VtkUtils
186
187/*---------------------------------------------------------------------------*/
188/*---------------------------------------------------------------------------*/
#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.