MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadConnectivity

Method ReadConnectivity

IO/NetCDF/vtkSLACReader.cxx:1220–1302  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

1218
1219//------------------------------------------------------------------------------
1220int vtkSLACReader::ReadConnectivity(
1221 int meshFD, vtkMultiBlockDataSet* surfaceOutput, vtkMultiBlockDataSet* volumeOutput)
1222{
1223 // Decide if we need to invert the tetrahedra to make them compatible
1224 // with VTK winding.
1225 int invertTets = !this->CheckTetrahedraWinding(meshFD);
1226
1227 // Read in interior tetrahedra.
1228 VTK_CREATE(vtkIdTypeArray, connectivity);
1229 if (this->ReadInternalVolume)
1230 {
1231 if (!this->ReadTetrahedronInteriorArray(meshFD, connectivity))
1232 return 0;
1233 vtkIdType numTetsInterior = connectivity->GetNumberOfTuples();
1234 for (vtkIdType i = 0; i < numTetsInterior; i++)
1235 {
1236 // Interior tetrahedra are defined with 5 integers. The first is an
1237 // element attribute (which we will use to separate into multiple blocks)
1238 // and the other four are ids for the 4 points of the tetrahedra. The
1239 // faces of the tetrahedra are the following:
1240 // Face 0: 0, 2, 1
1241 // Face 1: 0, 3, 2
1242 // Face 2: 0, 1, 3
1243 // Face 3: 1, 2, 3
1244 // There are two possible "windings," the direction in which the normals
1245 // face, for any given tetrahedra. SLAC files might support either
1246 // winding, but it should be consistent through the mesh. The invertTets
1247 // flag set earlier indicates whether we need to invert the tetrahedra.
1248 vtkIdType tetInfo[NumPerTetInt];
1249 connectivity->GetTypedTuple(i, tetInfo);
1250 if (invertTets)
1251 std::swap(tetInfo[1], tetInfo[2]);
1252 vtkUnstructuredGrid* ugrid = AllocateGetBlock(volumeOutput, tetInfo[0], IS_INTERNAL_VOLUME());
1253 ugrid->InsertNextCell(VTK_TETRA, 4, tetInfo + 1);
1254 }
1255 }
1256
1257 // Read in exterior tetrahedra.
1258 if (!this->ReadTetrahedronExteriorArray(meshFD, connectivity))
1259 return 0;
1260 vtkIdType numTetsExterior = connectivity->GetNumberOfTuples();
1261 for (vtkIdType i = 0; i < numTetsExterior; i++)
1262 {
1263 // Exterior tetrahedra are defined with 9 integers. The first is an element
1264 // attribute and the next 4 are point ids, which is the same as interior
1265 // tetrahedra (see above). The last 4 define the boundary condition of
1266 // each face (see above for the order of faces). A flag of -1 is used
1267 // when the face is internal. Other flags separate faces in a multiblock
1268 // data set.
1269 vtkIdType tetInfo[NumPerTetExt];
1270 connectivity->GetTypedTuple(i, tetInfo);
1271 if (invertTets)
1272 {
1273 std::swap(tetInfo[1], tetInfo[2]); // Invert point indices
1274 std::swap(tetInfo[6], tetInfo[8]); // Correct faces for inversion
1275 }
1276 if (this->ReadInternalVolume)
1277 {

Callers 1

RequestDataMethod · 0.95

Calls 8

AllocateGetBlockFunction · 0.85
swapFunction · 0.50
GetNumberOfTuplesMethod · 0.45
GetTypedTupleMethod · 0.45
InsertNextCellMethod · 0.45

Tested by

no test coverage detected