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

Method FindConnectedFaces

Common/DataModel/vtkExplicitStructuredGrid.cxx:1013–1081  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1011
1012//------------------------------------------------------------------------------
1013int vtkExplicitStructuredGrid::FindConnectedFaces(int foundFaces[3])
1014{
1015 int extent[6];
1016 this->GetExtent(extent);
1017 int nFoundFaces = 0;
1018 int neiAxisMod[3] = { 0, 0, 0 };
1019 vtkIdType ijkId[3];
1020 vtkIdType id0, neiCellId;
1021 vtkIdType* cellPtsIds;
1022 vtkIdType* neiCellPtsIds;
1023
1024 // Look for continuous connected visible cells for each axis in the whole dataset
1025 // And identify connected faces
1026 for (ijkId[0] = extent[0]; ijkId[0] < extent[1]; ijkId[0]++)
1027 {
1028 for (ijkId[1] = extent[2]; ijkId[1] < extent[3]; ijkId[1]++)
1029 {
1030 for (ijkId[2] = extent[4]; ijkId[2] < extent[5]; ijkId[2]++)
1031 {
1032 id0 = this->ComputeCellId(ijkId[0], ijkId[1], ijkId[2]);
1033 if (this->IsCellVisible(id0))
1034 {
1035 for (int axis = 0; axis < 3; axis++)
1036 {
1037 // A visible cell have been found
1038 if (foundFaces[axis] == -1 && ijkId[axis] + 1 < extent[axis * 2 + 1])
1039 {
1040 neiAxisMod[axis]++;
1041
1042 // find it's neighbour in the current axis
1043 neiCellId = this->ComputeCellId(
1044 ijkId[0] + neiAxisMod[0], ijkId[1] + neiAxisMod[1], ijkId[2] + neiAxisMod[2]);
1045 if (this->IsCellVisible(neiCellId))
1046 {
1047 // Find if they are connected and by which faces they are connected
1048 cellPtsIds = this->GetCellPoints(id0);
1049 neiCellPtsIds = this->GetCellPoints(neiCellId);
1050 for (int n = 0; n < 6; n++)
1051 {
1052 if (cellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 0]] ==
1053 neiCellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 1]] &&
1054 cellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 2]] ==
1055 neiCellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 3]] &&
1056 cellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 4]] ==
1057 neiCellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 5]] &&
1058 cellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 6]] ==
1059 neiCellPtsIds[HEXAHEDRON_POINT_MAP[n * 8 + 7]])
1060 {
1061 // Correctly ordered faces would be the following
1062 // Axis 0 -> face 1
1063 // Axis 1 -> face 3
1064 // Axis 2 -> face 5
1065 // See vtkHexahedron.h for doc
1066 foundFaces[axis] = n;
1067 nFoundFaces++;
1068 break;
1069 }
1070 }

Callers 1

Calls 4

ComputeCellIdMethod · 0.95
IsCellVisibleMethod · 0.95
GetCellPointsMethod · 0.95
GetExtentMethod · 0.45

Tested by

no test coverage detected