using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
namespace bimexploring
{
class Program
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SetDllDirectory(string lpPathName);
static int Main(string[] args)
{
SetDllDirectory("../../../../../../win64/vc14.1/bin");
string aKey = LicenseKey.Value();
if (!LicenseManager.Activate (aKey))
{
Console.WriteLine("Failed to activate CAD Exchanger license.");
return 1;
}
if (args.Length != 1)
{
Console.WriteLine("Usage: " + System.Reflection.Assembly.GetExecutingAssembly().Location
+ " <input_file>, where:");
Console.WriteLine(" <input_file> is a name of the file to be read");
return 1;
}
string aSource = args[0];
{
Console.WriteLine("Failed to read the file: " + aSource);
return 1;
}
BimStructureVisitor aStructureVisitor = new BimStructureVisitor();
aModel.
Accept(aStructureVisitor);
Console.WriteLine();
aStructureVisitor.PrintCounts();
return 0;
}
}
{
public BimStructureVisitor()
{
myNestingLevel = 0;
}
public void PrintCounts()
{
Console.WriteLine("Element Types:");
foreach (KeyValuePair<string, int> i in myCounts)
{
Console.WriteLine("{0}: {1}", i.Key, i.Value);
}
}
{
Console.WriteLine(GetFiller() + theElement.
Name());
myNestingLevel += 1;
AddCounts("Building");
return true;
}
{
myNestingLevel -= 1;
}
{
Console.WriteLine(GetFiller() + theElement.
Name());
myNestingLevel += 1;
AddCounts("Site");
return true;
}
{
myNestingLevel -= 1;
}
{
Console.WriteLine(GetFiller() + theElement.
Name());
myNestingLevel += 1;
AddCounts("CompositeElement");
return true;
}
{
myNestingLevel -= 1;
}
{
Console.WriteLine(GetFiller() + theElement.
Name());
myNestingLevel += 1;
AddCounts("Storey");
return true;
}
{
myNestingLevel -= 1;
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Beam");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Column");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("CustomGeometryElement");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Door");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Furniture");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Plate");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Railing");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Roof");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Slab");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Stair");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Wall");
}
{
Console.WriteLine(GetFiller() +
" " + theElement.
Name());
AddCounts("Window");
}
private string GetFiller()
{
IEnumerable<string> aTabs = Enumerable.Repeat("-", 4*myNestingLevel);
return (myNestingLevel > 0) ? aTabs.Aggregate((sum, next) => sum + next) : "";
}
private void AddCounts(string theElementType)
{
if (!myCounts.ContainsKey(theElementType))
{
myCounts.Add(theElementType, 1);
}
else
{
myCounts[theElementType] += 1;
}
}
private Dictionary<string, int> myCounts = new Dictionary<string, int>();
private int myNestingLevel;
}
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
const Base_UTF16String & Name() const
Returns an element name.
Definition: ModelData_BIMBaseObject.cxx:62
Beam represents a structural element that resists bending or lateraly loads.
Definition: ModelData_BIMBeam.hxx:30
Building is an element of spatial structure hierarchy (together with site, storey,...
Definition: ModelData_BIMBuilding.hxx:33
Column represents structural or architectural vertical element, that can transmit loads from top elem...
Definition: ModelData_BIMColumn.hxx:30
Composite Element represents the complex BIM Element, consisting of several other BIM Elements....
Definition: ModelData_BIMCompositeElement.hxx:30
CustomGeometryElement represents general bim element with geometry for defining elements that have no...
Definition: ModelData_BIMCustomGeometryElement.hxx:30
Door element can be used for represent standard entrance or internal doors, gates,...
Definition: ModelData_BIMDoor.hxx:30
Furniture represents element for defining furnishings such as a table, chair, cabinet,...
Definition: ModelData_BIMFurniture.hxx:30
Provides CAD Exchanger BIM data model.
Definition: ModelData_BIMModel.hxx:37
void Accept(ModelData_BIMVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_BIMModel.cxx:510
Plate represents planar element, that is often add-on part for wall, roof or slab.
Definition: ModelData_BIMPlate.hxx:30
Railing represents a frame assembly for physical support, fall prevention and also decorating.
Definition: ModelData_BIMRailing.hxx:30
Roof represents covering element of the top part of a building.
Definition: ModelData_BIMRoof.hxx:30
Site represents the area of land, on which the building construction is to be. Often,...
Definition: ModelData_BIMSite.hxx:32
Slab represents an element that encloses a building space vertically. The slab may provide the floor ...
Definition: ModelData_BIMSlab.hxx:30
Stair represents a passageway allowing persons to step from one level to another level at a different...
Definition: ModelData_BIMStair.hxx:30
Storey represents a horizontal aggregation of building spaces that are vertically bound and are all a...
Definition: ModelData_BIMStorey.hxx:32
Defines a BIM elements visitor.
Definition: ModelData_BIMVisitor.hxx:42
Wall represents an element that bounds or subdivides building spaces. Wall are usually vertical,...
Definition: ModelData_BIMWall.hxx:30
Window element can represent vertical, sloped or horizontal window in the wall or roof,...
Definition: ModelData_BIMWindow.hxx:30
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22