public class brepprimitives {
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);
}
ModelData_Model aModel = new ModelData_Model();
CreateBox(new ModelData_Point(10., 0., 0.), 8., 8., 8., aModel);
CreateSphere(new ModelData_Point(0., 10., 0.), 4., aModel);
CreateCylinder(new ModelData_Point(-10., 0., 0.), 4., 8., aModel);
CreateCone(new ModelData_Point(0., -10., 0.), 3., 5., 7., aModel);
CreateTorus(new ModelData_Point(0., 0., 0.), 2., 3., aModel);
ModelData_ModelWriter aWriter = new ModelData_ModelWriter();
if (!aWriter.Write(aModel, new Base_UTF16String("Primitives.cdx"))) {
System.out.println("Unable to save the model!");
System.exit(1);
}
}
static void AttachPrimitiveToModel(Base_UTF16String theName, ModelData_Solid thePrimitive, ModelData_Model theModel) {
ModelData_Part aPart = new ModelData_Part(new ModelData_BRepRepresentation(thePrimitive), theName);
theModel.AddRoot(aPart);
}
static void CreateBox(ModelData_Point thePosition, double Dx, double Dy, double Dz, ModelData_Model theModel) {
ModelData_Solid aBox = ModelAlgo_TopoPrimitives.CreateBox(thePosition, Dx, Dy, Dz);
AttachPrimitiveToModel(new Base_UTF16String("Box"), aBox, theModel);
}
static void CreateSphere(ModelData_Point thePosition, double theRadius, ModelData_Model theModel) {
ModelData_Solid aSphere = ModelAlgo_TopoPrimitives.CreateSphere(thePosition, theRadius);
AttachPrimitiveToModel(new Base_UTF16String("Sphere"), aSphere, theModel);
}
static void CreateCylinder(ModelData_Point thePosition, double theRadius, double theHeight, ModelData_Model theModel) {
ModelData_Axis2Placement anAxis = new ModelData_Axis2Placement(thePosition, ModelData_Direction.ZDir(), ModelData_Direction.YDir());
ModelData_Solid aCylinder = ModelAlgo_TopoPrimitives.CreateCylinder(anAxis, theRadius, theHeight);
AttachPrimitiveToModel(new Base_UTF16String("Cylinder"), aCylinder, theModel);
}
static void CreateCone(ModelData_Point thePosition, double theRadius1, double theRadius2, double theHeight, ModelData_Model theModel) {
ModelData_Axis2Placement anAxis = new ModelData_Axis2Placement(thePosition, ModelData_Direction.ZDir(), ModelData_Direction.YDir());
ModelData_Solid aCone = ModelAlgo_TopoPrimitives.CreateCone(anAxis, theRadius1, theRadius2, theHeight);
AttachPrimitiveToModel(new Base_UTF16String("Cone"), aCone, theModel);
}
static void CreateTorus(ModelData_Point thePosition, double theMinRadius, double theMaxRadius, ModelData_Model theModel) {
ModelData_Axis2Placement anAxis = new ModelData_Axis2Placement(thePosition, ModelData_Direction.ZDir(), ModelData_Direction.YDir());
ModelData_Solid aTorus = ModelAlgo_TopoPrimitives.CreateTorus(anAxis, theMaxRadius, theMinRadius);
AttachPrimitiveToModel(new Base_UTF16String("Torus"), aTorus, theModel);
}
}
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22