Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit fa33306

Browse files
authored
Merge pull request #5 from orbingol/devmaster
Master branch update - August 2017
2 parents ea5adbc + f90ff4c commit fa33306

20 files changed

+1362
-464
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
# Ignore everything in the build directory except .gitkeep
55
build/*
66
!build/.gitkeep
7+
8+
# Ignore all txt files in the examples directory
9+
examples/*.txt

CMakeLists.txt

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
cmake_minimum_required( VERSION 2.8 )
22
project( ACIS_Py3Module CXX )
33

4+
#
5+
# Application Configuration
6+
#
7+
8+
# Set Python version
9+
set( APP_PYTHON_VERSION 3.5 )
10+
411
#
512
# CMake setup and quick fixes
613
#
@@ -80,7 +87,7 @@ endif()
8087
#
8188

8289
# Find Python libs
83-
find_package( PythonLibs 3.5 REQUIRED )
90+
find_package( PythonLibs ${APP_PYTHON_VERSION} REQUIRED )
8491
if( PythonLibs_FOUND )
8592
include_directories( ${PYTHON_INCLUDE_DIRS} )
8693
else()
@@ -159,7 +166,7 @@ generate_export_header( Entity
159166
)
160167

161168
# Set link targets
162-
target_link_libraries( Entity ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} )
169+
target_link_libraries( Entity ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} GeometricAtoms )
163170

164171
# Add the build location to the include directories
165172
target_include_directories( Entity PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} )
@@ -358,6 +365,51 @@ endif()
358365
set_target_properties( Sweeping PROPERTIES PREFIX "" )
359366

360367

368+
#
369+
# ACIS Python Module - Booleans API
370+
#
371+
372+
# Set source files
373+
set( ACIS_SOURCES_Booleans
374+
src/acis_booleans.h
375+
src/acis_booleans.cpp
376+
src/utilities.cpp
377+
src/utilities.h
378+
${PROJECT_BINARY_DIR}/acis_booleans_export.h
379+
)
380+
381+
# Generate Python module
382+
add_library( Booleans SHARED ${ACIS_SOURCES_Booleans} )
383+
384+
# Generate export header file
385+
generate_export_header( Booleans
386+
BASE_NAME acis_booleans
387+
)
388+
389+
# Set link targets
390+
target_link_libraries( Booleans ${ACIS_LINK_LIBRARIES} ${PYTHON_LIBRARIES} Entity )
391+
392+
# Add the build location to the include directories
393+
target_include_directories( Booleans PUBLIC ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} )
394+
395+
# Set required C++ standard
396+
set_property( TARGET Booleans PROPERTY CXX_STANDARD 11 )
397+
set_property( TARGET Booleans PROPERTY CXX_STANDARD_REQUIRED ON )
398+
399+
# Add suffix to debug builds
400+
if( WIN32 )
401+
set_target_properties( Booleans PROPERTIES DEBUG_POSTFIX "_d" )
402+
endif()
403+
404+
# On Windows, Python modules have .pyd filename extension
405+
if( WIN32 AND NOT CYGWIN )
406+
set_target_properties( Booleans PROPERTIES SUFFIX ".pyd" )
407+
endif()
408+
409+
# This is only needed for the python case where a modulename.so is generated
410+
set_target_properties( Booleans PROPERTIES PREFIX "" )
411+
412+
361413
#
362414
# ACIS Python Module - Query API
363415
#
@@ -448,7 +500,13 @@ set_target_properties( Modeler PROPERTIES PREFIX "" )
448500

449501
# Install Python modules to APP_INSTALL_DIR
450502
install(
451-
TARGETS Modeler Licensing Entity Lists SaveRestore GeometricAtoms Sweeping Query
503+
TARGETS Modeler Licensing Entity Lists SaveRestore GeometricAtoms Sweeping Query Booleans
504+
DESTINATION ${APP_INSTALL_DIR}/${APP_MODULE_NAME}
505+
)
506+
507+
# Install helper modules
508+
install(
509+
DIRECTORY python/
452510
DESTINATION ${APP_INSTALL_DIR}/${APP_MODULE_NAME}
453511
)
454512

FUNCTION_REFERENCE.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,7 @@
2121
* api_make_torus
2222
* api_apply_transf
2323
* api_remove_transf
24-
* api_unite
25-
* api_intersect
26-
* api_subtract
27-
* api_imprint
2824
* api_sheet_from_ff
29-
* api_boolean_chop_body
3025

3126
## Entity
3227

@@ -58,6 +53,8 @@
5853
* SPAmatrix
5954
* SPAvector
6055
* SPAunit_vector
56+
* SPApar_pos
57+
* SPApar_vec
6158

6259
### Functions
6360

@@ -127,3 +124,17 @@
127124
### Functions
128125

129126
* spa_unlock_products
127+
128+
## Booleans
129+
130+
### Enums
131+
132+
* NDBOOL_KEEP
133+
134+
### Functions
135+
136+
* api_unite
137+
* api_intersect
138+
* api_subtract
139+
* api_imprint
140+
* api_boolean_chop_body

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ I would be glad if you cite this repository using the DOI provided as a badge at
1010

1111
## Introduction
1212

13-
This package wraps Spatial Corporation's 3D ACIS Modeler into a Python (v3.5.x) module with minor changes due to how Python's C interface works. _3D ACIS Modeler_ or _ACIS_, in short, is a [solid and geometric modeling kernel](https://en.wikipedia.org/wiki/Geometric_modeling_kernel). Solid modeling kernels are sometimes called as "CAD Engines" too. These systems work behind the scenes and responsible for generation of solid models or surfaces, evaluation of geometric operations on solid models or surfaces, and so.
13+
This package wraps Spatial Corporation's 3D ACIS Modeler into a Python (v3.5.x and v3.6.x) module with minor changes due to how Python's C interface works. _3D ACIS Modeler_ or _ACIS_, in short, is a [solid and geometric modeling kernel](https://en.wikipedia.org/wiki/Geometric_modeling_kernel). Solid modeling kernels are sometimes called as "CAD Engines" too. These systems work behind the scenes and responsible for generation of solid models or surfaces, evaluation of geometric operations on solid models or surfaces, and so.
1414

1515
_3D ACIS Modeler_ provides a C++ API and its Scheme extension with variety of additional features. Even though it is used in a variety of commercial and research applications, it doesn't provide a Python interface which would be very useful for integration purposes. This module tries to fulfill the gap up to some point.
1616

cmake-modules

examples/01_generate_solid_block.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
Please see the LICENSE file for details.
88
"""
99

10+
from ACIS import utilities as utils
1011
from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms
1112

1213
# Start ACIS Modeler
1314
Modeler.api_start_modeller(0)
1415

1516
# Unlock ACIS Modeler components
16-
unlock_key = "Your ACIS Unlock Key here"
17+
unlock_key = utils.read_spa_license_key("license.txt")
1718
Licensing.spa_unlock_products(unlock_key)
1819

1920
# Generate a simple solid block

examples/02_boolean_subtract.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99

1010
# This example is taken from the book "Rapid Prototyping and Engineering Applications" by Frank W. Liou (Example 5.1)
1111

12-
from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms
12+
from ACIS import utilities as utils
13+
from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Booleans
1314

1415
# Start ACIS Modeler
1516
Modeler.api_start_modeller(0)
1617

1718
# Unlock ACIS Modeler components
18-
unlock_key = "Your ACIS Unlock Key here"
19+
unlock_key = utils.read_spa_license_key("license.txt")
1920
Licensing.spa_unlock_products(unlock_key)
2021

2122
# Make a cuboid
@@ -37,7 +38,7 @@
3738
Modeler.api_apply_transf(cylinder, cylinder_transf)
3839

3940
# Subtract frustum from cuboid
40-
Modeler.api_subtract(cylinder, block)
41+
Booleans.api_subtract(cylinder, block)
4142

4243
# Assign attributes after generation
4344
block.name = "Drilled Cuboid"

examples/03_sweeping.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
Please see the LICENSE file for details.
88
"""
99

10+
from ACIS import utilities as utils
1011
from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Sweeping, Query
1112

1213
# Start ACIS Modeler
1314
Modeler.api_start_modeller(0)
1415

1516
# Unlock ACIS Modeler components
16-
unlock_key = "Your ACIS Unlock Key here"
17+
unlock_key = utils.read_spa_license_key("license.txt")
1718
Licensing.spa_unlock_products(unlock_key)
1819

1920
# Make a cuboid

examples/04_face_counting.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""
2+
Examples for the Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler
3+
4+
ACIS and SAT are registered trademarks of Spatial Corporation.
5+
6+
The Python module is developed by Onur R. Bingol and released under MIT license.
7+
Please see the LICENSE file for details.
8+
"""
9+
10+
from ACIS import utilities as utils
11+
from ACIS import Modeler, Licensing, SaveRestore, Entity, Lists, GeometricAtoms, Query
12+
13+
# Start ACIS Modeler
14+
Modeler.api_start_modeller(0)
15+
16+
# Unlock ACIS Modeler components
17+
unlock_key = utils.read_spa_license_key("license.txt")
18+
Licensing.spa_unlock_products(unlock_key)
19+
20+
# Generate a truncated cone
21+
frustum = Entity.BODY()
22+
Modeler.api_make_frustum(50, 20, 30, 10, frustum)
23+
24+
# Assign attributes after generation
25+
frustum.name = "Truncated Cone"
26+
frustum.id = 1
27+
28+
# Loop through the face list and print out the name of the entity type
29+
face_list = Lists.ENTITY_LIST()
30+
Query.api_get_faces(frustum, face_list)
31+
32+
for f in face_list.array():
33+
fs = f.geometry()
34+
print(fs.type_name())
35+
36+
# Prepare for saving
37+
save_list = Lists.ENTITY_LIST()
38+
save_list.add(frustum)
39+
40+
# Set file name
41+
filename = "ACIS_Ex04.SAT"
42+
43+
# ACIS requires FileInfo object to be set before saving SAT files
44+
file_info = SaveRestore.FileInfo()
45+
file_info.set_product_id(filename)
46+
file_info.set_units(1.0) # milimeters
47+
48+
SaveRestore.api_set_file_info(file_info, product_id=True, units=True)
49+
50+
## Enable sequence numbers (i.e., pointers) in the SAT file for debugging (optional step)
51+
#Modeler.api_set_int_option("sequence_save_files", 1)
52+
53+
# Save the model as a SAT file
54+
SaveRestore.api_save_entity_list(filename, True, save_list)
55+
56+
# Stop ACIS Modeler
57+
Modeler.api_stop_modeller()

python/utilities.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""
2+
Helper Functions for the Python 3 wrapper module for Spatial Corporation's 3D ACIS Modeler
3+
4+
ACIS and SAT are registered trademarks of Spatial Corporation.
5+
6+
The Python module is developed by Onur R. Bingol and released under MIT license.
7+
Please see the LICENSE file for details.
8+
"""
9+
10+
import re
11+
12+
13+
def read_spa_license_key(filename=''):
14+
regex_seq = re.compile(r'\s?\"(.*)\"')
15+
16+
license_text = ""
17+
search_obj = None
18+
19+
try:
20+
with open(filename, 'r') as fp:
21+
license_code = fp.read()
22+
search_obj = regex_seq.finditer(license_code.strip())
23+
fp.close()
24+
except IOError:
25+
raise IOError('Cannot open file: ' + filename)
26+
27+
if search_obj:
28+
for line in search_obj:
29+
license_text = license_text + line.group(1)
30+
else:
31+
raise ValueError('The file "' + filename + '" does not contain the unlock key!')
32+
33+
return license_text

0 commit comments

Comments
 (0)