Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -22,7 +22,7 @@ typedef std::list<unsigned int> cline_strip;
typedef std::list<cline_strip*> cline_strip_list;
typedef std::vector<cline_strip_list> cline_strip_list_vector;
class clist_contour : public ccontour
class clist_contour : public ccontour
{
public: //ccontour
// Adding segment to line strips
@@ -70,11 +70,11 @@ protected:
// returns true if contour is touching boundary
bool OnBoundary(cline_strip* pStrip);
// L.Garnier : check specials case for CompactStrip
bool SpecialCompactStripCase(double,double,double,double,double);
bool SpecialCompactStripCase(double,double,double,double,double);
private:
// array of line strips
cline_strip_list_vector m_vStripLists;
cline_strip_list_vector m_vStripLists;
typedef unsigned int UINT;
private:
@@ -124,10 +124,10 @@ inline void clist_contour::generate()
inline void clist_contour::InitMemory()
{
ccontour::InitMemory();
cline_strip_list::iterator pos;
cline_strip* pStrip;
if (!m_vStripLists.empty())
{
UINT i;
@@ -153,7 +153,7 @@ inline void clist_contour::InitMemory()
inline void clist_contour::CleanMemory()
{
ccontour::CleanMemory();
cline_strip_list::iterator pos;
cline_strip* pStrip;
UINT i;
@@ -176,13 +176,13 @@ inline void clist_contour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
{
_ASSERT_(iPlane>=0,"clist_contour::ExportLine::0");
_ASSERT_(iPlane<(int)get_number_of_planes(),"clist_contour::ExportLine::1");
// check that the two points are not at the beginning or end of the some line strip
UINT i1=y1*(m_iColSec+1)+x1;
UINT i2=y2*(m_iColSec+1)+x2;
cline_strip* pStrip;
cline_strip_list::iterator pos;
bool added = false;
for(pos=m_vStripLists[iPlane].begin(); pos!=m_vStripLists[iPlane].end() && !added; pos++)
@@ -211,7 +211,7 @@ inline void clist_contour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
return;
}
}
// segment was not part of any line strip, creating new one
pStrip=new cline_strip;
pStrip->insert(pStrip->begin(),i1);
@@ -219,15 +219,15 @@ inline void clist_contour::ExportLine(int iPlane,int x1, int y1, int x2, int y2)
m_vStripLists[iPlane].insert(m_vStripLists[iPlane].begin(),pStrip);
}
inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2,double aHeight)
inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2,double aHeight)
{
cline_strip::iterator pos;
cline_strip::reverse_iterator rpos;
if (pStrip2->empty())
return false;
double x[4], y[4], weldDist;
int index;
index = pStrip1->front();
@@ -242,12 +242,12 @@ inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2
index = pStrip2->back();
x[3] = get_xi(index);
y[3] = get_yi(index);
weldDist = 10*(m_dDx*m_dDx+m_dDy*m_dDy);
if (((x[1]-x[2])*(x[1]-x[2])+(y[1]-y[2])*(y[1]-y[2])< weldDist)
|| SpecialCompactStripCase(x[1],x[2],y[1],y[2],aHeight)) // L.Garnier
{
for (pos=pStrip2->begin(); pos!=pStrip2->end();pos++)
{
@@ -258,7 +258,7 @@ inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2
pStrip2->clear();
return true;
}
if (((x[3]-x[0])*(x[3]-x[0])+(y[3]-y[0])*(y[3]-y[0])< weldDist)
|| SpecialCompactStripCase(x[3],x[0],y[3],y[0],aHeight)) // L.Garnier
{
@@ -271,7 +271,7 @@ inline bool clist_contour::ForceMerge(cline_strip* pStrip1, cline_strip* pStrip2
pStrip2->clear();
return true;
}
if (((x[1]-x[3])*(x[1]-x[3])+(y[1]-y[3])*(y[1]-y[3])< weldDist)
|| SpecialCompactStripCase(x[1],x[3],y[1],y[3],aHeight)) // L.Garnier
{
@@ -307,7 +307,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
cline_strip::reverse_iterator rpos;
if (pStrip2->empty())
return false;
int index;
// debugging stuff
@@ -325,7 +325,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
pStrip2->clear();
return true;
}
if (pStrip2->front()==pStrip1->back())
{
pStrip2->pop_front();
@@ -339,7 +339,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
pStrip2->clear();
return true;
}
if (pStrip2->back()==pStrip1->front())
{
pStrip2->pop_back();
@@ -353,7 +353,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
pStrip2->clear();
return true;
}
if (pStrip2->back()==pStrip1->back())
{
pStrip2->pop_back();
@@ -367,7 +367,7 @@ inline bool clist_contour::MergeStrips(cline_strip* pStrip1, cline_strip* pStrip
pStrip2->clear();
return true;
}
return false;
}
@@ -378,8 +378,8 @@ inline bool clist_contour::compact_strips ()
UINT i;
cline_strip_list::iterator pos,pos2;
cline_strip_list newList;
bool again, changed;
bool again, changed;
const double weldDist = 10*(m_dDx*m_dDx+m_dDy*m_dDy);
if(!_ASSERT_RET_(m_vStripLists.size() == get_number_of_planes(),"clist_contour::compact_strips ::0")) return false;
@@ -390,7 +390,7 @@ inline bool clist_contour::compact_strips ()
while(again)
{
// REPEAT COMPACT PROCESS UNTILL LAST PROCESS MAKES NO CHANGE
again=false;
// building compacted list
if(!_ASSERT_RET_(newList.empty(),"clist_contour::compact_strips ::1")) return false;
@@ -411,7 +411,7 @@ inline bool clist_contour::compact_strips ()
else
newList.insert(newList.begin(),pStrip);
}
// deleting old list
m_vStripLists[i].clear();
@@ -421,7 +421,7 @@ inline bool clist_contour::compact_strips ()
{
pStrip2=(*pos2);
cline_strip::iterator pos1 = pStrip2->begin(),pos3;
while (pos1!=pStrip2->end())
while (pos1!=pStrip2->end())
{
pos3 = pos1;
pos3++;
@@ -442,19 +442,19 @@ inline bool clist_contour::compact_strips ()
else
pos1++;
}
//if (!(pStrip2->front()==pStrip2->back() && pStrip2->size()==2))
if (pStrip2->size()!=1)
if (pStrip2->size()!=1)
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStrip2 );
else
else
delete pStrip2;
}
// emptying temp list
newList.clear();
} // OF WHILE(AGAIN) (LAST COMPACT PROCESS MADE NO CHANGES)
if (m_vStripLists[i].empty())
continue;
///////////////////////////////////////////////////////////////////////
@@ -462,23 +462,23 @@ inline bool clist_contour::compact_strips ()
int index,count;
size_t Nstrip,j;
Nstrip = m_vStripLists[i].size();
Nstrip = m_vStripLists[i].size();
std::vector<bool> closed(Nstrip);
double x,y;
// First let's find the open and closed lists in m_vStripLists
for(pos2 = m_vStripLists[i].begin(), j=0, count=0; pos2 != m_vStripLists[i].end(); pos2++, j++)
for(pos2 = m_vStripLists[i].begin(), j=0, count=0; pos2 != m_vStripLists[i].end(); pos2++, j++)
{
pStrip = (*pos2);
// is it open ?
if (pStrip->front() != pStrip->back())
if (pStrip->front() != pStrip->back())
{
index = pStrip->front();
x = get_xi(index); y = get_yi(index);
index = pStrip->back();
x -= get_xi(index); y -= get_yi(index);
// is it "almost closed" ?
if ((x*x+y*y < weldDist) ||
SpecialCompactStripCase(get_xi(pStrip->front()), // L.Garnier
@@ -487,63 +487,63 @@ inline bool clist_contour::compact_strips ()
get_yi(pStrip->back()),
planeHeight))
{
closed[j] = true;
closed[j] = true;
// close it !!! Added by L.Garnier
pStrip->push_back(pStrip->front());
//
}
else
{
closed[j] = false;
else
{
closed[j] = false;
// updating not closed counter...
count ++;
count ++;
}
}
else
}
else
closed[j] = true;
}
// is there any open strip ?
if (count > 1)
{
if (count > 1)
{
// Merge the open strips into NewList
pos = m_vStripLists[i].begin();
for(j=0;j<Nstrip;j++)
for(j=0;j<Nstrip;j++)
{
if (closed[j] == false )
if (closed[j] == false )
{
pStrip = (*pos);
newList.insert(newList.begin(),pStrip);
newList.insert(newList.begin(),pStrip);
pos = m_vStripLists[i].erase(pos);
}
else
else
pos ++;
}
// are they open strips to process ?
while(newList.size()>1)
while(newList.size()>1)
{
pStripBase = newList.front();
// merge the rest to pStripBase
again = true;
while (again)
while (again)
{
again = false;
pos = newList.begin();
for(pos++; pos!=newList.end();)
pos = newList.begin();
for(pos++; pos!=newList.end();)
{
pStrip = (*pos);
changed = ForceMerge(pStripBase,pStrip,planeHeight);
if (changed)
{
if (changed)
{
again = true;
delete pStrip;
pos = newList.erase(pos);
}
else
}
else
pos ++;
}
}
} // while(again)
index = pStripBase->front();
@@ -568,15 +568,15 @@ inline bool clist_contour::compact_strips ()
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
newList.pop_front();
}
else
{
if (OnBoundary(pStripBase))
else
{
if (OnBoundary(pStripBase))
{
_TRACE_(_TT("# open strip ends on boundary, continue.\n"));
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
newList.pop_front();
}
else
else
{
_PROBLEM_(_TT("unpaird open strip at 1!\n"));
//exit(0);
@@ -586,27 +586,27 @@ inline bool clist_contour::compact_strips ()
} // while(newList.size()>1);
if (newList.size() ==1)
if (newList.size() ==1)
{
pStripBase = newList.front();
index = pStripBase->front(); // L.Garnier
x = get_xi(index); y = get_yi(index); // L.Garnier
index = pStripBase->back(); // L.Garnier
x -= get_xi(index); y -= get_yi(index); // L.Garnier
// is it "almost closed", give last chance...5*weldDist
if (x*x+y*y < 3*weldDist) // L.Garnier
{
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
newList.pop_front();
}
else if (OnBoundary(pStripBase))
else if (OnBoundary(pStripBase))
{
_TRACE_(_TT("# open strip ends on boundary, continue.\n"));
m_vStripLists[i].insert(m_vStripLists[i].begin(),pStripBase);
newList.pop_front();
}
else
else
{
_PROBLEM_(_TT("unpaird open strip at 2!\n"));
DumpPlane(i);
@@ -614,16 +614,16 @@ inline bool clist_contour::compact_strips ()
return false;
}
}
newList.clear();
}
else if (count == 1)
}
else if (count == 1)
{
pos = m_vStripLists[i].begin();
for(j=0;j<Nstrip;j++)
for(j=0;j<Nstrip;j++)
{
if (closed[j] == false )
if (closed[j] == false )
{
pStripBase = (*pos);
break;
@@ -634,19 +634,19 @@ inline bool clist_contour::compact_strips ()
x = get_xi(index); y = get_yi(index); // L.Garnier
index = pStripBase->back(); // L.Garnier
x -= get_xi(index); y -= get_yi(index); // L.Garnier
// is it "almost closed", give last chance...5*weldDist
if (x*x+y*y < 2*weldDist) // L.Garnier
{
//close it!!
pStripBase->push_back(pStripBase->front()); // L.Garnier
}
else if (OnBoundary(pStripBase))
else if (OnBoundary(pStripBase))
{
_TRACE_(_TT("# open strip ends on boundary, continue.\n"));
pStripBase->push_back(pStripBase->front()); // L.Garnier
}
else
}
else
{
_TRACE_(_TT("unpaird open strip at 3!"));
DumpPlane(i);
@@ -660,26 +660,26 @@ inline bool clist_contour::compact_strips ()
}
inline bool clist_contour::OnBoundary(cline_strip* pStrip)
inline bool clist_contour::OnBoundary(cline_strip* pStrip)
{
bool e1,e2;
int index = pStrip->front();
double x = get_xi(index), y = get_yi(index);
if (x==m_pLimits[0] || x == m_pLimits[1] ||
if (x==m_pLimits[0] || x == m_pLimits[1] ||
y == m_pLimits[2] || y == m_pLimits[3])
e1 = true;
else
else
e1 = false;
index = pStrip->back();
x = get_xi(index); y = get_yi(index);
if (x==m_pLimits[0] || x == m_pLimits[1] ||
if (x==m_pLimits[0] || x == m_pLimits[1] ||
y == m_pLimits[2] || y == m_pLimits[3])
e2 = true;
else
else
e2 = false;
return (e1 && e2);
}
@@ -688,11 +688,11 @@ inline void clist_contour::DumpPlane(UINT iPlane) const
cline_strip_list::const_iterator pos;
UINT i;
cline_strip* pStrip;
/*_ASSERT_(iPlane>=0,"clist_contour::DumpPlane");*/
_ASSERT_(iPlane<get_number_of_planes(),"clist_contour::DumpPlane::0");
_TRACE_(_TT("Level : %d"),get_plane(iPlane));
_TRACE_(_TT("Number of strips : %d\r\n"),m_vStripLists[iPlane].size());
_TRACE_(_TT("i np start end xstart ystart xend yend\r\n"));
for (pos = m_vStripLists[iPlane].begin(), i=0; pos != m_vStripLists[iPlane].end(); pos++, i++)
@@ -705,38 +705,38 @@ inline void clist_contour::DumpPlane(UINT iPlane) const
}
}
inline double clist_contour::Area(cline_strip* Line)
inline double clist_contour::Area(cline_strip* Line)
{
// if Line is not closed, return 0;
double Ar = 0, x, y, x0,y0,x1, y1;
int index;
cline_strip::iterator pos;
pos = Line->begin();
index = (*pos);
x0 = x = get_xi(index);
y0 = y = get_yi(index);
pos ++;
for(;pos!=Line->end();pos++)
for(;pos!=Line->end();pos++)
{
index = (*pos);
index = (*pos);
x1 = get_xi(index);
y1 = get_yi(index);
// Ar += (x1-x)*(y1+y);
Ar += (y1-y)*(x1+x)-(x1-x)*(y1+y);
x = x1;
y = y1;
y = y1;
}
//Ar += (x0-x)*(y0+y);
Ar += (y0-y)*(x0+x)-(x0-x)*(y0+y);
// if not closed curve, return 0;
if ((x0-x)*(x0-x) + (y0-y)*(y0-y)>20*(m_dDx*m_dDx+m_dDy*m_dDy))
if ((x0-x)*(x0-x) + (y0-y)*(y0-y)>20*(m_dDx*m_dDx+m_dDy*m_dDy))
{
Ar = 0;
_TRACE_(_TT("# open curve!\n"));
@@ -747,38 +747,38 @@ inline double clist_contour::Area(cline_strip* Line)
return Ar;
}
inline double clist_contour:: EdgeWeight(cline_strip* pLine, double R)
inline double clist_contour:: EdgeWeight(cline_strip* pLine, double R)
{
cline_strip::iterator pos;
int count = 0,index;
double x,y;
for(pos = pLine->begin(); pos!=pLine->end(); pos++)
for(pos = pLine->begin(); pos!=pLine->end(); pos++)
{
index = (*pos);
x = get_xi(index);
x = get_xi(index);
y = get_yi(index);
if (fabs(x) > R || fabs(y) > R)
if (fabs(x) > R || fabs(y) > R)
count ++;
}
return (double)count/pLine->size();
}
/*
inline bool clist_contour::PrintContour(std::ostream& a_out)
inline bool clist_contour::PrintContour(std::ostream& a_out)
{
std::streamsize old_prec = a_out.precision(3);
a_out << std::setprecision(10);
UINT i, index;
cline_strip* pStrip;
cline_strip::iterator pos2;
cline_strip_list::iterator pos;
for(i=0;i<get_number_of_planes();i++) {
for(pos = m_vStripLists[i].begin();pos!=m_vStripLists[i].end();pos++)
for(pos = m_vStripLists[i].begin();pos!=m_vStripLists[i].end();pos++)
{
pStrip = (*pos);
for(pos2 = pStrip->begin();pos2!=pStrip->end();pos2++)
for(pos2 = pStrip->begin();pos2!=pStrip->end();pos2++)
{
index = (*pos2);
a_out << get_xi(index)<<"\t"<<get_yi(index)<<"\n";
@@ -788,7 +788,7 @@ inline bool clist_contour::PrintContour(std::ostream& a_out)
}
a_out.precision(old_prec);
return true;
}
*/
@@ -800,9 +800,9 @@ inline cline_strip_list* clist_contour::get_lines(unsigned int iPlane) {
}
// Added by L.Garnier
inline bool clist_contour::SpecialCompactStripCase(double aXfront,double aXback,double aYfront,double aYback,double actualHeight)
inline bool clist_contour::SpecialCompactStripCase(double aXfront,double aXback,double aYfront,double aYback,double actualHeight)
{
// To solve the case of a list of strips
// To solve the case of a list of strips
// which appeared to be open but should correspond to a closed
// contour.
// With the today generate() algorithm, it appears that we fall
@@ -810,7 +810,7 @@ inline bool clist_contour::SpecialCompactStripCase(double aXfront,double aXback,
// are on a horizontal or vertical line.
// (case where front()->x == back()->x or front()->y == back()->y).
// We try to detect in this method this situation and decide to close
// or not the line. To do that we check the heigth of intermediate
// or not the line. To do that we check the heigth of intermediate
// points to see if there are on the same contour; if so we close
// the line (and return true), if not we do nothing (and return false).