Skip to content

Outcome Checking, Logging and Progress Reporting in 3D ACIS

← Back to blog | ADMIN | 25-06-2015

This article shares a simple architecture which can be used to capture meta-data about the use of ACIS APIs in your program.

Hexagon pattern 1

capture meta-data about ACIS APIs This article shares a simple architecture which can be used to capture meta-data about the use of ACIS APIs in your program. It can be used to record the filename, line number, arguments and outcome of each API. C language preprocessor macros are used to invoke methods on a static object called spa::CheckOutcome. The meta-data is sent to your implementation of spa::CheckOutcome::Logger interface.

 

Here is an example of the output produced by a simple implementation of the Logger interface:

api_start_modeller(0) from main.cpp @ line 56: OK
api_initialize_kernel() from main.cpp @ line 58: OK
api_set_file_info(0x01 | 0x02, fi) from main.cpp @ line 64: OK
api_solid_block(SPAposition(), SPAposition(), block) from main.cpp @ line 70: ERROR (width negative or zero)
api_solid_block(SPAposition(), SPAposition(1,1,1), block) from main.cpp @ line 73: OK
api_save_entity_list(fptr, true, elist) from main.cpp @ line 78: OK
api_restore_entity_list(fptr, true, elist) from main.cpp @ line 83: OK WARNING (restore data has unknown origin)
api_terminate_kernel() from main.cpp @ line 87: OK
api_stop_modeller() from main.cpp @ line 88: OK

Additionally, the spa::CheckOutcome class contains an interface that can be implemented to report and interrupt the progress of the API. The interface also provides pre-API and post-API methods that are invoked accordingly, which allow you to more easily show and hide a progress dialog box. Here is an (abbreviated) example of the output produced by a simple implementation of the Progress interface:

Restoring entity list (0%)
Restoring entity list (1%)
Restoring entity list (3%)
Restoring entity list (5%)
Restoring entity list (7%)

Restoring entity list (100%)
API call completed. result == ok

Using this architecture in your code is quite easy. Just surround each of your API calls with the checkOutcome or checkOutcomeWithProgress macros. Here are two examples of its use:

if(!checkOutcome(api_initialize_kernel())) {
std::cout << "Initialization failed: "
<< spa::CheckOutcome::getLastErrorMessage()
<< std::endl;
return -1;
}

if(!checkOutcomeWithProgress(api_restore_entity_list(fptr, true, elist), "Restoring entity list")) {
std::cout << "Restore failed: "
<< spa::CheckOutcome::getLastErrorMessage()
<< std::endl;
}

As you can see from these samples, spa::CheckOutcome provides you with easy access to the error message in the event of a failure. Additionally, the success or failure of an API call is simplified to a Boolean value by the checkOutcome macro which can be used more naturally in conditionals.

It is important to check the return value of your ACIS API calls and respond to failures appropriately. Information about the success of an API is returned in an outcome object. When an API fails, the outcome object can be queried to obtain specific information about the failure. The static method spa::CheckOutcome::getLastOutcome() can be used to obtain last outcome object for further processing when needed.

All of the capabilities described are can be easily added to your application. Just add click here to download CheckOutcome.cpp and CheckOutcome.h , then add the files to your project. To see an example implementation of the Logger and Progress interfaces, as well as how spa::CheckOutcome and the macros are used take a look at main.cpp.

You might also like...

5 Min read
3D Modeling
What is digital manufacturing? Here’s a simple digital manufacturing definition: the process of using computer systems...
5 Min read
3D Modeling
Software components are like the stage crew at a big concert performance: the audience doesn’t see them, but their...
Application Lifecycle Management Flow
4 Min read
3D Modeling
When you hear the term, Application Lifecycle Management (ALM), you likely think about the process that a software...
8 Min read
3D Modeling
What is Computer Aided Manufacturing The CAM Market Who Uses CAM Software? Trends in CAM What do CAM Software...
9 Min read
3D Modeling
SLS in Additive Manufacturing is used to convert 3D CAD designs into physical parts, in a matter of hours.
8 Min read
3D Modeling
There’s a lot of confusion around what the terms additive manufacturing and 3D printing mean.
4 Min read
3D Modeling
Additive manufacturing, often referred to as 3D printing, is a computer-controlled process for creating 3D objects.
5 Min read
3D Modeling
Take a fresh, new sheet of paper, and fold it in half, like you’re making a paper airplane. Place the folded paper on...
6 Min read
3D Modeling
Table of Contents Simulation in CAD Who Uses Simulation Modeling? Key Benefits of Simulation Modeling Challenges in...
8 Min read
3D Modeling
What do you do? What Exactly is FEM? What You Need to Know About Choosing a FEM Modeler FEM and Partial Differential...
5 Min read
3D Modeling
Computational Fluid Dynamics (CFD) is a type of analysis that provides insight into solving complex problems, and...
2 Min read
3D Modeling
WRL files are an extension of the Virtual Reality Modeling Language (VRML) format . VRML file types enable browser...
Voxel model example
3 Min read
3D Modeling
Voxels are to 3D what pixels are to 2D. Firstly -- let’s examine what pixels actually are. Everything you see on your...
Point_cloud_torus
2 Min read
3D Modeling
Point-cloud modeling is typically used in the process of 3D scanning objects. Rather than defining surfaces through...
Polygonal Modeling
2 Min read
3D Modeling
Polygonal (or polyhedral) modeling is the most common type of modeling for video games and animation studios. This type...
aerodynamics-CFD
9 Min read
3D Modeling
Computational fluid dynamics (CFD) is a science that uses data structures to solve issues of fluid flow -- like...
BREP Model example
2 Min read
3D Modeling
BRep modeling, or Boundary Representation modeling, is, in CAD applications, the most common type of modeling. BRep is...
Feature Recognition Zoomed
5 Min read
3D Modeling
IN THIS ARTICLE: What is FEA (Finite Element Analysis) Principles of Finite Element Analysis and Simulation Software A...