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

Method Query

Filters/CellGrid/vtkDGTransformResponder.cxx:31–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29vtkStandardNewMacro(vtkDGTransformResponder);
30
31bool vtkDGTransformResponder::Query(
32 vtkCellGridTransform::Query* request, vtkCellMetadata* cellType, vtkCellGridResponders* caches)
33{
34 (void)cellType;
35 (void)caches;
36
37 std::string cellTypeName = cellType->GetClassName();
38 vtkStringToken cellTypeToken(cellTypeName);
39 auto* dgCell = vtkDGCell::SafeDownCast(cellType);
40 if (!dgCell)
41 {
42 vtkErrorMacro("Unsupported cell type \"" << cellTypeName << "\".");
43 return false;
44 }
45
46 auto* attribute = request->GetCellAttribute();
47 if (!attribute)
48 {
49 attribute = cellType->GetCellGrid()->GetShapeAttribute();
50 }
51 auto cellTypeInfo = attribute->GetCellTypeInfo(cellTypeToken);
52
53 auto it = cellTypeInfo.ArraysByRole.find("values");
54 if (it == cellTypeInfo.ArraysByRole.end() || !vtkDataArray::SafeDownCast(it->second))
55 {
56 vtkErrorMacro("No array in \"values\" role or the array was not a vtkDataArray.");
57 return false;
58 }
59 auto* values = vtkDataArray::SafeDownCast(it->second);
60 int nc = values->GetNumberOfComponents();
61 auto basisOp = dgCell->GetOperatorEntry("Basis"_token, cellTypeInfo);
62 bool dofSharing = cellTypeInfo.DOFSharing.IsValid();
63
64 // ncpb = number of components per basis function:
65 // nvpt = number of 3-d vectors per tuple:
66 int ncpb = (dofSharing ? nc : nc / basisOp.NumberOfFunctions);
67 int nvpt = (dofSharing ? nc / 3 : nc / 3);
68 // TODO: Handle nvpt == 9 as well to transform matrices.
69 if (ncpb != 3)
70 {
71 vtkErrorMacro("Values to be transformed must be 3-d vectors.");
72 return false;
73 }
74 bool ok = true;
75
76 auto xfm = request->GetTransform();
77 auto* transformedValues = request->CreateNewDataArray(values);
78 vtkIdType nt = values->GetNumberOfTuples();
79 transformedValues->SetName(values->GetName());
80 transformedValues->SetNumberOfComponents(values->GetNumberOfComponents());
81 transformedValues->SetNumberOfTuples(values->GetNumberOfTuples());
82 // Note that we keep values and transformedValues around at the same
83 // time in order to always apply transforms in the highest possible
84 // precision before writing to the transformedValues array.
85 // If you are reading this, DO NOT try to speed things up in a way that
86 // loses precision; always use TransformPoint(double*, double*).
87 if (dofSharing)
88 {

Callers

nothing calls this directly

Calls 15

GetCellAttributeMethod · 0.80
GetShapeAttributeMethod · 0.80
GetCellTypeInfoMethod · 0.80
GetOperatorEntryMethod · 0.80
FastDeleteMethod · 0.80
SetCellTypeInfoMethod · 0.80
DeleteMethod · 0.65
ForFunction · 0.50
GetClassNameMethod · 0.45
findMethod · 0.45
endMethod · 0.45
GetNumberOfComponentsMethod · 0.45

Tested by

no test coverage detected