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;
126 delete trajectoryPointAttValues;
129 const std::vector<G4ThreeVector>* auxiliaries
131 if (0 != auxiliaries) {
132 for (
size_t iAux=0; iAux<auxiliaries->size(); ++iAux) {
133 const G4ThreeVector& auxPointPosition = (*auxiliaries)[iAux];
134 if (positions.size() == 0 ||
135 auxPointPosition != positions[positions.size()-1]) {
137 positions.push_back(trajectoryPointPosition);
138 trajectoryLine.push_back(auxPointPosition);
139 auxiliaryPoints.push_back(auxPointPosition);
143 (auxPointPosition - lastTrajectoryPointPosition).mag();
145 (trajectoryPointPosition - auxPointPosition).mag();
146 G4double t = trajectoryPointPreTime +
147 (trajectoryPointPostTime - trajectoryPointPreTime) *
149 trajectoryLineTimes.push_back(t);
150 auxiliaryPointTimes.push_back(t);
156 positions.push_back(trajectoryPointPosition);
157 trajectoryLine.push_back(trajectoryPointPosition);
158 stepPoints.push_back(trajectoryPointPosition);
160 trajectoryLineTimes.push_back(trajectoryPointPostTime);
161 stepPointTimes.push_back(trajectoryPointPostTime);
163 lastTrajectoryPointPosition = trajectoryPointPosition;
171 std::vector<G4double>& trajectoryLineTimes)
176 std::vector<G4double> newTrajectoryLineTimes;
178 newTrajectoryLine.push_back(trajectoryLine[0]);
179 newTrajectoryLineTimes.push_back(trajectoryLineTimes[0]);
180 size_t lineSize = trajectoryLine.size();
182 for (
size_t i = 1; i < trajectoryLine.size(); ++i) {
183 G4double deltaT = trajectoryLineTimes[i] - trajectoryLineTimes[i - 1];
186 std::max(timeIncrement, deltaT / 100.);
188 (
int(trajectoryLineTimes[i - 1]/practicalTimeIncrement) + 1) *
189 practicalTimeIncrement;
190 t <= trajectoryLineTimes[i];
191 t += practicalTimeIncrement) {
193 (trajectoryLine[i] - trajectoryLine[i - 1]) *
194 ((t - trajectoryLineTimes[i - 1]) / deltaT);
195 newTrajectoryLine.push_back(pos);
196 newTrajectoryLineTimes.push_back(t);
199 newTrajectoryLine.push_back(trajectoryLine[i]);
200 newTrajectoryLineTimes.push_back(trajectoryLineTimes[i]);
204 trajectoryLine = newTrajectoryLine;
205 trajectoryLineTimes = newTrajectoryLineTimes;
216 if (0 == pVVisManager)
return;
223 pVVisManager->
Draw(trajectoryLine);
226 if (myContext.
GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
235 pVVisManager->
Draw(auxiliaryPoints);
247 pVVisManager->
Draw(stepPoints);
255 std::vector<G4double>& trajectoryLineTimes,
256 std::vector<G4double>& auxiliaryPointTimes,
257 std::vector<G4double>& stepPointTimes)
262 if (0 == pVVisManager)
return;
268 for (
size_t i = 1; i < trajectoryLine.size(); ++i ) {
270 slice.push_back(trajectoryLine[i -1]);
271 slice.push_back(trajectoryLine[i]);
272 trajectoryLineAttribs.SetStartTime(trajectoryLineTimes[i - 1]);
273 trajectoryLineAttribs.SetEndTime(trajectoryLineTimes[i]);
275 pVVisManager->
Draw(slice);
279 if (myContext.
GetDrawAuxPts() && (auxiliaryPoints.size() > 0)) {
283 for (
size_t i = 0; i < auxiliaryPoints.size(); ++i ) {
285 point.push_back(auxiliaryPoints[i]);
289 auxiliaryPointsAttribs.SetStartTime(auxiliaryPointTimes[i]);
290 auxiliaryPointsAttribs.SetEndTime(auxiliaryPointTimes[i]);
292 pVVisManager->
Draw(point);
300 for (
size_t i = 0; i < stepPoints.size(); ++i ) {
302 point.push_back(stepPoints[i]);
306 stepPointsAttribs.SetStartTime(stepPointTimes[i]);
307 stepPointsAttribs.SetEndTime(stepPointTimes[i]);
309 pVVisManager->
Draw(point);
324 std::vector<G4double> trajectoryLineTimes;
325 std::vector<G4double> stepPointTimes;
326 std::vector<G4double> auxiliaryPointTimes;
330 trajectoryLine, auxiliaryPoints, stepPoints,
331 trajectoryLineTimes, auxiliaryPointTimes, stepPointTimes);
336 trajectoryLine, trajectoryLineTimes);
339 trajectoryLine, auxiliaryPoints, stepPoints,
340 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