File indexing completed on 2026-04-17 08:35:33
0001 #ifndef VECGEOM_SURFACE_CONVHELPER_H_
0002 #define VECGEOM_SURFACE_CONVHELPER_H_
0003
0004 #include <VecGeom/surfaces/conv/Builder.h>
0005 #include <VecGeom/surfaces/Model.h>
0006
0007 namespace vgbrep {
0008 namespace conv {
0009
0010
0011
0012
0013
0014
0015
0016
0017 template <typename Real_t>
0018 bool IsRightSided(vecgeom::Vector3D<Real_t> const &v1, vecgeom::Vector3D<Real_t> const &v2,
0019 vecgeom::Vector3D<Real_t> const &v3)
0020 {
0021 Real_t dot = (v1[0] - v2[0]) * (v3[1] - v2[1]) - (v1[1] - v2[1]) * (v3[0] - v2[0]);
0022 return (dot < -vecgeom::kToleranceDist<Real_t>) ? false : true;
0023 }
0024
0025
0026
0027
0028
0029
0030
0031
0032 template <typename Real_t, typename Container>
0033 bool IsConvexConcave(const int iSect, Container &zArray, Container &rArray, const bool convex, const int nsec)
0034 {
0035 if (nsec == 2) return true;
0036
0037 if (iSect == 0) {
0038 int i = iSect;
0039 int j = (i + 1);
0040 int k = (i + 2);
0041
0042 if (rArray[j] == rArray[k]) k++;
0043 if (convex ^
0044 IsRightSided<Real_t>({rArray[i], zArray[i], 0.}, {rArray[j], zArray[j], 0.}, {rArray[k], zArray[k], 0.})) {
0045 return false;
0046 }
0047 }
0048
0049
0050 if (iSect > 0 && iSect < nsec - 2) {
0051 int i = iSect - 1;
0052 int j = (i + 1);
0053 int k = (i + 2);
0054
0055
0056 if (rArray[i] == rArray[j] && i > 0) i--;
0057 if (convex ^
0058 IsRightSided<Real_t>({rArray[i], zArray[i], 0.}, {rArray[j], zArray[j], 0.}, {rArray[k], zArray[k], 0.})) {
0059 return false;
0060 }
0061 i = iSect;
0062 j = (i + 1);
0063 k = (i + 2);
0064
0065 if (rArray[j] == rArray[k]) k++;
0066 if (convex ^
0067 IsRightSided<Real_t>({rArray[i], zArray[i], 0.}, {rArray[j], zArray[j], 0.}, {rArray[k], zArray[k], 0.})) {
0068 return false;
0069 }
0070 }
0071
0072
0073 if (iSect == nsec - 2) {
0074 int i = iSect - 1;
0075 int j = (i + 1);
0076 int k = (i + 2);
0077
0078
0079 if (rArray[i] == rArray[j] && i > 0) i--;
0080 if (convex ^
0081 IsRightSided<Real_t>({rArray[i], zArray[i], 0.}, {rArray[j], zArray[j], 0.}, {rArray[k], zArray[k], 0.})) {
0082 return false;
0083 }
0084 }
0085
0086 return true;
0087 };
0088
0089 }
0090 }
0091 #endif