10 #ifndef vtk_m_exec_ParametricCoordinates_h
11 #define vtk_m_exec_ParametricCoordinates_h
29 template <
typename ParametricCoordType,
typename CellShapeTag>
35 auto lclTag =
typename vtkm::internal::CellShapeTagVtkmToVtkc<CellShapeTag>::Type{};
38 if (numPoints != lclTag.numberOfPoints())
43 return vtkm::internal::LclErrorToVtkmError(lcl::parametricCenter(lclTag, pcoords));
46 template <
typename ParametricCoordType>
60 template <
typename ParametricCoordType>
74 template <
typename ParametricCoordType>
93 template <
typename ParametricCoordType>
112 return vtkm::internal::LclErrorToVtkmError(
113 lcl::parametricCenter(lcl::Polygon(numPoints), pcoords));
125 template <
typename ParametricCoordType>
135 ParametricCoordinatesCenter(numPoints, CellShapeTag(), pcoords));
144 template <
typename ParametricCoordType,
typename CellShapeTag>
151 auto lclTag =
typename vtkm::internal::CellShapeTagVtkmToVtkc<CellShapeTag>::Type{};
153 if (numPoints != lclTag.numberOfPoints())
158 if ((pointIndex < 0) || (pointIndex >= numPoints))
165 return vtkm::internal::LclErrorToVtkmError(lcl::parametricPoint(lclTag, pointIndex, pcoords));
168 template <
typename ParametricCoordType>
175 pcoords[0] = pcoords[1] = pcoords[2] = 0;
179 template <
typename ParametricCoordType>
198 template <
typename ParametricCoordType>
218 static_cast<ParametricCoordType
>(pointIndex) /
static_cast<ParametricCoordType
>(numPoints - 1);
224 template <
typename ParametricCoordType>
239 return vtkm::internal::LclErrorToVtkmError(
240 lcl::parametricPoint(lcl::Polygon(numPoints), pointIndex, pcoords));
254 template <
typename ParametricCoordType>
265 status = ParametricCoordinatesPoint(numPoints, pointIndex, CellShapeTag(), pcoords));
267 pcoords[0] = pcoords[1] = pcoords[2] = 0;
277 template <
typename LclCellShapeTag,
typename WorldCoordVector,
typename PCoordType>
280 const WorldCoordVector& pointWCoords,
281 const PCoordType& pcoords,
282 typename WorldCoordVector::ComponentType& wcoords)
284 return vtkm::internal::LclErrorToVtkmError(lcl::parametricToWorld(
285 tag, lcl::makeFieldAccessorNestedSOA(pointWCoords, 3), pcoords, wcoords));
290 template <
typename WorldCoordVector,
typename PCoordType,
typename CellShapeTag>
292 const WorldCoordVector& pointWCoords,
295 typename WorldCoordVector::ComponentType& result)
297 auto numPoints = pointWCoords.GetNumberOfComponents();
298 return internal::ParametricCoordinatesToWorldCoordinatesImpl(
299 vtkm::internal::make_LclCellShapeTag(shape, numPoints), pointWCoords, pcoords, result);
302 template <
typename WorldCoordVector,
typename PCoordType>
304 const WorldCoordVector& pointWCoords,
307 typename WorldCoordVector::ComponentType& result)
312 template <
typename WorldCoordVector,
typename PCoordType>
314 const WorldCoordVector& pointWCoords,
317 typename WorldCoordVector::ComponentType& result)
322 template <
typename WorldCoordVector,
typename PCoordType>
324 const WorldCoordVector& pointWCoords,
327 typename WorldCoordVector::ComponentType& result)
329 auto numPoints = pointWCoords.GetNumberOfComponents();
333 return ParametricCoordinatesToWorldCoordinates(
336 return ParametricCoordinatesToWorldCoordinates(
339 return internal::ParametricCoordinatesToWorldCoordinatesImpl(
340 lcl::Polygon(numPoints), pointWCoords, pcoords, result);
344 template <
typename WorldCoordVector,
typename PCoordType>
349 typename WorldCoordVector::ComponentType& result)
351 return internal::ParametricCoordinatesToWorldCoordinatesImpl(
352 lcl::Pixel{}, pointWCoords, pcoords, result);
355 template <
typename WorldCoordVector,
typename PCoordType>
360 typename WorldCoordVector::ComponentType& result)
362 return internal::ParametricCoordinatesToWorldCoordinatesImpl(
363 lcl::Voxel{}, pointWCoords, pcoords, result);
378 template <
typename WorldCoordVector,
typename PCoordType>
380 const WorldCoordVector& pointWCoords,
383 typename WorldCoordVector::ComponentType& result)
389 pointWCoords, pcoords, CellShapeTag(), result));
401 template <
typename LclCellShapeTag,
typename WorldCoordVector>
404 const WorldCoordVector& pointWCoords,
405 const typename WorldCoordVector::ComponentType& wcoords,
406 typename WorldCoordVector::ComponentType& result)
408 if (pointWCoords.GetNumberOfComponents() != tag.numberOfPoints())
415 return vtkm::internal::LclErrorToVtkmError(
416 lcl::worldToParametric(tag, lcl::makeFieldAccessorNestedSOA(pointWCoords, 3), wcoords, result));
421 template <
typename WorldCoordVector,
typename CellShapeTag>
423 const WorldCoordVector& pointWCoords,
424 const typename WorldCoordVector::ComponentType& wcoords,
426 typename WorldCoordVector::ComponentType& result)
428 auto numPoints = pointWCoords.GetNumberOfComponents();
429 return internal::WorldCoordinatesToParametricCoordinatesImpl(
430 vtkm::internal::make_LclCellShapeTag(shape, numPoints), pointWCoords, wcoords, result);
433 template <
typename WorldCoordVector>
435 const WorldCoordVector&,
436 const typename WorldCoordVector::ComponentType&,
438 typename WorldCoordVector::ComponentType& result)
444 template <
typename WorldCoordVector>
446 const WorldCoordVector& pointWCoords,
447 const typename WorldCoordVector::ComponentType&,
449 typename WorldCoordVector::ComponentType& result)
451 if (pointWCoords.GetNumberOfComponents() != 1)
456 result =
typename WorldCoordVector::ComponentType(0, 0, 0);
460 template <
typename WorldCoordVector>
462 const WorldCoordVector& pointWCoords,
463 const typename WorldCoordVector::ComponentType& wcoords,
465 typename WorldCoordVector::ComponentType& result)
476 return WorldCoordinatesToParametricCoordinates(
480 using Vector3 =
typename WorldCoordVector::ComponentType;
481 using T =
typename Vector3::ComponentType;
485 Vector3 vec = pointWCoords[0] - wcoords;
486 T minDistSq = vtkm::Dot(vec, vec);
489 vec = pointWCoords[i] - wcoords;
490 T d = vtkm::Dot(vec, vec);
513 T dParam =
static_cast<T
>(1) /
static_cast<T
>(numPoints - 1);
514 T polyLineParam =
static_cast<T
>(idx - 1) * dParam + lpc[0] * dParam;
516 result = Vector3(polyLineParam, 0, 0);
520 template <
typename WorldCoordVector>
522 const WorldCoordVector& pointWCoords,
523 const typename WorldCoordVector::ComponentType& wcoords,
525 typename WorldCoordVector::ComponentType& result)
527 auto numPoints = pointWCoords.GetNumberOfComponents();
531 return WorldCoordinatesToParametricCoordinates(
534 return WorldCoordinatesToParametricCoordinates(
537 return internal::WorldCoordinatesToParametricCoordinatesImpl(
538 lcl::Polygon(numPoints), pointWCoords, wcoords, result);
548 return internal::WorldCoordinatesToParametricCoordinatesImpl(
549 lcl::Pixel{}, pointWCoords, wcoords, result);
558 return internal::WorldCoordinatesToParametricCoordinatesImpl(
559 lcl::Voxel{}, pointWCoords, wcoords, result);
575 template <
typename WorldCoordVector>
577 const WorldCoordVector& pointWCoords,
578 const typename WorldCoordVector::ComponentType& wcoords,
580 typename WorldCoordVector::ComponentType& result)
586 pointWCoords, wcoords, CellShapeTag(), result));
597 #endif //vtk_m_exec_ParametricCoordinates_h