55 XmGridTraceImpl(BSHP<XmUGrid> a_ugrid);
58 double GetVectorMultiplier() const final;
59 void SetVectorMultiplier(const
double a_vectorMultiplier) final;
61 double GetMaxTracingTime() const final;
62 void SetMaxTracingTime(const
double a_maxTracingTime) final;
64 double GetMaxTracingDistance() const final;
65 void SetMaxTracingDistance(const
double a_maxTracingDistance) final;
67 double GetMinDeltaTime() const final;
68 void SetMinDeltaTime(const
double a_minDeltaTime) final;
70 double GetMaxChangeDistance() const final;
71 void SetMaxChangeDistance(const
double a_maxChangeDistance) final;
73 double GetMaxChangeVelocity() const final;
74 void SetMaxChangeVelocity(const
double a_maxChangeVelocity) final;
76 double GetMaxChangeDirectionInRadians() const final;
77 void SetMaxChangeDirectionInRadians(const
double a_maxChangeDirection) final;
79 void AddGridScalarsAtTime(const
VecPt3d& a_scalars,
85 void TracePoint(const
Pt3d& a_pt,
86 const
double& a_ptTime,
90 std::
string GetExitMessage() final;
93 bool GetVectorAtLocationAndTime(const
xms::
Pt3d& a_pt,
121 double iGetDirAsCosTheta(
double a_vx0,
double a_vy0,
double a_vx1,
double a_vy1)
124 double mag0 = sqrt(a_vx0 * a_vx0 + a_vy0 * a_vy0);
125 double mag1 = sqrt(a_vx1 * a_vx1 + a_vy1 * a_vy1);
126 return (a_vx0 * a_vx1 + a_vy0 * a_vy1) / (mag0 * mag1);
132 XmGridTraceImpl::XmGridTraceImpl(BSHP<XmUGrid> a_ugrid)
144 double XmGridTraceImpl::GetVectorMultiplier()
const 152 void XmGridTraceImpl::SetVectorMultiplier(
const double a_vectorMultiplier)
159 double XmGridTraceImpl::GetMaxTracingTime()
const 167 void XmGridTraceImpl::SetMaxTracingTime(
const double a_maxTracingTime)
174 double XmGridTraceImpl::GetMaxTracingDistance()
const 182 void XmGridTraceImpl::SetMaxTracingDistance(
const double a_maxTracingDistance)
189 double XmGridTraceImpl::GetMinDeltaTime()
const 197 void XmGridTraceImpl::SetMinDeltaTime(
const double a_minDeltaTime)
199 if (a_minDeltaTime <= 0)
211 double XmGridTraceImpl::GetMaxChangeDistance()
const 219 void XmGridTraceImpl::SetMaxChangeDistance(
const double a_maxChangeDistance)
226 double XmGridTraceImpl::GetMaxChangeVelocity()
const 234 void XmGridTraceImpl::SetMaxChangeVelocity(
const double a_maxChangeVelocity)
241 double XmGridTraceImpl::GetMaxChangeDirectionInRadians()
const 249 void XmGridTraceImpl::SetMaxChangeDirectionInRadians(
const double a_maxChangeDirection)
251 if (a_maxChangeDirection > XM_PI || a_maxChangeDirection < 0)
259 std::string XmGridTraceImpl::GetExitMessage()
273 void XmGridTraceImpl::AddGridScalarsAtTime(
const VecPt3d& a_scalars,
275 xms::DynBitset& a_activity,
289 std::vector<float> xx, yy;
290 for (
auto& pt : a_scalars)
292 xx.push_back((
float)pt.x);
293 yy.push_back((
float)pt.y);
295 if (a_scalarLoc == DataLocationEnum::LOC_POINTS)
297 m_extractor2x->SetGridPointScalars(xx, a_activity, a_activityLoc);
298 m_extractor2y->SetGridPointScalars(yy, a_activity, a_activityLoc);
302 m_extractor2x->SetGridCellScalars(xx, a_activity, a_activityLoc);
303 m_extractor2y->SetGridCellScalars(yy, a_activity, a_activityLoc);
314 void XmGridTraceImpl::TracePoint(
const Pt3d& a_pt,
315 const double& a_ptTime,
320 double deltaT = 1.00;
321 double mag0 = 0, mag1 = 0;
322 Pt3d pt0 = a_pt, pt1;
323 double vx0 = 0, vx1 = 0, vy0 = 0, vy1 = 0, elapsedTime = 0;
324 bool bContinue =
true;
333 !GetVectorAtLocationAndTime(a_pt, a_ptTime, vector))
338 if (
EQ_TOL(vector.
x, XM_NODATA, 1) ||
EQ_TOL(vector.
y, XM_NODATA, 1))
340 m_exitMessage =
"Point does not start inside an active cell.";
344 a_outTrace.push_back(a_pt);
345 a_outTimes.push_back(a_ptTime);
349 mag0 = sqrt(vector.
x * vector.
x + vector.
y * vector.
y);
360 double dt = sqrt(d2 / denom);
364 m_exitMessage =
"Change distance was greater than the max change distance.";
368 if (elapsedTime + deltaT + a_ptTime >
m_time2)
370 deltaT =
m_time2 - elapsedTime - a_ptTime;
372 m_exitMessage =
"The point has traveled beyond, or reached the second time step.";
384 pt1.x = pt0.
x + deltaT * vx0;
385 pt1.y = pt0.
y + deltaT * vy0;
387 if (!GetVectorAtLocationAndTime(pt1, a_ptTime + elapsedTime + deltaT, vtkVec))
395 if (
EQ_TOL(vtkVec.
x, XM_NODATA, 1) ||
EQ_TOL(vtkVec.
y, XM_NODATA, 1))
400 BSHP<XmUGrid2dPolylineDataExtractor> polylineExtractor =
401 XmUGrid2dPolylineDataExtractor::New(
m_ugrid, DataLocationEnum::LOC_POINTS);
402 polylineExtractor->SetPolyline(points);
403 points = polylineExtractor->GetExtractLocations();
404 if (points.size() < 3)
409 double segDist =
Mdist(pt0.
x, pt0.
y, pt1.x, pt1.y);
410 pt1 = points[points.size() - 2];
411 double newSegDist =
Mdist(pt0.
x, pt0.
y, pt1.x, pt1.y);
412 deltaT *= (newSegDist / segDist);
414 if (!GetVectorAtLocationAndTime(pt1, a_ptTime + elapsedTime + deltaT, vtkVec) ||
428 a_outTrace.push_back(pt1);
429 a_outTimes.push_back(a_ptTime + elapsedTime + deltaT);
435 mag1 = sqrt(vx1 * vx1 + vy1 * vy1);
441 double changeVel = fabs(mag1 - mag0);
450 double dir = iGetDirAsCosTheta(vx0, vy0, vx1, vy1);
451 if (dir < maxAngleChange)
465 m_exitMessage +=
" Delta time was less than min delta time.";
470 double segDist =
Mdist(pt0.
x, pt0.
y, pt1.x, pt1.y);
477 double perc = distancePast / segDist;
479 newPt.
x = (pt0.
x * perc) + (pt1.x * (1 - perc));
480 newPt.
y = (pt0.
y * perc) + (pt1.y * (1 - perc));
483 a_outTrace.push_back(newPt);
484 a_outTimes.push_back(a_ptTime + elapsedTime + deltaT * perc);
485 m_exitMessage =
"Point has reached or exceeded the max tracing distance.";
490 int size = (int)a_outTrace.size();
496 a_outTrace.push_back(pt1);
501 a_outTrace.push_back(pt1);
504 elapsedTime += deltaT;
509 a_outTimes.push_back(a_ptTime + elapsedTime);
519 bool XmGridTraceImpl::GetVectorAtLocationAndTime(
const xms::Pt3d& a_pt,
520 double a_currentTime,
521 xms::Pt3d& a_data)
const 527 xms::VecFlt dataOutx1;
528 xms::VecFlt dataOuty1;
531 if (dataOutx1.size() != 1 || dataOuty1.size() != 1)
539 xms::VecFlt dataOutx2;
540 xms::VecFlt dataOuty2;
543 if (dataOutx2.size() != 1 || dataOuty2.size() != 1)
549 if (a_currentTime <
m_time1 - XM_ZERO_TOL)
555 double perc1 = fabs(a_currentTime -
m_time1) / totalTime;
556 double perc2 = fabs(a_currentTime -
m_time2) / totalTime;
557 a_data.x = dataOutx1[0] * perc1 + dataOutx2[0] * perc2;
558 a_data.y = dataOuty1[0] * perc1 + dataOuty2[0] * perc2;
569 XmGridTrace::XmGridTrace()
585 return BSHP<XmGridTraceImpl>(
new XmGridTraceImpl(a_ugrid));
602 void iCreateDefaultSingleCell(BSHP<XmGridTrace>& a_tracer)
610 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
611 VecInt cells = {XMU_TRIANGLE, 3, 0, 1, 2, XMU_TRIANGLE, 3, 2, 3, 0};
615 a_tracer->SetVectorMultiplier(vm);
616 TS_ASSERT_EQUALS(a_tracer->GetVectorMultiplier(), vm);
618 const double tt = 100;
619 a_tracer->SetMaxTracingTime(tt);
620 TS_ASSERT_EQUALS(a_tracer->GetMaxTracingTime(), tt);
622 const double td = 100;
623 a_tracer->SetMaxTracingDistance(td);
624 TS_ASSERT_EQUALS(a_tracer->GetMaxTracingDistance(), td);
626 const double dt = .1;
627 a_tracer->SetMinDeltaTime(dt);
628 TS_ASSERT_EQUALS(a_tracer->GetMinDeltaTime(), dt);
630 const double cd = 100;
631 a_tracer->SetMaxChangeDistance(cd);
632 TS_ASSERT_EQUALS(a_tracer->GetMaxChangeDistance(), cd);
634 const double cv = 100;
635 a_tracer->SetMaxChangeVelocity(cv);
636 TS_ASSERT_EQUALS(a_tracer->GetMaxChangeVelocity(), cv);
638 const double cdir = 1.5 *
XM_PI;
639 a_tracer->SetMaxChangeDirectionInRadians(cdir);
640 TS_ASSERT_EQUALS(a_tracer->GetMaxChangeDirectionInRadians(), cdir);
643 VecPt3d scalars = {{1, 1, 0}, {1, 1, 0}, {1, 1, 0}, {1, 1, 0}};
645 for (
int i = 0; i < 4; ++i)
647 pointActivity.push_back(
true);
649 a_tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
650 DataLocationEnum::LOC_POINTS, time);
654 a_tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
655 DataLocationEnum::LOC_POINTS, time);
661 void iCreateDefaultTwoCell(BSHP<XmGridTrace>& a_tracer)
671 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {2, 0, 0}, {2, 1, 0}};
672 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3, XMU_QUAD, 4, 1, 4, 5, 2};
676 a_tracer->SetVectorMultiplier(vm);
678 const double tt = 100;
679 a_tracer->SetMaxTracingTime(tt);
681 const double td = 100;
682 a_tracer->SetMaxTracingDistance(td);
684 const double dt = .1;
685 a_tracer->SetMinDeltaTime(dt);
687 const double cd = 100;
688 a_tracer->SetMaxChangeDistance(cd);
690 const double cv = 100;
691 a_tracer->SetMaxChangeVelocity(cv);
693 const double cdir = 1.5 *
XM_PI;
694 a_tracer->SetMaxChangeDirectionInRadians(cdir);
697 VecPt3d scalars = {{.1, 0, 0}, {.2, 0, 0}};
699 for (
int i = 0; i < 2; ++i)
701 pointActivity.push_back(
true);
703 a_tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_CELLS, pointActivity,
704 DataLocationEnum::LOC_CELLS, time);
708 a_tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_CELLS, pointActivity,
709 DataLocationEnum::LOC_CELLS, time);
721 BSHP<XmGridTrace> tracer;
722 iCreateDefaultSingleCell(tracer);
726 Pt3d startPoint = {.5, .5, 0};
727 double startTime = .5;
729 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
731 VecPt3d expectedOutTrace = {{.5, .5, 0}, {1, 1, 0}};
732 VecDbl expectedOutTimes = {.5, 1};
741 BSHP<XmGridTrace> tracer;
742 iCreateDefaultSingleCell(tracer);
743 tracer->SetMaxChangeDistance(.25);
747 Pt3d startPoint = {.5, .5, 0};
748 double startTime = .5;
750 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
752 VecPt3d expectedOutTrace = {{.5, .5, 0},
753 {0.67677668424809445, 0.67677668424809445, 0.00000000000000000},
754 {0.85355336849618890, 0.85355336849618890, 0.00000000000000000},
756 VecDbl expectedOutTimes = {.5, 0.67677668424809445, 0.85355336849618890, 1};
765 BSHP<XmGridTrace> tracer;
766 iCreateDefaultSingleCell(tracer);
770 VecPt3d scalars = {{.1, .1, 0}, {.1, .1, 0}, {.1, .1, 0}, {.1, .1, 0}};
772 for (
int i = 0; i < 4; ++i)
774 pointActivity.push_back(
true);
776 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
777 DataLocationEnum::LOC_POINTS, time);
781 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
782 DataLocationEnum::LOC_POINTS, time);
786 Pt3d startPoint = {.5, .5, 0};
787 double startTime = .5;
788 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
790 VecPt3d expectedOutTrace = {{.5, .5, 0},
791 {0.60000000149011612, 0.60000000149011612, 0},
792 {0.72000000327825542, 0.72000000327825542, 0},
793 {0.86400000542402267, 0.86400000542402267, 0},
795 VecDbl expectedOutTimes = {.5, 1.5, 2.7, 4.14, 5.5};
797 if (expectedOutTrace.size() == outTrace.size())
799 for (
int i = 0; i < expectedOutTrace.size(); ++i)
801 TS_ASSERT_DELTA(expectedOutTrace[i].x, outTrace[i].x, .001);
802 TS_ASSERT_DELTA(expectedOutTrace[i].y, outTrace[i].y, .001);
803 TS_ASSERT_DELTA(expectedOutTrace[i].z, outTrace[i].z, .001);
807 TS_FAIL(
"Expected trace size != actual trace size");
816 BSHP<XmGridTrace> tracer;
817 iCreateDefaultSingleCell(tracer);
819 tracer->SetMaxChangeDirectionInRadians(
XM_PI * .2);
820 tracer->SetMinDeltaTime(-1);
823 VecPt3d scalars = {{0, 1, 0}, {-1, 0, 0}, {0, -1, 0}, {1, 0, 0}};
825 for (
int i = 0; i < 4; ++i)
827 pointActivity.push_back(
true);
829 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
830 DataLocationEnum::LOC_POINTS, time);
834 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
835 DataLocationEnum::LOC_POINTS, time);
839 Pt3d startPoint = {0, 0, 0};
840 double startTime = .5;
841 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
843 VecPt3d expectedOutTrace = {{0, 0, 0},
844 {0.00000000000000000, 0.25000000000000000, 0.00000000000000000},
845 {0.074999999999999997, 0.47499999999999998, 0.00000000000000000},
846 {0.21900000214576720, 0.63699999570846555, 0.00000000000000000},
847 {0.30928799843788146, 0.66810399758815764, 0.00000000000000000},
848 {0.40229310507774352, 0.67396399235725402, 0.00000000000000000},
849 {0.48679361495018003, 0.65024498560905453, 0.00000000000000000},
850 {0.54780151323509219, 0.59909560095787040, 0.00000000000000000},
851 {0.55928876277122497, 0.56619817004051198, 0.00000000000000000},
852 {0.56114558691518779, 0.53247499044700608, 0.00000000000000000},
853 {0.55189971330840681, 0.50228363992173752, 0.00000000000000000},
854 {0.53269911067322617, 0.48131557500677169, 0.00000000000000000},
855 {0.52076836142536975, 0.47806150355091476, 0.00000000000000000},
856 {0.50886902895577013, 0.47838753608466128, 0.00000000000000000},
857 {0.49867742691962913, 0.48264835153512164, 0.00000000000000000},
858 {0.49224616907898289, 0.49014090685121131, 0.00000000000000000},
859 {0.49173935940609609, 0.49438094923206660, 0.00000000000000000},
860 {0.49250246625151450, 0.49839053740482164, 0.00000000000000000},
861 {0.49454361321306389, 0.50154755045413602, 0.00000000000000000},
862 {0.49745717820065949, 0.50317358562752867, 0.00000000000000000},
863 {0.49888395770889871, 0.50301615091938545, 0.00000000000000000},
864 {0.50012160117661586, 0.50244704462921241, 0.00000000000000000},
865 {0.50095740046883197, 0.50152383477622209, 0.00000000000000000},
866 {0.50107955145675120, 0.50098875888952354, 0.00000000000000000},
867 {0.50105605626599747, 0.50045352403892940, 0.00000000000000000},
868 {0.50086894918345870, 0.49998474718699493, 0.00000000000000000},
869 {0.50053945884260675, 0.49966662451478433, 0.00000000000000000},
870 {0.50034430627617277, 0.49962054739305783, 0.00000000000000000},
871 {0.50015012042108842, 0.49962997721910873, 0.00000000000000000},
872 {0.49998265395837810, 0.49970077747304897, 0.00000000000000000},
873 {0.49987374966305814, 0.49982308521808211, 0.00000000000000000},
874 {0.49986302487024292, 0.49988726006383088, 0.00000000000000000},
875 {0.49986815504448728, 0.49994012045071656, 0.00000000000000000}};
876 VecDbl expectedOutTimes = {.5,
917 BSHP<XmGridTrace> tracer;
918 iCreateDefaultSingleCell(tracer);
920 tracer->SetMaxChangeDirectionInRadians(
XM_PI * .2);
921 tracer->SetMinDeltaTime(-1);
922 tracer->SetMaxTracingTime(5);
925 VecPt3d scalars = {{0, 1, 0}, {-1, 0, 0}, {0, -1, 0}, {1, 0, 0}};
927 for (
int i = 0; i < 4; ++i)
929 pointActivity.push_back(
true);
931 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
932 DataLocationEnum::LOC_POINTS, time);
936 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
937 DataLocationEnum::LOC_POINTS, time);
941 Pt3d startPoint = {0, 0, 0};
942 double startTime = .5;
943 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
945 VecPt3d expectedOutTrace = {{0, 0, 0},
946 {0.00000000000000000, 0.25000000000000000, 0.00000000000000000},
947 {0.074999999999999997, 0.47499999999999998, 0.00000000000000000},
948 {0.21900000214576720, 0.63699999570846555, 0.00000000000000000},
949 {0.30928799843788146, 0.66810399758815764, 0.00000000000000000},
950 {0.40229310507774352, 0.67396399235725402, 0.00000000000000000},
951 {0.48679361495018003, 0.65024498560905453, 0.00000000000000000},
952 {0.54780151323509219, 0.59909560095787040, 0.00000000000000000},
953 {0.55928876277122497, 0.56619817004051198, 0.00000000000000000},
954 {0.56114558691518779, 0.53247499044700608, 0.00000000000000000},
955 {0.55189971330840681, 0.50228363992173752, 0.00000000000000000},
956 {0.53269911067322617, 0.48131557500677169, 0.00000000000000000},
957 {0.52076836142536975, 0.47806150355091476, 0.00000000000000000},
958 {0.50886902895577013, 0.47838753608466128, 0.00000000000000000},
959 {0.49867742691962913, 0.48264835153512164, 0.00000000000000000},
960 {0.49224616907898289, 0.49014090685121131, 0.00000000000000000},
961 {0.49173935940609609, 0.49438094923206660, 0.00000000000000000},
962 {0.49237657318600692, 0.49772905815126539, 0.00000000000000000}};
963 VecDbl expectedOutTimes = {.5,
989 BSHP<XmGridTrace> tracer;
990 iCreateDefaultSingleCell(tracer);
992 tracer->SetMaxChangeDirectionInRadians(
XM_PI * .2);
993 tracer->SetMinDeltaTime(-1);
994 tracer->SetMaxTracingDistance(1.0);
997 VecPt3d scalars = {{0, 1, 0}, {-1, 0, 0}, {0, -1, 0}, {1, 0, 0}};
999 for (
int i = 0; i < 4; ++i)
1001 pointActivity.push_back(
true);
1003 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
1004 DataLocationEnum::LOC_POINTS, time);
1008 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
1009 DataLocationEnum::LOC_POINTS, time);
1013 Pt3d startPoint = {0, 0, 0};
1014 double startTime = .5;
1015 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1017 VecPt3d expectedOutTrace = {{0, 0, 0},
1018 {0.00000000000000000, 0.25000000000000000, 0.00000000000000000},
1019 {0.074999999999999997, 0.47499999999999998, 0.00000000000000000},
1020 {0.21900000214576720, 0.63699999570846555, 0.00000000000000000},
1021 {0.30928799843788146, 0.66810399758815764, 0.00000000000000000},
1022 {0.40229310507774352, 0.67396399235725402, 0.00000000000000000},
1023 {0.48679361495018003, 0.65024498560905453, 0.00000000000000000},
1024 {0.50183556502673621, 0.63763372523131490, 0.00000000000000000}};
1025 VecDbl expectedOutTimes = {.5,
1026 0.75000000000000000,
1032 2.4774609356360582};
1041 BSHP<XmGridTrace> tracer;
1042 iCreateDefaultSingleCell(tracer);
1046 Pt3d startPoint = {-.1, 0, 0};
1047 double startTime = .5;
1049 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1051 VecPt3d expectedOutTrace = {};
1052 VecDbl expectedOutTimes = {};
1061 TS_ASSERT_DELTA(iGetDirAsCosTheta(0, 1, 1, 0), 0, .1);
1062 TS_ASSERT_DELTA(iGetDirAsCosTheta(0, 1, 1, 1), .707, .1);
1063 TS_ASSERT_DELTA(iGetDirAsCosTheta(0, 1, 0, -1), -1, .1);
1064 TS_ASSERT_DELTA(iGetDirAsCosTheta(1, 1, -1, -1), -1, .1);
1065 TS_ASSERT_DELTA(iGetDirAsCosTheta(2, 5, 3, 6), .9965, .1);
1066 TS_ASSERT_DELTA(iGetDirAsCosTheta(0, 1, 0, 1), 1, .1);
1073 BSHP<XmGridTrace> tracer;
1074 iCreateDefaultSingleCell(tracer);
1078 Pt3d startPoint = {.5, .5, 0};
1079 double startTime = 10.1;
1081 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1083 VecPt3d expectedOutTrace = {};
1084 VecDbl expectedOutTimes = {};
1093 BSHP<XmGridTrace> tracer;
1094 iCreateDefaultSingleCell(tracer);
1098 Pt3d startPoint = {.5, .5, 0};
1099 double startTime = -0.1;
1101 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1103 VecPt3d expectedOutTrace = {{.5, .5, 0}, {1, 1, 0}};
1104 VecDbl expectedOutTimes = {-.1, .4};
1113 BSHP<XmGridTrace> tracer;
1114 iCreateDefaultSingleCell(tracer);
1116 tracer->SetMaxChangeDirectionInRadians(
XM_PI * .2);
1117 tracer->SetMinDeltaTime(-1);
1118 tracer->SetVectorMultiplier(0.5);
1121 VecPt3d scalars = {{0, 1, 0}, {-1, 0, 0}, {0, -1, 0}, {1, 0, 0}};
1123 for (
int i = 0; i < 4; ++i)
1125 pointActivity.push_back(
true);
1127 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
1128 DataLocationEnum::LOC_POINTS, time);
1132 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_POINTS, pointActivity,
1133 DataLocationEnum::LOC_POINTS, time);
1137 Pt3d startPoint = {0, 0, 0};
1138 double startTime = .5;
1139 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1141 VecPt3d expectedOutTrace = {{0, 0, 0},
1142 {0.00000000000000000, 0.25000000000000000, 0.00000000000000000},
1143 {0.074999999999999997, 0.47499999999999998, 0.00000000000000000},
1144 {0.21900000214576720, 0.63699999570846555, 0.00000000000000000},
1145 {0.30928799843788146, 0.66810399758815764, 0.00000000000000000},
1146 {0.40229310507774352, 0.67396399235725402, 0.00000000000000000},
1147 {0.48679361495018003, 0.65024498560905453, 0.00000000000000000},
1148 {0.54780151323509219, 0.59909560095787040, 0.00000000000000000},
1149 {0.55928876277122497, 0.56619817004051198, 0.00000000000000000},
1150 {0.56114558691518779, 0.53247499044700608, 0.00000000000000000},
1151 {0.55189971330840681, 0.50228363992173752, 0.00000000000000000},
1152 {0.53269911067322617, 0.48131557500677169, 0.00000000000000000},
1153 {0.52076836142536975, 0.47806150355091476, 0.00000000000000000},
1154 {0.50886902895577013, 0.47838753608466128, 0.00000000000000000},
1155 {0.49867742691962913, 0.48264835153512164, 0.00000000000000000},
1156 {0.49224616907898289, 0.49014090685121131, 0.00000000000000000},
1157 {0.49175783605462037, 0.49422637094165467, 0.00000000000000000}};
1158 VecDbl expectedOutTimes = {.5,
1174 10.000000000000000};
1183 BSHP<XmGridTrace> tracer;
1184 iCreateDefaultTwoCell(tracer);
1188 Pt3d startPoint = {.5, .5, 0};
1189 double startTime = 0;
1191 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1193 VecPt3d expectedOutTrace = {{.5, .5, 0},
1194 {0.60000000149011612, 0.50000000000000000, 0.00000000000000000},
1195 {0.73200000077486038, 0.50000000000000000, 0.00000000000000000},
1196 {0.90940801054239273, 0.50000000000000000, 0.00000000000000000},
1197 {1.1529537134766579, 0.50000000000000000, 0.00000000000000000},
1198 {1.4957102079987525, 0.50000000000000000, 0.00000000000000000},
1199 {1.9923067892670629, 0.50000000000000000, 0.00000000000000000},
1201 VecDbl expectedOutTimes = {0,
1208 9.9683860530914945};
1219 BSHP<XmGridTrace> tracer;
1220 iCreateDefaultTwoCell(tracer);
1221 tracer->SetMaxChangeVelocity(.01);
1222 tracer->SetMinDeltaTime(0.001);
1226 Pt3d startPoint = {.5, .5, 0};
1227 double startTime = 0;
1229 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1231 VecPt3d expectedOutTrace = {{.5, .5, 0},
1232 {0.60000000149011612, 0.50000000000000000, 0.00000000000000000},
1233 {0.66600000113248825, 0.50000000000000000, 0.00000000000000000},
1234 {0.74995200067758561, 0.50000000000000000, 0.00000000000000000},
1235 {0.80394992786645891, 0.50000000000000000, 0.00000000000000000},
1236 {0.87154669338464741, 0.50000000000000000, 0.00000000000000000},
1237 {0.95686786960840231, 0.50000000000000000, 0.00000000000000000},
1238 {1.0112451727318765, 0.50000000000000000, 0.00000000000000000},
1239 {1.0789334834771158, 0.50000000000000000, 0.00000000000000000},
1240 {1.1637975516948893, 0.50000000000000000, 0.00000000000000000},
1241 {1.2174527417415202, 0.50000000000000000, 0.00000000000000000},
1242 {1.2839153379250163, 0.50000000000000000, 0.00000000000000000},
1243 {1.3667568384715398, 0.50000000000000000, 0.00000000000000000},
1244 {1.4187699365302351, 0.50000000000000000, 0.00000000000000000},
1245 {1.4829247317645506, 0.50000000000000000, 0.00000000000000000},
1246 {1.5624845364724593, 0.50000000000000000, 0.00000000000000000},
1247 {1.6587784227485147, 0.50000000000000000, 0.00000000000000000},
1248 {1.7743310862797812, 0.50000000000000000, 0.00000000000000000},
1249 {1.9129942825173010, 0.50000000000000000, 0.00000000000000000},
1251 VecDbl expectedOutTimes = {0,
1270 9.6267364611093829};
1279 BSHP<XmGridTrace> tracer;
1280 iCreateDefaultTwoCell(tracer);
1283 VecPt3d scalars = {{.2, 0, 0}, {.3, 0, 0}};
1285 for (
int i = 0; i < 2; ++i)
1287 pointActivity.push_back(
true);
1289 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_CELLS, pointActivity,
1290 DataLocationEnum::LOC_CELLS, time);
1294 Pt3d startPoint = {.5, .5, 0};
1295 double startTime = 10;
1297 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1299 VecPt3d expectedOutTrace = {{.5, .5, 0},
1300 {0.70000000298023224, 0.50000000000000000, 0.00000000000000000},
1301 {0.95200000226497650, 0.50000000000000000, 0.00000000000000000},
1302 {1.2734079944372176, 0.50000000000000000, 0.00000000000000000},
1303 {1.6897536998434066, 0.50000000000000000, 0.00000000000000000},
1305 VecDbl expectedOutTimes = {10,
1310 16.627525378316030};
1321 BSHP<XmGridTrace> tracer;
1322 iCreateDefaultTwoCell(tracer);
1325 VecPt3d scalars = {{.2, 0, 0}, {99999, 0, 0}};
1327 pointActivity.push_back(
true);
1328 pointActivity.push_back(
false);
1329 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_CELLS, pointActivity,
1330 DataLocationEnum::LOC_CELLS, time);
1334 Pt3d startPoint = {.5, .5, 0};
1335 double startTime = 10;
1337 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1339 VecPt3d expectedOutTrace = {{.5, .5, 0},
1340 {0.70000000298023224, 0.50000000000000000, 0.00000000000000000},
1341 {0.93040000677108770, 0.50000000000000000, 0.00000000000000000},
1342 {0.99788877571821222, 0.50000000000000000, 0.00000000000000000}};
1343 VecDbl expectedOutTimes = {10, 11.000000000000000, 12.199999999999999, 12.560000000000000};
1352 BSHP<XmGridTrace> tracer;
1353 iCreateDefaultTwoCell(tracer);
1356 VecPt3d scalars = {{1, 0, 0}, {99999, 0, 0}};
1358 pointActivity.push_back(
false);
1359 pointActivity.push_back(
true);
1360 tracer->AddGridScalarsAtTime(scalars, DataLocationEnum::LOC_CELLS, pointActivity,
1361 DataLocationEnum::LOC_CELLS, time);
1365 Pt3d startPoint = {.5, .5, 0};
1366 double startTime = 10;
1368 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1370 VecPt3d expectedOutTrace = {};
1371 VecDbl expectedOutTimes = {};
1398 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {0, 1, 0}, {1, 1, 0},
1399 {2, 1, 0}, {0, 2, 0}, {1, 2, 0}, {2, 2, 0}};
1400 VecInt cells = {XMU_QUAD, 4, 0, 1, 4, 3, XMU_QUAD, 4, 1, 2, 5, 4,
1401 XMU_QUAD, 4, 3, 4, 7, 6, XMU_QUAD, 4, 4, 5, 8, 7};
1408 tracer->SetVectorMultiplier(2);
1409 tracer->SetMaxTracingTime(-1);
1410 tracer->SetMaxTracingDistance(-1);
1411 tracer->SetMinDeltaTime(.01);
1412 tracer->SetMaxChangeDistance(-1);
1413 tracer->SetMaxChangeVelocity(-1);
1414 tracer->SetMaxChangeDirectionInRadians(
XM_PI / 4);
1420 VecPt3d scalars1 = {{0, 1, 0}, {-.1, 0, 0}, {-1, 0, 0}, {0, .1, 0}, {0, 0, 0},
1421 {0, -.1, 0}, {1, 0, 0}, {.1, 0, 0}, {0, -1, 0}};
1423 for (
int i = 0; i < 9; ++i)
1425 pointActivity.push_back(
true);
1427 tracer->AddGridScalarsAtTime(scalars1, DataLocationEnum::LOC_POINTS, pointActivity,
1428 DataLocationEnum::LOC_POINTS, time);
1431 VecPt3d scalars2 = {{0, 2, 0}, {-.2, 0, 0}, {-2, 0, 0}, {0, .2, 0}, {0, 0, 0},
1432 {0, -.2, 0}, {2, 0, 0}, {.2, 0, 0}, {0, -2, 0}};
1435 tracer->AddGridScalarsAtTime(scalars2, DataLocationEnum::LOC_POINTS, pointActivity,
1436 DataLocationEnum::LOC_POINTS, time);
1440 Pt3d startPoint = {.5, .5, 0};
1441 double startTime = 0;
1444 tracer->TracePoint(startPoint, startTime, outTrace, outTimes);
1449 VecPt3d expectedOutTrace = {{0.50000000000000000, 0.50000000000000000, 0.00000000000000000},
1450 {0.50000000000000000, 1.2500000000000000, 0.00000000000000000},
1451 {0.54457812566426578, 1.3391562513285316, 0.00000000000000000},
1452 {0.61632493250262921, 1.4354984729093498, 0.00000000000000000},
1453 {0.72535406450374607, 1.5315533661126233, 0.00000000000000000},
1454 {0.88236797164001590, 1.6126801842666139, 0.00000000000000000},
1455 {0.98873181403598276, 1.6331015959080102, 0.00000000000000000},
1456 {1.0538503898747653, 1.6342606013582104, 0.00000000000000000},
1457 {1.1249433009705341, 1.5683006835455087, 0.00000000000000000},
1458 {1.1895097427498795, 1.3863448896225066, 0.00000000000000000},
1459 {1.2235242118635632, 1.0588590059131318, 0.00000000000000000},
1460 {1.2235242118635632, 0.90477286425654002, 0.00000000000000000},
1461 {1.2005336220528682, 0.85080764250970042, 0.00000000000000000},
1462 {1.1581790674742278, 0.79387770198395835, 0.00000000000000000},
1463 {1.0896874578697060, 0.74131697161132859, 0.00000000000000000},
1464 {0.98966250551038770, 0.70663752692174131, 0.00000000000000000},
1465 {0.95806149614159530, 0.71817980325332686, 0.00000000000000000},
1466 {0.92629620502521459, 0.77371504022050730, 0.00000000000000000},
1467 {0.90239412753251202, 0.88917318465162865, 0.00000000000000000},
1468 {0.89995172701803572, 1.0694875660697027, 0.00000000000000000},
1469 {0.91503139037776327, 1.0911992829869794, 0.00000000000000000},
1470 {0.93816744602651825, 1.1127546977629765, 0.00000000000000000},
1471 {0.97140028507849163, 1.1309789606067331, 0.00000000000000000},
1472 {0.99364912627842006, 1.1358370729524059, 0.00000000000000000},
1473 {1.0071524474802995, 1.1364684019706512, 0.00000000000000000},
1474 {1.0223447138862345, 1.1280655805979485, 0.00000000000000000},
1475 {1.0369737821057583, 1.0971462034407997, 0.00000000000000000},
1476 {1.0467397711865176, 1.0371377237101163, 0.00000000000000000},
1477 {1.0467397711865176, 0.96499504248441559, 0.00000000000000000},
1478 {1.0390576209755447, 0.95473758230148376, 0.00000000000000000},
1479 {1.0276444556154691, 0.94488898976070590, 0.00000000000000000},
1480 {1.0208791233912420, 0.94149540451099356, 0.00000000000000000}};
1481 VecDbl expectedOutTimes = {
1482 0.00000000000000000, 0.37500000000000000, 0.82499999999999996, 1.3649999999999998,
1483 2.0129999999999999, 2.7905999999999995, 3.2571599999999994, 3.5370959999999991,
1484 3.8730191999999990, 4.2761270399999987, 4.7598564479999981, 5.3403317375999979,
1485 6.0369020851199977, 6.8727865021439971, 7.8758478025727969, 9.0795213630873555,
1486 9.4406234312417237, 9.8739459130269651, 10.393932891169255, 11.017917264940003,
1487 11.766698513464901, 12.665236011694777, 13.743481009570628, 14.390428008296139,
1488 14.778596207531445, 15.244398046613812, 15.803360253512654, 16.474114901791264,
1489 17.279020479725595, 18.244907173246794, 19.403971205472232, 20.000000000000000};
BSHP< XmUGrid2dDataExtractor > m_extractor1x
data extractor for the x component for the first time step
double m_distTraveled
distance traveled in the last TracePoint operation
void testStrongDirectionChange()
test behavior when having large changes in direction
std::vector< int > VecInt
void testMultiCell()
test behavior of multiple cells
void testTutorial()
2nd cell is inactive in the 2nd time step. // Thus it does not pull as hard. Also once the point reac...
void testMaxTracingTime()
test setting max tracing time
double m_maxChangeDistance
maximum distance per trace step
std::vector< double > VecDbl
void testUniqueTimeSteps()
Test behavior for unique timesteps.
double m_maxChangeVelocity
maximum change in velocity per trace step
void testInactiveCell()
2nd cell is inactive in the 2nd time step. // Thus it does not pull as hard. Also once the point reac...
BSHP< XmUGrid > m_ugrid
UGrid for the TracePoint operation.
void testVectorMultiplier()
test behavior of the vector multiplier
Contains the XmGridTrace Class and supporting data types.
static BSHP< XmUGrid > New()
double m_time2
time of the second time step
void testStartInactiveCell()
The point starts in an inactive cell, and doesnt move.
void testMaxTracingDistance()
test setting the max tracing distance
boost::dynamic_bitset< size_t > DynBitset
void testBeyondTimestep()
test behavior when starting beyond the second time step
BSHP< XmUGrid2dDataExtractor > m_extractor2x
data extractor for the x component for the second time step
void testBasicTracePoint()
test the basic functionality of trace point
double m_maxTracingDistance
maximum distance for trace
bool EQ_TOL(const _T &A, const _U &B, const _V &tolerance)
void testDotProduct()
test the angle function
void testStartOutOfCell()
test behavior when starting point is out of the cell
virtual ~XmGridTrace()
Deconstruct XmGridTrace.
std::string m_exitMessage
exit message for the last TracePoint operation
void testMaxChangeVelocity()
Testing what happens when the maximum change in velocity is low / It reaches a point of high accelera...
double m_minDeltaTime
minimum time per trace step
static BSHP< XmGridTrace > New(BSHP< XmUGrid > a_ugrid)
Construct XmGridTrace for a UGrid.
Traces points in an XmUGrid following a vector dataset.
double Mdist(_T x1, _U y1, _V x2, _W y2)
void testBeforeTimestep()
test the behavior when starting before the first timestep
void testSmallScalarsTracePoint()
test with small scalars to create more points
double m_maxChangeDirectionInRadians
maxmium change in direction per trace step
void testMaxChangeDistance()
Speed is limited to .25. It doesnt reach the edge because it goes below min delta time...
double m_vectorMultiplier
multiplier for all vectors in grid
BSHP< XmUGrid2dDataExtractor > m_extractor2y
data extractor for the y component for the second time step
BSHP< XmUGrid2dDataExtractor > m_extractor1y
data extractor for the y component for the first time step
double m_maxTracingTime
maximum time for trace
std::vector< Pt3d > VecPt3d