using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace bom
{
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");
if (!LicenseManager.CADExLicense_ActivateRuntimeKeyFromAbsolutePath(AppDomain.CurrentDomain.BaseDirectory + "/runtime_key.lic"))
{
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 XML file to be read");
return 1;
}
string aSource = args[0];
{
Console.WriteLine("Failed to read the file " + aSource);
return 1;
}
SceneGraphVisitor aCounter = new SceneGraphVisitor();
aCounter.PrintCounts();
return 0;
}
}
{
public SceneGraphVisitor()
{
myNestingLevel = 0;
margin = 0;
}
public void PrintCounts()
{
Console.WriteLine("Total:");
Console.WriteLine("\t{0,8:c}", "name".PadRight(margin, ' ') + " | " + "type".PadRight(margin, ' ') + " | count");
foreach (KeyValuePair<ModelData_BaseObject, int> i in mySGEMap)
{
Console.WriteLine("\t{0,8:c}", i.Key.Name().ToString().PadRight(margin, ' ') + " | " + PrintSGEType(i.Key).PadRight(margin, ' ') + " | " + i.Value);
}
}
{
PrintName(
"Part", thePart.
Name());
UpdateTable(thePart);
}
{
PrintName(
"Assembly", theAssembly.
Name());
UpdateTable(theAssembly);
++myNestingLevel;
return true;
}
{
PrintName(
"Instance", theInstance.
Name());
++myNestingLevel;
return true;
}
{
--myNestingLevel;
}
{
--myNestingLevel;
}
{
for (int i = 0; i < myNestingLevel; ++i)
{
Console.Write("--- ");
}
{
Console.WriteLine(theSGElement + ": " + theName);
}
else
{
Console.WriteLine(theSGElement + ": <noname>");
}
margin = Math.Max(margin, (
int)theName.
Length());
}
{
if (!mySGEMap.ContainsKey(theSGE))
{
mySGEMap.Add(theSGE, 1);
}
else
{
++mySGEMap[theSGE];
}
}
{
{
return "Part";
}
{
return "Assembly";
}
{
return "Instance";
}
return "Undefined";
}
private int margin;
private Dictionary<ModelData_BaseObject, int> mySGEMap = new Dictionary<ModelData_BaseObject, int>(new ModelData_BaseObjectHash());
private int myNestingLevel;
}
}
Defines a Unicode (UTF-16) string wrapping a standard string.
Definition: Base_UTF16String.hxx:34
size_t Length() const
Returns a string length in UTF16 characters.
Definition: Base_UTF16String.cxx:231
bool IsEmpty() const
Returns true if the string is empty.
Definition: Base_UTF16String.cxx:233
Defines a group of scene graph element.
Definition: ModelData_Assembly.hxx:33
Base class for all objects that have private implementation (pimpl) back-end.
Definition: ModelData_BaseObject.hxx:34
IdType TypeId() const
Returns an object type id.
Definition: ModelData_BaseObject.cxx:199
Base_UTF16String Name() const
Definition: ModelData_BaseObject.cxx:218
Defines an occurrence of assembly or part in a scene graph.
Definition: ModelData_Instance.hxx:34
Provides CAD Exchanger data model.
Definition: ModelData_Model.hxx:41
void Accept(ElementVisitor &theVisitor) const
Accepts a visitor.
Definition: ModelData_Model.cxx:738
Reads any format that CAD Exchanger can import.
Definition: ModelData_ModelReader.hxx:33
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:35
Base class for part, instance and assembly.
Definition: ModelData_SceneGraphElement.hxx:39
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22