Skip to content

Commit 56a08b9

Browse files
committed
Furhter updatest to fix traxk system
1 parent f0b18f7 commit 56a08b9

13 files changed

+194
-130
lines changed

System/attachComp/ContainedComp.cxx

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include "BaseModVisit.h"
4646
#include "writeSupport.h"
4747
#include "Vec3D.h"
48+
#include "interPoint.h"
4849
#include "Surface.h"
4950
#include "SurInter.h"
5051
#include "Rules.h"
@@ -327,10 +328,10 @@ ContainedComp::surfOuterIntersect(const Geometry::Line& LA) const
327328

328329
if (outerSurf.hasRule())
329330
{
330-
const std::tuple<int,const Geometry::Surface*,Geometry::Vec3D,double>
331+
const Geometry::interPoint
331332
result=outerSurf.trackSurfIntersect(LA.getOrigin(),LA.getDirect());
332333

333-
return std::get<0>(result);
334+
return result.SNum;
334335
}
335336
return 0;
336337
}

System/attachComp/LayerComp.cxx

+4-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include "OutputLog.h"
4141
#include "MatrixBase.h"
4242
#include "Vec3D.h"
43+
#include "interPoint.h"
4344
#include "HeadRule.h"
4445
#include "LayerComp.h"
4546

@@ -102,9 +103,10 @@ LayerComp::intersectDist(const size_t layerIndex,
102103
return -std::numeric_limits<double>::max();
103104

104105
HR.populateSurf();
105-
const auto [SN,D] =HR.trackSurfDistance(Origin,Unit);
106+
const Geometry::interPoint inter=
107+
HR.trackSurfIntersect(Origin,Unit);
106108

107-
return (SN) ? D : -std::numeric_limits<double>::max();
109+
return (inter.SNum) ? inter.D : -std::numeric_limits<double>::max();
108110
}
109111

110112
} // NAMESPACE attachSystem

System/attachComp/LinkSupport.cxx

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "RegMethod.h"
4040
#include "OutputLog.h"
4141
#include "Vec3D.h"
42+
#include "interPoint.h"
4243
#include "support.h"
4344
#include "HeadRule.h"
4445
#include "surfRegister.h"
@@ -184,13 +185,13 @@ calcBoundaryLink(attachSystem::FixedComp& FC,const size_t linkIndex,
184185
{
185186
ELog::RegMethod RegA("LinkSupport[F]","calcBoundaryLink");
186187

187-
std::tuple<int,const Geometry::Surface*,Geometry::Vec3D,double>
188+
const Geometry::interPoint
188189
result=boundary.trackSurfIntersect(Origin,Axis);
189-
const int SN=std::get<0>(result);
190+
const int SN=result.SNum;
190191
if (SN)
191192
{
192193
FC.setLinkSurf(linkIndex,SN);
193-
FC.setConnect(linkIndex,std::get<2>(result),Axis);
194+
FC.setConnect(linkIndex,result.Pt,Axis);
194195
}
195196
return;
196197
}

System/attachComp/SpaceCut.cxx

+12-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
* File: attachComp/SpaceCut.cxx
55
*
6-
* Copyright (c) 2004-2023 by Stuart Ansell
6+
* Copyright (c) 2004-2024 by Stuart Ansell
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by
@@ -45,6 +45,7 @@
4545
#include "BaseVisit.h"
4646
#include "BaseModVisit.h"
4747
#include "Vec3D.h"
48+
#include "interPoint.h"
4849
#include "Surface.h"
4950
#include "Quadratic.h"
5051
#include "Plane.h"
@@ -453,13 +454,16 @@ SpaceCut::calcBoundary(const HeadRule& objHR,
453454
for(size_t i=0;i<NDivide;i++)
454455
{
455456
const Geometry::Vec3D Axis=XX*cos(angle)+ZZ*sin(angle);
456-
const auto [SN,D] =objHR.trackSurfDistance(Org,Axis,linkSN);
457+
const Geometry::interPoint inter=
458+
objHR.trackSurfIntersect(Org,Axis,linkSN);
459+
const int SN(inter.SNum);
460+
457461
if (SN && surfN.find(-SN)==surfN.end())
458462
{
459463
surfN.insert(-SN);
460464
// test if cylinder/sphere and extra plane exist
461465
const int divideSN=
462-
testPlaneDivider(objSurfMap,SN,Org+Axis*(D*1.1),Axis);
466+
testPlaneDivider(objSurfMap,SN,Org+Axis*(inter.D*1.1),Axis);
463467
if (divideSN)
464468
surfN.insert(-divideSN);
465469
}
@@ -469,9 +473,11 @@ SpaceCut::calcBoundary(const HeadRule& objHR,
469473
// forward going trajectory
470474
if (!ALink.isComplete() || !BLink.isComplete())
471475
{
472-
const int SN=objHR.trackSurf(CPoint,-YA);
473-
if (SN)
474-
surfN.insert(-SN);
476+
const Geometry::interPoint inter=
477+
objHR.trackSurfIntersect(CPoint,-YA);
478+
479+
if (inter.SNum)
480+
surfN.insert(-inter.SNum);
475481
}
476482

477483

System/attachComp/WrapperCell.cxx

+13-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
* File: attachComp/WrapperCell.cxx
55
*
6-
* Copyright (c) 2004-2022 by Stuart Ansell
6+
* Copyright (c) 2004-2024 by Stuart Ansell
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by
@@ -42,6 +42,7 @@
4242
#include "BaseVisit.h"
4343
#include "BaseModVisit.h"
4444
#include "Vec3D.h"
45+
#include "interPoint.h"
4546
#include "varList.h"
4647
#include "Code.h"
4748
#include "FuncDataBase.h"
@@ -253,17 +254,20 @@ WrapperCell::createLinks()
253254

254255
const HeadRule& HR=ContainedComp::outerSurf;
255256

256-
const auto [SA,DA]=HR.trackSurfDistance(Origin,-Y);
257-
const auto [SB,DB]=HR.trackSurfDistance(Origin,Y);
258-
if (SA)
257+
const Geometry::interPoint interAA=
258+
HR.trackSurfIntersect(Origin,-Y);
259+
const Geometry::interPoint interBB=
260+
HR.trackSurfIntersect(Origin,Y);
261+
262+
if (interAA.SNum)
259263
{
260-
FixedComp::setConnect(0,Origin-Y*DA,-Y);
261-
FixedComp::setLinkSurf(0,SA);
264+
FixedComp::setConnect(0,Origin-Y*interAA.D,-Y);
265+
FixedComp::setLinkSurf(0,interAA.SNum);
262266
}
263-
if (SB)
267+
if (interBB.SNum)
264268
{
265-
FixedComp::setConnect(0,Origin-Y*DA,-Y);
266-
FixedComp::setLinkSurf(0,SA);
269+
FixedComp::setConnect(1,Origin-Y*interBB.D,Y);
270+
FixedComp::setLinkSurf(1,interBB.SNum);
267271
}
268272
return;
269273
}

System/geomInc/interPoint.h

+7-11
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ namespace Geometry
4141

4242
struct interPoint
4343
{
44-
Geometry::Vec3D Pt; ///< Crosssing point;
45-
double D; ///< Distance
46-
int SNum; ///< signed surf number [true as particle moves fwd]
47-
const Surface* SPtr; ///< SurfPointer
48-
bool outFlag; ///< true if particle leaves
44+
Geometry::Vec3D Pt; ///< Crosssing point;
45+
double D; ///< Distance
46+
int SNum; ///< signed surf number [true as particle moves fwd]
47+
const Surface* SPtr; ///< SurfPointer
48+
bool outFlag; ///< true if particle leaves
4949

5050

5151
explicit interPoint() :
52-
D(0,0),SNum(0),SPtr(nullptr),outFlag(0) {}
52+
D(0.0),SNum(0),SPtr(nullptr),outFlag(0) {}
5353
explicit interPoint(Geometry::Vec3D P) :
5454
Pt(std::move(P)),D(0.0),SNum(0),SPtr(nullptr),outFlag(0) {}
5555
interPoint(const Geometry::Vec3D& P,const int SN) :
@@ -64,11 +64,7 @@ namespace Geometry
6464

6565

6666
std::ostream&
67-
operator<<(std::ostream& OX,const interPoint& A)
68-
{
69-
OX<<A.Pt<<" : "<<A.D<<" SN["<<A.outFlag<<"]="<<A.SNum;
70-
return OX;
71-
}
67+
operator<<(std::ostream& OX,const interPoint& A);
7268

7369
}
7470

System/geometry/CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ set (geometrySources
44
CylCan.cxx Cylinder.cxx DblLine.cxx
55
Edge.cxx Ellipse.cxx Ellipsoid.cxx
66
EllipticCyl.cxx Face.cxx General.cxx
7-
geomSupport.cxx Intersect.cxx Line.cxx
8-
localRotate.cxx M2.cxx M3.cxx
7+
geomSupport.cxx interPoint.cxx Intersect.cxx
8+
Line.cxx localRotate.cxx M2.cxx M3.cxx
99
MBrect.cxx Mesh3D.cxx
1010
MeshGrid.cxx NullSurface.cxx Plane.cxx
1111
Pnt.cxx Quadratic.cxx Quadrilateral.cxx
@@ -50,6 +50,7 @@ set (SRC_LIST ${SRC_LIST}
5050
${tarDIR}/Face.cxx
5151
${tarDIR}/General.cxx
5252
${tarDIR}/geomSupport.cxx
53+
${tarDIR}/interPoint.cxx
5354
${tarDIR}/Intersect.cxx
5455
${tarDIR}/Line.cxx
5556
${tarDIR}/localRotate.cxx
@@ -96,6 +97,7 @@ set (SRC_LIST ${SRC_LIST}
9697
${tarINC}/Face.h
9798
${tarINC}/General.h
9899
${tarINC}/geomSupport.h
100+
${tarINC}/interPoint.h
99101
${tarINC}/Intersect.h
100102
${tarINC}/Line.h
101103
${tarINC}/localRotate.h

System/geometry/Triangle.cxx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
* File: geometry/Triangle.cxx
55
*
6-
* Copyright (c) 2004-2015 by Stuart Ansell
6+
* Copyright (c) 2004-2024 by Stuart Ansell
77
*
88
* This program is free software: you can redistribute it and/or modify
99
* it under the terms of the GNU General Public License as published by

System/monte/HeadRule.cxx

+45-36
Original file line numberDiff line numberDiff line change
@@ -2714,8 +2714,7 @@ HeadRule::trackSurfIntersect(const Geometry::Vec3D& Org,
27142714
ELog::RegMethod RegA("HeadRule","trackSurfIntersect");
27152715

27162716
std::vector<Geometry::interPoint> IPTvec;
2717-
calcSurfIntersection(Org,Unit,IPTvec)
2718-
MonteCarlo::LineIntersectVisit LI(Org,Unit);
2717+
calcSurfIntersection(Org,Unit,IPTvec);
27192718
for(const Geometry::interPoint& inter : IPTvec)
27202719
if (inter.D>Geometry::zeroTol)
27212720
return inter;
@@ -2725,44 +2724,57 @@ HeadRule::trackSurfIntersect(const Geometry::Vec3D& Org,
27252724

27262725
}
27272726

2728-
std::pair<int,double>
2729-
HeadRule::trackSurfDistance(const Geometry::Vec3D& Org,
2730-
const Geometry::Vec3D& Unit) const
2731-
2727+
Geometry::interPoint
2728+
HeadRule::trackSurfIntersect(const Geometry::Vec3D& Org,
2729+
const Geometry::Vec3D& Unit,
2730+
const std::set<int>& sActive) const
27322731
/*!
27332732
Calculate a track of a line to a change in state surface
27342733
\param Org :: Origin of line
27352734
\param Unit :: Direction of line
2736-
\return exit surface [signed??]
2735+
\param sActive :: surface to ignore
2736+
\return Signed Surf : SurfacePtr : Point : Distance
27372737
*/
27382738
{
2739-
ELog::RegMethod RegA("HeadRule","trackSurfDistance");
2740-
const std::tuple<int,const Geometry::Surface*,Geometry::Vec3D,double>
2741-
result=trackSurfIntersect(Org,Unit);
2739+
ELog::RegMethod RegA("HeadRule","trackSurfIntersect");
27422740

2743-
return std::pair<int,double>(std::get<0>(result),std::get<3>(result));
2744-
}
2741+
std::vector<Geometry::interPoint> IPTvec;
2742+
calcSurfIntersection(Org,Unit,IPTvec);
2743+
for(const Geometry::interPoint& inter : IPTvec)
2744+
if (inter.D>Geometry::zeroTol &&
2745+
sActive.find(inter.SNum)==sActive.end())
2746+
return inter;
27452747

2746-
std::pair<int,double>
2747-
HeadRule::trackSurfDistance(const Geometry::Vec3D& Org,
2748-
const Geometry::Vec3D& Unit,
2749-
const std::set<int>& ) const
2748+
// ok all failed:
2749+
return Geometry::interPoint();
2750+
}
27502751

2752+
Geometry::interPoint
2753+
HeadRule::trackSurfIntersect(const Geometry::Vec3D& Org,
2754+
const Geometry::Vec3D& Unit,
2755+
const int sActive) const
27512756
/*!
27522757
Calculate a track of a line to a change in state surface
27532758
\param Org :: Origin of line
27542759
\param Unit :: Direction of line
2755-
\return exit surface [signed??] / distance
2760+
\param sActive :: surface to ignore
2761+
\return Signed Surf : SurfacePtr : Point : Distance
27562762
*/
27572763
{
2758-
ELog::RegMethod RegA("HeadRule","trackSurfDistance");
2759-
2760-
const std::tuple<int,const Geometry::Surface*,Geometry::Vec3D,double>
2761-
result=trackSurfIntersect(Org,Unit);
2764+
ELog::RegMethod RegA("HeadRule","trackSurfIntersect");
2765+
2766+
std::vector<Geometry::interPoint> IPTvec;
2767+
calcSurfIntersection(Org,Unit,IPTvec);
2768+
for(const Geometry::interPoint& inter : IPTvec)
2769+
if (inter.D>Geometry::zeroTol &&
2770+
inter.SNum!=sActive)
2771+
return inter;
27622772

2763-
return std::pair<int,double>(std::get<0>(result),std::get<3>(result));
2773+
// ok all failed:
2774+
return Geometry::interPoint();
27642775
}
27652776

2777+
27662778
int
27672779
HeadRule::trackSurf(const Geometry::Vec3D& Org,
27682780
const Geometry::Vec3D& Unit) const
@@ -2779,10 +2791,10 @@ HeadRule::trackSurf(const Geometry::Vec3D& Org,
27792791
ELog::RegMethod RegA("HeadRule","trackSurf(O,U)");
27802792

27812793
// surface/surfPtr/point/distance
2782-
const std::tuple<int,const Geometry::Surface*,Geometry::Vec3D,double>
2794+
const Geometry::interPoint
27832795
result=trackSurfIntersect(Org,Unit);
27842796

2785-
return std::get<0>(result);
2797+
return result.SNum;
27862798
}
27872799

27882800
int
@@ -2804,13 +2816,10 @@ HeadRule::trackSurf(const Geometry::Vec3D& Org,
28042816

28052817
Geometry::Vec3D Pt(Org);
28062818

2807-
auto [SN,DD]=trackSurfDistance(Pt,Unit);
2808-
while (SN && activeSurf.find(SN)!=activeSurf.end())
2809-
{
2810-
Pt+=Unit*DD;
2811-
std::tie(SN,DD)=trackSurfDistance(Pt,Unit);
2812-
}
2813-
return SN;
2819+
const Geometry::interPoint
2820+
result=trackSurfIntersect(Org,Unit,activeSurf);
2821+
2822+
return result.SNum;
28142823
}
28152824

28162825
size_t
@@ -2885,11 +2894,11 @@ HeadRule::calcSurfIntersection(const Geometry::Vec3D& Org,
28852894
const int pAB=isValid(inter.Pt,inter.SNum);
28862895
const int mAB=isValid(inter.Pt,-inter.SNum);
28872896

2888-
const Geometry::Surface* surfPtr=surfIndex[i];
2889-
// Is point possible closer
2890-
const int NS=surfPtr->getName(); // NOT SIGNED
2891-
const int pAB=isValid(IPts[i],NS);
2892-
const int mAB=isValid(IPts[i],-NS);
2897+
// const Geometry::Surface* surfPtr=surfIndex[i];
2898+
// // Is point possible closer
2899+
// const int NS=surfPtr->getName(); // NOT SIGNED
2900+
// const int pAB=isValid(IPts[i],NS);
2901+
// const int mAB=isValid(IPts[i],-NS);
28932902

28942903
if (pAB!=mAB) // exiting/entering surface
28952904
{

0 commit comments

Comments
 (0)