mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-09-16 17:22:55 +00:00
Longer fixed message
This commit is contained in:
parent
fd9c21c0d4
commit
3b123594fb
@ -65,7 +65,8 @@ public:
|
||||
{
|
||||
if (Mode != VOLUME_MODE)
|
||||
{
|
||||
std::cout << "Volume Tracer Error: must set volume mode before setting sample dist\n";
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Conn Proxy: volume mode must be set before sample distance set");
|
||||
return;
|
||||
}
|
||||
Tracer.SetSampleDistance(distance);
|
||||
@ -97,13 +98,16 @@ public:
|
||||
VTKM_CONT
|
||||
void SetDebugPrints(bool on) { Tracer.SetDebugOn(on); }
|
||||
|
||||
VTKM_CONT
|
||||
void SetEpsilon(vtkm::Float64 epsilon) { Tracer.SetEpsilon(epsilon); }
|
||||
|
||||
VTKM_CONT
|
||||
void SetEmissionField(const std::string& fieldName)
|
||||
{
|
||||
if (Mode != ENERGY_MODE)
|
||||
{
|
||||
std::cout << "Volume Tracer Error: must set energy mode before setting emission field\n";
|
||||
return;
|
||||
throw vtkm::cont::ErrorBadValue(
|
||||
"Conn Proxy: energy mode must be set before setting emission field");
|
||||
}
|
||||
EmissionField = Dataset.GetField(fieldName);
|
||||
}
|
||||
@ -120,7 +124,10 @@ public:
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void SetScalarRange(const vtkm::Range& range) { ScalarRange = range; }
|
||||
void SetScalarRange(const vtkm::Range& range) { this->ScalarRange = range; }
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Range GetScalarRange() { return this->ScalarRange; }
|
||||
|
||||
VTKM_CONT
|
||||
void Trace(vtkm::rendering::raytracing::Ray<vtkm::Float64>& rays)
|
||||
@ -206,7 +213,6 @@ public:
|
||||
|
||||
if (canvas == nullptr)
|
||||
{
|
||||
std::cout << "Conn proxy: canvas is NULL\n";
|
||||
throw vtkm::cont::ErrorBadValue("Conn Proxy: null canvas");
|
||||
}
|
||||
vtkm::rendering::raytracing::Camera rayCamera;
|
||||
@ -261,11 +267,6 @@ ConnectivityProxy::~ConnectivityProxy()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
ConnectivityProxy::ConnectivityProxy()
|
||||
{
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ConnectivityProxy::SetSampleDistance(const vtkm::Float32& distance)
|
||||
{
|
||||
@ -320,6 +321,12 @@ void ConnectivityProxy::SetScalarRange(const vtkm::Range& range)
|
||||
Internals->SetScalarRange(range);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
vtkm::Range ConnectivityProxy::GetScalarRange()
|
||||
{
|
||||
return Internals->GetScalarRange();
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ConnectivityProxy::Trace(vtkm::rendering::raytracing::Ray<vtkm::Float64>& rays)
|
||||
{
|
||||
@ -418,6 +425,12 @@ void ConnectivityProxy::SetDebugPrints(bool on)
|
||||
Internals->SetDebugPrints(on);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ConnectivityProxy::SetEpsilon(vtkm::Float64 epsilon)
|
||||
{
|
||||
Internals->SetEpsilon(epsilon);
|
||||
}
|
||||
|
||||
VTKM_CONT
|
||||
void ConnectivityProxy::SetUnitScalar(vtkm::Float32 unitScalar)
|
||||
{
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
ConnectivityProxy(const vtkm::cont::DynamicCellSet& cellset,
|
||||
const vtkm::cont::CoordinateSystem& coords,
|
||||
const vtkm::cont::Field& scalarField);
|
||||
// Do not allow the default constructor
|
||||
ConnectivityProxy() = delete;
|
||||
~ConnectivityProxy();
|
||||
enum RenderMode
|
||||
{
|
||||
@ -52,9 +54,11 @@ public:
|
||||
void SetCompositeBackground(bool on);
|
||||
void SetDebugPrints(bool on);
|
||||
void SetUnitScalar(vtkm::Float32 unitScalar);
|
||||
void SetEpsilon(vtkm::Float64 epsilon); // epsilon for bumping lost rays
|
||||
|
||||
vtkm::Bounds GetSpatialBounds();
|
||||
vtkm::Range GetScalarFieldRange();
|
||||
vtkm::Range GetScalarRange();
|
||||
|
||||
void Trace(const vtkm::rendering::Camera& camera, vtkm::rendering::CanvasRayTracer* canvas);
|
||||
void Trace(vtkm::rendering::raytracing::Ray<vtkm::Float64>& rays);
|
||||
@ -67,10 +71,6 @@ protected:
|
||||
struct InternalsType;
|
||||
struct BoundsFunctor;
|
||||
std::shared_ptr<InternalsType> Internals;
|
||||
|
||||
private:
|
||||
// Do not allow the default constructor
|
||||
ConnectivityProxy();
|
||||
};
|
||||
}
|
||||
} //namespace vtkm::rendering
|
||||
|
@ -250,10 +250,12 @@ struct ExpandFunctorSignature
|
||||
template <typename Device>
|
||||
bool operator()(Device device)
|
||||
{
|
||||
vtkm::cont::Token token;
|
||||
|
||||
vtkm::Id totalSize = this->OutputLength * static_cast<vtkm::Id>(this->NumChannels);
|
||||
this->Output->Buffer.PrepareForOutput(totalSize, device, token);
|
||||
{
|
||||
vtkm::cont::Token token;
|
||||
this->Output->Buffer.PrepareForOutput(totalSize, device, token);
|
||||
}
|
||||
ChannelBufferOperations::InitChannels(*this->Output, this->Signature, device);
|
||||
|
||||
vtkm::worklet::DispatcherMapField<Expand> dispatcher((Expand(this->NumChannels)));
|
||||
@ -293,10 +295,12 @@ struct ExpandFunctor
|
||||
template <typename Device>
|
||||
bool operator()(Device device)
|
||||
{
|
||||
vtkm::cont::Token token;
|
||||
|
||||
vtkm::Id totalSize = this->OutputLength * static_cast<vtkm::Id>(this->NumChannels);
|
||||
this->Output->Buffer.PrepareForOutput(totalSize, device, token);
|
||||
{
|
||||
vtkm::cont::Token token;
|
||||
this->Output->Buffer.PrepareForOutput(totalSize, device, token);
|
||||
}
|
||||
ChannelBufferOperations::InitConst(*this->Output, this->InitVal, device);
|
||||
|
||||
vtkm::worklet::DispatcherMapField<Expand> dispatcher((Expand(this->NumChannels)));
|
||||
|
@ -154,9 +154,15 @@ void ConnectivityTracer::Init()
|
||||
//
|
||||
// Check to see if a sample distance was set
|
||||
//
|
||||
vtkm::Bounds coordsBounds = Coords.GetBounds();
|
||||
vtkm::Float64 maxLength = 0.;
|
||||
maxLength = vtkm::Max(maxLength, coordsBounds.X.Length());
|
||||
maxLength = vtkm::Max(maxLength, coordsBounds.Y.Length());
|
||||
maxLength = vtkm::Max(maxLength, coordsBounds.Z.Length());
|
||||
BumpDistance = maxLength * BumpEpsilon;
|
||||
|
||||
if (SampleDistance <= 0)
|
||||
{
|
||||
vtkm::Bounds coordsBounds = Coords.GetBounds();
|
||||
BoundingBox[0] = vtkm::Float32(coordsBounds.X.Min);
|
||||
BoundingBox[1] = vtkm::Float32(coordsBounds.X.Max);
|
||||
BoundingBox[2] = vtkm::Float32(coordsBounds.Y.Min);
|
||||
@ -215,6 +221,10 @@ void ConnectivityTracer::SetVolumeData(const vtkm::cont::Field& scalarField,
|
||||
}
|
||||
MeshConnectivityBuilder builder;
|
||||
MeshContainer = builder.BuildConnectivity(cellSet, coords);
|
||||
|
||||
Locator.SetCellSet(this->CellSet);
|
||||
Locator.SetCoordinates(this->Coords);
|
||||
Locator.Update();
|
||||
}
|
||||
|
||||
void ConnectivityTracer::SetEnergyData(const vtkm::cont::Field& absorption,
|
||||
@ -276,8 +286,12 @@ void ConnectivityTracer::SetEnergyData(const vtkm::cont::Field& absorption,
|
||||
{
|
||||
delete MeshContainer;
|
||||
}
|
||||
|
||||
MeshConnectivityBuilder builder;
|
||||
MeshContainer = builder.BuildConnectivity(cellSet, coords);
|
||||
Locator.SetCellSet(this->CellSet);
|
||||
Locator.SetCoordinates(this->Coords);
|
||||
Locator.Update();
|
||||
}
|
||||
|
||||
void ConnectivityTracer::SetBackgroundColor(const vtkm::Vec4f_32& backgroundColor)
|
||||
@ -461,10 +475,12 @@ class RayBumper : public vtkm::worklet::WorkletMapField
|
||||
{
|
||||
private:
|
||||
CellIntersector<255> Intersector;
|
||||
vtkm::Float64 BumpDistance;
|
||||
const vtkm::UInt8 FailureStatus; // the status to assign ray if we fail to find the intersection
|
||||
public:
|
||||
RayBumper(vtkm::UInt8 failureStatus = RAY_ABANDONED)
|
||||
: FailureStatus(failureStatus)
|
||||
RayBumper(vtkm::Float64 bumpDistance, vtkm::UInt8 failureStatus = RAY_ABANDONED)
|
||||
: BumpDistance(bumpDistance)
|
||||
, FailureStatus(failureStatus)
|
||||
{
|
||||
}
|
||||
|
||||
@ -477,10 +493,11 @@ public:
|
||||
FieldInOut,
|
||||
FieldIn,
|
||||
FieldInOut,
|
||||
ExecObject meshConnectivity);
|
||||
using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, _8, _9);
|
||||
ExecObject meshConnectivity,
|
||||
ExecObject locator);
|
||||
using ExecutionSignature = void(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10);
|
||||
|
||||
template <typename FloatType, typename PointPortalType>
|
||||
template <typename FloatType, typename PointPortalType, typename LocatorType>
|
||||
VTKM_EXEC inline void operator()(vtkm::Id& currentCell,
|
||||
PointPortalType& vertices,
|
||||
FloatType& enterDistance,
|
||||
@ -489,13 +506,27 @@ public:
|
||||
vtkm::UInt8& rayStatus,
|
||||
const vtkm::Vec<FloatType, 3>& origin,
|
||||
vtkm::Vec<FloatType, 3>& rdir,
|
||||
const MeshWrapper& meshConn) const
|
||||
const MeshWrapper& meshConn,
|
||||
const LocatorType& locator) const
|
||||
{
|
||||
// We only process lost rays
|
||||
if (rayStatus != RAY_LOST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const FloatType bumpDistance = static_cast<FloatType>(BumpDistance);
|
||||
enterDistance += bumpDistance;
|
||||
vtkm::Vec<FloatType, 3> location = origin + rdir * (enterDistance);
|
||||
|
||||
vtkm::Id cellId;
|
||||
vtkm::Vec<vtkm::FloatDefault, 3> pcoords;
|
||||
locator->FindCell(location, cellId, pcoords, *this);
|
||||
currentCell = cellId;
|
||||
if (currentCell == -1)
|
||||
{
|
||||
rayStatus = RAY_EXITED_MESH;
|
||||
return;
|
||||
}
|
||||
|
||||
FloatType xpoints[8];
|
||||
FloatType ypoints[8];
|
||||
@ -503,35 +534,17 @@ public:
|
||||
vtkm::Id cellConn[8];
|
||||
FloatType distances[6];
|
||||
|
||||
vtkm::Vec<FloatType, 3> centroid(0., 0., 0.);
|
||||
|
||||
const vtkm::Int32 numIndices = meshConn.GetCellIndices(cellConn, currentCell);
|
||||
//load local cell data
|
||||
for (int i = 0; i < numIndices; ++i)
|
||||
{
|
||||
BOUNDS_CHECK(vertices, cellConn[i]);
|
||||
vtkm::Vec<FloatType, 3> point = vtkm::Vec<FloatType, 3>(vertices.Get(cellConn[i]));
|
||||
centroid = centroid + point;
|
||||
xpoints[i] = point[0];
|
||||
ypoints[i] = point[1];
|
||||
zpoints[i] = point[2];
|
||||
}
|
||||
|
||||
FloatType invNumIndices = static_cast<FloatType>(1.) / static_cast<FloatType>(numIndices);
|
||||
centroid[0] = centroid[0] * invNumIndices;
|
||||
centroid[1] = centroid[1] * invNumIndices;
|
||||
centroid[2] = centroid[2] * invNumIndices;
|
||||
|
||||
vtkm::Vec<FloatType, 3> toCentroid = centroid - origin;
|
||||
vtkm::Normalize(toCentroid);
|
||||
|
||||
vtkm::Vec<FloatType, 3> dir = rdir;
|
||||
vtkm::Vec<FloatType, 3> bump = toCentroid - dir;
|
||||
dir = dir + RAY_TUG_EPSILON * bump;
|
||||
|
||||
vtkm::Normalize(dir);
|
||||
rdir = dir;
|
||||
|
||||
const vtkm::UInt8 cellShape = meshConn.GetCellShape(currentCell);
|
||||
Intersector.IntersectCell(xpoints, ypoints, zpoints, rdir, origin, distances, cellShape);
|
||||
|
||||
@ -1153,7 +1166,7 @@ void ConnectivityTracer::FindLostRays(Ray<FloatType>& rays, detail::RayTracking<
|
||||
vtkm::cont::Timer timer;
|
||||
timer.Start();
|
||||
|
||||
vtkm::worklet::DispatcherMapField<RayBumper> bumpDispatch;
|
||||
vtkm::worklet::DispatcherMapField<RayBumper> bumpDispatch(RayBumper(this->BumpDistance));
|
||||
bumpDispatch.Invoke(rays.HitIdx,
|
||||
this->Coords,
|
||||
*(tracker.EnterDist),
|
||||
@ -1162,7 +1175,8 @@ void ConnectivityTracer::FindLostRays(Ray<FloatType>& rays, detail::RayTracking<
|
||||
rays.Status,
|
||||
rays.Origin,
|
||||
rays.Dir,
|
||||
MeshContainer);
|
||||
MeshContainer,
|
||||
&this->Locator);
|
||||
|
||||
this->LostRayTime += timer.GetElapsedTime();
|
||||
}
|
||||
@ -1286,7 +1300,7 @@ template <typename FloatType>
|
||||
void ConnectivityTracer::OffsetMinDistances(Ray<FloatType>& rays)
|
||||
{
|
||||
vtkm::worklet::DispatcherMapField<AdvanceRay<FloatType>> dispatcher(
|
||||
AdvanceRay<FloatType>(FloatType(0.001)));
|
||||
AdvanceRay<FloatType>(FloatType(this->BumpDistance)));
|
||||
dispatcher.Invoke(rays.Status, rays.MinDistance);
|
||||
}
|
||||
|
||||
@ -1391,6 +1405,7 @@ template <typename FloatType>
|
||||
std::vector<PartialComposite<FloatType>> ConnectivityTracer::PartialTrace(Ray<FloatType>& rays)
|
||||
{
|
||||
|
||||
//this->CountRayStatus = true;
|
||||
bool hasPathLengths = rays.HasBuffer("path_lengths");
|
||||
this->RaysLost = 0;
|
||||
RayOperations::ResetStatus(rays, RAY_EXITED_MESH);
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <vtkm/rendering/vtkm_rendering_export.h>
|
||||
|
||||
#include <vtkm/cont/ArrayHandle.h>
|
||||
#include <vtkm/cont/CellLocatorGeneral.h>
|
||||
|
||||
#include <vtkm/rendering/raytracing/MeshConnectivityContainers.h>
|
||||
#include <vtkm/rendering/raytracing/PartialComposite.h>
|
||||
@ -72,6 +73,7 @@ class VTKM_RENDERING_EXPORT ConnectivityTracer
|
||||
public:
|
||||
ConnectivityTracer()
|
||||
: MeshContainer(nullptr)
|
||||
, BumpEpsilon(1e-3)
|
||||
, CountRayStatus(false)
|
||||
, UnitScalar(1.f)
|
||||
{
|
||||
@ -113,6 +115,7 @@ public:
|
||||
void SetDebugOn(bool on) { CountRayStatus = on; }
|
||||
|
||||
void SetUnitScalar(const vtkm::Float32 unitScalar) { UnitScalar = unitScalar; }
|
||||
void SetEpsilon(const vtkm::Float64 epsilon) { BumpEpsilon = epsilon; }
|
||||
|
||||
|
||||
vtkm::Id GetNumberOfMeshCells() const;
|
||||
@ -191,6 +194,9 @@ protected:
|
||||
IntegrationMode Integrator;
|
||||
|
||||
MeshConnContainer* MeshContainer;
|
||||
vtkm::cont::CellLocatorGeneral Locator;
|
||||
vtkm::Float64 BumpEpsilon;
|
||||
vtkm::Float64 BumpDistance;
|
||||
//
|
||||
// flags
|
||||
bool CountRayStatus;
|
||||
|
Loading…
Reference in New Issue
Block a user