import java.util.Stack;
public class transformations {
static {
try {
System.loadLibrary("CadExCore");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load.\n" + e);
System.exit(1);
}
}
public static void main(String[] args) {
String aKey = LicenseKey.Value();
if (!LicenseManager.Activate(aKey)) {
System.out.println("Failed to activate CAD Exchanger license.");
System.exit(1);
}
if (args.length != 1) {
System.out.println("Usage: " + " <input_file>, where:");
System.out.println(" <input_file> is a name of the XML file to be read");
System.exit(1);
}
String aSource = args[0];
ModelData_Model aModel = new ModelData_Model();
if (!new ModelData_ModelReader().Read(new Base_UTF16String(aSource), aModel)) {
System.out.println("Failed to read the file");
System.exit(1);
}
InstancesTransformationsVisitor aVisitor = new InstancesTransformationsVisitor();
aModel.Accept(aVisitor);
}
}
class InstancesTransformationsVisitor extends ModelData_Model.VoidElementVisitor {
public InstancesTransformationsVisitor() {
ModelData_Transformation anIdentity = new ModelData_Transformation();
myTransformationMatrix.push(anIdentity);
}
@Override
public boolean VisitEnter(ModelData_Instance theInstance) {
if (theInstance.HasTransformation()) {
ModelData_Transformation aTrsf = theInstance.Transformation();
myTransformationMatrix.push(myTransformationMatrix.peek().Multiplied(aTrsf));
} else {
ModelData_Transformation anIdentity = new ModelData_Transformation();
myTransformationMatrix.push(anIdentity);
}
PrintTransformation(theInstance.Name());
return true;
}
@Override
public void VisitLeave(ModelData_Instance theInstance) {
myTransformationMatrix.pop();
}
private void PrintTransformation(Base_UTF16String theName) {
if (theName.IsEmpty()) {
theName = new Base_UTF16String("noName");
}
System.out.println("Instance " + theName + " has transformations:");
ModelData_Transformation.RotationPart aR = myTransformationMatrix.peek().GetRotationPart();
ModelData_Vector aTranslation = myTransformationMatrix.peek().TranslationPart();
System.out.println("| " + aR.v00 + " " + aR.v01 + " " + aR.v02 + " " + aTranslation.X() + " |");
System.out.println("| " + aR.v10 + " " + aR.v11 + " " + aR.v12 + " " + aTranslation.Y() + " |");
System.out.println("| " + aR.v20 + " " + aR.v21 + " " + aR.v22 + " " + aTranslation.Z() + " |");
}
private Stack<ModelData_Transformation> myTransformationMatrix = new Stack<>();
}
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22