spatial developer tips & tricks ebook

11
SpaƟal Developer Tips & Tricks

Upload: spatialcorp

Post on 18-Nov-2014

943 views

Category:

Technology


1 download

DESCRIPTION

Developing engineering software applications is not easy. The use of 3D software components can reduce the workload and shorten your time to market. To make the implementation of Spatial’s components a bit easier, we have compiled some tricks and tips on using ACIS® and 3D InterOp in your application. So whether you’re a current Spatial developer or someone considering using Spatial components, download the eBook and learn how you can get the most out of Spatial's 3D Software Components.

TRANSCRIPT

Page 1: Spatial Developer Tips & Tricks eBook

Spa al Developer

Tips & Tricks

Page 2: Spatial Developer Tips & Tricks eBook

2Spa al Developer Tips & Tricks

Developer Tips & TricksArticles taken from Spatial’s Quarterly e-Newsletter, The Spatial Blend

ACIS Memory Manager 1

ACIS Adaptive Faceting 2

Confi gurable Translation using 3D InterOp 3

ACIS Healing Workfl ow 4

Choosing a Stitching Tolerance 6

Library Consolidation 7

Using Entity Point Distance Functionality 8

Page 3: Spatial Developer Tips & Tricks eBook

Spa al Developer Tips & Tricks 1

ACIS Memory ManagerYou can use ACIS Memory Manager to keep track of memory usage and leaks in your C++ application.

By default, ACIS memory management is used only within ACIS code. However, the application developer can also use ACIS memory management within the application code.

Advantages: Route all memory requests through a common interface

for processing Allocate and deallocate memory, and allow this to be

customizable by the application developer Pattern-fi ll unused memory with SNaN (Signal Not A

Number) or other easily recognizable data to help spot references to uninitialized memory

Collect statistics about memory usage, such as who allocates memory, how much memory is being used, the maximum amount of memory used, and where memory leaks have occurred

How to Implement: Use ACIS_NEW and ACIS_DELETE instead of ‘new’ and

‘delete’, respectively To get the complete memory report, initialize base

component with base_confi guration parameter enable_audit_leaks=TRUE

Similarly, to customize memory allocation and deallocation, customer can plug-in their own allocator/deallocator functions to base_confi guration

Deciphering the Memory Usage and Leaks ReportAfter running his application, the user has a ‘mmgr.log’ fi le. This report contains information about memory usage and leaks.

The Report has Two Parts:I. Memory Leaks details:c:\app\fi lename.cpp(119) : {0000270302} at 0x093932F0 16 Bytes Type: 1 Call: 27

Where each line contains seven pieces of information, as follows:

The fi rst two are the fi le and line where the allocation took place

The rest provide additional details to track the exact allocation call which leaked. The third fi eld is allocation sequence number, followed by the address of the storage location, and the number of bytes allocated. To be able to make full use of this information see ‘Breaking’ on a Particular Allocation Number.

II. Memory usage statistics

High-water-mark: 3022316 Bytes Bad delete pointers: 0 Stack high-water-mark: 333948 Bytes Elapsed seconds: 16.315

By Mohit Jain, Software Developer

Page 4: Spatial Developer Tips & Tricks eBook

2Spa al Developer Tips & Tricks

ACIS Adaptive FacetingThe adaptive faceting algorithm off ers signifi cant quality and performance. To increase the quality of facets, change the global option header adaptive_triangles (or adaptive_t for short) to TRUE. Normally the faceting algorithm estimates the number of grid lines necessary for a surface, and for the sake of performance, does not refi ne any further. This works very well for the vast majority of surfaces. But for surfaces that vary greatly in curvature, having low curvature in some area and high curvature in other areas, this approach will not necessarily meet surface and normal tolerances. This can be compensated for by using adaptive faceting, which will make the faceting algorithm further refi ne the facets until it does meet tolerances. The result is that surfaces with highly varying degrees of curvature will improve in rendering quality.

Click here for more information on Adaptive Faceting.

By Guy Radcliff e, Software Engineer

Page 5: Spatial Developer Tips & Tricks eBook

3Spa al Developer Tips & Tricks

Configurable Translation Using 3D InterOp3D InterOp translators have a fl exible interface which gives an application developer many more options than traditional one step fi le-to-fi le translation. Application developers can use this fl exible interface to confi gure the mode of fi le import/export in their application.

The Basic Workfl ow Consists of Three Steps:

1. Query the source fi le for document type using the SPAIDocumentHeaderInfo interface, and then query for key document settings (e.g. units) and/or summary information using the appropriate document info class (SPAIDocumentBRepInfo or SPAIDocumentAssemblyInfo). These query methods load only small sections of the fi le and are faster than doing a full translation.

2. Use the queried information to confi gure the conversion step using the SPAIOptions and SPAIConverter classes. During this step the user can also review the summary information to determine if some or all of the fi le or associated fi les should be converted.

3. Finally, perform the conversion as specifi ed.

A common use of this workfl ow is in translation of large assemblies. Often an application only needs to translate a few parts or sub-assemblies, so translating the entire assembly would incur unnecessary performance costs.

1. Use SPAIDocumentAssemblyInfo to create an xml summary of the product structure for the input assembly.

2. Parse the xml fi le and its nodes to process the product structure to obtain the fi le names and paths of the parts or sub-assemblies.

3. Use the fi le names and paths to convert each part or sub-assembly fi le individually. This could be done in a loop or even in diff erent processes of a multi-process application.

By Venugopal Chiramdasu, Software Developer

Page 6: Spatial Developer Tips & Tricks eBook

4Spa al Developer Tips & Tricks

ACIS Healing WorkflowWorking with Imported CAD Models in ACISThe more advanced modeling operations customers intend to perform, the more preprocessing of the ACIS model is required. For example, a visualization application would need less preprocessing than an engineering application. The fi gure below gives the typical preprocessing needed on a translated ACIS model for engineering applications.

In comparison, a visualization application may import the CAD model into ACIS without any preprocessing.

Healing Workfl owThe Healing Workfl ow improves CAD models imported into ACIS in order to make them most usable in ACIS. Models created in some other modeling system and translated into an ACIS model may have:

Geometrical inaccuracies Topological inaccuracies

The workfl ow effi ciently addresses these issues to create an optimized ACIS model. Here is the recommended workfl ow for healing ACIS models.

The workfl ow involves three steps: ‘Stitch’, ‘Simplify’ and ‘Tighten gaps’.

Step 1: Stitch

The stitch (Tolerant Stitch) functionality builds topology, if not already present or partially present, in the translated ACIS model by stitching or sewing separate faces together to make a sheet or manifold solid body that is topologically complete.

Is there a need to stitch?

The stitch step is required if the customer application requires surface connectivity. If the incoming model is already stitched, then the stitch step can be skipped.

How to customize stitch?

The Tolerant Stitch functionality allows a tolerance parameter to be passed for stitching the separate faces having gaps less than this parameter value. For details on this click here.

Click here for more information on customizing the stitch functionality.

Step 2: SimplifyThe simplify step converts spline data in the incoming model to corresponding analytic forms (for example: plane, cone,

Page 7: Spatial Developer Tips & Tricks eBook

5Spa al Developer Tips & Tricks

torus, or sphere) wherever possible. It results in reduction of data size and speed improvements in geometric operations.

Is there a need to simplify? The simplify step can be skipped if:

The customer application does not require changes in the model geometry

The customer application does not want the gaps in the model to increase (up to simplifi cation tolerance)

How to customize simplify?

The simplifi cation functionality works with a user defi ned simplifi cation tolerance. Users can set this tolerance value to either:

The source modeler tolerance in which the data was created (best choice)

If the above information is not available, then users can use their manufacturing tolerance (i.e. how big gaps user wants to permit)

Click here for more information on customizing the simplify functionality

Step 3: Tighten GapsThe Tighten Gaps step tightens the gaps (inaccuracies) in the input models by building geometry as necessary. In this phase a series of geometric operations are performed to improve the precision of face, edge, and vertex data. Geometry building essentially removes the gaps between adjacent surfaces by recomputing the intersections.

Is there a need to Tighten Gaps?

The tighten gaps step can be skipped if: There is no requirement on model tolerances being below

a particular limit There is no plan to do complex modeling operations like

blending

The tighten gaps step changes the model geometry and is usually associated with increased data size.

How to customize Tighten Gaps?

Users can pass in a ‘desired_gap_tightness’ parameter to enable the functionality to tighten only those gaps in the model that are greater than this value. The ‘desired_gap_tightness’ parameter should be same as the users manufacturing tolerance which is usually bigger than ACIS resolution SPAresabs.

105 is a good value to use by default for CAD & CAM applications

104 may be suffi cient for CAE applications

By Rajesh Chakravarty, Software Developer

Examples of tightening gaps

Page 8: Spatial Developer Tips & Tricks eBook

Spa al Developer Tips & Tricks 6

Choosing a Stitching ToleranceHealing allows you to import a model and prepare it for use in ACIS. One of the key decisions you will need to make is specifying a stitching tolerance. It is advised that you choose a tolerance that is smaller than the minimum allowable feature in your application. So how do you choose a minimum allowable tolerance? Here are two types of applications and some guidance on choosing a minimum allowable tolerance:

CAE Applications – In many analysis cases an edge length less than 1 mm is considered too small to aff ect the analysis output. In this case you would select 1 mm as the stitching tolerance.

CAM Applications – Many machining processes allow users to have a surface accuracy of 1 micron, but an edge length below 1 mm is too small. In this case you would also select 1 mm as the stitching tolerance.

The choice of tolerance depends on the specifi c application and should be selected carefully. If you use ACIS tolerance capabilities, the algorithm chooses by default a very high value of maximum stitch tolerance (of the order of 1.0). Internally the algorithm does incremental stitching by increasing the tolerance value until maximum stitch tolerance. The impact of using the ACIS default is that it may overrun the edges/faces that are part of the model and, therefore, may corrupt results (e.g. overlapping tolerant vertex due to edge removal).

By Yogesh Biyani, Support Operations Manager

Page 9: Spatial Developer Tips & Tricks eBook

7Spa al Developer Tips & Tricks

Library ConsolidationReducing the number of dll’s in your application by consolidating them into fewer numbers can produce many benefi ts. As an example, before ACIS R10, we built ACIS into a set of dll’s that corresponded to each ACIS component. For instance, blending functionality was in blend.dll and advanced blending functionality was in abl.dll.

In an eff ort to simplify our packaging, we consolidated like pieces of ACIS functionality into what we call ‘composite’ libraries. For example, all blending and advanced blending functionality are now merged into a single ‘composite’ library named SpaABlend.dll. In doing so, we achieved a 5% overall performance improvement.

We continue to look at ways to consolidate dll’s. One area of investigation is placing all core ACIS functionality into a single dll: SpaACIS.dll. In our preliminary tests, we are observing a 5% performance improvement.

Not only do we obtain a nice performance improvement each time we’ve consolidated many dll’s into fewer dll’s, but we also 1) make smaller the ACIS disk footprint (roughly 10% smaller), and 2) our ACIS based test applications start up much faster - up to 50% faster once cached. These types of improvements can be achieved within your applications through dll consolidation.

We achieved these performance gains largely due to how ACIS is designed: while componentized, we make 100’s of thousands of lightweight calls into our “base” component

just performing a simple modeling operation. Having all core components “glued” together into a single ACIS dll eliminates dll jumps. Additionally, the linker optimizer can inline more of these lightweight calls, avoiding function call overhead altogether.

In conclusion, there are lots of benefi ts to dll consolidation: improved run-time performance, smaller disk footprint, and faster application start up. Consider this the next time you’re asked to tackle one of these problems and you may be surprised.

By Kevin Tatterson, Director QA & Production

Page 10: Spatial Developer Tips & Tricks eBook

8Spa al Developer Tips & Tricks

Using Entity Point Distance FunctionalityThe api_entity_point_distance algorithm has had signifi cant improvements in ACIS in recent releases. An optimized multi-point interface is available for large point sets – a common workfl ow for Metrology customers. The multi-point interface is ‘thread-hot’, and automatically makes use of multiple processor cores when ACIS threading is enabled.

The API returns a distance and a closest point. Optionally we provide the closest entity and any relevant parameter information about the closest point on that entity.

When using the algorithm, for best performance we

recommend that:

The multi-point interface be used for all but the smallest sets of points – the optimizations can show benefi ts even for sets of 2 or 3 points

The application passes complete entities, rather than making multiple calls for each face on a body for a set of points – otherwise internal optimization may be bypassed

Better performance is also gained if sequential points are close together – such as ‘scanline’ data.

Within the multi-point interface, ACIS provides a ‘signed_distance’ mode. In the default mode, ACIS returns the closest point on the solid – so a point inside a body returns a distance of 0. In the ‘signed distance’ mode, ACIS returns the closest point on the solid boundary, so a point inside a body returns a negative distance.

By Tony Hornbuckle, Software Engineer

Page 11: Spatial Developer Tips & Tricks eBook

www.spatial.com

Learn MoreFind out how Spatial’s 3D Software Components will help you bring your market to application faster by signing up for a Free 90-day Product Evaluation:

Read More Spatial Developer-Authored Articles at

www.spatial.com/products/evaluation