private void DetermineAdjacencies(
Dictionary<Space, List<Space>> a,
Dictionary<Segment, Segment> segmentPairs)
{
foreach( Segment s in segmentPairs.Keys )
{
// Analyse the relationship between the two
// closest segments s and t. If their distance
// exceeds the maximum wall thickness, the
// spaces are not considered adjacent.
// Otherwise, calculate a test point 2 mm
// away from s in the direction of t and
// use the Space.IsPointInSpace method:
Segment t = segmentPairs[s];
double d = s.Distance( t );
if( d < MaxWallThickness )
{
XYZ direction = s.DirectionTo( t );
XYZ startPt = t.MidPoint;
XYZ testPoint = startPt + direction * D2mm;
if( t.Space.IsPointInSpace( testPoint ) )
{
if( !a.ContainsKey( s.Space ) )
{
a.Add( s.Space, new List<Space>() );
}
if( !a[s.Space].Contains( t.Space ) )
{
a[s.Space].Add( t.Space );
}
}
}
}
}