|
@@ -3,9 +3,263 @@
|
|
|
#include <iostream>
|
|
|
#include "test.h"
|
|
|
|
|
|
-int main(int argc, char** argv)
|
|
|
+// int main(int argc, char** argv)
|
|
|
+// {
|
|
|
+// myprint();
|
|
|
+// system("pause");
|
|
|
+// return 0;
|
|
|
+// }
|
|
|
+// MyfirstAcisProject.cpp : Defines the entry point for the console application.
|
|
|
+//
|
|
|
+#include "acis.hxx"
|
|
|
+#include "kernapi.hxx"
|
|
|
+#include "lists.hxx"
|
|
|
+#include "acistype.hxx"
|
|
|
+#include "fileinfo.hxx"
|
|
|
+#include "position.hxx"
|
|
|
+#include "body.hxx"
|
|
|
+#include "cstrapi.hxx"
|
|
|
+#include "license.hxx"
|
|
|
+#include "spa_unlock_result.hxx"
|
|
|
+
|
|
|
+#include "hc.h"
|
|
|
+#include <HDB.h>
|
|
|
+
|
|
|
+#include "HBaseView.h"
|
|
|
+#include "HBaseModel.h"
|
|
|
+#include "ha_bridge.h"
|
|
|
+#include <HIOManager.h>
|
|
|
+#include "varray.h"
|
|
|
+#include "HMFCDemoModel.h"
|
|
|
+#include "HMFCDemoView.h"
|
|
|
+#include "hoops_license.h"
|
|
|
+#include "part_api.hxx"
|
|
|
+void process(outcome result);
|
|
|
+void process_file(FILE* fp);
|
|
|
+ENTITY_LIST retrieve_sat_file(char *fileName);
|
|
|
+void create_sat_file(ENTITY *ent, char *fileName);
|
|
|
+void create_sat_file(ENTITY_LIST elist, char *fileName);
|
|
|
+void Initialize_ACIS();
|
|
|
+void Terminate_ACIS();
|
|
|
+void Check_Entity(ENTITY* input);
|
|
|
+void unlock_license();
|
|
|
+void doSometing();
|
|
|
+int main()
|
|
|
{
|
|
|
- myprint();
|
|
|
- system("pause");
|
|
|
+
|
|
|
+ Initialize_ACIS();
|
|
|
+ //add unlock license key here; refer to the "Application Licensing" article
|
|
|
+ unlock_license();
|
|
|
+ doSometing();
|
|
|
+
|
|
|
+ //add ACIS calls here
|
|
|
+ Terminate_ACIS();
|
|
|
return 0;
|
|
|
}
|
|
|
+
|
|
|
+int saveImage()
|
|
|
+{
|
|
|
+ HC_Define_System_Options("license = `" VISUALIZE_LICENSE "`");
|
|
|
+ HDB gHDB;
|
|
|
+ gHDB.Init();
|
|
|
+ gHDB.SetIsolatedDrivers(true);
|
|
|
+ HMFCDemoModel *modelPlane = new HMFCDemoModel();
|
|
|
+ //modelPlane->Init();
|
|
|
+ HMFCDemoView view(modelPlane,NULL,"opengl");
|
|
|
+ view.Init();
|
|
|
+ view.FitWorld();
|
|
|
+ view.GetModel();
|
|
|
+ HC_KEY model_key = modelPlane->GetModelKey();
|
|
|
+ HC_Open_Segment_By_Key(model_key);
|
|
|
+ HC_Open_Segment("");
|
|
|
+ ENTITY_LIST entityList;
|
|
|
+ BODY* sphere = NULL;
|
|
|
+ api_solid_sphere(SPAposition(0, 0, 0), 1, sphere, NULL);
|
|
|
+ entityList.add(sphere);
|
|
|
+
|
|
|
+
|
|
|
+ HA_Render_Entities(entityList);
|
|
|
+ ((HMFCDemoModel*)(view.GetModel()))->AddAcisEntity(sphere);
|
|
|
+
|
|
|
+
|
|
|
+ //static HPoint point_list[8] = {
|
|
|
+ // { -0.4f, -0.4f, -0.4f },
|
|
|
+ // { 0.4f, -0.4f, -0.4f },
|
|
|
+ // { 0.4f, 0.4f, -0.4f },
|
|
|
+ // { -0.4f, 0.4f, -0.4f },
|
|
|
+ // { -0.4f, -0.4f, 0.4f },
|
|
|
+ // { 0.4f, -0.4f, 0.4f },
|
|
|
+ // { 0.4f, 0.4f, 0.4f },
|
|
|
+ // { -0.4f, 0.4f, 0.4f } };
|
|
|
+ //static int face_list[30] = {
|
|
|
+ // 4, 0, 1, 2, 3,
|
|
|
+ // 4, 4, 5, 1, 0,
|
|
|
+ // 4, 2, 1, 5, 6,
|
|
|
+ // 4, 7, 4, 0, 3,
|
|
|
+ // 4, 7, 6, 5, 4,
|
|
|
+ // 4, 3, 2, 6, 7 };
|
|
|
+ //HC_Insert_Shell(8, point_list, 30, face_list);
|
|
|
+ //HC_Rotate_Object(75.0, 0.0, 0.0);//旋转
|
|
|
+ //HC_Translate_Object(-0.5, 0.0, 0.0);//平移
|
|
|
+ //HC_Set_Visibility("no markers, no faces");//没有材质、没有面
|
|
|
+ HC_Close_Segment();
|
|
|
+ HC_Close_Segment();
|
|
|
+
|
|
|
+ modelPlane->Write("E://w.png",&view,1,400, 400);
|
|
|
+
|
|
|
+
|
|
|
+ //HOutputHandlerOptions options;
|
|
|
+ //VCharArray width_str(128), height_str(128), temp(128), xpixels_str(128);
|
|
|
+ //HC_Open_Segment_By_Key(view.GetViewKey());
|
|
|
+ ///* Get the size in milimeters. */
|
|
|
+ //HC_Show_Device_Info(".", "size", temp);
|
|
|
+ //HC_Parse_String(temp, ",", 0, width_str);
|
|
|
+ //HC_Parse_String(temp, ",", 1, height_str);
|
|
|
+
|
|
|
+ ///* Get the pixels in the x direction so we can find DPI. */
|
|
|
+ //HC_Show_Device_Info(".", "pixels", temp);
|
|
|
+ //HC_Parse_String(temp, ",", 0, xpixels_str);
|
|
|
+ //HC_Close_Segment();
|
|
|
+
|
|
|
+ ///* Save off the window width and height in inches. */
|
|
|
+ //options.WindowWidth(atof(width_str) / 2.54f);
|
|
|
+ //options.WindowHeight(atof(height_str) / 2.54f);
|
|
|
+
|
|
|
+ //modelPlane->WriteWithOptions("E://t.png", &view, &options);
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+void doSometing()
|
|
|
+{
|
|
|
+
|
|
|
+ saveImage();
|
|
|
+ //outcome result;
|
|
|
+ //FileInfo fileinfo;
|
|
|
+ //fileinfo.set_units(1.0);
|
|
|
+ //fileinfo.set_product_id("ACIS (c) SPATIAL");
|
|
|
+ //result = api_set_file_info(3, fileinfo);
|
|
|
+ //process(result);
|
|
|
+ //ENTITY_LIST entityList;
|
|
|
+ //// Create a Sphere.
|
|
|
+ //BODY* sphere = NULL;
|
|
|
+ //api_solid_sphere(SPAposition(30, 30, 30), 10, sphere, NULL);
|
|
|
+ //entityList.add(sphere);
|
|
|
+ //// Create a SAT File.
|
|
|
+ //create_sat_file(entityList, "E:/MyFirstAcisProject2.sat");
|
|
|
+ //HA_Set_Rendering_Options("RenderEdgesMode=on/off");
|
|
|
+ //char buffer[1024];
|
|
|
+ //HA_Render_Entities(entityList);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void Initialize_ACIS()
|
|
|
+{
|
|
|
+ /*initialize_base();
|
|
|
+ api_start_modeller(0);
|
|
|
+ api_initialize_hoops_acis_bridge();*/
|
|
|
+ base_configuration base_config;
|
|
|
+ logical ok = initialize_base(&base_config);
|
|
|
+ api_start_modeller(0);
|
|
|
+ api_initialize_hoops_acis_bridge();
|
|
|
+ api_initialize_part_manager();
|
|
|
+ api_set_int_option("annotations", false);
|
|
|
+ api_set_int_option("cell_recompute", 8);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void Terminate_ACIS()
|
|
|
+{
|
|
|
+
|
|
|
+ api_terminate_part_manager();
|
|
|
+ api_terminate_hoops_acis_bridge();
|
|
|
+ api_stop_modeller();
|
|
|
+ terminate_base();
|
|
|
+}
|
|
|
+
|
|
|
+void process(outcome result)
|
|
|
+{
|
|
|
+ if (!result.ok())
|
|
|
+ {
|
|
|
+ print_warnerr_mess("API", result.error_number(), stdout);
|
|
|
+ }
|
|
|
+ err_mess_type* warnings = NULL;
|
|
|
+ int nwarn = get_warnings(warnings);
|
|
|
+ for (int i = 0; i < nwarn; ++i)
|
|
|
+ {
|
|
|
+ printf("Warning %d : %s\n", warnings[i], find_err_mess(warnings[i]));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void process_file(FILE* fp)
|
|
|
+{
|
|
|
+ if (!fp)
|
|
|
+ {
|
|
|
+ printf("Unable to open input/output File\n");
|
|
|
+ exit(0);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+ENTITY_LIST retrieve_sat_file(char *fileName)
|
|
|
+{
|
|
|
+ outcome result;
|
|
|
+ // NOTE: to retrieve a binary sab file, use the following code:
|
|
|
+ // FILE *input_file = fopen (fileName, "rb");
|
|
|
+ FILE *input_file = fopen(fileName, "r");
|
|
|
+ process_file(input_file);
|
|
|
+
|
|
|
+ ENTITY_LIST elist;
|
|
|
+ result = api_restore_entity_list(input_file, TRUE, elist);
|
|
|
+ process(result);
|
|
|
+ fclose(input_file);
|
|
|
+
|
|
|
+ return elist;
|
|
|
+}
|
|
|
+
|
|
|
+void create_sat_file(ENTITY *ent, char *fileName)
|
|
|
+{
|
|
|
+ outcome result;
|
|
|
+
|
|
|
+ // Setting the units and product_id
|
|
|
+
|
|
|
+ FileInfo fileinfo;
|
|
|
+
|
|
|
+ fileinfo.set_units(1.0);
|
|
|
+ fileinfo.set_product_id("ACIS (c) SPATIAL");
|
|
|
+
|
|
|
+ result = api_set_file_info(3, fileinfo);
|
|
|
+ process(result);
|
|
|
+
|
|
|
+ FILE *output_file = fopen(fileName, "w");
|
|
|
+ process_file(output_file);
|
|
|
+
|
|
|
+ ENTITY_LIST save_list;
|
|
|
+ save_list.add(ent);
|
|
|
+
|
|
|
+ result = api_save_entity_list(output_file, TRUE, save_list);
|
|
|
+ process(result);
|
|
|
+
|
|
|
+ fclose(output_file);
|
|
|
+}
|
|
|
+
|
|
|
+void create_sat_file(ENTITY_LIST elist, char *fileName)
|
|
|
+{
|
|
|
+ outcome result;
|
|
|
+
|
|
|
+ // Setting the units and product_id
|
|
|
+
|
|
|
+ FileInfo fileinfo;
|
|
|
+
|
|
|
+ fileinfo.set_units(1.0);
|
|
|
+ fileinfo.set_product_id("ACIS (c) SPATIAL");
|
|
|
+
|
|
|
+ result = api_set_file_info(3, fileinfo);
|
|
|
+ process(result);
|
|
|
+
|
|
|
+ FILE *output_file = fopen(fileName, "w");
|
|
|
+ process_file(output_file);
|
|
|
+
|
|
|
+ result = api_save_entity_list(output_file, TRUE, elist);
|
|
|
+ process(result);
|
|
|
+
|
|
|
+ fclose(output_file);
|
|
|
+}
|