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

Method AddDataSet

Filters/FlowPaths/vtkLagrangianBasicIntegrationModel.cxx:131–211  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

129
130//------------------------------------------------------------------------------
131void vtkLagrangianBasicIntegrationModel::AddDataSet(
132 vtkDataSet* dataset, bool surface, unsigned int surfaceFlatIndex)
133{
134 // Sanity check
135 if (!dataset || dataset->GetNumberOfPoints() == 0 || dataset->GetNumberOfCells() == 0)
136 {
137 vtkErrorMacro(<< "Dataset is null or empty");
138 return;
139 }
140
141 if (!this->Locator)
142 {
143 vtkErrorMacro(<< "Locator is null");
144 return;
145 }
146
147 // There seems to be some kind of problem with the garbage collector
148 // and the referencing of datasets and locators.
149 // In order to avoid leaks we shallow copy the dataset.
150 // This could be removed once this problem is fixed.
151 vtkSmartPointer<vtkDataObject> dob;
152 dob.TakeReference(vtkDataObjectTypes::NewDataObject(dataset->GetDataObjectType()));
153 vtkDataSet* datasetCpy = vtkDataSet::SafeDownCast(dob);
154 datasetCpy->ShallowCopy(dataset);
155
156 // insert the dataset into DataSet vector
157 if (surface)
158 {
159 this->Surfaces->push_back(std::make_pair(surfaceFlatIndex, datasetCpy));
160 }
161 else
162 {
163 this->DataSets->push_back(datasetCpy);
164 }
165
166 // insert a locator into Locators vector, non-null only for vtkPointSet
167 vtkSmartPointer<vtkAbstractCellLocator> locator = nullptr;
168 if (dataset->IsA("vtkPointSet"))
169 {
170 if (surface)
171 {
172 locator.TakeReference(vtkStaticCellLocator::New());
173 }
174 else
175 {
176 locator.TakeReference(this->Locator->NewInstance());
177 }
178 locator->SetTolerance(this->LocatorTolerance);
179 locator->SetDataSet(datasetCpy);
180 locator->CacheCellBoundsOn();
181 locator->AutomaticOn();
182 locator->BuildLocator();
183 }
184 else
185 {
186 // for non-vtkPointSet vtkDataSet, we are using their internal locator
187 // It is required to do a findCell call before the threaded code
188 // so the locator is built first.

Callers 6

AddDataSetAtTimeMethod · 0.45
CheckInputsMethod · 0.45
CheckInputsMethod · 0.45
InitializeFlowMethod · 0.45
InitializeSurfaceMethod · 0.45

Calls 15

GetDataObjectTypeMethod · 0.80
IsAMethod · 0.80
NewFunction · 0.50
maxFunction · 0.50
GetNumberOfPointsMethod · 0.45
GetNumberOfCellsMethod · 0.45
TakeReferenceMethod · 0.45
ShallowCopyMethod · 0.45
push_backMethod · 0.45
NewInstanceMethod · 0.45
SetToleranceMethod · 0.45
SetDataSetMethod · 0.45

Tested by 1