ATLAS Offline Software
Loading...
Searching...
No Matches
SbPolyhedronArbitrary Class Reference

#include <SbPolyhedron.h>

Inheritance diagram for SbPolyhedronArbitrary:
Collaboration diagram for SbPolyhedronArbitrary:

Public Member Functions

 SbPolyhedronArbitrary (const int nVertices, const int nFacets)
virtual ~SbPolyhedronArbitrary ()
virtual SbPolyhedronoperator= (const SbPolyhedron &from)
void AddVertex (const double v1, const double v2, const double v3)
void AddFacet (const int iv1, const int iv2, const int iv3, const int iv4=0)
void Finalize ()
int GetNoVertices () const
int GetNoFacets () const
SbPolyhedronTransform (const HEPVis::SbRotation &rot, const SbVec3d &trans)
bool GetNextVertexIndex (int &index, int &edgeFlag) const
HVPoint3D GetVertex (int index) const
const HVPoint3DGetVertexFast (int index) const
bool GetNextVertex (HVPoint3D &vertex, int &edgeFlag) const
bool GetNextVertex (HVPoint3D &vertex, int &edgeFlag, HVNormal3D &normal) const
bool GetNextEdgeIndeces (int &i1, int &i2, int &edgeFlag, int &iface1, int &iface2) const
bool GetNextEdgeIndeces (int &i1, int &i2, int &edgeFlag) const
bool GetNextEdge (HVPoint3D &p1, HVPoint3D &p2, int &edgeFlag) const
bool GetNextEdge (HVPoint3D &p1, HVPoint3D &p2, int &edgeFlag, int &iface1, int &iface2) const
void GetFacet (int iFace, int &n, int *iNodes, int *edgeFlags=0, int *iFaces=0) const
void GetFacet (int iFace, int &n, HVPoint3D *nodes, int *edgeFlags=0, HVNormal3D *normals=0) const
bool GetNextFacet (int &n, HVPoint3D *nodes, int *edgeFlags=0, HVNormal3D *normals=0) const
HVNormal3D GetNormal (int iFace) const
HVNormal3D GetUnitNormal (int iFace) const
bool GetNextNormal (HVNormal3D &normal) const
bool GetNextUnitNormal (HVNormal3D &normal) const
SbPolyhedron add (const SbPolyhedron &p) const
SbPolyhedron subtract (const SbPolyhedron &p) const
SbPolyhedron intersect (const SbPolyhedron &p) const
double GetSurfaceArea () const
double GetVolume () const

Static Public Member Functions

static int GetNumberOfRotationSteps ()
static void SetNumberOfRotationSteps (int n)
static void ResetNumberOfRotationSteps ()

Protected Member Functions

void AllocateMemory (int Nvert, int Nface)
int FindNeighbour (int iFace, int iNode, int iOrder) const
HVNormal3D FindNodeNormal (int iFace, int iNode) const
void CreatePrism ()
void RotateEdge (int k1, int k2, double r1, double r2, int v1, int v2, int vEdge, bool ifWholeCircle, int ns, int &kface)
void SetSideFacets (int ii[4], int vv[4], int *kk, double *r, double dphi, int ns, int &kface)
void RotateAroundZ (int nstep, double phi, double dphi, int np1, int np2, const double *z, double *r, int nodeVis, int edgeVis)
void SetReferences ()
void InvertFacets ()

Protected Attributes

int m_nVertexCount
int m_nFacetCount
int m_nvert
int m_nface
HVPoint3Dm_pV
SbFacetm_pF

Static Private Attributes

static int s_numberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS

Detailed Description

Definition at line 552 of file SbPolyhedron.h.

Constructor & Destructor Documentation

◆ SbPolyhedronArbitrary()

SbPolyhedronArbitrary::SbPolyhedronArbitrary ( const int nVertices,
const int nFacets )

Definition at line 2354 of file SbPolyhedron.cxx.

2355{
2356 AllocateMemory(nVertices, nFacets);
2357 m_nVertexCount = 0;
2358 m_nFacetCount = 0;
2359}
void AllocateMemory(int Nvert, int Nface)

◆ ~SbPolyhedronArbitrary()

SbPolyhedronArbitrary::~SbPolyhedronArbitrary ( )
virtual

Definition at line 2361 of file SbPolyhedron.cxx.

2362{
2363}

Member Function Documentation

◆ add()

SbPolyhedron SbPolyhedron::add ( const SbPolyhedron & p) const
inherited

Definition at line 1843 of file SbPolyhedron.cxx.

1852{
1853 // rbianchi change
1854 //return processor.execute(OP_UNION, *this, p);
1855 HEPVis_BooleanProcessor processor; //G.Barrand
1856 int err;
1857 return processor.execute(OP_UNION, *this, p, err);
1858 //---
1859}
#define OP_UNION
static HEPVis_BooleanProcessor processor

◆ AddFacet()

void SbPolyhedronArbitrary::AddFacet ( const int iv1,
const int iv2,
const int iv3,
const int iv4 = 0 )

Definition at line 2377 of file SbPolyhedron.cxx.

2378{
2379 if(m_nFacetCount==m_nface) {
2380 std::cerr <<"ERROR in SbPolyhedronArbitrary::AddFacet. Attempt to exceed maximum number of facets: "
2381 << m_nFacetCount << std::endl;
2382 }
2383 else if(iv1 < 1
2384 || iv1 > m_nvert
2385 || iv2 < 1
2386 || iv2 > m_nvert
2387 || iv3 < 1
2388 || iv3 > m_nvert
2389 || iv4 > m_nvert) {
2390 std::cerr <<"ERROR in SbPolyhedronArbitrary::AddFacet. Attempt to index vertex number which is out-of-range: ("
2391 << iv1 << "," << iv2 << "," << iv3 << "," << iv4 << ")" << std::endl;
2392 }
2393 else if(iv1 > m_nVertexCount
2394 || iv2 > m_nVertexCount
2395 || iv3 > m_nVertexCount
2396 || iv4 > m_nVertexCount) {
2397 std::cerr <<"ERROR in SbPolyhedronArbitrary::AddFacet. Vertex needs to be defined first : ("
2398 << iv1 << "," << iv2 << "," << iv3 << "," << iv4 << ")" << std::endl;
2399 }
2400 else {
2401 m_nFacetCount++;
2402 m_pF[m_nFacetCount] = SbFacet(iv1, 0, iv2, 0, iv3, 0, iv4, 0);
2403 }
2404}
SbFacet * m_pF

◆ AddVertex()

void SbPolyhedronArbitrary::AddVertex ( const double v1,
const double v2,
const double v3 )

Definition at line 2365 of file SbPolyhedron.cxx.

2366{
2367 if(m_nVertexCount==m_nvert+1) {
2368 std::cerr <<"ERROR in SbPolyhedronArbitrary::AddVertex. Attempt to exceed maximum number of vertices: "
2369 << m_nVertexCount << std::endl;
2370 }
2371 else {
2373 m_pV[m_nVertexCount] = HVPoint3D(v1,v2,v3);
2374 }
2375}
HVPoint3D * m_pV

◆ AllocateMemory()

void SbPolyhedron::AllocateMemory ( int Nvert,
int Nface )
protectedinherited

Definition at line 268 of file SbPolyhedron.cxx.

280{
281 m_nvert = Nvert;
282 m_nface = Nface;
283 m_pV = new HVPoint3D[m_nvert+1];
284 m_pF = new SbFacet[m_nface+1];
285}

◆ CreatePrism()

void SbPolyhedron::CreatePrism ( )
protectedinherited

Definition at line 287 of file SbPolyhedron.cxx.

296{
297 enum {DUMMY, BOTTOM, LEFT, BACK, RIGHT, FRONT, TOP};
298
299 m_pF[1] = SbFacet(1,LEFT, 4,BACK, 3,RIGHT, 2,FRONT);
300 m_pF[2] = SbFacet(5,TOP, 8,BACK, 4,BOTTOM, 1,FRONT);
301 m_pF[3] = SbFacet(8,TOP, 7,RIGHT, 3,BOTTOM, 4,LEFT);
302 m_pF[4] = SbFacet(7,TOP, 6,FRONT, 2,BOTTOM, 3,BACK);
303 m_pF[5] = SbFacet(6,TOP, 5,LEFT, 1,BOTTOM, 2,RIGHT);
304 m_pF[6] = SbFacet(5,FRONT, 6,RIGHT, 7,BACK, 8,LEFT);
305}
@ RIGHT
the drift radius is positive (see Trk::AtaStraightLine)
@ LEFT
the drift radius is negative (see Trk::AtaStraightLine)

◆ Finalize()

void SbPolyhedronArbitrary::Finalize ( )

Definition at line 2406 of file SbPolyhedron.cxx.

2407{
2408 SetReferences();
2409}

◆ FindNeighbour()

int SbPolyhedron::FindNeighbour ( int iFace,
int iNode,
int iOrder ) const
protectedinherited

Definition at line 190 of file SbPolyhedron.cxx.

199{
200 int i;
201 for (i=0; i<4; i++) {
202 if (iNode == iabs(m_pF[iFace].m_edge[i].v)) break;
203 }
204 if (i == 4) {
205 std::cerr
206 << "SbPolyhedron::FindNeighbour: face " << iFace
207 << " has no node " << iNode
208 << std::endl;
209 return 0;
210 }
211 if (iOrder < 0) {
212 if ( --i < 0) i = 3;
213 if (m_pF[iFace].m_edge[i].v == 0) i = 2;
214 }
215 return (m_pF[iFace].m_edge[i].v > 0) ? 0 : m_pF[iFace].m_edge[i].f;
216}
int iabs(int a)

◆ FindNodeNormal()

HVNormal3D SbPolyhedron::FindNodeNormal ( int iFace,
int iNode ) const
protectedinherited

Definition at line 218 of file SbPolyhedron.cxx.

227{
228 HVNormal3D normal = GetUnitNormal(iFace);
229 int k = iFace, iOrder = 1;
230
231 for(;;) {
232 k = FindNeighbour(k, iNode, iOrder);
233 if (k == iFace) break;
234 if (k > 0) {
235 normal += GetUnitNormal(k);
236 }else{
237 if (iOrder < 0) break;
238 k = iFace;
239 iOrder = -iOrder;
240 }
241 }
242 normal.normalize();
243 return normal;
244}
HVPoint3D HVNormal3D
int FindNeighbour(int iFace, int iNode, int iOrder) const
HVNormal3D GetUnitNormal(int iFace) const

◆ GetFacet() [1/2]

void SbPolyhedron::GetFacet ( int iFace,
int & n,
HVPoint3D * nodes,
int * edgeFlags = 0,
HVNormal3D * normals = 0 ) const
inherited

Definition at line 1152 of file SbPolyhedron.cxx.

1162{
1163 int iNodes[4];
1164 GetFacet(index, n, iNodes, edgeFlags);
1165 if (n != 0) {
1166 for (int i=0; i<4; i++) {
1167 nodes[i] = m_pV[iNodes[i]];
1168 if (normals != 0) normals[i] = FindNodeNormal(index,iNodes[i]);
1169 }
1170 }
1171}
HVNormal3D FindNodeNormal(int iFace, int iNode) const
void GetFacet(int iFace, int &n, int *iNodes, int *edgeFlags=0, int *iFaces=0) const

◆ GetFacet() [2/2]

void SbPolyhedron::GetFacet ( int iFace,
int & n,
int * iNodes,
int * edgeFlags = 0,
int * iFaces = 0 ) const
inherited

Definition at line 1118 of file SbPolyhedron.cxx.

1128{
1129 if (iFace < 1 || iFace > m_nface) {
1130 std::cerr
1131 << "SbPolyhedron::GetFacet: irrelevant index " << iFace
1132 << std::endl;
1133 n = 0;
1134 }else{
1135 int i, k;
1136 for (i=0; i<4; i++) {
1137 k = m_pF[iFace].m_edge[i].v;
1138 if (k == 0) break;
1139 if (iFaces != 0) iFaces[i] = m_pF[iFace].m_edge[i].f;
1140 if (k > 0) {
1141 iNodes[i] = k;
1142 if (edgeFlags != 0) edgeFlags[i] = 1;
1143 }else{
1144 iNodes[i] = -k;
1145 if (edgeFlags != 0) edgeFlags[i] = -1;
1146 }
1147 }
1148 n = i;
1149 }
1150}

◆ GetNextEdge() [1/2]

bool SbPolyhedron::GetNextEdge ( HVPoint3D & p1,
HVPoint3D & p2,
int & edgeFlag ) const
inherited

Definition at line 1077 of file SbPolyhedron.cxx.

1089{
1090 int i1,i2;
1091 bool rep = GetNextEdgeIndeces(i1,i2,edgeFlag);
1092 p1 = m_pV[i1];
1093 p2 = m_pV[i2];
1094 return rep;
1095}
bool GetNextEdgeIndeces(int &i1, int &i2, int &edgeFlag, int &iface1, int &iface2) const

◆ GetNextEdge() [2/2]

bool SbPolyhedron::GetNextEdge ( HVPoint3D & p1,
HVPoint3D & p2,
int & edgeFlag,
int & iface1,
int & iface2 ) const
inherited

Definition at line 1098 of file SbPolyhedron.cxx.

1110{
1111 int i1,i2;
1112 bool rep = GetNextEdgeIndeces(i1,i2,edgeFlag,iface1,iface2);
1113 p1 = m_pV[i1];
1114 p2 = m_pV[i2];
1115 return rep;
1116}

◆ GetNextEdgeIndeces() [1/2]

bool SbPolyhedron::GetNextEdgeIndeces ( int & i1,
int & i2,
int & edgeFlag ) const
inherited

Definition at line 1061 of file SbPolyhedron.cxx.

1071{
1072 int kface1, kface2;
1073 return GetNextEdgeIndeces(i1, i2, edgeFlag, kface1, kface2);
1074}

◆ GetNextEdgeIndeces() [2/2]

bool SbPolyhedron::GetNextEdgeIndeces ( int & i1,
int & i2,
int & edgeFlag,
int & iface1,
int & iface2 ) const
inherited

Definition at line 1008 of file SbPolyhedron.cxx.

1020{
1021 static int iFace = 1;
1022 static int iQVertex = 0;
1023 static int iOrder = 1;
1024 int k1, k2, kflag, kface1, kface2;
1025
1026 if (iFace == 1 && iQVertex == 0) {
1027 k2 = m_pF[m_nface].m_edge[0].v;
1028 k1 = m_pF[m_nface].m_edge[3].v;
1029 if (k1 == 0) k1 = m_pF[m_nface].m_edge[2].v;
1030 if (iabs(k1) > iabs(k2)) iOrder = -1;
1031 }
1032
1033 do {
1034 k1 = m_pF[iFace].m_edge[iQVertex].v;
1035 kflag = k1;
1036 k1 = iabs(k1);
1037 kface1 = iFace;
1038 kface2 = m_pF[iFace].m_edge[iQVertex].f;
1039 if (iQVertex >= 3 || m_pF[iFace].m_edge[iQVertex+1].v == 0) {
1040 iQVertex = 0;
1041 k2 = iabs(m_pF[iFace].m_edge[iQVertex].v);
1042 iFace++;
1043 }else{
1044 iQVertex++;
1045 k2 = iabs(m_pF[iFace].m_edge[iQVertex].v);
1046 }
1047 } while (iOrder*k1 > iOrder*k2);
1048
1049 i1 = k1; i2 = k2; edgeFlag = (kflag > 0) ? 1 : 0;
1050 iface1 = kface1; iface2 = kface2;
1051
1052 if (iFace > m_nface) {
1053 iFace = 1; iOrder = 1;
1054 return false;
1055 }else{
1056 return true;
1057 }
1058}

◆ GetNextFacet()

bool SbPolyhedron::GetNextFacet ( int & n,
HVPoint3D * nodes,
int * edgeFlags = 0,
HVNormal3D * normals = 0 ) const
inherited

Definition at line 1174 of file SbPolyhedron.cxx.

1185{
1186 static int iFace = 1;
1187
1188 if (edgeFlags == 0) {
1189 GetFacet(iFace, n, nodes);
1190 }else if (normals == 0) {
1191 GetFacet(iFace, n, nodes, edgeFlags);
1192 }else{
1193 GetFacet(iFace, n, nodes, edgeFlags, normals);
1194 }
1195
1196 if (++iFace > m_nface) {
1197 iFace = 1;
1198 return false;
1199 }else{
1200 return true;
1201 }
1202}

◆ GetNextNormal()

bool SbPolyhedron::GetNextNormal ( HVNormal3D & normal) const
inherited

Definition at line 1256 of file SbPolyhedron.cxx.

1266{
1267 static int iFace = 1;
1268 normal = GetNormal(iFace);
1269 if (++iFace > m_nface) {
1270 iFace = 1;
1271 return false;
1272 }else{
1273 return true;
1274 }
1275}
HVNormal3D GetNormal(int iFace) const

◆ GetNextUnitNormal()

bool SbPolyhedron::GetNextUnitNormal ( HVNormal3D & normal) const
inherited

Definition at line 1277 of file SbPolyhedron.cxx.

1287{
1288 bool rep = GetNextNormal(normal);
1289 normal.normalize();
1290 return rep;
1291}
bool GetNextNormal(HVNormal3D &normal) const

◆ GetNextVertex() [1/2]

bool SbPolyhedron::GetNextVertex ( HVPoint3D & vertex,
int & edgeFlag ) const
inherited

Definition at line 958 of file SbPolyhedron.cxx.

969{
970 int index;
971 bool rep = GetNextVertexIndex(index, edgeFlag);
972 vertex = m_pV[index];
973 return rep;
974}
bool GetNextVertexIndex(int &index, int &edgeFlag) const
str index
Definition DeMoScan.py:362

◆ GetNextVertex() [2/2]

bool SbPolyhedron::GetNextVertex ( HVPoint3D & vertex,
int & edgeFlag,
HVNormal3D & normal ) const
inherited

Definition at line 976 of file SbPolyhedron.cxx.

988{
989 static int iFace = 1;
990 static int iNode = 0;
991
992 if (m_nface == 0) return false; // empty polyhedron
993
994 int k = m_pF[iFace].m_edge[iNode].v;
995 if (k > 0) { edgeFlag = 1; } else { edgeFlag = -1; k = -k; }
996 vertex = m_pV[k];
997 normal = FindNodeNormal(iFace,k);
998 if (iNode >= 3 || m_pF[iFace].m_edge[iNode+1].v == 0) {
999 iNode = 0;
1000 if (++iFace > m_nface) iFace = 1;
1001 return false; // last node
1002 }else{
1003 ++iNode;
1004 return true; // not last node
1005 }
1006}

◆ GetNextVertexIndex()

bool SbPolyhedron::GetNextVertexIndex ( int & index,
int & edgeFlag ) const
inherited

Definition at line 903 of file SbPolyhedron.cxx.

912{
913 static int iFace = 1;
914 static int iQVertex = 0;
915 int vIndex = m_pF[iFace].m_edge[iQVertex].v;
916
917 edgeFlag = (vIndex > 0) ? 1 : 0;
918 index = iabs(vIndex);
919
920 if (iQVertex >= 3 || m_pF[iFace].m_edge[iQVertex+1].v == 0) {
921 iQVertex = 0;
922 if (++iFace > m_nface) iFace = 1;
923 return false; // Last Edge
924 }else{
925 ++iQVertex;
926 return true; // not Last Edge
927 }
928}

◆ GetNoFacets()

int SbPolyhedron::GetNoFacets ( ) const
inlineinherited

Definition at line 296 of file SbPolyhedron.h.

296{ return m_nface; }

◆ GetNormal()

HVNormal3D SbPolyhedron::GetNormal ( int iFace) const
inherited

Definition at line 1204 of file SbPolyhedron.cxx.

1213{
1214 if (iFace < 1 || iFace > m_nface) {
1215 std::cerr
1216 << "SbPolyhedron::GetNormal: irrelevant index " << iFace
1217 << std::endl;
1218 return HVNormal3D();
1219 }
1220
1221 int i0 = iabs(m_pF[iFace].m_edge[0].v);
1222 int i1 = iabs(m_pF[iFace].m_edge[1].v);
1223 int i2 = iabs(m_pF[iFace].m_edge[2].v);
1224 int i3 = iabs(m_pF[iFace].m_edge[3].v);
1225 if (i3 == 0) i3 = i0;
1226 return (m_pV[i2] - m_pV[i0]).cross(m_pV[i3] - m_pV[i1]);
1227}

◆ GetNoVertices()

int SbPolyhedron::GetNoVertices ( ) const
inlineinherited

Definition at line 293 of file SbPolyhedron.h.

293{ return m_nvert; }

◆ GetNumberOfRotationSteps()

int SbPolyhedron::GetNumberOfRotationSteps ( )
inlinestaticinherited

Definition at line 375 of file SbPolyhedron.h.

375{ return s_numberOfRotationSteps; }
static int s_numberOfRotationSteps

◆ GetSurfaceArea()

double SbPolyhedron::GetSurfaceArea ( ) const
inherited

Definition at line 1293 of file SbPolyhedron.cxx.

1302{
1303 double s = 0.;
1304 for (int iFace=1; iFace<=m_nface; iFace++) {
1305 int i0 = iabs(m_pF[iFace].m_edge[0].v);
1306 int i1 = iabs(m_pF[iFace].m_edge[1].v);
1307 int i2 = iabs(m_pF[iFace].m_edge[2].v);
1308 int i3 = iabs(m_pF[iFace].m_edge[3].v);
1309 if (i3 == 0) i3 = i0;
1310 s += ((m_pV[i2] - m_pV[i0]).cross(m_pV[i3] - m_pV[i1])).length();
1311 }
1312 return s/2.;
1313}

◆ GetUnitNormal()

HVNormal3D SbPolyhedron::GetUnitNormal ( int iFace) const
inherited

Definition at line 1229 of file SbPolyhedron.cxx.

1238{
1239 if (iFace < 1 || iFace > m_nface) {
1240 std::cerr
1241 << "SbPolyhedron::GetUnitNormal: irrelevant index " << iFace
1242 << std::endl;
1243 return HVNormal3D();
1244 }
1245
1246 int i0 = iabs(m_pF[iFace].m_edge[0].v);
1247 int i1 = iabs(m_pF[iFace].m_edge[1].v);
1248 int i2 = iabs(m_pF[iFace].m_edge[2].v);
1249 int i3 = iabs(m_pF[iFace].m_edge[3].v);
1250 if (i3 == 0) i3 = i0;
1251 HVNormal3D nm = (m_pV[i2] - m_pV[i0]).cross(m_pV[i3] - m_pV[i1]);
1252 nm.normalize();
1253 return nm;
1254}

◆ GetVertex()

HVPoint3D SbPolyhedron::GetVertex ( int index) const
inherited

Definition at line 930 of file SbPolyhedron.cxx.

939{
940 if (index <= 0 || index > m_nvert) {
941 std::cerr
942 << "SbPolyhedron::GetVertex: irrelevant index " << index
943 << std::endl;
944 return HVPoint3D();
945 }
946 return m_pV[index];
947}

◆ GetVertexFast()

const HVPoint3D & SbPolyhedron::GetVertexFast ( int index) const
inherited

Definition at line 951 of file SbPolyhedron.cxx.

951 { //G.Barrand
952 return m_pV[index];
953}

◆ GetVolume()

double SbPolyhedron::GetVolume ( ) const
inherited

Definition at line 1315 of file SbPolyhedron.cxx.

1324{
1325 double v = 0.;
1326 for (int iFace=1; iFace<=m_nface; iFace++) {
1327 int i0 = iabs(m_pF[iFace].m_edge[0].v);
1328 int i1 = iabs(m_pF[iFace].m_edge[1].v);
1329 int i2 = iabs(m_pF[iFace].m_edge[2].v);
1330 int i3 = iabs(m_pF[iFace].m_edge[3].v);
1331 HVPoint3D g;
1332 if (i3 == 0) {
1333 i3 = i0;
1334 g = (m_pV[i0]+m_pV[i1]+m_pV[i2]) * (1.0f/3.0f);
1335 }else{
1336 g = (m_pV[i0]+m_pV[i1]+m_pV[i2]+m_pV[i3]) * 0.25f;
1337 }
1338 v += ((m_pV[i2] - m_pV[i0]).cross(m_pV[i3] - m_pV[i1])).dot(g);
1339 }
1340 return v/6.;
1341}

◆ intersect()

SbPolyhedron SbPolyhedron::intersect ( const SbPolyhedron & p) const
inherited

Definition at line 1861 of file SbPolyhedron.cxx.

1870{
1871 // rbianchi change
1872 //return processor.execute(OP_INTERSECTION, *this, p);
1873 HEPVis_BooleanProcessor processor; //G.Barrand
1874 int err;
1875 return processor.execute(OP_INTERSECTION, *this, p, err);
1876 //---
1877}
#define OP_INTERSECTION

◆ InvertFacets()

void SbPolyhedron::InvertFacets ( )
protectedinherited

Definition at line 820 of file SbPolyhedron.cxx.

829{
830 if (m_nface <= 0) return;
831 int i, k, nnode, v[4],f[4];
832 for (i=1; i<=m_nface; i++) {
833 nnode = (m_pF[i].m_edge[3].v == 0) ? 3 : 4;
834 for (k=0; k<nnode; k++) {
835 v[k] = (k+1 == nnode) ? m_pF[i].m_edge[0].v : m_pF[i].m_edge[k+1].v;
836 if (v[k] * m_pF[i].m_edge[k].v < 0) v[k] = -v[k];
837 f[k] = m_pF[i].m_edge[k].f;
838 }
839 for (k=0; k<nnode; k++) {
840 m_pF[i].m_edge[nnode-1-k].v = v[k];
841 m_pF[i].m_edge[nnode-1-k].f = f[k];
842 }
843 }
844}

◆ operator=()

virtual SbPolyhedron & SbPolyhedronArbitrary::operator= ( const SbPolyhedron & from)
inlinevirtual

Reimplemented from SbPolyhedron.

Definition at line 558 of file SbPolyhedron.h.

558 {
559 return SbPolyhedron::operator = (from);
560 }
virtual SbPolyhedron & operator=(const SbPolyhedron &from)

◆ ResetNumberOfRotationSteps()

void SbPolyhedron::ResetNumberOfRotationSteps ( )
inlinestaticinherited

Definition at line 381 of file SbPolyhedron.h.

381 {
383 }
#define DEFAULT_NUMBER_OF_STEPS

◆ RotateAroundZ()

void SbPolyhedron::RotateAroundZ ( int nstep,
double phi,
double dphi,
int np1,
int np2,
const double * z,
double * r,
int nodeVis,
int edgeVis )
protectedinherited

Definition at line 439 of file SbPolyhedron.cxx.

464{
465 static double wholeCircle = 2*M_PI;
466
467 // S E T R O T A T I O N P A R A M E T E R S
468
469 bool ifWholeCircle = (fabs(dphi-wholeCircle) < perMillion) ?
470 true : false;
471 double delPhi = ifWholeCircle ? wholeCircle : dphi;
472 int nSphi = (nstep > 0) ?
473 nstep : int(delPhi*GetNumberOfRotationSteps()/wholeCircle+.5);
474 if (nSphi == 0) nSphi = 1;
475 int nVphi = ifWholeCircle ? nSphi : nSphi+1;
476 bool ifClosed = np1 > 0 ? false : true;
477
478 // C O U N T V E R T E C E S
479
480 int absNp1 = iabs(np1);
481 int absNp2 = iabs(np2);
482 int i1beg = 0;
483 int i1end = absNp1-1;
484 int i2beg = absNp1;
485 int i2end = absNp1+absNp2-1;
486 int i, j, k;
487
488 for(i=i1beg; i<=i2end; i++) {
489 if (fabs(r[i]) < perMillion) r[i] = 0.;
490 }
491
492 j = 0; // external nodes
493 for (i=i1beg; i<=i1end; i++) {
494 j += (r[i] == 0.) ? 1 : nVphi;
495 }
496
497 bool ifSide1 = false; // internal nodes
498 bool ifSide2 = false;
499
500 if (r[i2beg] != r[i1beg] || z[i2beg] != z[i1beg]) {
501 j += (r[i2beg] == 0.) ? 1 : nVphi;
502 ifSide1 = true;
503 }
504
505 for(i=i2beg+1; i<i2end; i++) {
506 j += (r[i] == 0.) ? 1 : nVphi;
507 }
508
509 if (r[i2end] != r[i1end] || z[i2end] != z[i1end]) {
510 if (absNp2 > 1) j += (r[i2end] == 0.) ? 1 : nVphi;
511 ifSide2 = true;
512 }
513
514 // C O U N T F A C E S
515
516 k = ifClosed ? absNp1*nSphi : (absNp1-1)*nSphi; // external faces
517
518 if (absNp2 > 1) { // internal faces
519 for(i=i2beg; i<i2end; i++) {
520 if (r[i] > 0. || r[i+1] > 0.) k += nSphi;
521 }
522
523 if (ifClosed) {
524 if (r[i2end] > 0. || r[i2beg] > 0.) k += nSphi;
525 }
526 }
527
528 if (!ifClosed) { // side faces
529 if (ifSide1 && (r[i1beg] > 0. || r[i2beg] > 0.)) k += nSphi;
530 if (ifSide2 && (r[i1end] > 0. || r[i2end] > 0.)) k += nSphi;
531 }
532
533 if (!ifWholeCircle) { // phi_side faces
534 k += ifClosed ? 2*absNp1 : 2*(absNp1-1);
535 }
536
537 // A L L O C A T E M E M O R Y
538
539 AllocateMemory(j, k);
540
541 // G E N E R A T E V E R T E C E S
542
543 int *kk;
544 kk = new int[absNp1+absNp2];
545
546 k = 1;
547 for(i=i1beg; i<=i1end; i++) {
548 kk[i] = k;
549 if (r[i] == 0.) { m_pV[k++] = HVPoint3D(0, 0, z[i]); } else { k += nVphi; }
550 }
551
552 i = i2beg;
553 if (ifSide1) {
554 kk[i] = k;
555 if (r[i] == 0.) { m_pV[k++] = HVPoint3D(0, 0, z[i]); } else { k += nVphi; }
556 }else{
557 kk[i] = kk[i1beg];
558 }
559
560 for(i=i2beg+1; i<i2end; i++) {
561 kk[i] = k;
562 if (r[i] == 0.) { m_pV[k++] = HVPoint3D(0, 0, z[i]); } else { k += nVphi; }
563 }
564
565 if (absNp2 > 1) {
566 i = i2end;
567 if (ifSide2) {
568 kk[i] = k;
569 if (r[i] == 0.) m_pV[k] = HVPoint3D(0, 0, z[i]);
570 }else{
571 kk[i] = kk[i1end];
572 }
573 }
574
575 double cosPhi, sinPhi;
576
577 for(j=0; j<nVphi; j++) {
578 cosPhi = cos(phi+j*delPhi/nSphi);
579 sinPhi = sin(phi+j*delPhi/nSphi);
580 for(i=i1beg; i<=i2end; i++) {
581 if (r[i] != 0.) m_pV[kk[i]+j] = HVPoint3D(r[i]*cosPhi,r[i]*sinPhi,z[i]);
582 }
583 }
584
585 // G E N E R A T E E X T E R N A L F A C E S
586
587 int v1,v2;
588
589 k = 1;
590 v2 = ifClosed ? nodeVis : 1;
591 for(i=i1beg; i<i1end; i++) {
592 v1 = v2;
593 if (!ifClosed && i == i1end-1) {
594 v2 = 1;
595 }else{
596 v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
597 }
598 RotateEdge(kk[i], kk[i+1], r[i], r[i+1], v1, v2,
599 edgeVis, ifWholeCircle, nSphi, k);
600 }
601 if (ifClosed) {
602 RotateEdge(kk[i1end], kk[i1beg], r[i1end],r[i1beg], nodeVis, nodeVis,
603 edgeVis, ifWholeCircle, nSphi, k);
604 }
605
606 // G E N E R A T E I N T E R N A L F A C E S
607
608 if (absNp2 > 1) {
609 v2 = ifClosed ? nodeVis : 1;
610 for(i=i2beg; i<i2end; i++) {
611 v1 = v2;
612 if (!ifClosed && i==i2end-1) {
613 v2 = 1;
614 }else{
615 v2 = (r[i] == r[i+1] && r[i+1] == r[i+2]) ? -1 : nodeVis;
616 }
617 RotateEdge(kk[i+1], kk[i], r[i+1], r[i], v2, v1,
618 edgeVis, ifWholeCircle, nSphi, k);
619 }
620 if (ifClosed) {
621 RotateEdge(kk[i2beg], kk[i2end], r[i2beg], r[i2end], nodeVis, nodeVis,
622 edgeVis, ifWholeCircle, nSphi, k);
623 }
624 }
625
626 // G E N E R A T E S I D E F A C E S
627
628 if (!ifClosed) {
629 if (ifSide1) {
630 RotateEdge(kk[i2beg], kk[i1beg], r[i2beg], r[i1beg], 1, 1,
631 -1, ifWholeCircle, nSphi, k);
632 }
633 if (ifSide2) {
634 RotateEdge(kk[i1end], kk[i2end], r[i1end], r[i2end], 1, 1,
635 -1, ifWholeCircle, nSphi, k);
636 }
637 }
638
639 // G E N E R A T E S I D E F A C E S for the case of incomplete circle
640
641 if (!ifWholeCircle) {
642
643 int ii[4], vv[4];
644
645 if (ifClosed) {
646 for (i=i1beg; i<=i1end; i++) {
647 ii[0] = i;
648 ii[3] = (i == i1end) ? i1beg : i+1;
649 ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
650 ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
651 vv[0] = -1;
652 vv[1] = 1;
653 vv[2] = -1;
654 vv[3] = 1;
655 SetSideFacets(ii, vv, kk, r, dphi, nSphi, k);
656 }
657 }else{
658 for (i=i1beg; i<i1end; i++) {
659 ii[0] = i;
660 ii[3] = i+1;
661 ii[1] = (absNp2 == 1) ? i2beg : ii[0]+absNp1;
662 ii[2] = (absNp2 == 1) ? i2beg : ii[3]+absNp1;
663 vv[0] = (i == i1beg) ? 1 : -1;
664 vv[1] = 1;
665 vv[2] = (i == i1end-1) ? 1 : -1;
666 vv[3] = 1;
667 SetSideFacets(ii, vv, kk, r, dphi, nSphi, k);
668 }
669 }
670 }
671
672 delete [] kk;
673
674 if (k-1 != m_nface) {
675 std::cerr
676 << "Polyhedron::RotateAroundZ: number of generated faces ("
677 << k-1 << ") is not equal to the number of allocated faces ("
678 << m_nface << ")"
679 << std::endl;
680 }
681}
#define M_PI
Scalar phi() const
phi method
#define perMillion
#define z
void SetSideFacets(int ii[4], int vv[4], int *kk, double *r, double dphi, int ns, int &kface)
void RotateEdge(int k1, int k2, double r1, double r2, int v1, int v2, int vEdge, bool ifWholeCircle, int ns, int &kface)
static int GetNumberOfRotationSteps()
int r
Definition globals.cxx:22

◆ RotateEdge()

void SbPolyhedron::RotateEdge ( int k1,
int k2,
double r1,
double r2,
int v1,
int v2,
int vEdge,
bool ifWholeCircle,
int ns,
int & kface )
protectedinherited

Definition at line 307 of file SbPolyhedron.cxx.

328{
329 if (r1 == 0. && r2 == 0) return;
330
331 int i;
332 int i1 = k1;
333 int i2 = k2;
334 int ii1 = ifWholeCircle ? i1 : i1+ns;
335 int ii2 = ifWholeCircle ? i2 : i2+ns;
336 int vv = ifWholeCircle ? vEdge : 1;
337
338 if (ns == 1) {
339 if (r1 == 0.) {
340 m_pF[kface++] = SbFacet(i1,0, v2*i2,0, (i2+1),0);
341 }else if (r2 == 0.) {
342 m_pF[kface++] = SbFacet(i1,0, i2,0, v1*(i1+1),0);
343 }else{
344 m_pF[kface++] = SbFacet(i1,0, v2*i2,0, (i2+1),0, v1*(i1+1),0);
345 }
346 }else{
347 if (r1 == 0.) {
348 m_pF[kface++] = SbFacet(vv*i1,0, v2*i2,0, vEdge*(i2+1),0);
349 for (i2++,i=1; i<ns-1; i2++,i++) {
350 m_pF[kface++] = SbFacet(vEdge*i1,0, v2*i2,0, vEdge*(i2+1),0);
351 }
352 m_pF[kface++] = SbFacet(vEdge*i1,0, v2*i2,0, vv*ii2,0);
353 }else if (r2 == 0.) {
354 m_pF[kface++] = SbFacet(vv*i1,0, vEdge*i2,0, v1*(i1+1),0);
355 for (i1++,i=1; i<ns-1; i1++,i++) {
356 m_pF[kface++] = SbFacet(vEdge*i1,0, vEdge*i2,0, v1*(i1+1),0);
357 }
358 m_pF[kface++] = SbFacet(vEdge*i1,0, vv*i2,0, v1*ii1,0);
359 }else{
360 m_pF[kface++] = SbFacet(vv*i1,0, v2*i2,0, vEdge*(i2+1),0,v1*(i1+1),0);
361 for (i1++,i2++,i=1; i<ns-1; i1++,i2++,i++) {
362 m_pF[kface++] = SbFacet(vEdge*i1,0, v2*i2,0, vEdge*(i2+1),0,v1*(i1+1),0);
363 }
364 m_pF[kface++] = SbFacet(vEdge*i1,0, v2*i2,0, vv*ii2,0, v1*ii1,0);
365 }
366 }
367}

◆ SetNumberOfRotationSteps()

void SbPolyhedron::SetNumberOfRotationSteps ( int n)
staticinherited

Definition at line 246 of file SbPolyhedron.cxx.

255{
256 const int nMin = 3;
257 if (n < nMin) {
258 std::cerr
259 << "SbPolyhedron::SetNumberOfRotationSteps: attempt to set the\n"
260 << "number of steps per circle < " << nMin << "; forced to " << nMin
261 << std::endl;
263 }else{
265 }
266}

◆ SetReferences()

void SbPolyhedron::SetReferences ( )
protectedinherited

Definition at line 683 of file SbPolyhedron.cxx.

692{
693 if (m_nface <= 0) return;
694
695 struct edgeListMember {
696 edgeListMember *next;
697 int v2;
698 int iface;
699 int iedge;
700 } *edgeList, *freeList, **headList;
701
702
703 // A L L O C A T E A N D I N I T I A T E L I S T S
704
705 edgeList = new edgeListMember[2*m_nface];
706 headList = new edgeListMember*[m_nvert];
707
708 int i;
709 for (i=0; i<m_nvert; i++) {
710 headList[i] = 0;
711 }
712 freeList = edgeList;
713 for (i=0; i<2*m_nface-1; i++) {
714 edgeList[i].next = &edgeList[i+1];
715 }
716 edgeList[2*m_nface-1].next = 0;
717
718 // L O O P A L O N G E D G E S
719
720 int iface, iedge, nedge, i1, i2, k1, k2;
721 edgeListMember *prev, *cur;
722
723 for(iface=1; iface<=m_nface; iface++) {
724 nedge = (m_pF[iface].m_edge[3].v == 0) ? 3 : 4;
725 for (iedge=0; iedge<nedge; iedge++) {
726 i1 = iedge;
727 i2 = (iedge < nedge-1) ? iedge+1 : 0;
728 i1 = iabs(m_pF[iface].m_edge[i1].v);
729 i2 = iabs(m_pF[iface].m_edge[i2].v);
730 k1 = (i1 < i2) ? i1 : i2; // k1 = ::min(i1,i2);
731 k2 = (i1 > i2) ? i1 : i2; // k2 = ::max(i1,i2);
732
733 // check head of the List corresponding to k1
734 cur = headList[k1];
735 if (cur == 0) {
736 headList[k1] = freeList;
737 freeList = freeList->next;
738 cur = headList[k1];
739 cur->next = 0;
740 cur->v2 = k2;
741 cur->iface = iface;
742 cur->iedge = iedge;
743 continue;
744 }
745
746 if (cur->v2 == k2) {
747 headList[k1] = cur->next;
748 cur->next = freeList;
749 freeList = cur;
750 m_pF[iface].m_edge[iedge].f = cur->iface;
751 m_pF[cur->iface].m_edge[cur->iedge].f = iface;
752 i1 = (m_pF[iface].m_edge[iedge].v < 0) ? -1 : 1;
753 i2 = (m_pF[cur->iface].m_edge[cur->iedge].v < 0) ? -1 : 1;
754 if (i1 != i2) {
755 std::cerr
756 << "Polyhedron::SetReferences: different edge visibility "
757 << iface << "/" << iedge << "/"
758 << m_pF[iface].m_edge[iedge].v << " and "
759 << cur->iface << "/" << cur->iedge << "/"
760 << m_pF[cur->iface].m_edge[cur->iedge].v
761 << std::endl;
762 }
763 continue;
764 }
765
766 // check List itself
767 for (;;) {
768 prev = cur;
769 cur = prev->next;
770 if (cur == 0) {
771 prev->next = freeList;
772 freeList = freeList->next;
773 cur = prev->next;
774 cur->next = 0;
775 cur->v2 = k2;
776 cur->iface = iface;
777 cur->iedge = iedge;
778 break;
779 }
780
781 if (cur->v2 == k2) {
782 prev->next = cur->next;
783 cur->next = freeList;
784 freeList = cur;
785 m_pF[iface].m_edge[iedge].f = cur->iface;
786 m_pF[cur->iface].m_edge[cur->iedge].f = iface;
787 i1 = (m_pF[iface].m_edge[iedge].v < 0) ? -1 : 1;
788 i2 = (m_pF[cur->iface].m_edge[cur->iedge].v < 0) ? -1 : 1;
789 if (i1 != i2) {
790 std::cerr
791 << "Polyhedron::SetReferences: different edge visibility "
792 << iface << "/" << iedge << "/"
793 << m_pF[iface].m_edge[iedge].v << " and "
794 << cur->iface << "/" << cur->iedge << "/"
795 << m_pF[cur->iface].m_edge[cur->iedge].v
796 << std::endl;
797 }
798 break;
799 }
800 }
801 }
802 }
803
804 // C H E C K T H A T A L L L I S T S A R E E M P T Y
805
806 for (i=0; i<m_nvert; i++) {
807 if (headList[i] != 0) {
808 std::cerr
809 << "Polyhedron::SetReferences: List " << i << " is not empty"
810 << std::endl;
811 }
812 }
813
814 // F R E E M E M O R Y
815
816 delete [] edgeList;
817 delete [] headList;
818}

◆ SetSideFacets()

void SbPolyhedron::SetSideFacets ( int ii[4],
int vv[4],
int * kk,
double * r,
double dphi,
int ns,
int & kface )
protectedinherited

Definition at line 369 of file SbPolyhedron.cxx.

388{
389 int k1, k2, k3, k4;
390 if (fabs(dphi-M_PI) < perMillion) { // half a circle
391 for (int i=0; i<4; i++) {
392 k1 = ii[i];
393 k2 = (i == 3) ? ii[0] : ii[i+1];
394 if (r[k1] == 0. && r[k2] == 0.) vv[i] = -1;
395 }
396 }
397
398 if (ii[1] == ii[2]) {
399 k1 = kk[ii[0]];
400 k2 = kk[ii[2]];
401 k3 = kk[ii[3]];
402 m_pF[kface++] = SbFacet(vv[0]*k1,0, vv[2]*k2,0, vv[3]*k3,0);
403 if (r[ii[0]] != 0.) k1 += ns;
404 if (r[ii[2]] != 0.) k2 += ns;
405 if (r[ii[3]] != 0.) k3 += ns;
406 m_pF[kface++] = SbFacet(vv[2]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
407 }else if (kk[ii[0]] == kk[ii[1]]) {
408 k1 = kk[ii[0]];
409 k2 = kk[ii[2]];
410 k3 = kk[ii[3]];
411 m_pF[kface++] = SbFacet(vv[1]*k1,0, vv[2]*k2,0, vv[3]*k3,0);
412 if (r[ii[0]] != 0.) k1 += ns;
413 if (r[ii[2]] != 0.) k2 += ns;
414 if (r[ii[3]] != 0.) k3 += ns;
415 m_pF[kface++] = SbFacet(vv[2]*k3,0, vv[1]*k2,0, vv[3]*k1,0);
416 }else if (kk[ii[2]] == kk[ii[3]]) {
417 k1 = kk[ii[0]];
418 k2 = kk[ii[1]];
419 k3 = kk[ii[2]];
420 m_pF[kface++] = SbFacet(vv[0]*k1,0, vv[1]*k2,0, vv[3]*k3,0);
421 if (r[ii[0]] != 0.) k1 += ns;
422 if (r[ii[1]] != 0.) k2 += ns;
423 if (r[ii[2]] != 0.) k3 += ns;
424 m_pF[kface++] = SbFacet(vv[1]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
425 }else{
426 k1 = kk[ii[0]];
427 k2 = kk[ii[1]];
428 k3 = kk[ii[2]];
429 k4 = kk[ii[3]];
430 m_pF[kface++] = SbFacet(vv[0]*k1,0, vv[1]*k2,0, vv[2]*k3,0, vv[3]*k4,0);
431 if (r[ii[0]] != 0.) k1 += ns;
432 if (r[ii[1]] != 0.) k2 += ns;
433 if (r[ii[2]] != 0.) k3 += ns;
434 if (r[ii[3]] != 0.) k4 += ns;
435 m_pF[kface++] = SbFacet(vv[2]*k4,0, vv[1]*k3,0, vv[0]*k2,0, vv[3]*k1,0);
436 }
437}

◆ subtract()

SbPolyhedron SbPolyhedron::subtract ( const SbPolyhedron & p) const
inherited

Definition at line 1879 of file SbPolyhedron.cxx.

1888{
1889 // rbianchi change
1890 //return processor.execute(OP_SUBTRACTION, *this, p);
1891 HEPVis_BooleanProcessor processor; //G.Barrand
1892 int err;
1893 return processor.execute(OP_SUBTRACTION, *this, p, err);
1894 //---
1895}
#define OP_SUBTRACTION

◆ Transform()

SbPolyhedron & SbPolyhedron::Transform ( const HEPVis::SbRotation & rot,
const SbVec3d & trans )
inherited

Definition at line 879 of file SbPolyhedron.cxx.

883{
884 if (m_nvert > 0) {
885 SbVec3d tmp;
886 for (int i=1; i<=m_nvert; i++) {
887 rotation.multVec(m_pV[i],tmp);
888 m_pV[i] = tmp+translation;
889 }
890 SbVec3d x; rotation.multVec(SbVec3d(1,0,0),x);
891 SbVec3d y; rotation.multVec(SbVec3d(0,1,0),y);
892 SbVec3d z; rotation.multVec(SbVec3d(0,0,1),z);
893 if ((x.cross(y)).dot(z) < 0) InvertFacets();
894 }
895 return *this;
896}
#define y
#define x

Member Data Documentation

◆ m_nface

int SbPolyhedron::m_nface
protectedinherited

Definition at line 238 of file SbPolyhedron.h.

◆ m_nFacetCount

int SbPolyhedronArbitrary::m_nFacetCount
protected

Definition at line 569 of file SbPolyhedron.h.

◆ m_nvert

int SbPolyhedron::m_nvert
protectedinherited

Definition at line 238 of file SbPolyhedron.h.

◆ m_nVertexCount

int SbPolyhedronArbitrary::m_nVertexCount
protected

Definition at line 568 of file SbPolyhedron.h.

◆ m_pF

SbFacet* SbPolyhedron::m_pF
protectedinherited

Definition at line 240 of file SbPolyhedron.h.

◆ m_pV

HVPoint3D* SbPolyhedron::m_pV
protectedinherited

Definition at line 239 of file SbPolyhedron.h.

◆ s_numberOfRotationSteps

int SbPolyhedron::s_numberOfRotationSteps = DEFAULT_NUMBER_OF_STEPS
staticprivateinherited

Definition at line 235 of file SbPolyhedron.h.


The documentation for this class was generated from the following files: