52 std::vector<G4double>& trajectoryLineTimes,
53 std::vector<G4double>& auxiliaryPointTimes,
54 std::vector<G4double>& stepPointTimes)
66 std::vector<G4ThreeVector> positions;
75 if (positions.size() == 0 ||
76 trajectoryPointPosition != positions[positions.size()-1]) {
84 std::vector<G4AttValue>* trajectoryPointAttValues =
86 if (!trajectoryPointAttValues) {
87 static G4bool warnedNoAttValues =
false;
88 if (!warnedNoAttValues) {
90 "*************************************************************************"
91 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: no att values."
92 "\n*************************************************************************"
94 warnedNoAttValues =
true;
98 G4bool foundPreTime =
false, foundPostTime =
false;
99 for (std::vector<G4AttValue>::iterator i =
100 trajectoryPointAttValues->begin();
101 i != trajectoryPointAttValues->end(); ++i) {
102 if (i->GetName() ==
"PreT") {
103 trajectoryPointPreTime =
107 if (i->GetName() ==
"PostT") {
108 trajectoryPointPostTime =
110 foundPostTime =
true;
113 if (!foundPreTime || !foundPostTime) {
114 static G4bool warnedTimesNotFound =
false;
115 if (!warnedTimesNotFound) {
117 "*************************************************************************"
118 "\n* WARNING: G4TrajectoryDrawerUtils::GetPointsAndTimes: times not found."
119 "\n*************************************************************************"
121 warnedTimesNotFound =
true;
128 const std::vector<G4ThreeVector>* auxiliaries
130 if (0 != auxiliaries) {
131 for (
size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
132 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
133 if (positions.size() == 0 ||
134 auxPointPosition != positions[positions.size()-1]) {
136 positions.push_back(trajectoryPointPosition);
137 trajectoryLine.push_back(auxPointPosition);
138 auxiliaryPoints.push_back(auxPointPosition);
142 (auxPointPosition - lastTrajectoryPointPosition).mag();
144 (trajectoryPointPosition - auxPointPosition).mag();
145 G4double t = trajectoryPointPreTime +
146 (trajectoryPointPostTime - trajectoryPointPreTime) *
148 trajectoryLineTimes.push_back(t);
149 auxiliaryPointTimes.push_back(t);
155 positions.push_back(trajectoryPointPosition);
156 trajectoryLine.push_back(trajectoryPointPosition);
157 stepPoints.push_back(trajectoryPointPosition);
159 trajectoryLineTimes.push_back(trajectoryPointPostTime);
160 stepPointTimes.push_back(trajectoryPointPostTime);
162 lastTrajectoryPointPosition = trajectoryPointPosition;
170 std::vector<G4double>& trajectoryLineTimes)
175 std::vector<G4double> newTrajectoryLineTimes;
177 newTrajectoryLine.push_back(trajectoryLine[0]);
178 newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
179 size_t lineSize = trajectoryLine.size();
181 for (
size_t i = 1; i < trajectoryLine.size(); ++i) {
182 G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
185 std::max(timeIncrement, deltaT / 100.);
187 (
int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
188 practicalTimeIncrement;
189 t <= trajectoryLineTimes[i];
190 t += practicalTimeIncrement) {
192 (trajectoryLine[i] - trajectoryLine[i - 1]) *
193 ((t - trajectoryLineTimes[i - 1]) / deltaT);
194 newTrajectoryLine.push_back(pos);
195 newTrajectoryLineTimes.push_back(t);
198 newTrajectoryLine.push_back(trajectoryLine[i]);
199 newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
203 trajectoryLine = newTrajectoryLine;
204 trajectoryLineTimes = newTrajectoryLineTimes;
215 if (0 == pVVisManager)
return;
222 pVVisManager->
Draw(trajectoryLine);
225 if (myContext.
GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
234 pVVisManager->
Draw(auxiliaryPoints);
246 pVVisManager->
Draw(stepPoints);
254 std::vector<G4double>& trajectoryLineTimes,
255 std::vector<G4double>& auxiliaryPointTimes,
256 std::vector<G4double>& stepPointTimes)
261 if (0 == pVVisManager)
return;
267 for (
size_t i = 1; i < trajectoryLine.size(); ++i ) {
269 slice.push_back(trajectoryLine[i -1]);
270 slice.push_back(trajectoryLine[i]);
271 trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
272 trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
274 pVVisManager->
Draw(slice);
278 if (myContext.
GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
282 for (
size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
284 point.push_back(auxiliaryPoints[i]);
288 auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
289 auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
291 pVVisManager->
Draw(point);
299 for (
size_t i = 0; i < stepPoints.size(); ++i ) {
301 point.push_back(stepPoints[i]);
305 stepPointsAttribs.SetStartTime(stepPointTimes[i]);
306 stepPointsAttribs.SetEndTime(stepPointTimes[i]);
308 pVVisManager->
Draw(point);
323 std::vector<G4double> trajectoryLineTimes;
324 std::vector<G4double> stepPointTimes;
325 std::vector<G4double> auxiliaryPointTimes;
329 trajectoryLine, auxiliaryPoints, stepPoints,
330 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
335 trajectoryLine, trajectoryLineTimes);
338 trajectoryLine, auxiliaryPoints, stepPoints,
339 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
virtual void Draw(const G4Circle &, const G4Transform3D &objectTransformation=G4Transform3D())=0
G4VMarker::FillStyle GetAuxPtsFillStyle() const
G4double GetStepPtsSize() const
G4VMarker::FillStyle GetStepPtsFillStyle() const
G4bool GetDrawLine() const
CLHEP::Hep3Vector G4ThreeVector
virtual const std::vector< G4ThreeVector > * GetAuxiliaryPoints() const
static G4VVisManager * GetConcreteInstance()
G4double GetAuxPtsSize() const
virtual G4VTrajectoryPoint * GetPoint(G4int i) const =0
void SetVisibility(G4bool)
void SetMarkerType(MarkerType)
void SetFillStyle(FillStyle)
G4Colour GetAuxPtsColour() const
G4Polymarker::MarkerType GetAuxPtsType() const
G4double GetTimeSliceInterval() const
static G4double ConvertToDimensionedDouble(const char *st)
G4VMarker::SizeType GetAuxPtsSizeType() const
virtual std::vector< G4AttValue > * CreateAttValues() const
static void SliceLine(G4double timeIncrement, G4Polyline &trajectoryLine, std::vector< G4double > &trajectoryLineTimes)
G4bool GetAuxPtsVisible() const
virtual int GetPointEntries() const =0
static void DrawWithTime(const G4VisTrajContext &myContext, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints, std::vector< G4double > &trajectoryLineTimes, std::vector< G4double > &auxiliaryPointTimes, std::vector< G4double > &stepPointTimes)
G4GLOB_DLL std::ostream G4cout
void DrawLineAndPoints(const G4VTrajectory &traj, const G4VisTrajContext &)
G4bool GetLineVisible() const
G4VMarker::SizeType GetStepPtsSizeType() const
void SetSize(SizeType, G4double)
G4bool GetDrawStepPts() const
void SetVisAttributes(const G4VisAttributes *)
G4Colour GetLineColour() const
virtual const G4ThreeVector GetPosition() const =0
G4Colour GetStepPtsColour() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4Polymarker::MarkerType GetStepPtsType() const
static void DrawWithoutTime(const G4VisTrajContext &myContext, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints)
G4bool GetDrawAuxPts() const
G4bool GetStepPtsVisible() const
TimesValidity GetPointsAndTimes(const G4VTrajectory &traj, const G4VisTrajContext &context, G4Polyline &trajectoryLine, G4Polymarker &auxiliaryPoints, G4Polymarker &stepPoints, std::vector< G4double > &trajectoryLineTimes, std::vector< G4double > &auxiliaryPointTimes, std::vector< G4double > &stepPointTimes)
static const G4double pos